mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Speed up API tests (#624)
* Adjust API tests internal API * Refactor API tests to take less time - sqlite: tests 15s, overall time: 1m - mysql: tests 15s, overall time: 59s * Use retry func to survive in faulty places * Use retry func while trying to ping SQL datastore - implements retry func specifically for SQL datastore ping - fmt fixes - using sqlx.Db.PingContext instead of sqlx.Db.Ping - propogate context to SQL datastore * Simplify TestCanCauseTimeout retry loop * Call retry with sane timeout * Fix TestOversizedLog, use retry func * Increase number of attempts 2 test cases are really faulty in CI, so they need a lot more time to finish. * Increase TestCanCauseTimeout timeout * Use retry at TestMultiLog to speed it up * Use retry at TestCanWriteLogs to speed it up * Use retry at TestGetCallsSuccess to speed it up * Use retry at TestCanGetAsyncState to speed it up * Use retry at TestListCallsSuccess to speed it up * Remove sleep calls * Remove dup test case * Cleaup Calls API test * Build API tests binary once This patch lets CI to build API tests binary once and reuse that whenever it needs it * Swap API tests checks * Build API test binary by default dirty fix for CircleCI * Use retry func to determine if datastore is alive in tests * go install should also reduce build time * Fix rebase issues
This commit is contained in:
committed by
Reed Allman
parent
cafc277325
commit
9d6f0b2a05
28
api_test.sh
28
api_test.sh
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -exuo pipefail
|
||||
set -exo pipefail
|
||||
|
||||
function host {
|
||||
case ${DOCKER_LOCATION:-localhost} in
|
||||
@@ -24,17 +24,16 @@ case "$1" in
|
||||
"sqlite3" )
|
||||
rm -fr /tmp/fn_integration_tests.db
|
||||
touch /tmp/fn_integration_tests.db
|
||||
FN_DB_URL="sqlite3:///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
|
||||
sleep 15
|
||||
MYSQL_HOST=`host ${DB_CONTAINER}`
|
||||
MYSQL_PORT=3306
|
||||
FN_DB_URL="mysql://root:root@tcp(${MYSQL_HOST}:${MYSQL_PORT})/funcs"
|
||||
export FN_DB_URL="mysql://root:root@tcp(${MYSQL_HOST}:${MYSQL_PORT})/funcs"
|
||||
|
||||
;;
|
||||
|
||||
@@ -42,12 +41,29 @@ case "$1" in
|
||||
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
|
||||
sleep 15
|
||||
POSTGRES_HOST=`host ${DB_CONTAINER}`
|
||||
POSTGRES_PORT=5432
|
||||
FN_DB_URL="postgres://postgres:root@${POSTGRES_HOST}:${POSTGRES_PORT}/funcs?sslmode=disable"
|
||||
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 ../../
|
||||
cd test/fn-api-tests && FN_API_URL="http://localhost:8080" FN_DB_URL=${FN_DB_URL} go test -v -parallel ${2:-1} ./...; cd ../../
|
||||
|
||||
Reference in New Issue
Block a user