From e014ad67c67355e9e69660c425ba7e2b59fb26fa Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 16 Jul 2025 15:20:39 -0400 Subject: [PATCH 1/6] Makefile: validate-local depends on tools This is required for fetching golangci-lint if it doesn't exist. Signed-off-by: Lokesh Mandvekar --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c1bfe463..a707d44c 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ validate: test-all-local: validate-local validate-docs test-unit-local .PHONY: validate-local -validate-local: +validate-local: tools hack/validate-git-marks.sh hack/validate-gofmt.sh $(GOBIN)/golangci-lint run --build-tags "${BUILDTAGS}" From 48878185249e788913c7dd9903e3651601c8f0ca Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 16 Jul 2025 15:25:54 -0400 Subject: [PATCH 2/6] Makefile: test-system-local checks for SKOPEO_BINARY Signed-off-by: Lokesh Mandvekar --- Makefile | 3 +-- hack/test-system.sh | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a707d44c..d0fb5fac 100644 --- a/Makefile +++ b/Makefile @@ -220,8 +220,7 @@ test-system: exit $$rc # Intended for CI, assumed to already be running in quay.io/libpod/skopeo_cidev container. -test-system-local: bin/skopeo - hack/warn-destructive-tests.sh +test-system-local: $(if $(SKOPEO_BINARY),,bin/skopeo) hack/test-system.sh test-unit: diff --git a/hack/test-system.sh b/hack/test-system.sh index 5474cfca..a2550183 100755 --- a/hack/test-system.sh +++ b/hack/test-system.sh @@ -37,8 +37,12 @@ EOF export CONTAINERS_STORAGE_CONF=/etc/containers/storage.conf fi -# Build skopeo, install into /usr/bin -make PREFIX=/usr install +# Print what binary is being used for tests +if [[ -v SKOPEO_BINARY ]]; then + echo "Testing with $SKOPEO_BINARY ..." +else + echo "Testing with $(git rev-parse --show-toplevel)/bin/skopeo ..." +fi -# Run tests -SKOPEO_BINARY=/usr/bin/skopeo bats --tap systemtest +# The skopeo binary will be at ../bin/skopeo unless set via SKOPEO_BINARY var +bats --tap systemtest From 1495c459821c465cb62f99707ca3d431e3ed3eda Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 16 Jul 2025 15:33:01 -0400 Subject: [PATCH 3/6] integration: default to "registry" binary The "registry-v2" binary currently being used is present in the container image but it can't be found on local environments. The docker-distribution provides the `registry` binary which does work for the integration tests. This commit switches to preferring the `registry-v2` binary and defaults to `registry`. `make test-integration-local` passes with this change and docker-distribution installed. Signed-off-by: Lokesh Mandvekar --- integration/registry_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/integration/registry_test.go b/integration/registry_test.go index 320fa425..c93271dc 100644 --- a/integration/registry_test.go +++ b/integration/registry_test.go @@ -13,10 +13,17 @@ import ( ) const ( - binaryV2 = "registry-v2" binaryV2Schema1 = "registry-v2-schema1" ) +// getBinaryV2 returns the available registry binary name, preferring "registry-v2" over "registry" +func getBinaryV2() string { + if _, err := exec.LookPath("registry-v2"); err == nil { + return "registry-v2" + } + return "registry" +} + type testRegistryV2 struct { cmd *exec.Cmd url string @@ -92,7 +99,7 @@ compatibility: if schema1 { cmd = exec.Command(binaryV2Schema1, confPath) } else { - cmd = exec.Command(binaryV2, "serve", confPath) + cmd = exec.Command(getBinaryV2(), "serve", confPath) } consumeAndLogOutputs(t, fmt.Sprintf("registry-%s", url), cmd) From 0636578e3053904ce2542271fb4e8e001a24d1ba Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 16 Jul 2025 15:20:17 -0400 Subject: [PATCH 4/6] Makefile: test-integration-local depends on install-binary Signed-off-by: Lokesh Mandvekar --- Makefile | 6 ++---- hack/test-integration.sh | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d0fb5fac..04cb596e 100644 --- a/Makefile +++ b/Makefile @@ -201,10 +201,8 @@ test-integration: $(CONTAINER_CMD) --security-opt label=disable --cap-add=cap_mknod -v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) $(SKOPEO_CIDEV_CONTAINER_FQIN) \ $(MAKE) test-integration-local - -# Intended for CI, assumed to be running in quay.io/libpod/skopeo_cidev container. -test-integration-local: bin/skopeo - hack/warn-destructive-tests.sh +# Expects binary in $PATH, so better to depend on install-binary target +test-integration-local: install-binary hack/test-integration.sh # complicated set of options needed to run podman-in-podman diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 63dc2485..4d121a9a 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -1,8 +1,6 @@ #!/bin/bash set -e -make PREFIX=/usr install - echo "cd ./integration;" go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} cd ./integration -go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} \ No newline at end of file +go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} From 3ec5f078812bdd0bb524efd28e54212205d116d4 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 16 Jul 2025 15:40:11 -0400 Subject: [PATCH 5/6] hack/test-integration.sh: Shellcheck fixes Signed-off-by: Lokesh Mandvekar --- hack/test-integration.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 4d121a9a..138bae43 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -echo "cd ./integration;" go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} +echo "cd ./integration;" go test "$TESTFLAGS" ${BUILDTAGS:+-tags "$BUILDTAGS"} cd ./integration -go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} +go test "$TESTFLAGS" ${BUILDTAGS:+-tags "$BUILDTAGS"} From 70334e70c52e8e1dcf40924c83ed87eaa80f969f Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Mon, 14 Jul 2025 10:48:30 -0400 Subject: [PATCH 6/6] TMT: add more tests Signed-off-by: Lokesh Mandvekar --- .packit.yaml | 77 +++++++++++++++++++++++++++------ Makefile | 6 +++ hack/tmt/bats-setup.sh | 16 +++++++ hack/tmt/dnf-repo-setup.sh | 10 +++++ plans/main.fmf | 26 ----------- plans/no-rpm.fmf | 25 +++++++++++ plans/rpm.fmf | 22 ++++++++++ systemtest/tmt/main.fmf | 14 ------ systemtest/tmt/test.sh | 13 ------ tmt/main.fmf | 88 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 230 insertions(+), 67 deletions(-) create mode 100644 hack/tmt/bats-setup.sh create mode 100644 hack/tmt/dnf-repo-setup.sh delete mode 100644 plans/main.fmf create mode 100644 plans/no-rpm.fmf create mode 100644 plans/rpm.fmf delete mode 100644 systemtest/tmt/main.fmf delete mode 100644 systemtest/tmt/test.sh create mode 100644 tmt/main.fmf diff --git a/.packit.yaml b/.packit.yaml index e7c125f2..25936eaf 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -21,7 +21,7 @@ files_to_sync: dest: plans/ delete: true mkpath: true - - src: systemtest/tmt/ + - src: tmt/ dest: test/tmt/ delete: true mkpath: true @@ -47,9 +47,9 @@ jobs: - job: copr_build trigger: pull_request packages: [skopeo-fedora] - notifications: &copr_build_failure_notification + notifications: &packit_failure_notification failure_comment: - message: "Ephemeral COPR build failed. @containers/packit-build please check." + message: "Packit jobs failed. @containers/packit-build please check." targets: &fedora_copr_targets - fedora-all-x86_64 - fedora-all-aarch64 @@ -62,7 +62,7 @@ jobs: - job: copr_build trigger: ignore packages: [skopeo-eln] - notifications: *copr_build_failure_notification + notifications: *packit_failure_notification targets: fedora-eln-x86_64: additional_repos: @@ -76,7 +76,7 @@ jobs: - job: copr_build trigger: ignore packages: [skopeo-centos] - notifications: *copr_build_failure_notification + notifications: *packit_failure_notification targets: ¢os_copr_targets - centos-stream-9-x86_64 - centos-stream-9-aarch64 @@ -88,34 +88,83 @@ jobs: - job: copr_build trigger: commit packages: [skopeo-fedora] - notifications: - failure_comment: - message: "podman-next COPR build failed. @containers/packit-build please check." branch: main owner: rhcontainerbot project: podman-next enable_net: true - # Tests on Fedora for main branch + # System tests on Fedora - job: tests trigger: pull_request packages: [skopeo-fedora] - notifications: &test_failure_notification - failure_comment: - message: "Tests failed. @containers/packit-build please check." + notifications: *packit_failure_notification targets: *fedora_copr_targets - tf_extra_params: + tf_extra_params: &extra_dnf_repos environments: - artifacts: - type: repository-file id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo + tmt_plan: "/plans/rpm/system" + identifier: "system" + + # ostree-rs-ext tests on Fedora + - job: tests + trigger: pull_request + packages: [skopeo-fedora] + notifications: *packit_failure_notification + targets: *fedora_copr_targets + tf_extra_params: *extra_dnf_repos + tmt_plan: "/plans/rpm/ostree-rs-ext" + identifier: "ostree-rs-ext" + + # Integration tests on Fedora + - job: tests + trigger: pull_request + skip_build: true + packages: [skopeo-fedora] + notifications: *packit_failure_notification + targets: + # x86_6 only because of quay.io/coreos/11bot + # See: integration/proxy_test.go + - fedora-all + tf_extra_params: *extra_dnf_repos + tmt_plan: "/plans/no-rpm/integration" + identifier: "integration" + + # Unit tests on Fedora + - job: tests + trigger: pull_request + skip_build: true + notifications: *packit_failure_notification + targets: &fedora_no_rpm_targets + - fedora-latest-stable + tmt_plan: "/plans/no-rpm/unit" + identifier: "unit" + + # Validate test on Fedora + - job: tests + trigger: pull_request + skip_build: true + notifications: *packit_failure_notification + targets: *fedora_no_rpm_targets + tmt_plan: "/plans/no-rpm/validate" + identifier: "validate" + + # Test w/ opengpg static linked on Fedora + - job: tests + trigger: pull_request + skip_build: true + notifications: *packit_failure_notification + targets: *fedora_no_rpm_targets + tmt_plan: "/plans/no-rpm/opengpg" + identifier: "opengpg" # Tests on CentOS Stream for main branch # Ignore until golang is updated in distro buildroot to go 1.23.3+ - job: tests trigger: ignore packages: [skopeo-centos] - notifications: *test_failure_notification + notifications: *packit_failure_notification targets: *centos_copr_targets tf_extra_params: environments: diff --git a/Makefile b/Makefile index 04cb596e..c538887b 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,13 @@ test-integration: $(CONTAINER_CMD) --security-opt label=disable --cap-add=cap_mknod -v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) $(SKOPEO_CIDEV_CONTAINER_FQIN) \ $(MAKE) test-integration-local +<<<<<<< HEAD # Expects binary in $PATH, so better to depend on install-binary target +======= + +# Intended for CI, assumed to be running in quay.io/libpod/skopeo_cidev container. +# Expects binary in PATH, so better to depend on install-binary target +>>>>>>> 5bf4e23d (TMT: add more tests) test-integration-local: install-binary hack/test-integration.sh diff --git a/hack/tmt/bats-setup.sh b/hack/tmt/bats-setup.sh new file mode 100644 index 00000000..15bbec54 --- /dev/null +++ b/hack/tmt/bats-setup.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -exo pipefail + +# Install bats +# https://bats-core.readthedocs.io/en/stable/installation.html + +BATS_TMPDIR=$(mktemp -d) +pushd "$BATS_TMPDIR" + +BATS_VERSION=1.12.0 +curl -ssfL https://github.com/bats-core/bats-core/archive/refs/tags/v"$BATS_VERSION".tar.gz | tar -xz +pushd bats-core-"$BATS_VERSION" +./install.sh /usr +popd +popd diff --git a/hack/tmt/dnf-repo-setup.sh b/hack/tmt/dnf-repo-setup.sh new file mode 100644 index 00000000..6153bc37 --- /dev/null +++ b/hack/tmt/dnf-repo-setup.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -exo pipefail + +COPR_REPO_FILE=$(compgen -G "/etc/yum.repos.d/*podman-next*.repo") +if [[ -n "$COPR_REPO_FILE" ]]; then + # shellcheck disable=SC2016 + sed -i -n '/^priority=/!p;$apriority=1' "${COPR_REPO_FILE}" +fi +dnf -y upgrade --allowerasing diff --git a/plans/main.fmf b/plans/main.fmf deleted file mode 100644 index 1bc9fef7..00000000 --- a/plans/main.fmf +++ /dev/null @@ -1,26 +0,0 @@ -discover: - how: fmf -execute: - how: tmt -prepare: - - when: distro == centos-stream or distro == rhel - how: shell - script: | - # Install bats - # https://bats-core.readthedocs.io/en/stable/installation.html - BATS_VERSION=1.12.0 - curl -L https://github.com/bats-core/bats-core/archive/refs/tags/v"$BATS_VERSION".tar.gz | tar -xz - pushd bats-core-"$BATS_VERSION" - ./install.sh /usr - popd - rm -rf bats-core-"$BATS_VERSION" - order: 10 - - when: initiator == packit - how: shell - script: | - COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo" - if compgen -G $COPR_REPO_FILE > /dev/null; then - sed -i -n '/^priority=/!p;$apriority=1' $COPR_REPO_FILE - fi - dnf -y upgrade --allowerasing - order: 20 diff --git a/plans/no-rpm.fmf b/plans/no-rpm.fmf new file mode 100644 index 00000000..51ed3f37 --- /dev/null +++ b/plans/no-rpm.fmf @@ -0,0 +1,25 @@ +discover: + how: fmf +execute: + how: tmt + +/integration: + discover+: + test: /tmt/integration + +/validate: + discover+: + test: /tmt/validate + +/unit: + discover+: + test: /tmt/unit + +/opengpg: + prepare+: + - when: distro == centos-stream or distro == rhel + how: shell + script: bash hack/tmt/bats-setup.sh + order: 10 + discover+: + test: /tmt/opengpg diff --git a/plans/rpm.fmf b/plans/rpm.fmf new file mode 100644 index 00000000..f61c5783 --- /dev/null +++ b/plans/rpm.fmf @@ -0,0 +1,22 @@ +discover: + how: fmf +execute: + how: tmt +prepare: + - when: initiator == packit + how: shell + script: bash hack/tmt/dnf-repo-setup.sh + order: 5 + +/ostree-rs-ext: + discover+: + test: /tmt/ostree-rs-ext + +/system: + prepare+: + - when: distro == centos-stream or distro == rhel + how: shell + script: bash hack/tmt/bats-setup.sh + order: 10 + discover+: + test: /tmt/system diff --git a/systemtest/tmt/main.fmf b/systemtest/tmt/main.fmf deleted file mode 100644 index fd0b3e66..00000000 --- a/systemtest/tmt/main.fmf +++ /dev/null @@ -1,14 +0,0 @@ -require: - - skopeo-tests - -environment: - SKOPEO_BINARY: /usr/bin/skopeo - -adjust: - - when: initiator != "packit" - environment+: - RELEASE_TESTING: true - -summary: System test -test: bash ./test.sh -duration: 60m diff --git a/systemtest/tmt/test.sh b/systemtest/tmt/test.sh deleted file mode 100644 index 7c80eba9..00000000 --- a/systemtest/tmt/test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -exo pipefail - -uname -r - -rpm -q \ - bats \ - containers-common \ - skopeo \ - skopeo-tests \ - -bats /usr/share/skopeo/test/system diff --git a/tmt/main.fmf b/tmt/main.fmf new file mode 100644 index 00000000..ea2ca7b1 --- /dev/null +++ b/tmt/main.fmf @@ -0,0 +1,88 @@ +require: + # Some of these are only required for non-rpm tests but it's much simpler + # to list them as common deps. Shouldn't be too much of a burden for rpm + # jobs. + - btrfs-progs-devel + - containers-common + - docker-distribution + - go-md2man + - golang + - gpgme-devel + - httpd-tools + - jq + - make + +/integration: + summary: Integration test + test: | + rpm -q containers-common + make -C $TMT_TREE test-integration-local + duration: 20m + +/ostree-rs-ext: + /build: + summary: ostree-rs-ext build + test: bash $TMT_TREE/hack/test-ostree.sh build + + /test: + summary: ostree-rs-ext test + test: bash $TMT_TREE/hack/test-ostree.sh test + require+: + - ostree + +/opengpg: + # w/ opengpg will only be tested upstream, so we don't care about setting + # $RELEASE_TESTING. + + enabled: false + adjust: + enabled: true + when: initiator == packit + + /validate+unit: + summary: System test with opengpg + test: | + make -C $TMT_TREE BUILDTAGS+=" containers_image_openpgp" bin/skopeo + make -C $TMT_TREE test-all-local + + /integration: + summary: Integration test with opengpg + test: | + make -C $TMT_TREE BUILDTAGS+=" containers_image_openpgp" bin/skopeo + make -C $TMT_TREE test-integration-local + duration: 30m + + /system: + summary: System tests with opengpg + test: | + make -C $TMT_TREE BUILDTAGS+=" containers_image_openpgp" bin/skopeo + make -C $TMT_TREE test-system-local + duration: 30m + require+: + - bats + +/system: + summary: System test + test: | + rpm -q containers-common skopeo + make -C $TMT_TREE test-system-local + environment: + SKOPEO_BINARY: /usr/bin/skopeo + adjust: + - when: initiator != "packit" + environment+: + RELEASE_TESTING: true + duration: 60m + +/unit: + summary: Unit test + test: | + make -C $TMT_TREE + make -C $TMT_TREE test-unit-local + +/validate: + summary: Validate test + test: | + make -C $TMT_TREE + make -C $TMT_TREE validate-docs validate-local +