Skip to content

Commit c08ada2

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

File tree

13 files changed

+233
-70
lines changed

13 files changed

+233
-70
lines changed

.packit.yaml

Lines changed: 54 additions & 3 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
@@ -96,19 +96,70 @@ jobs:
9696
project: podman-next
9797
enable_net: true
9898

99-
# Tests on Fedora for main branch
99+
# System tests on Fedora
100100
- job: tests
101101
trigger: pull_request
102102
packages: [skopeo-fedora]
103103
notifications: &test_failure_notification
104104
failure_comment:
105105
message: "Tests failed. @containers/packit-build please check."
106106
targets: *fedora_copr_targets
107-
tf_extra_params:
107+
tf_extra_params: &extra_repos
108108
environments:
109109
- artifacts:
110110
- type: repository-file
111111
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
112+
tmt_plan: "/plans/rpm/system"
113+
identifier: "system"
114+
115+
# ostree-rs-ext tests on Fedora
116+
- job: tests
117+
trigger: pull_request
118+
packages: [skopeo-fedora]
119+
notifications: &test_failure_notification
120+
targets: *fedora_copr_targets
121+
tf_extra_params: *extra_repos
122+
tmt_plan: "/plans/rpm/ostree-rs-ext"
123+
identifier: "ostree-rs-ext"
124+
125+
# Integration tests on Fedora
126+
- job: tests
127+
trigger: pull_request
128+
skip_build: true
129+
packages: [skopeo-fedora]
130+
notifications: *test_failure_notification
131+
targets: *fedora_copr_targets
132+
tf_extra_params: *extra_repos
133+
tmt_plan: "/plans/no-rpm/integration"
134+
identifier: "integration"
135+
136+
# Unit tests on Fedora
137+
- job: tests
138+
trigger: pull_request
139+
skip_build: true
140+
notifications: *test_failure_notification
141+
targets: &fedora_no_rpm_targets
142+
- fedora-latest-stable
143+
tmt_plan: "/plans/no-rpm/unit"
144+
identifier: "unit"
145+
146+
# Validate test on Fedora
147+
- job: tests
148+
trigger: pull_request
149+
skip_build: true
150+
notifications: *test_failure_notification
151+
targets: *fedora_no_rpm_targets
152+
tmt_plan: "/plans/no-rpm/validate"
153+
identifier: "validate"
154+
155+
# Test w/ opengpg static linked on Fedora
156+
- job: tests
157+
trigger: pull_request
158+
skip_build: true
159+
notifications: *test_failure_notification
160+
targets: *fedora_no_rpm_targets
161+
tmt_plan: "/plans/no-rpm/opengpg"
162+
identifier: "opengpg"
112163

113164
# Tests on CentOS Stream for main branch
114165
# Ignore until golang is updated in distro buildroot to go 1.23.3+

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)