forked from fnproject/fn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.sh
executable file
·55 lines (48 loc) · 1.83 KB
/
api_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -exo pipefail
source ./helpers.sh
remove_containers
case "$1" in
"sqlite3" )
rm -fr /tmp/fn_integration_tests.db
touch /tmp/fn_integration_tests.db
export FN_DB_URL="sqlite3:///tmp/fn_integration_tests.db"
;;
"mysql" )
DB_CONTAINER="func-mysql-test"
docker rm -fv ${DB_CONTAINER} || echo No prev mysql test db container
docker run --name ${DB_CONTAINER} -p 3306:3306 -e MYSQL_DATABASE=funcs -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.22
MYSQL_HOST=`host ${DB_CONTAINER}`
MYSQL_PORT=3306
export FN_DB_URL="mysql://root:root@tcp(${MYSQL_HOST}:${MYSQL_PORT})/funcs"
;;
"postgres" )
DB_CONTAINER="func-postgres-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 5432:5432 -d postgres:9.3-alpine
POSTGRES_HOST=`host ${DB_CONTAINER}`
POSTGRES_PORT=5432
export FN_DB_URL="postgres://postgres:root@${POSTGRES_HOST}:${POSTGRES_PORT}/funcs?sslmode=disable"
;;
esac
#test test/fn-api-tests/fn-api-tests.test
#status=`echo $?`
#rebuild="${3:-1}"
#circleci=`echo ${CIRCLECI}`
#cd test/fn-api-tests
#if [[ $status -ne 0 ]] || [[ $rebuild -ne 0 ]] ; then
# if [[ $circleci == "true" ]]; then
# # dirty things to make CI pass
# ls -lah /usr/local/go/pkg/linux_amd64/runtime
# sudo chown -R `whoami`:root /usr/local/go
# sudo chmod -R 777 /usr/local/go/pkg/linux_amd64
# ls -lah /usr/local/go/pkg/linux_amd64/runtime
# fi
# pwd
# go test -i -a -o fn-api-tests.test
#fi
#pwd
#./fn-api-tests.test -test.v -test.parallel ${2:-1} ./...; cd ../../
export FN_DS_DB_PING_MAX_RETRIES=60
cd test/fn-api-tests && FN_API_URL="http://localhost:8080" FN_DB_URL=${FN_DB_URL} go test -v -parallel ${2:-1} ./...; cd ../../
remove_containers