Test framework improvement (#1128)

This commit is contained in:
Chia-Chun Tai
2019-05-23 22:52:39 +08:00
committed by Ta-Ching Chen
parent 1e8dfa38da
commit c3177f9ebd
47 changed files with 1192 additions and 832 deletions
+10 -12
View File
@@ -1,15 +1,19 @@
#!/bin/bash
set -euo pipefail
source $(dirname $0)/../utils.sh
TEST_ID=$(generate_test_id)
echo "TEST_ID = $TEST_ID"
ROOT=$(dirname $0)/../..
fn=nodejs-hello-$(date +%N)
env=nodejs-$TEST_ID
fn=nodejs-hello-$TEST_ID
cleanup() {
log "Cleaning up..."
fission env delete --name nodejs || true
fission fn delete --name $fn || true
clean_resource_by_id $TEST_ID
}
if [ -z "${TEST_NOCLEANUP:-}" ]; then
@@ -19,14 +23,11 @@ else
fi
# Create a hello world function in nodejs, test it with an http trigger
log "Pre-test cleanup"
fission env delete --name nodejs || true
log "Creating nodejs env"
fission env create --name nodejs --image fission/node-env
fission env create --name $env --image $NODE_RUNTIME_IMAGE
log "Creating function"
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
fission fn create --name $fn --env $env --code $ROOT/examples/nodejs/hello.js
log "Creating route"
fission route create --function $fn --url /$fn --method GET
@@ -35,12 +36,9 @@ log "Waiting for router to catch up"
sleep 3
log "Doing an HTTP GET on the function's route"
response=$(curl http://$FISSION_ROUTER/$fn)
response=$(curl --retry 5 http://$FISSION_ROUTER/$fn)
log "Checking for valid response"
echo $response | grep -i hello
routeid=$(fission route list|grep "$fn"|awk '{print $1}')
fission route delete --name $routeid || true
log "All done."