Skip to content

Commit

Permalink
fn: test and release scripts now run some jobs in background
Browse files Browse the repository at this point in the history
  • Loading branch information
skinowski committed Dec 21, 2017
1 parent a8a3e14 commit ff0354e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
11 changes: 5 additions & 6 deletions go-fmt.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/sh
#!/bin/bash
# find and output all Go files that are not correctly formatted

set -e
set -euo pipefail

# Find all .go files except those under vendor/ or .git, run gofmt -l on them
OUT=$(find ! \( -path ./vendor -prune \) ! \( -path ./.git -prune \) -name '*.go' -exec gofmt -l {} +)
OUT=$(find ! \( -path ./vendor -prune \) ! \( -path ./.git -prune \) -name '*.go' | xargs gofmt -l)

if [ -n "$OUT" ]; then
echo "$OUT"
exit 1
echo $OUT
exit 1
fi
12 changes: 8 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ docker push $user/$image_deprecated:$version
docker push $user/$image_deprecated:latest

# release test utils docker image
(cd images/fn-test-utils && ./release.sh)
(cd images/fn-test-utils && ./release.sh) &
PID1=$!

cd fnlb
./release.sh
cd ..
# release fnlb
(cd fnlb && ./release.sh ) &
PID2=$!

wait $PID1
wait $PID2
44 changes: 30 additions & 14 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
# Top level test script to start all other tests

set -ex
set -exuo pipefail

CUR=`pwd`

function host {
case ${DOCKER_LOCATION:-localhost} in
Expand All @@ -23,19 +25,33 @@ function host {
}

docker rm -fv func-postgres-test || echo No prev test db container
docker run --name func-postgres-test -e "POSTGRES_DB=funcs" -e "POSTGRES_PASSWORD=root" -p 5432:5432 -d postgres
docker rm -fv func-mysql-test || echo No prev mysql test db container
docker run --name func-mysql-test -p 3306:3306 -e MYSQL_DATABASE=funcs -e MYSQL_ROOT_PASSWORD=root -d mysql
docker rm -fv func-minio-test || echo No prev minio test container
docker run -d -p 9000:9000 --name func-minio-test -e "MINIO_ACCESS_KEY=admin" -e "MINIO_SECRET_KEY=password" minio/minio server /data

# build test image locally first
(cd images/fn-test-utils && ./build.sh)
(cd images/fn-test-utils && ./build.sh) &
PID1=$!

# pull all images used in tests so that tests don't time out and fail spuriously
docker pull fnproject/sleeper
docker pull fnproject/error
docker pull fnproject/hello
( docker pull fnproject/sleeper && docker pull fnproject/error && docker pull fnproject/hello) &
PID2=$!

# pull db images
( docker pull postgres && docker pull mysql && docker pull minio/minio) &
PID3=$!

# pull swagger image
(docker pull quay.io/goswagger/swagger ) &
PID4=$!

wait $PID1
wait $PID2
wait $PID3
wait $PID4

docker run --name func-postgres-test -e "POSTGRES_DB=funcs" -e "POSTGRES_PASSWORD=root" -p 5432:5432 -d postgres
docker run --name func-mysql-test -p 3306:3306 -e MYSQL_DATABASE=funcs -e MYSQL_ROOT_PASSWORD=root -d mysql
docker run -d -p 9000:9000 --name func-minio-test -e "MINIO_ACCESS_KEY=admin" -e "MINIO_SECRET_KEY=password" minio/minio server /data

MYSQL_HOST=`host func-mysql-test`
MYSQL_PORT=3306
Expand All @@ -52,17 +68,17 @@ export MINIO_URL="s3://admin:password@${MINIO_HOST}:${MINIO_PORT}/us-east-1/fnlo

go test $(go list ./... | grep -v vendor | grep -v examples | grep -v test/fn-api-tests | grep -v images/fn-test-utils)
go vet $(go list ./... | grep -v vendor)
docker rm --force func-postgres-test
docker rm --force func-mysql-test
docker rm --force func-minio-test

docker run -v `pwd`:/go/src/github.com/fnproject/fn --rm quay.io/goswagger/swagger validate /go/src/github.com/fnproject/fn/docs/swagger.yml
docker rm --force func-postgres-test func-mysql-test func-minio-test

docker run -v ${CUR}:/go/src/github.com/fnproject/fn --rm quay.io/goswagger/swagger validate /go/src/github.com/fnproject/fn/docs/swagger.yml

# test middlware, extensions, examples, etc
# TODO: do more here, maybe as part of fn tests
cd examples/middleware
go build
cd ../..
cd ${CUR}

cd examples/extensions
go build
cd ../..
cd ${CUR}

0 comments on commit ff0354e

Please sign in to comment.