Skip to content

Commit 285c38b

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

File tree

13 files changed

+246
-81
lines changed

13 files changed

+246
-81
lines changed

.packit.yaml

Lines changed: 63 additions & 14 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,83 @@ 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
106101
targets: *fedora_copr_targets
107-
tf_extra_params:
102+
tf_extra_params: &extra_dnf_repos
108103
environments:
109104
- artifacts:
110105
- type: repository-file
111106
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
115+
targets: *fedora_copr_targets
116+
tf_extra_params: *extra_dnf_repos
117+
tmt_plan: "/plans/rpm/ostree-rs-ext"
118+
identifier: "ostree-rs-ext"
119+
120+
# Integration tests on Fedora
121+
- job: tests
122+
trigger: pull_request
123+
skip_build: true
124+
packages: [skopeo-fedora]
125+
notifications: *packit_failure_notification
126+
targets:
127+
# x86_6 only because of quay.io/coreos/11bot
128+
# See: integration/proxy_test.go
129+
- fedora-all
130+
tf_extra_params: *extra_dnf_repos
131+
tmt_plan: "/plans/no-rpm/integration"
132+
identifier: "integration"
133+
134+
# Unit tests on Fedora
135+
- job: tests
136+
trigger: pull_request
137+
skip_build: true
138+
notifications: *packit_failure_notification
139+
targets: &fedora_no_rpm_targets
140+
- fedora-latest-stable
141+
tmt_plan: "/plans/no-rpm/unit"
142+
identifier: "unit"
143+
144+
# Validate test on Fedora
145+
- job: tests
146+
trigger: pull_request
147+
skip_build: true
148+
notifications: *packit_failure_notification
149+
targets: *fedora_no_rpm_targets
150+
tmt_plan: "/plans/no-rpm/validate"
151+
identifier: "validate"
152+
153+
# Test w/ opengpg static linked on Fedora
154+
- job: tests
155+
trigger: pull_request
156+
skip_build: true
157+
notifications: *packit_failure_notification
158+
targets: *fedora_no_rpm_targets
159+
tmt_plan: "/plans/no-rpm/opengpg"
160+
identifier: "opengpg"
112161

113162
# Tests on CentOS Stream for main branch
114163
# Ignore until golang is updated in distro buildroot to go 1.23.3+
115164
- job: tests
116165
trigger: ignore
117166
packages: [skopeo-centos]
118-
notifications: *test_failure_notification
167+
notifications: *packit_failure_notification
119168
targets: *centos_copr_targets
120169
tf_extra_params:
121170
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=$(compgen -G "/etc/yum.repos.d/*podman-next*.repo")
6+
if [[ -n "$COPR_REPO_FILE" ]]; 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)