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
+13 -16
View File
@@ -1,21 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
source $(dirname $0)/../utils.sh
# test_annotations.sh - tests whether a user is able to add pod annotations to a Fission environment deployment
TEST_ID=$(date +%s)
TEST_ID=$(generate_test_id)
echo "TEST_ID = $TEST_ID"
tmp_dir="/tmp/test-$TEST_ID"
mkdir -p $tmp_dir
ENV=python-${TEST_ID}
FN=foo-${TEST_ID}
RESOURCE_NS=default # Change to test-specific namespace once we support namespaced CRDs
FUNCTION_NS=${FUNCTION_NAMESPACE:-fission-function}
BUILDER_NS=fission-builder
LIST_ANNOTATIONS=go-template='{{range $key,$value := .metadata.annotations}}{{$key}}: {{$value}}{{"\n"}}{{end}}'
# fs
TEST_DIR=/tmp/${TEST_ID}
ENV_SPEC_FILE=${TEST_DIR}/${ENV}.yaml
FN_FILE=${TEST_DIR}/${FN}.yaml
ENV_SPEC_FILE=$tmp_dir/${ENV}.yaml
log_exec() {
cmd=$@
@@ -25,22 +28,16 @@ log_exec() {
cleanup() {
log "Cleaning up..."
kubectl -n ${RESOURCE_NS} delete environment/${ENV} || true
rm -rf ${TEST_DIR}
clean_resource_by_id $TEST_ID
rm -rf $tmp_dir
}
cleanup
if [ -z "${TEST_NOCLEANUP:-}" ]; then
trap cleanup EXIT
else
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
fi
if ! stat ${TEST_DIR} >/dev/null 2>&1 ; then
mkdir ${TEST_DIR}
fi
getPodName() {
NS=$1
POD=$2
@@ -57,7 +54,7 @@ getPodName() {
# https://unix.stackexchange.com/questions/82598/how-do-i-write-a-retry-logic-in-script-to-keep-retrying-to-run-it-upto-5-times/82610
function retry {
local n=1
local max=5
local max=10
local delay=10 # pods take time to get ready
while true; do
"$@" && break || {
@@ -88,9 +85,9 @@ metadata:
spec:
builder:
command: build
image: gcr.io/fission-ci/python-env-builder:test
image: ${PYTHON_BUILDER_IMAGE}
runtime:
image: gcr.io/fission-ci/python-env:test
image: ${PYTHON_RUNTIME_IMAGE}
version: 2
poolsize: 1
EOM