Files
fission-src/test/tests/test_environments/test_go_env.sh
T
90c479b23c Restructured authmiddleware fn and added tests (#2410)
* Created separate file for authmiddleware fn
* Optimize auth login and middleware
* Added unittests for authmiddleware
* Fixed authURL
* Removed featureConfig as global variable
* Fix integration test according to examples repo changes
* Fix integration test path for go module-example

Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
2022-04-22 14:21:58 +05:30

83 lines
2.2 KiB
Bash
Executable File

#!/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() {
log "Cleaning up..."
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
cd $ROOT/examples/go/hello-world
log "Creating environment for Golang"
fission env create --name $env --image $GO_RUNTIME_IMAGE --builder $GO_BUILDER_IMAGE --period 5
timeout 90 bash -c "wait_for_builder $env"
pkgName=$(generate_test_id)
fission package create --name $pkgName --src hello.go --env $env
# 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 $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 $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 $fn_poolmgr 'Hello'"
log "Testing new deployment function"
timeout 60 bash -c "test_fn $fn_nd 'Hello'"
# Create zip file without top level directory (module-example)
cd ../module-example && zip -r $tmp_dir/module.zip *
pkgName=$(generate_test_id)
fission package create --name $pkgName --src $tmp_dir/module.zip --env $env
# wait for build to finish at most 90s
timeout 90 bash -c "waitBuild $pkgName"
log "Update function package"
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 $fn_poolmgr 'Vendor'"
log "Testing new deployment function with new package"
timeout 60 bash -c "test_fn $fn_nd 'Vendor'"
log "Test PASSED"