mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: test scripts should use well defined ports (#1077)
* fn: test scripts should use well defined ports Moved allocation of listener ports for mysql/minio/postgres to helper script with a list of service list names. * fn: makefile docker pull mysql version must match tests
This commit is contained in:
@@ -1,42 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -exo pipefail
|
||||
|
||||
export CONTEXT="fn_system_tests"
|
||||
source ./helpers.sh
|
||||
|
||||
function remove_system_containers {
|
||||
docker rm -fv func-mysql-system-test 2>/dev/null || true
|
||||
docker rm -fv func-postgres-system-test 2>/dev/null || true
|
||||
}
|
||||
|
||||
remove_system_containers
|
||||
remove_containers ${CONTEXT}
|
||||
|
||||
DB_NAME=$1
|
||||
|
||||
case "$DB_NAME" in
|
||||
"sqlite3" )
|
||||
rm -fr /tmp/fn_system_tests.db
|
||||
touch /tmp/fn_system_tests.db
|
||||
export FN_DB_URL="sqlite3:///tmp/fn_system_tests.db"
|
||||
;;
|
||||
|
||||
"mysql" )
|
||||
DB_CONTAINER="func-mysql-system-test"
|
||||
docker rm -fv ${DB_CONTAINER} || echo No prev mysql test db container
|
||||
docker run --name ${DB_CONTAINER} -p 3307:3306 -e MYSQL_DATABASE=funcs -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.22
|
||||
MYSQL_HOST=`host ${DB_CONTAINER}`
|
||||
MYSQL_PORT=3307
|
||||
export FN_DB_URL="mysql://root:root@tcp(${MYSQL_HOST}:${MYSQL_PORT})/funcs"
|
||||
;;
|
||||
|
||||
"postgres" )
|
||||
DB_CONTAINER="func-postgres-system-test"
|
||||
docker rm -fv ${DB_CONTAINER} || echo No prev test db container
|
||||
docker run --name ${DB_CONTAINER} -e "POSTGRES_DB=funcs" -e "POSTGRES_PASSWORD=root" -p 5433:5432 -d postgres:9.3-alpine
|
||||
POSTGRES_HOST=`host ${DB_CONTAINER}`
|
||||
POSTGRES_PORT=5433
|
||||
export FN_DB_URL="postgres://postgres:root@${POSTGRES_HOST}:${POSTGRES_PORT}/funcs?sslmode=disable"
|
||||
;;
|
||||
esac
|
||||
export FN_DB_URL=$(spawn_${DB_NAME} ${CONTEXT})
|
||||
|
||||
# avoid port conflicts with api_test.sh which are run in parallel
|
||||
export FN_API_URL="http://localhost:8085"
|
||||
@@ -54,4 +24,4 @@ export SYSTEM_TEST_PROMETHEUS_FILE=./prometheus.${DB_NAME}.txt
|
||||
|
||||
cd test/fn-system-tests && FN_DB_URL=${FN_DB_URL} FN_API_URL=${FN_API_URL} go test -v -parallel ${2:-1} ./...; cd ../../
|
||||
|
||||
remove_system_containers
|
||||
remove_containers ${CONTEXT}
|
||||
|
||||
Reference in New Issue
Block a user