Test framework improvement (#1128)
This commit is contained in:
committed by
Ta-Ching Chen
parent
1e8dfa38da
commit
c3177f9ebd
@@ -1,13 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../utils.sh
|
||||
|
||||
ROOT=$(dirname $0)/../..
|
||||
ROOT=$(dirname $0)/../..
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
nodejs_env=nodejs-$TEST_ID
|
||||
fn0=nodejs-hello-0-$TEST_ID
|
||||
fn1=nodejs-hello-1-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name nodejs || true
|
||||
fission fn delete --name $fn1 || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
@@ -17,19 +23,13 @@ else
|
||||
fi
|
||||
|
||||
# Create a hello world function in nodejs, test it with an http trigger
|
||||
log "NewDeploy ExecutorType: Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
log "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
#trap "fission env delete --name nodejs" EXIT
|
||||
fission env create --name $nodejs_env --image $NODE_RUNTIME_IMAGE --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
|
||||
# TODO Imporve test code by reusing common blocks
|
||||
|
||||
log "Creating function, testing for cold start with MinScale 0"
|
||||
fn0=nodejs-hello-$(date +%N)
|
||||
fission fn create --name $fn0 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 0 --maxscale 4 --executortype newdeploy
|
||||
#trap "fission fn delete --name $fn0" EXIT
|
||||
fission fn create --name $fn0 --env $nodejs_env --code $ROOT/examples/nodejs/hello.js --minscale 0 --maxscale 4 --executortype newdeploy
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function $fn0 --url /$fn0 --method GET
|
||||
@@ -38,16 +38,13 @@ log "Waiting for router & newdeploy deployment creation"
|
||||
sleep 5
|
||||
|
||||
log "Doing an HTTP GET on the function's route"
|
||||
response0=$(curl http://$FISSION_ROUTER/$fn0)
|
||||
response0=$(curl --retry 5 http://$FISSION_ROUTER/$fn0)
|
||||
|
||||
log "Checking for valid response"
|
||||
echo $response0 | grep -i hello
|
||||
|
||||
|
||||
log "Creating function, testing for warm start with MinScale 1"
|
||||
fn1=nodejs-hello-$(date +%N)
|
||||
fission fn create --name $fn1 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 1 --maxscale 4 --executortype newdeploy
|
||||
#trap "fission fn delete --name $fn1" EXIT
|
||||
fission fn create --name $fn1 --env $nodejs_env --code $ROOT/examples/nodejs/hello.js --minscale 1 --maxscale 4 --executortype newdeploy
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function $fn1 --url /$fn1 --method GET
|
||||
@@ -56,12 +53,9 @@ log "Waiting for router & newdeploy deployment creation"
|
||||
sleep 5
|
||||
|
||||
log "Doing an HTTP GET on the function's route"
|
||||
response1=$(curl http://$FISSION_ROUTER/$fn1)
|
||||
response1=$(curl --retry 5 http://$FISSION_ROUTER/$fn1)
|
||||
|
||||
log "Checking for valid response"
|
||||
echo $response1 | grep -i hello
|
||||
|
||||
# crappy cleanup, improve this later
|
||||
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
|
||||
|
||||
log "NewDeploy ExecutorType: All done."
|
||||
|
||||
Reference in New Issue
Block a user