From b43ef2dba47e1752b9bf9a75cef68c8fdaf5296b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Thu, 23 Jan 2025 09:15:03 +0100 Subject: [PATCH] Many: replace 'which' with 'type -p' in test cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately, `which` does not seem to be installed by default on our F41 CI images. Instead of doing the dance with rebuilds, which has been problematic recently, let's not rely on `which` in scripts any more, since we can replace it with the Bash built-in `type` command. Signed-off-by: Tomáš Hozza --- test/cases/api.sh | 4 ++-- test/cases/aws.sh | 4 ++-- test/cases/aws_s3.sh | 4 ++-- test/cases/azure.sh | 4 ++-- test/cases/filesystem.sh | 2 +- test/cases/gcp.sh | 4 ++-- test/cases/generic_s3.sh | 4 ++-- test/cases/image_tests.sh | 2 +- test/cases/koji.sh | 4 ++-- test/cases/oci.sh | 4 ++-- test/cases/regression-old-worker-new-composer.sh | 4 ++-- test/cases/ubi-wsl.sh | 4 ++-- test/cases/worker-executor.sh | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/cases/api.sh b/test/cases/api.sh index 06f4f4b5c1..072431a892 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -101,9 +101,9 @@ export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" # # Set up the database queue # -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/aws.sh b/test/cases/aws.sh index f9acf5b60e..fbeb6715fb 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -20,9 +20,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/aws_s3.sh b/test/cases/aws_s3.sh index 5e1634b28e..d28ab0a496 100755 --- a/test/cases/aws_s3.sh +++ b/test/cases/aws_s3.sh @@ -11,9 +11,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/azure.sh b/test/cases/azure.sh index 5138ecb8b8..ddde74776c 100755 --- a/test/cases/azure.sh +++ b/test/cases/azure.sh @@ -24,9 +24,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/filesystem.sh b/test/cases/filesystem.sh index f03564d4ad..8d8a889b0c 100644 --- a/test/cases/filesystem.sh +++ b/test/cases/filesystem.sh @@ -37,7 +37,7 @@ function cleanup_on_exit() { trap cleanup_on_exit EXIT # Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image -OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)") +OSBUILD_LABEL=$(matchpathcon -n "$(type -p osbuild)") sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info # Build ostree image. diff --git a/test/cases/gcp.sh b/test/cases/gcp.sh index 3182848e67..485512f958 100755 --- a/test/cases/gcp.sh +++ b/test/cases/gcp.sh @@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/generic_s3.sh b/test/cases/generic_s3.sh index 6344261ae4..4ec8de5bdf 100755 --- a/test/cases/generic_s3.sh +++ b/test/cases/generic_s3.sh @@ -12,9 +12,9 @@ CONTAINER_MINIO_SERVER="quay.io/minio/minio:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/image_tests.sh b/test/cases/image_tests.sh index 27270a36ed..149bf2f568 100755 --- a/test/cases/image_tests.sh +++ b/test/cases/image_tests.sh @@ -97,7 +97,7 @@ run_test_case () { cd $WORKING_DIRECTORY # Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image -OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)") +OSBUILD_LABEL=$(matchpathcon -n "$(type -p osbuild)") sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info # Run each test case. diff --git a/test/cases/koji.sh b/test/cases/koji.sh index 507fff2932..11fc0f3a06 100755 --- a/test/cases/koji.sh +++ b/test/cases/koji.sh @@ -78,9 +78,9 @@ if [[ "$TEST_TYPE" == "$TEST_TYPE_CLOUD_UPLOAD" ]]; then # Container image used for cloud provider CLI tools export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" - if which podman 2>/dev/null >&2; then + if type -p podman 2>/dev/null >&2; then export CONTAINER_RUNTIME=podman - elif which docker 2>/dev/null >&2; then + elif type -p docker 2>/dev/null >&2; then export CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/oci.sh b/test/cases/oci.sh index bc0e4cbfb1..81aeb7fa98 100755 --- a/test/cases/oci.sh +++ b/test/cases/oci.sh @@ -17,9 +17,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" # Provision the software under test. /usr/libexec/osbuild-composer-test/provision.sh none -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/regression-old-worker-new-composer.sh b/test/cases/regression-old-worker-new-composer.sh index c269bfd8fe..4aa6db0f36 100644 --- a/test/cases/regression-old-worker-new-composer.sh +++ b/test/cases/regression-old-worker-new-composer.sh @@ -84,9 +84,9 @@ sudo dnf install -y osbuild-composer-worker podman composer-cli # verify the right worker is installed just to be sure rpm -q "$DESIRED_WORKER_RPM" -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/ubi-wsl.sh b/test/cases/ubi-wsl.sh index ccc08b0ce3..fec9a67da9 100755 --- a/test/cases/ubi-wsl.sh +++ b/test/cases/ubi-wsl.sh @@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" /usr/libexec/osbuild-composer-test/provision.sh none # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker. diff --git a/test/cases/worker-executor.sh b/test/cases/worker-executor.sh index 5f8947e178..6ccacd3db6 100644 --- a/test/cases/worker-executor.sh +++ b/test/cases/worker-executor.sh @@ -22,9 +22,9 @@ KEYPAIR=${TEMPDIR}/keypair.pem INSTANCE_ID=$(curl -Ls http://169.254.169.254/latest/meta-data/instance-id) # Check available container runtime -if which podman 2>/dev/null >&2; then +if type -p podman 2>/dev/null >&2; then CONTAINER_RUNTIME=podman -elif which docker 2>/dev/null >&2; then +elif type -p docker 2>/dev/null >&2; then CONTAINER_RUNTIME=docker else echo No container runtime found, install podman or docker.