Skip to content

Commit 9f56d1c

Browse files
Merge pull request #548 from inknos/testing-podman-pnext
Improve testing against distro and podman-next
2 parents c4aad1b + cec8a83 commit 9f56d1c

File tree

10 files changed

+175
-151
lines changed

10 files changed

+175
-151
lines changed

.cirrus.yml

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

.packit.yaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ jobs:
102102
dist_git_branches:
103103
- fedora-branched # rawhide updates are created automatically
104104

105+
105106
# Test linting on the codebase
106107
# This test might break based on the OS and lint used, so we follow fedora-latest as a reference
107108
- job: tests
108109
trigger: pull_request
109-
identifier: upstream-sanity
110-
tmt_plan: /upstream/sanity
110+
identifier: distro-sanity
111+
tmt_plan: /distro/sanity
111112
packages: [python-podman-fedora]
112113
targets:
113114
- fedora-latest-stable
@@ -118,7 +119,7 @@ jobs:
118119
- job: tests
119120
trigger: pull_request
120121
identifier: unittest-coverage
121-
tmt_plan: /upstream/unittest_coverage
122+
tmt_plan: /distro/unittest_coverage
122123
packages: [python-podman-fedora]
123124
targets:
124125
- fedora-latest-stable
@@ -130,30 +131,43 @@ jobs:
130131
# run all tests for all python versions on all fedoras
131132
- job: tests
132133
trigger: pull_request
133-
identifier: upstream-all-fedora
134-
tmt_plan: /upstream/all
134+
identifier: distro-fedora-all
135+
tmt_plan: /distro/all_python
135136
packages: [python-podman-fedora]
136137
targets:
137138
- fedora-all
139+
140+
# run tests for the rawhide python version using podman-next packages
141+
- job: tests
142+
trigger: pull_request
143+
identifier: podman-next-fedora-base
144+
tmt_plan: /pnext/base_python
145+
packages: [python-podman-fedora]
146+
targets:
147+
- fedora-rawhide
138148
tf_extra_params:
139149
environments:
140150
- artifacts:
141151
- type: repository-file
142152
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
153+
manual_trigger: true
154+
labels:
155+
- pnext
156+
- podman-next
143157

144158
- job: tests
145159
trigger: pull_request
146-
identifier: upstream-base-centos
147-
tmt_plan: /upstream/base
160+
identifier: distro-centos-base
161+
tmt_plan: /distro/base_python
148162
packages: [python-podman-centos]
149163
targets:
150164
- centos-stream-9
151165
- centos-stream-10
152166

153167
- job: tests
154168
trigger: pull_request
155-
identifier: upstream-base-rhel
156-
tmt_plan: /upstream/base
169+
identifier: distro-rhel-base
170+
tmt_plan: /distro/base_python
157171
packages: [python-podman-rhel]
158172
targets:
159173
- epel-9

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,45 @@ pip install tox
4545
tox -e coverage
4646
```
4747

48+
#### Advanced testing
49+
50+
Always prefer to run `tox` directly, even when you want to run a specific test or scenario.
51+
Instead of running `pytest` directly, you should run:
52+
53+
```
54+
tox -e py -- podman/tests/integration/test_container_create.py -k test_container_directory_volume_mount
55+
```
56+
57+
If you'd like to test against a specific `tox` environment you can do:
58+
59+
```
60+
tox -e py12 -- podman/tests/integration/test_container_create.py -k test_container_directory_volume_mount
61+
```
62+
63+
Pass pytest options after `--`.
64+
65+
#### Testing future features
66+
67+
Since `podman-py` follows stable releases of `podman`, tests are thought to be run against
68+
libpod's versions that are commonly installed in the distributions. Tests can be versioned,
69+
but preferably they should not. Occasionally, upstream can diverge and have features that
70+
are not included in a specific version of libpod, or that will be included eventually.
71+
To run a test against such changes, you need to have
72+
[podman-next](https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next) installed.
73+
Then, you need to mark the test as `@pytest.mark.pnext`. Marked tests willbe excluded from the
74+
runs, unless you pass `--pnext` as a cli option.
75+
Preferably, this should be a rare case and it's better to use this marker as a temporary solution,
76+
with the goal of removing the marker within few PRs.
77+
78+
To run these tests use:
79+
80+
```
81+
tox -e py -- --pnext -m pnext podman/tests/integration/test_container_create.py -k test_container_mounts_without_rw_as_default
82+
```
83+
84+
The option `--pnext` **enables** the tests with the `pnext` pytest marker, and `-m pnext` will run
85+
the marked tests **only**.
86+
4887
## Submitting changes
4988

5089
- Create a github pull request (PR)

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ tests: tox
2626
# see tox.ini for environment variable settings
2727
$(PYTHON) -m tox -e coverage,py39,py310,py311,py312,py313
2828

29+
.PHONY: tests-ci-base-python-podman-next
30+
tests-ci-base-python-podman-next:
31+
$(PYTHON) -m tox -e py -- --pnext -m pnext
32+
2933
.PHONY: tests-ci-base-python
3034
tests-ci-base-python:
3135
$(PYTHON) -m tox -e coverage,py
3236

37+
# TODO: coverage is probably not necessary here and in tests-ci-base-python
38+
# but for now it's ok to leave it here so it's run
3339
.PHONY: tests-ci-all-python
3440
tests-ci-all-python:
3541
$(PYTHON) -m tox -e coverage,py39,py310,py311,py312,py313

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# podman-py
2-
[![Build Status](https://api.cirrus-ci.com/github/containers/podman-py.svg)](https://cirrus-ci.com/github/containers/podman-py/main)
2+
[![PyPI Latest Version](https://img.shields.io/pypi/v/podman)](https://pypi.org/project/podman/)
33

44
This python package is a library of bindings to use the RESTful API of [Podman](https://github.com/containers/podman).
55
It is currently under development and contributors are welcome!

plans/main.fmf

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ prepare:
1212
- python3-pip
1313
- podman
1414

15-
- name: enable rhcontainerbot/podman-next update podman
16-
when: initiator == packit
17-
how: shell
18-
script: |
19-
COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo"
20-
if compgen -G $COPR_REPO_FILE > /dev/null; then
21-
sed -i -n '/^priority=/!p;$apriority=1' $COPR_REPO_FILE
22-
fi
23-
dnf -y upgrade --allowerasing
24-
2515
- name: pip dependencies
2616
how: shell
2717
script:
@@ -34,20 +24,46 @@ prepare:
3424
- cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys%
3525
- cat /root/.ssh/id_ecdsa.pub >>/root/.ssh/authorized_keys
3626

37-
/upstream:
27+
# Run tests agains Podman Next builds.
28+
# These tests should NOT overlap with the ones who run in the distro plan and should only include
29+
# tests against upcoming features or upstream tests that we need to run for reasons.
30+
/pnext:
31+
prepare+:
32+
- name: enable rhcontainerbot/podman-next update podman
33+
when: initiator == packit
34+
how: shell
35+
script: |
36+
COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo"
37+
if compgen -G $COPR_REPO_FILE > /dev/null; then
38+
sed -i -n '/^priority=/!p;$apriority=1' $COPR_REPO_FILE
39+
fi
40+
dnf -y upgrade --allowerasing
41+
42+
/base_python:
43+
summary: Run Tests Upstream PRs for base Python
44+
discover+:
45+
filter: tag:pnext
46+
47+
adjust+:
48+
enabled: false
49+
when: initiator is not defined or initiator != packit
50+
51+
52+
# Run tests against Podman buids installed from the distribution.
53+
/distro:
3854
/sanity:
3955
summary: Run Sanity and Coverage checks on Python Podman
4056
discover+:
4157
# we want to change this to tag:stable once all the coverage tests are fixed
4258
filter: tag:lint
4359

44-
/base:
45-
summary: Run Python Podman Tests on Upstream PRs for base Python
60+
/base_python:
61+
summary: Run Tests Upstream for base Python
4662
discover+:
4763
filter: tag:base
4864

49-
/all:
50-
summary: Run Python Podman Tests on Upstream PRs for all Python versions
65+
/all_python:
66+
summary: Run Tests Upstream PRs for all Python versions
5167
prepare+:
5268
- name: install all python versions
5369
how: install
@@ -60,6 +76,7 @@ prepare:
6076
discover+:
6177
filter: tag:matrix
6278

79+
# TODO: replace with /coverage and include integration tests coverage
6380
/unittest_coverage:
6481
summary: Run Unit test coverage
6582
discover+:
@@ -69,9 +86,11 @@ prepare:
6986
enabled: false
7087
when: initiator is not defined or initiator != packit
7188

89+
# Run tests against downstream Podman. These tests should be the all_python only since the sanity
90+
# of code is tested in the distro environment
7291
/downstream:
7392
/all:
74-
summary: Run Python Podman Tests on bodhi / errata and dist-git PRs
93+
summary: Run Tests on bodhi / errata and dist-git PRs
7594
prepare+:
7695
- name: install all python versions
7796
how: install

podman/tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
4+
def pytest_addoption(parser):
5+
parser.addoption(
6+
"--pnext", action="store_true", default=False, help="run tests against podman_next copr"
7+
)
8+
9+
10+
def pytest_configure(config):
11+
config.addinivalue_line("markers", "pnext: mark test as run against podman_next")
12+
13+
14+
def pytest_collection_modifyitems(config, items):
15+
if config.getoption("--pnext"):
16+
# --pnext given in cli: run tests marked as pnext
17+
return
18+
podman_next = pytest.mark.skip(reason="need --pnext option to run")
19+
for item in items:
20+
if "pnext" in item.keywords:
21+
item.add_marker(podman_next)

0 commit comments

Comments
 (0)