Skip to content

Commit ca0ad09

Browse files
committed
TMT: add more tests
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent cb17ded commit ca0ad09

File tree

13 files changed

+249
-80
lines changed

13 files changed

+249
-80
lines changed

.packit.yaml

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ files_to_sync:
2121
dest: plans/
2222
delete: true
2323
mkpath: true
24-
- src: systemtest/tmt/
24+
- src: tmt/
2525
dest: test/tmt/
2626
delete: true
2727
mkpath: true
@@ -47,9 +47,9 @@ jobs:
4747
- job: copr_build
4848
trigger: pull_request
4949
packages: [skopeo-fedora]
50-
notifications: &copr_build_failure_notification
50+
notifications: &packit_failure_notification
5151
failure_comment:
52-
message: "Ephemeral COPR build failed. @containers/packit-build please check."
52+
message: "Packit jobs failed. @containers/packit-build please check."
5353
targets: &fedora_copr_targets
5454
- fedora-all-x86_64
5555
- fedora-all-aarch64
@@ -62,7 +62,7 @@ jobs:
6262
- job: copr_build
6363
trigger: ignore
6464
packages: [skopeo-eln]
65-
notifications: *copr_build_failure_notification
65+
notifications: *packit_failure_notification
6666
targets:
6767
fedora-eln-x86_64:
6868
additional_repos:
@@ -76,7 +76,7 @@ jobs:
7676
- job: copr_build
7777
trigger: ignore
7878
packages: [skopeo-centos]
79-
notifications: *copr_build_failure_notification
79+
notifications: *packit_failure_notification
8080
targets: &centos_copr_targets
8181
- centos-stream-9-x86_64
8282
- centos-stream-9-aarch64
@@ -88,34 +88,88 @@ jobs:
8888
- job: copr_build
8989
trigger: commit
9090
packages: [skopeo-fedora]
91-
notifications:
92-
failure_comment:
93-
message: "podman-next COPR build failed. @containers/packit-build please check."
9491
branch: main
9592
owner: rhcontainerbot
9693
project: podman-next
9794
enable_net: true
9895

99-
# Tests on Fedora for main branch
96+
# System tests on Fedora
10097
- job: tests
10198
trigger: pull_request
10299
packages: [skopeo-fedora]
103-
notifications: &test_failure_notification
104-
failure_comment:
105-
message: "Tests failed. @containers/packit-build please check."
100+
notifications: *packit_failure_notification
101+
targets: *fedora_copr_targets
102+
tf_extra_params:
103+
environments:
104+
- artifacts:
105+
- type: repository-file
106+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
107+
tmt_plan: "/plans/rpm/system"
108+
identifier: "system"
109+
110+
# ostree-rs-ext tests on Fedora
111+
- job: tests
112+
trigger: pull_request
113+
packages: [skopeo-fedora]
114+
notifications: *packit_failure_notification
106115
targets: *fedora_copr_targets
107116
tf_extra_params:
108117
environments:
109118
- artifacts:
110119
- type: repository-file
111120
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
121+
tmt_plan: "/plans/rpm/ostree-rs-ext"
122+
identifier: "ostree-rs-ext"
123+
124+
# Integration tests on Fedora
125+
- job: tests
126+
trigger: pull_request
127+
skip_build: true
128+
packages: [skopeo-fedora]
129+
notifications: *packit_failure_notification
130+
targets: *fedora_copr_targets
131+
tf_extra_params:
132+
environments:
133+
- artifacts:
134+
- type: repository-file
135+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
136+
tmt_plan: "/plans/no-rpm/integration"
137+
identifier: "integration"
138+
139+
# Unit tests on Fedora
140+
- job: tests
141+
trigger: pull_request
142+
skip_build: true
143+
notifications: *packit_failure_notification
144+
targets: &fedora_no_rpm_targets
145+
- fedora-latest-stable
146+
tmt_plan: "/plans/no-rpm/unit"
147+
identifier: "unit"
148+
149+
# Validate test on Fedora
150+
- job: tests
151+
trigger: pull_request
152+
skip_build: true
153+
notifications: *packit_failure_notification
154+
targets: *fedora_no_rpm_targets
155+
tmt_plan: "/plans/no-rpm/validate"
156+
identifier: "validate"
157+
158+
# Test w/ opengpg static linked on Fedora
159+
- job: tests
160+
trigger: pull_request
161+
skip_build: true
162+
notifications: *packit_failure_notification
163+
targets: *fedora_no_rpm_targets
164+
tmt_plan: "/plans/no-rpm/opengpg"
165+
identifier: "opengpg"
112166

113167
# Tests on CentOS Stream for main branch
114168
# Ignore until golang is updated in distro buildroot to go 1.23.3+
115169
- job: tests
116170
trigger: ignore
117171
packages: [skopeo-centos]
118-
notifications: *test_failure_notification
172+
notifications: *packit_failure_notification
119173
targets: *centos_copr_targets
120174
tf_extra_params:
121175
environments:

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ test-integration:
203203

204204

205205
# Intended for CI, assumed to be running in quay.io/libpod/skopeo_cidev container.
206-
test-integration-local: bin/skopeo
207-
hack/warn-destructive-tests.sh
206+
# Expects binary in PATH, so better to depend on install-binary target
207+
test-integration-local: install-binary
208208
hack/test-integration.sh
209209

210210
# complicated set of options needed to run podman-in-podman
@@ -220,8 +220,7 @@ test-system:
220220
exit $$rc
221221

222222
# Intended for CI, assumed to already be running in quay.io/libpod/skopeo_cidev container.
223-
test-system-local: bin/skopeo
224-
hack/warn-destructive-tests.sh
223+
test-system-local: $(if $(SKOPEO_BINARY),,bin/skopeo)
225224
hack/test-system.sh
226225

227226
test-unit:
@@ -235,7 +234,7 @@ validate:
235234
test-all-local: validate-local validate-docs test-unit-local
236235

237236
.PHONY: validate-local
238-
validate-local:
237+
validate-local: tools
239238
hack/validate-git-marks.sh
240239
hack/validate-gofmt.sh
241240
$(GOBIN)/golangci-lint run --build-tags "${BUILDTAGS}"

hack/test-integration.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
22
set -e
33

4-
make PREFIX=/usr install
5-
6-
echo "cd ./integration;" go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"}
4+
echo "cd ./integration;" go test "$TESTFLAGS" ${BUILDTAGS:+-tags "$BUILDTAGS"}
75
cd ./integration
8-
go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"}
6+
go test "$TESTFLAGS" ${BUILDTAGS:+-tags "$BUILDTAGS"}

hack/test-system.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ EOF
3737
export CONTAINERS_STORAGE_CONF=/etc/containers/storage.conf
3838
fi
3939

40-
# Build skopeo, install into /usr/bin
41-
make PREFIX=/usr install
40+
if [[ -v SKOPEO_BINARY ]]; then
41+
echo "Testing with $SKOPEO_BINARY ..."
42+
else
43+
echo "Testing with $(git rev-parse --show-toplevel)/bin/skopeo ..."
44+
fi
4245

4346
# Run tests
44-
SKOPEO_BINARY=/usr/bin/skopeo bats --tap systemtest
47+
# The skopeo binary used will be at ../bin/skopeo unless set via SKOPEO_BINARY
48+
bats --tap systemtest

hack/tmt/bats-setup.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
# Install bats
6+
# https://bats-core.readthedocs.io/en/stable/installation.html
7+
8+
BATS_TMPDIR=$(mktemp -d)
9+
pushd "$BATS_TMPDIR"
10+
11+
BATS_VERSION=1.12.0
12+
curl -ssfL https://github.com/bats-core/bats-core/archive/refs/tags/v"$BATS_VERSION".tar.gz | tar -xz
13+
pushd bats-core-"$BATS_VERSION"
14+
./install.sh /usr
15+
popd
16+
popd

hack/tmt/dnf-repo-setup.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo"
6+
if compgen -G "$COPR_REPO_FILE" > /dev/null; then
7+
# shellcheck disable=SC2016
8+
sed -i -n '/^priority=/!p;$apriority=1' "$COPR_REPO_FILE"
9+
fi
10+
dnf -y upgrade --allowerasing

integration/registry_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ import (
1313
)
1414

1515
const (
16-
binaryV2 = "registry-v2"
1716
binaryV2Schema1 = "registry-v2-schema1"
1817
)
1918

19+
// getBinaryV2 returns the available registry binary name, preferring "registry-v2" over "registry"
20+
func getBinaryV2() string {
21+
if _, err := exec.LookPath("registry-v2"); err == nil {
22+
return "registry-v2"
23+
}
24+
return "registry"
25+
}
26+
2027
type testRegistryV2 struct {
2128
cmd *exec.Cmd
2229
url string
@@ -92,7 +99,7 @@ compatibility:
9299
if schema1 {
93100
cmd = exec.Command(binaryV2Schema1, confPath)
94101
} else {
95-
cmd = exec.Command(binaryV2, "serve", confPath)
102+
cmd = exec.Command(getBinaryV2(), "serve", confPath)
96103
}
97104

98105
consumeAndLogOutputs(t, fmt.Sprintf("registry-%s", url), cmd)

plans/main.fmf

Lines changed: 0 additions & 26 deletions
This file was deleted.

plans/no-rpm.fmf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
5+
6+
/integration:
7+
discover+:
8+
test: /tmt/integration
9+
10+
/validate:
11+
discover+:
12+
test: /tmt/validate
13+
14+
/unit:
15+
discover+:
16+
test: /tmt/unit
17+
18+
/opengpg:
19+
prepare+:
20+
- when: distro == centos-stream or distro == rhel
21+
how: shell
22+
script: bash hack/tmt/bats-setup.sh
23+
order: 10
24+
discover+:
25+
test: /tmt/opengpg

plans/rpm.fmf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
5+
prepare:
6+
- when: initiator == packit
7+
how: shell
8+
script: bash hack/tmt/dnf-repo-setup.sh
9+
order: 5
10+
11+
/ostree-rs-ext:
12+
discover+:
13+
test: /tmt/ostree-rs-ext
14+
15+
/system:
16+
prepare+:
17+
- when: distro == centos-stream or distro == rhel
18+
how: shell
19+
script: bash hack/tmt/bats-setup.sh
20+
order: 10
21+
discover+:
22+
test: /tmt/system

0 commit comments

Comments
 (0)