Test framework improvement (#1128)
This commit is contained in:
committed by
Ta-Ching Chen
parent
1e8dfa38da
commit
c3177f9ebd
@@ -1,108 +1,112 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
cleanup() {
|
||||
fission fn delete --name hello-go-poolmgr || true
|
||||
fission fn delete --name hello-go-nd || true
|
||||
fission env delete --name go || true
|
||||
rm $ROOT/examples/go/vendor-example/vendor.zip || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
env=go-$TEST_ID
|
||||
fn_poolmgr=hello-go-poolmgr-$TEST_ID
|
||||
fn_nd=hello-go-nd-$TEST_ID
|
||||
|
||||
wait_for_builder() {
|
||||
env=$1
|
||||
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
|
||||
|
||||
# wait for tiller ready
|
||||
set +e
|
||||
while true; do
|
||||
kubectl --namespace fission-builder get pod -l envName=go -o jsonpath="$JSONPATH" | grep "Ready=True"
|
||||
kubectl --namespace fission-builder get pod -l envName=$env -o jsonpath="$JSONPATH" | grep "Ready=True"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
sleep 1
|
||||
done
|
||||
set -e
|
||||
}
|
||||
|
||||
waitBuild() {
|
||||
log "Waiting for builder manager to finish the build"
|
||||
|
||||
set +e
|
||||
while true; do
|
||||
kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
test_fn() {
|
||||
log "Checking for valid response"
|
||||
|
||||
while true; do
|
||||
response0=$(curl http://$FISSION_ROUTER/$1)
|
||||
log $response0 | grep -i $2
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
set -e
|
||||
}
|
||||
|
||||
export -f wait_for_builder
|
||||
export -f waitBuild
|
||||
export -f test_fn
|
||||
|
||||
cd $ROOT/examples/go
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
GO_RUNTIME_IMAGE=${GO_RUNTIME_IMAGE:-gcr.io/fission-ci/go-env:test}
|
||||
GO_BUILDER_IMAGE=${GO_BUILDER_IMAGE:-gcr.io/fission-ci/go-env-builder:test}
|
||||
|
||||
log "Creating environment for Golang"
|
||||
fission env create --name go --image $GO_RUNTIME_IMAGE --builder $GO_BUILDER_IMAGE --period 5
|
||||
fission env create --name $env --image $GO_RUNTIME_IMAGE --builder $GO_BUILDER_IMAGE --period 5
|
||||
|
||||
timeout 90 bash -c "wait_for_builder"
|
||||
timeout 90 bash -c "wait_for_builder $env"
|
||||
|
||||
pkgName=$(fission package create --src hello.go --env go| cut -f2 -d' '| tr -d \')
|
||||
pkgName=$(fission package create --src hello.go --env $env| cut -f2 -d' '| tr -d \')
|
||||
|
||||
# wait for build to finish at most 90s
|
||||
timeout 90 bash -c "waitBuild $pkgName"
|
||||
|
||||
log "Creating pool manager & new deployment function for Golang"
|
||||
fission fn create --name hello-go-poolmgr --env go --pkg $pkgName --entrypoint Handler
|
||||
fission fn create --name hello-go-nd --env go --pkg $pkgName --entrypoint Handler --executortype newdeploy
|
||||
fission fn create --name $fn_poolmgr --env $env --pkg $pkgName --entrypoint Handler
|
||||
fission fn create --name $fn_nd --env $env --pkg $pkgName --entrypoint Handler --executortype newdeploy
|
||||
|
||||
log "Creating route for new deployment function"
|
||||
fission route create --function hello-go-poolmgr --url /hello-go-poolmgr --method GET
|
||||
fission route create --function hello-go-nd --url /hello-go-nd --method GET
|
||||
fission route create --function $fn_poolmgr --url /$fn_poolmgr --method GET
|
||||
fission route create --function $fn_nd --url /$fn_nd --method GET
|
||||
|
||||
log "Waiting for router & pools to catch up"
|
||||
sleep 5
|
||||
|
||||
log "Testing pool manager function"
|
||||
timeout 60 bash -c "test_fn hello-go-poolmgr 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_poolmgr 'Hello'"
|
||||
|
||||
log "Testing new deployment function"
|
||||
timeout 60 bash -c "test_fn hello-go-nd 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_nd 'Hello'"
|
||||
|
||||
# Create zip file without top level directory (vendor-example)
|
||||
cd vendor-example && zip -r vendor.zip *
|
||||
cd vendor-example && zip -r $tmp_dir/vendor.zip *
|
||||
|
||||
pkgName=$(fission package create --src vendor.zip --env go| cut -f2 -d' '| tr -d \')
|
||||
pkgName=$(fission package create --src $tmp_dir/vendor.zip --env $env| cut -f2 -d' '| tr -d \')
|
||||
|
||||
# wait for build to finish at most 90s
|
||||
timeout 90 bash -c "waitBuild $pkgName"
|
||||
|
||||
log "Update function package"
|
||||
fission fn update --name hello-go-poolmgr --pkg $pkgName
|
||||
fission fn update --name hello-go-nd --pkg $pkgName
|
||||
fission fn update --name $fn_poolmgr --pkg $pkgName
|
||||
fission fn update --name $fn_nd --pkg $pkgName
|
||||
|
||||
log "Waiting for router & pools to catch up"
|
||||
sleep 5
|
||||
|
||||
log "Testing pool manager function with new package"
|
||||
timeout 60 bash -c "test_fn hello-go-poolmgr 'vendor'"
|
||||
timeout 60 bash -c "test_fn $fn_poolmgr 'Vendor'"
|
||||
|
||||
log "Testing new deployment function with new package"
|
||||
timeout 60 bash -c "test_fn hello-go-nd 'vendor'"
|
||||
timeout 60 bash -c "test_fn $fn_nd 'Vendor'"
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
JVM_RUNTIME_IMAGE=${JVM_RUNTIME_IMAGE:-gcr.io/fission-ci/jvm-env:test}
|
||||
JVM_BUILDER_IMAGE=${JVM_BUILDER_IMAGE:-gcr.io/fission-ci/jvm-env-builder:test}
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
env=java-$TEST_ID
|
||||
fn_p=pbuilderhello-$TEST_ID
|
||||
fn_n=nbuilderhello-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
fission fn delete --name pbuilderhello || true
|
||||
fission fn delete --name nbuilderhello || true
|
||||
fission env delete --name java || true
|
||||
rm $ROOT/examples/jvm/java/java-src-pkg.zip || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
test_fn() {
|
||||
echo "Checking for valid response"
|
||||
|
||||
while true; do
|
||||
response0=$(curl http://$FISSION_ROUTER/$1)
|
||||
echo $response0 | grep -i $2
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
test_pkg() {
|
||||
echo "Checking for valid response"
|
||||
echo "Checking package for valid response"
|
||||
|
||||
set +e
|
||||
while true; do
|
||||
response0=$(kubectl get -ndefault package $1 -o=jsonpath='{.status.buildstatus}')
|
||||
echo $response0 | grep -i $2
|
||||
@@ -38,43 +38,43 @@ test_pkg() {
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
set -e
|
||||
}
|
||||
|
||||
export -f test_fn
|
||||
export -f test_pkg
|
||||
|
||||
cd $ROOT/examples/jvm/java
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
log "Creating zip from source code"
|
||||
zip -r java-src-pkg.zip *
|
||||
zip -r $tmp_dir/java-src-pkg.zip *
|
||||
|
||||
log "Creating Java environment with Java Builder"
|
||||
fission env create --name java --image $JVM_RUNTIME_IMAGE --version 2 --keeparchive --builder $JVM_BUILDER_IMAGE
|
||||
fission env create --name $env --image $JVM_RUNTIME_IMAGE --version 2 --keeparchive --builder $JVM_BUILDER_IMAGE
|
||||
|
||||
log "Creating package from the source archive"
|
||||
pkg_name=`fission package create --sourcearchive java-src-pkg.zip --env java|cut -d' ' -f 2|cut -d"'" -f 2`
|
||||
pkg_name=`fission package create --sourcearchive $tmp_dir/java-src-pkg.zip --env $env|cut -d' ' -f 2|cut -d"'" -f 2`
|
||||
log "Created package $pkg_name"
|
||||
|
||||
log "Checking the status of package"
|
||||
timeout 300 bash -c "test_pkg $pkg_name 'succeeded'"
|
||||
timeout 400 bash -c "test_pkg $pkg_name 'succeeded'"
|
||||
|
||||
log "Creating pool manager & new deployment function for Java"
|
||||
fission fn create --name nbuilderhello --pkg $pkg_name --env java --entrypoint io.fission.HelloWorld --executortype newdeploy --minscale 1 --maxscale 1
|
||||
fission fn create --name pbuilderhello --pkg $pkg_name --env java --entrypoint io.fission.HelloWorld
|
||||
fission fn create --name $fn_n --pkg $pkg_name --env $env --entrypoint io.fission.HelloWorld --executortype newdeploy --minscale 1 --maxscale 1
|
||||
fission fn create --name $fn_p --pkg $pkg_name --env $env --entrypoint io.fission.HelloWorld
|
||||
|
||||
log "Creating route for pool manager function"
|
||||
fission route create --function pbuilderhello --url /pbuilderhello --method GET
|
||||
fission route create --function $fn_p --url /$fn_p --method GET
|
||||
|
||||
log "Creating route for new deployment function"
|
||||
fission route create --function nbuilderhello --url /nbuilderhello --method GET
|
||||
fission route create --function $fn_n --url /$fn_n --method GET
|
||||
|
||||
log "Waiting for router & pools to catch up"
|
||||
sleep 5
|
||||
|
||||
log "Testing pool manager function"
|
||||
timeout 60 bash -c "test_fn pbuilderhello 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_p 'Hello'"
|
||||
|
||||
log "Testing new deployment function"
|
||||
timeout 60 bash -c "test_fn nbuilderhello 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_n 'Hello'"
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -3,29 +3,26 @@
|
||||
#test:disabled
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=jvm-$TEST_ID
|
||||
fn_n=jvm-hello-n-$TEST_ID
|
||||
fn_p=jvm-hello-p-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
fission fn delete --name hellon || true
|
||||
fission fn delete --name hellop || true
|
||||
fission env delete --name jvm || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
test_fn() {
|
||||
echo "Checking for valid response"
|
||||
|
||||
while true; do
|
||||
response0=$(curl http://$FISSION_ROUTER/$1)
|
||||
echo $response0 | grep -i $2
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
export -f test_fn
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
cd $ROOT/examples/jvm/java
|
||||
|
||||
@@ -34,24 +31,25 @@ log "Creating the jar from application"
|
||||
docker run -it --rm -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.5-jdk-8 mvn clean package -q
|
||||
|
||||
log "Creating environment for Java"
|
||||
fission env create --name jvm --image gcr.io/fission-ci/jvm-env:test --version 2 --keeparchive=true
|
||||
fission env create --name $env --image $JVM_RUNTIME_IMAGE --version 2 --keeparchive=true
|
||||
|
||||
log "Creating pool manager & new deployment function for Java"
|
||||
fission fn create --name hellop --deploy target/hello-world-1.0-SNAPSHOT-jar-with-dependencies.jar --env jvm --entrypoint io.fission.HelloWorld
|
||||
fission fn create --name hellon --deploy target/hello-world-1.0-SNAPSHOT-jar-with-dependencies.jar --env jvm --executortype newdeploy --entrypoint io.fission.HelloWorld
|
||||
trap cleanup EXIT
|
||||
fission fn create --name $fn_p --deploy target/hello-world-1.0-SNAPSHOT-jar-with-dependencies.jar --env $env --entrypoint io.fission.HelloWorld
|
||||
fission fn create --name $fn_n --deploy target/hello-world-1.0-SNAPSHOT-jar-with-dependencies.jar --env $env --executortype newdeploy --entrypoint io.fission.HelloWorld
|
||||
|
||||
log "Creating route for pool manager function"
|
||||
fission route create --function hellop --url /hellop --method GET
|
||||
fission route create --name $fn_p --function $fn_p --url /$fn_p --method GET
|
||||
|
||||
log "Creating route for new deployment function"
|
||||
fission route create --function hellon --url /hellon --method GET
|
||||
fission route create --name $fn_n --function $fn_n --url /$fn_n --method GET
|
||||
|
||||
log "Waiting for router & pools to catch up"
|
||||
sleep 5
|
||||
|
||||
log "Testing pool manager function"
|
||||
timeout 60 bash -c "test_fn hellop 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_p 'Hello'"
|
||||
|
||||
log "Testing new deployment function"
|
||||
timeout 60 bash -c "test_fn hellon 'Hello'"
|
||||
timeout 60 bash -c "test_fn $fn_n 'Hello'"
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
Reference in New Issue
Block a user