Test framework improvement (#1128)
This commit is contained in:
committed by
Ta-Ching Chen
parent
1e8dfa38da
commit
c3177f9ebd
@@ -1,17 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
fn=spec-$(date +%N)
|
||||
env=python-$fn
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=python-$TEST_ID
|
||||
fn=spec-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission spec destroy || true
|
||||
rm -rf specs || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
cp $ROOT/test/tests/test_specs/hello.py $tmp_dir
|
||||
pushd $tmp_dir
|
||||
|
||||
# init
|
||||
fission spec init
|
||||
@@ -21,13 +37,13 @@ fission spec init
|
||||
[ -f specs/README ]
|
||||
[ -f specs/fission-deployment-config.yaml ]
|
||||
|
||||
fission env create --spec --name $env --image fission/python-env
|
||||
fission env create --spec --name $env --image $PYTHON_RUNTIME_IMAGE
|
||||
|
||||
log "create env spec"
|
||||
fission spec apply
|
||||
|
||||
log "verify env created"
|
||||
fission env list | grep python
|
||||
fission env list | grep $env
|
||||
|
||||
log "generate function spec"
|
||||
fission fn create --spec --name $fn --env $env --code hello.py
|
||||
@@ -40,7 +56,6 @@ grep Function specs/*.yaml
|
||||
|
||||
log "Apply specs"
|
||||
fission spec apply
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
log "verify function exists"
|
||||
fission fn list | grep $fn
|
||||
@@ -48,4 +63,6 @@ fission fn list | grep $fn
|
||||
sleep 3
|
||||
|
||||
log "Test the function"
|
||||
fission fn test --name $fn | grep -i hello
|
||||
fission fn test --name $fn | grep -i hello
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
#!/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)/../../..
|
||||
|
||||
fn=spec-$(date +%N)
|
||||
env=python-$fn
|
||||
env=python-$TEST_ID
|
||||
fn=spec-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
pushd $ROOT/examples/python
|
||||
fission spec destroy
|
||||
rm -rf $ROOT/examples/python/specs
|
||||
log "Cleaning up..."
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
pushd $ROOT/examples/python
|
||||
cp -r $ROOT/examples/python/multifile $tmp_dir/
|
||||
pushd $tmp_dir
|
||||
|
||||
fission spec init
|
||||
|
||||
log "Creating environment spec"
|
||||
fission env create --spec --name $env --image fission/python-env --builder fission/python-builder
|
||||
fission env list | grep python
|
||||
fission env create --spec --name $env --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
||||
|
||||
log "Creating function spec"
|
||||
fission fn create --spec --name $fn --env $env --deploy "multifile/*" --entrypoint main.main
|
||||
@@ -37,4 +48,6 @@ fission fn test --name $fn | grep -i hello
|
||||
|
||||
log "Destroying spec objects"
|
||||
fission spec destroy
|
||||
popd
|
||||
popd
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
Reference in New Issue
Block a user