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 9d0962c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 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
36 changes: 25 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Top level test script to start all other tests

set -ex
set -exuo pipefail

function host {
case ${DOCKER_LOCATION:-localhost} in
Expand All @@ -23,19 +23,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,9 +66,8 @@ 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 rm --force func-postgres-test func-mysql-test 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

Expand All @@ -63,6 +76,7 @@ docker run -v `pwd`:/go/src/github.com/fnproject/fn --rm quay.io/goswagger/swag
cd examples/middleware
go build
cd ../..

cd examples/extensions
go build
cd ../..

0 comments on commit 9d0962c

Please sign in to comment.