Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fn: test and release scripts now run some jobs in background #620

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ) &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments at related issue, this image huge, why not just download binary for releases?

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}