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
|
|
@ -49,6 +49,9 @@ class ImageStreamChecker(object):
|
|||
def check_version(self, json_dict: Dict[Any, Any]) -> List[str]:
|
||||
res = []
|
||||
for tags in json_dict["spec"]["tags"]:
|
||||
print(
|
||||
f"check_version: Compare tags['name']:'{tags['name']}' against version:'{self.version}'"
|
||||
)
|
||||
# The name can be"<stream>" or "<stream>-elX" or "<stream>-ubiX"
|
||||
if tags["name"] == self.version or tags["name"].startswith(
|
||||
self.version + "-"
|
||||
|
|
@ -61,11 +64,15 @@ class ImageStreamChecker(object):
|
|||
for tags in json_dict["spec"]["tags"]:
|
||||
if tags["name"] != "latest":
|
||||
continue
|
||||
print(
|
||||
f"check_latest_tag: Compare tags['name']:'{tags['name']}' against version:'{self.version}'"
|
||||
)
|
||||
# The latest can link to either "<stream>" or "<stream>-elX" or "<stream>-ubiX"
|
||||
if tags["from"]["name"] == self.version or tags["from"]["name"].startswith(
|
||||
self.version + "-"
|
||||
):
|
||||
latest_tag_correct = True
|
||||
print(f"Latest tag found.")
|
||||
return latest_tag_correct
|
||||
|
||||
def check_imagestreams(self) -> int:
|
||||
|
|
|
|||
|
|
@ -5,22 +5,23 @@ source "$(dirname "${BASH_SOURCE[0]}")"/test-lib.sh
|
|||
|
||||
# Set of functions for testing docker images in OpenShift using 'oc' command
|
||||
|
||||
# A variable containing the overall test result; must be changed to 0 in the end
|
||||
# of the testing script:
|
||||
# OS_TESTSUITE_RESULT=0
|
||||
# A variable containing the overall test result
|
||||
# TESTSUITE_RESULT=0
|
||||
# And the following trap must be set, in the beginning of the test script:
|
||||
# trap ct_os_cleanup EXIT SIGINT
|
||||
OS_TESTSUITE_RESULT=1
|
||||
TESTSUITE_RESULT=0
|
||||
OS_CLUSTER_STARTED_BY_TEST=0
|
||||
|
||||
function ct_os_cleanup() {
|
||||
echo "${test_short_summary:-}"
|
||||
if [ $OS_TESTSUITE_RESULT -eq 0 ] ; then
|
||||
echo "${TEST_SUMMARY:-}"
|
||||
if [ $TESTSUITE_RESULT -eq 0 ] ; then
|
||||
# shellcheck disable=SC2153
|
||||
echo "OpenShift tests for ${IMAGE_NAME} succeeded."
|
||||
exit 0
|
||||
else
|
||||
# shellcheck disable=SC2153
|
||||
echo "OpenShift tests for ${IMAGE_NAME} failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ source "$(dirname "${BASH_SOURCE[0]}")"/test-lib.sh
|
|||
|
||||
# Set of functions for testing docker images in OpenShift using 'oc' command
|
||||
|
||||
# A variable containing the overall test result; must be changed to 0 in the end
|
||||
# of the testing script:
|
||||
# OS_TESTSUITE_RESULT=0
|
||||
# A variable containing the overall test result
|
||||
# TESTSUITE_RESULT=0
|
||||
# And the following trap must be set, in the beginning of the test script:
|
||||
# trap ct_os_cleanup EXIT SIGINT
|
||||
|
||||
|
|
@ -32,13 +31,6 @@ function ct_os_set_path_oc_4() {
|
|||
return 1
|
||||
fi
|
||||
export PATH="${oc_path}:${PATH}"
|
||||
oc version
|
||||
if ! oc version | grep -q "Client Version: ${oc_version}." ; then
|
||||
echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${oc_version} not found in PATH ($PATH)" >&1
|
||||
return 1
|
||||
else
|
||||
echo "PATH set correctly, binary oc found in version ${oc_version}: $(command -v oc)"
|
||||
fi
|
||||
}
|
||||
|
||||
# ct_os_prepare_ocp4
|
||||
|
|
@ -55,10 +47,15 @@ function ct_os_set_ocp4() {
|
|||
OS_OC_CLIENT_VERSION=${OS_OC_CLIENT_VERSION:-4.4}
|
||||
ct_os_set_path_oc_4 "${OS_OC_CLIENT_VERSION}"
|
||||
|
||||
oc version
|
||||
|
||||
login=$(cat "$KUBEPASSWORD")
|
||||
oc login -u kubeadmin -p "$login"
|
||||
oc version
|
||||
if ! oc version | grep -q "Client Version: ${OS_OC_CLIENT_VERSION}." ; then
|
||||
echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${OS_OC_CLIENT_VERSION} not found in PATH ($PATH)" >&1
|
||||
return 1
|
||||
else
|
||||
echo "PATH set correctly, binary oc found in version ${OS_OC_CLIENT_VERSION}: $(command -v oc)"
|
||||
fi
|
||||
echo "Login to OpenShift ${OS_OC_CLIENT_VERSION} is DONE"
|
||||
# let openshift cluster to sync to avoid some race condition errors
|
||||
sleep 3
|
||||
|
|
|
|||
|
|
@ -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