From d4856a20e70f015c8f05c715cbfb36ee965351b4 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" <phracek@redhat.com> Date: Wed, 27 Mar 2024 12:32:59 +0100 Subject: [PATCH 1/5] Add build_args also to `ct_s2i_build_as_df` function. We have to functions to build image. This one and `ct_test_app_dockerfile` In case of --ulimit is defined in s2i_args variable we will add this parameter to docker/podman command line. Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com> --- test-lib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test-lib.sh b/test-lib.sh index c38647e..b544eba 100644 --- a/test-lib.sh +++ b/test-lib.sh @@ -902,6 +902,7 @@ ct_s2i_build_as_df() local incremental=false local mount_options=() local id_file + local build_args="" # Run the entire thing inside a subshell so that we do not leak shell options outside of the function ( @@ -988,8 +989,9 @@ EOF # Check if -v parameter is present in s2i_args and add it into docker build command read -ra mount_options <<< "$(echo "$s2i_args" | grep -o -e '\(-v\)[[:space:]]\.*\S*' || true)" + echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') # Run the build and tag the result - ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image ." + ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image . $build_args" #shellcheck disable=SC2181 if [ "$?" -ne 0 ]; then echo " ERROR: Failed to to build $df_name" >&2 From cb248e0eb51c785f812d432820d64f178c3eedad Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" <phracek@redhat.com> Date: Thu, 28 Mar 2024 12:49:05 +0100 Subject: [PATCH 2/5] Add comments for --ulimit parameter. An example: $ s2i_args="pull-policy=never --incremental -e DEV_MODE=true -v /var/lib/psql --ulimit nofile=4096:4096" $ echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') $ echo $build_args --ulimit nofile=4096:4096 The second example: $ s2i_args="pull-policy=never --incremental -e DEV_MODE=true -v /var/lib/psql --ulimit nofile=4096:4096 -v /etc" $ echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') $ echo $build_args --ulimit nofile=4096:4096 Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com> --- test-lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-lib.sh b/test-lib.sh index b544eba..a57e911 100644 --- a/test-lib.sh +++ b/test-lib.sh @@ -989,6 +989,8 @@ EOF # Check if -v parameter is present in s2i_args and add it into docker build command read -ra mount_options <<< "$(echo "$s2i_args" | grep -o -e '\(-v\)[[:space:]]\.*\S*' || true)" + # Check if s2i_args contains --ulimit + # if so, add it into docker build command. The format is like --ulimit nofile=4096:4096 echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') # Run the build and tag the result ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image . $build_args" From ad945b853928acaaac8a4ad735ed6e79a4eb6821 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" <phracek@redhat.com> Date: Thu, 28 Mar 2024 15:03:23 +0100 Subject: [PATCH 3/5] Do not use latest tag for quay.io/centos7/* images Instead of use :centos7 tag Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com> --- test-lib.sh | 2 +- tests/failures/check/v0/Dockerfile | 2 +- tests/test-lib/image_availability | 8 ++++---- tests/test-lib/public_image_name | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test-lib.sh b/test-lib.sh index a57e911..130dba2 100644 --- a/test-lib.sh +++ b/test-lib.sh @@ -813,7 +813,7 @@ ct_get_public_image_name() { elif [ "$os" == "rhel9" ]; then public_image_name=$registry/rhel9/$base_image_name-${version//./} elif [ "$os" == "centos7" ]; then - public_image_name=$registry/centos7/$base_image_name-${version//./}-centos7 + public_image_name=$registry/centos7/$base_image_name-${version//./}-centos7:centos7 elif [ "$os" == "c8s" ]; then public_image_name=$registry/sclorg/$base_image_name-${version//./}-c8s elif [ "$os" == "c9s" ]; then diff --git a/tests/failures/check/v0/Dockerfile b/tests/failures/check/v0/Dockerfile index 6fc6c9f..1fb2bd2 100644 --- a/tests/failures/check/v0/Dockerfile +++ b/tests/failures/check/v0/Dockerfile @@ -1,2 +1,2 @@ -FROM quay.io/centos7/s2i-core-centos7 +FROM quay.io/centos7/s2i-core-centos7:centos7 LABEL name=test-image diff --git a/tests/test-lib/image_availability b/tests/test-lib/image_availability index 0ed9b27..d1c0ecd 100755 --- a/tests/test-lib/image_availability +++ b/tests/test-lib/image_availability @@ -5,25 +5,25 @@ set -e . test-lib.sh # This should succeed -if ! ct_pull_image quay.io/centos7/ruby-27-centos7; then +if ! ct_pull_image quay.io/centos7/ruby-27-centos7:centos7; then echo "image_availability test failed" false fi # This should fail -if ct_pull_image quay.io/centos7/ruby-24-centos7 false 1; then +if ct_pull_image quay.io/centos7/ruby-24-centos7:centos7 false 1; then echo "image_availability test failed" false fi # This should succeed -if ! ct_check_image_availability quay.io/centos7/ruby-27-centos7; then +if ! ct_check_image_availability quay.io/centos7/ruby-27-centos7:centos7; then echo "check_image_availability test failed" false fi # This should fail -if ct_check_image_availability quay.io/centos7/ruby-24-centos7; then +if ct_check_image_availability quay.io/centos7/ruby-24-centos7:centos7; then echo "check_image_availability test failed" false fi diff --git a/tests/test-lib/public_image_name b/tests/test-lib/public_image_name index 92fcb2b..c9001ac 100755 --- a/tests/test-lib/public_image_name +++ b/tests/test-lib/public_image_name @@ -5,7 +5,7 @@ set -e . test-lib.sh combinations="rhel7:registry.redhat.io/rhscl/postgresql-10-rhel7 -centos7:quay.io/centos7/postgresql-10-centos7 +centos7:quay.io/centos7/postgresql-10-centos7:centos7 rhel8:registry.redhat.io/rhel8/postgresql-10 " From 3f0dced6f172381e115ab5de5ec85a6603dbf2b6 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" <phracek@redhat.com> Date: Tue, 2 Apr 2024 15:56:03 +0200 Subject: [PATCH 4/5] Add wrapper for building images by podman with arguments Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com> --- test-lib.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test-lib.sh b/test-lib.sh index 130dba2..ac76fe3 100644 --- a/test-lib.sh +++ b/test-lib.sh @@ -894,6 +894,26 @@ ct_s2i_build_as_df() local src_image=$1; shift local dst_image=$1; shift local s2i_args="$*"; + + ct_s2i_build_as_df_build_args "$app_path" "$src_image" "$dst_image" "" "$s2i_args" +} + +# ct_s2i_build_as_df_build_args APP_PATH SRC_IMAGE DST_IMAGE [S2I_ARGS] +# ---------------------------- +# Create a new s2i app image from local sources in a similar way as source-to-image would have used. +# Argument: APP_PATH - local path to the app sources to be used in the test +# Argument: SRC_IMAGE - image to be used as a base for the s2i build +# Argument: DST_IMAGE - image name to be used during the tagging of the s2i build result +# Argument: BUILD_ARGS - Build arguments to be used in the s2i build +# Argument: S2I_ARGS - Additional list of source-to-image arguments. +# Only used to check for pull-policy=never and environment variable definitions. +ct_s2i_build_as_df_build_args() +{ + local app_path=$1; shift + local src_image=$1; shift + local dst_image=$1; shift + local build_args=$1; shift + local s2i_args="$*"; local local_app=upload/src/ local local_scripts=upload/scripts/ local user_id= @@ -902,7 +922,6 @@ ct_s2i_build_as_df() local incremental=false local mount_options=() local id_file - local build_args="" # Run the entire thing inside a subshell so that we do not leak shell options outside of the function ( @@ -989,9 +1008,6 @@ EOF # Check if -v parameter is present in s2i_args and add it into docker build command read -ra mount_options <<< "$(echo "$s2i_args" | grep -o -e '\(-v\)[[:space:]]\.*\S*' || true)" - # Check if s2i_args contains --ulimit - # if so, add it into docker build command. The format is like --ulimit nofile=4096:4096 - echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') # Run the build and tag the result ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image . $build_args" #shellcheck disable=SC2181 From ca4f716c7b500c2ad9796a7c79b94f42e9848474 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" <phracek@redhat.com> Date: Wed, 3 Apr 2024 01:16:48 +0200 Subject: [PATCH 5/5] Add description about wrapper and why it was added. Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com> --- test-lib.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-lib.sh b/test-lib.sh index ac76fe3..355ea97 100644 --- a/test-lib.sh +++ b/test-lib.sh @@ -883,6 +883,9 @@ ct_s2i_usage() # ct_s2i_build_as_df APP_PATH SRC_IMAGE DST_IMAGE [S2I_ARGS] # ---------------------------- # Create a new s2i app image from local sources in a similar way as source-to-image would have used. +# This function is wrapper for ct_s2i_build_as_df_build_args in case user do not want to add build args +# This function is used in all https://github.com/sclorg/*-container test cases and we do not +# want to break functionality # Argument: APP_PATH - local path to the app sources to be used in the test # Argument: SRC_IMAGE - image to be used as a base for the s2i build # Argument: DST_IMAGE - image name to be used during the tagging of the s2i build result @@ -898,7 +901,7 @@ ct_s2i_build_as_df() ct_s2i_build_as_df_build_args "$app_path" "$src_image" "$dst_image" "" "$s2i_args" } -# ct_s2i_build_as_df_build_args APP_PATH SRC_IMAGE DST_IMAGE [S2I_ARGS] +# ct_s2i_build_as_df_build_args APP_PATH SRC_IMAGE DST_IMAGE BUILD_ARGS [S2I_ARGS] # ---------------------------- # Create a new s2i app image from local sources in a similar way as source-to-image would have used. # Argument: APP_PATH - local path to the app sources to be used in the test