Merge pull request #501 from sclorg/support_test_build_push_c9s
Support test, build, and push for CentOS Stream 9
This commit is contained in:
parent
aa1ec203ed
commit
fe411e1004
5 changed files with 158 additions and 38 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
# may be redefined in the specific container testfile
|
||||
EXPECTED_EXIT_CODE=0
|
||||
export TESTSUITE_RESULT=0
|
||||
|
||||
# ct_cleanup
|
||||
# --------------------
|
||||
|
|
@ -33,12 +34,17 @@ function ct_cleanup() {
|
|||
|
||||
: "Stopping and removing container $container..."
|
||||
docker stop "$container"
|
||||
exit_status=$(docker inspect -f '{{.State.ExitCode}}' "$container")
|
||||
if [ "$exit_status" != "$EXPECTED_EXIT_CODE" ]; then
|
||||
: "Dumping logs for $container"
|
||||
docker logs "$container"
|
||||
|
||||
# Container has not been removed by `docker stop` and still exists
|
||||
if [ $( docker ps -a -f id=$container | wc -l ) -eq 2 ]; then
|
||||
exit_status=$(docker inspect -f '{{.State.ExitCode}}' "$container")
|
||||
if [ "$exit_status" != "$EXPECTED_EXIT_CODE" ]; then
|
||||
: "Dumping logs for $container"
|
||||
docker logs "$container"
|
||||
fi
|
||||
docker rm -v "$container"
|
||||
fi
|
||||
docker rm -v "$container"
|
||||
|
||||
rm "$cid_file"
|
||||
done
|
||||
rmdir "$CID_FILE_DIR"
|
||||
|
|
@ -125,6 +131,7 @@ function ct_check_envs_set {
|
|||
for value in $stripped; do
|
||||
# If the falue checked does not go through env_filter we do not care about it
|
||||
echo "$value" | grep -q "$env_filter" || continue
|
||||
# shellcheck disable=SC2295
|
||||
if [ -n "${filtered_envs##${env_format//VALUE/$value}}" ]; then
|
||||
echo " Value $value is missing from variable $var_name"
|
||||
echo "$filtered_envs"
|
||||
|
|
@ -489,21 +496,6 @@ ct_path_foreach ()
|
|||
}
|
||||
|
||||
|
||||
# ct_run_test_list
|
||||
# --------------------
|
||||
# Execute the tests specified by TEST_LIST
|
||||
# Uses: $TEST_LIST - list of test names
|
||||
function ct_run_test_list() {
|
||||
for test_case in $TEST_LIST; do
|
||||
: "Running test $test_case"
|
||||
# shellcheck source=/dev/null
|
||||
[ -f "test/$test_case" ] && source "test/$test_case"
|
||||
# shellcheck source=/dev/null
|
||||
[ -f "../test/$test_case" ] && source "../test/$test_case"
|
||||
$test_case
|
||||
done;
|
||||
}
|
||||
|
||||
# ct_gen_self_signed_cert_pem
|
||||
# ---------------------------
|
||||
# Generates a self-signed PEM certificate pair into specified directory.
|
||||
|
|
@ -1069,4 +1061,45 @@ ct_test_app_dockerfile() {
|
|||
return $ret
|
||||
}
|
||||
|
||||
# ct_check_testcase_result
|
||||
# -----------------------------
|
||||
# Check if testcase ended in success or error
|
||||
# Argument: result - testcase result value
|
||||
# Uses: $TESTCASE_RESULT - result of the testcase
|
||||
# Uses: $IMAGE_NAME - name of the image being tested
|
||||
ct_check_testcase_result() {
|
||||
local result="$1"
|
||||
if [[ "$result" != "0" ]]; then
|
||||
echo "Test for image '${IMAGE_NAME}' FAILED (exit code: ${result})"
|
||||
TESTCASE_RESULT=1
|
||||
fi
|
||||
return "$result"
|
||||
}
|
||||
|
||||
# ct_run_tests_from_testset
|
||||
# -----------------------------
|
||||
# Runs all tests in $TEST_SET, prints result to
|
||||
# the $TEST_SUMMARY variable
|
||||
# Argument: app_name - application name to log
|
||||
# Uses: $TEST_SET - set of test cases to run
|
||||
# Uses: $TEST_SUMMARY - variable for storing test results
|
||||
# Uses: $IMAGE_NAME - name of the image being tested
|
||||
ct_run_tests_from_testset() {
|
||||
local app_name="$1"
|
||||
for test_case in $TEST_SET; do
|
||||
TESTCASE_RESULT=0
|
||||
echo "Running test $test_case ... "
|
||||
$test_case
|
||||
ct_check_testcase_result $?
|
||||
local test_msg
|
||||
if [ $TESTCASE_RESULT -eq 0 ]; then
|
||||
test_msg="[PASSED]"
|
||||
else
|
||||
test_msg="[FAILED]"
|
||||
TESTSUITE_RESULT=1
|
||||
fi
|
||||
printf -v TEST_SUMMARY "%s %s for '%s' %s\n" "${TEST_SUMMARY}" "${test_msg}" "${app_name}" "$test_case"
|
||||
done;
|
||||
}
|
||||
|
||||
# vim: set tabstop=2:shiftwidth=2:expandtab:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue