Skip to content

Commit f4c0879

Browse files
committed
Standardize on OCI images in test-suite
Instead of manually bootstrapping our own base "image" using a host specific script, just use the official, prebuilt OCI images with Podman/Docker. This has several advantages: - Standard, ubiquitous OCI images (easy support for other distros) - No manual setup of DNF, RPM macros, user namespaces and whatnot - Single recipe (Dockerfile) for both the local and CI purposes - Outsourced image caching (Podman storage) - Faster (just downloads the prebuilt image) - Less dependencies on the host Now that we've prepared mktree.podman for local use, just switch to it in cmake and remove the Fedora backend. Update the docs and comments accordingly, too, those should explain the details. Fixes: #2643
1 parent a7732d6 commit f4c0879

File tree

5 files changed

+59
-233
lines changed

5 files changed

+59
-233
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77

88
/_build
99
/docs/_site
10-
/mktree.*

tests/CMakeLists.txt

+19-27
Original file line numberDiff line numberDiff line change
@@ -71,40 +71,32 @@ if (nproc GREATER 1)
7171
set(JOBS -j${nproc})
7272
endif()
7373

74-
# Detect suitable mktree backend
75-
find_program(BWRAP bwrap)
76-
mark_as_advanced(BWRAP)
77-
find_program(PODMAN NAMES podman docker)
78-
mark_as_advanced(PODMAN)
79-
if ("${MKTREE_BACKEND}" STREQUAL "")
80-
if (BWRAP AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mktree.${OS_NAME})
81-
set(MKTREE_BACKEND ${OS_NAME})
82-
elseif (PODMAN)
83-
set(MKTREE_BACKEND podman)
84-
else()
85-
message(WARNING
86-
"No suitable mktree backend found for this platform. "
87-
"Disabling test-suite.")
88-
return()
89-
endif()
90-
endif()
91-
message(STATUS "Using mktree backend: ${MKTREE_BACKEND}")
92-
9374
# Set up mktree
94-
if ("${MKTREE_BACKEND}" STREQUAL "podman")
75+
set(MKTREE_BACKEND podman CACHE STRING "Mktree backend to use")
76+
if (MKTREE_BACKEND STREQUAL "podman")
9577
find_program(PODMAN NAMES podman docker REQUIRED)
96-
configure_file(Dockerfile Dockerfile COPYONLY)
97-
else()
98-
find_program(BWRAP bwrap REQUIRED)
99-
if (PODMAN)
100-
get_filename_component(PODMAN ${PODMAN} NAME)
78+
find_program(BUILDAH buildah)
79+
get_filename_component(PODMAN_NAME ${PODMAN} NAME)
80+
mark_as_advanced(PODMAN PODMAN_NAME BUILDAH)
81+
if (PODMAN_NAME STREQUAL "podman" AND BUILDAH AND
82+
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Dockerfile.${OS_NAME})
83+
set(MKTREE_NATIVE ON)
84+
configure_file(Dockerfile.${OS_NAME} Dockerfile COPYONLY)
10185
add_custom_target(ci
102-
COMMAND ./mktree.${PODMAN} build
103-
COMMAND ./mktree.${PODMAN} check ${JOBS} $(TESTOPTS)
86+
COMMAND ./mktree.podman build
87+
COMMAND ./mktree.podman check --log ${JOBS} $(TESTOPTS)
10488
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
10589
)
90+
else()
91+
set(MKTREE_NATIVE OFF)
92+
configure_file(Dockerfile Dockerfile COPYONLY)
10693
endif()
94+
set(MKTREE_MODE " (native: ${MKTREE_NATIVE})")
95+
elseif(MKTREE_BACKEND STREQUAL "rootfs")
96+
find_program(BWRAP bwrap REQUIRED)
97+
mark_as_advanced(BWRAP)
10798
endif()
99+
message(STATUS "Using mktree backend: ${MKTREE_BACKEND}${MKTREE_MODE}")
108100
configure_file(mktree.common mktree.common @ONLY)
109101
configure_file(mktree.${MKTREE_BACKEND} mktree @ONLY)
110102

tests/README.md

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
To run these tests, you need at least these dependencies on the host:
1+
To run these tests, you need either of:
22

3-
1. [bwrap](https://github.com/containers/bubblewrap/)
4-
1. [gdb](https://www.gnu.org/software/gdb/)
5-
1. [gnupg](https://www.gnupg.org/) >= 2.0
3+
1. [podman](https://github.com/containers/podman)
4+
1. [docker](https://github.com/docker)
5+
6+
Optionally, the following is also recommended (see below):
7+
8+
1. [buildah](https://github.com/containers/buildah)
9+
10+
The test suite runs in a Podman/Docker container and supports two modes:
11+
12+
1. *Native* - Exercises the local build of RPM against a minimal image of the
13+
host Linux distribution. Currently, only Fedora Linux is supported. This
14+
mode is optimized for local RPM development and requires Podman and Buildah.
15+
1. *Non-native* - Performs a fresh build of RPM (including cmake configuration)
16+
from the local checkout as part of a Fedora-based image. This mode is
17+
optimized for portability (CI environment) and works with both Podman and
18+
Docker.
19+
20+
The mode is selected automatically by cmake based on the host distribution and
21+
the container tools installed, with the native mode being preferred whenever
22+
possible.
623

724
Then run the command
825

@@ -32,16 +49,21 @@ For all available options, see the output of the command:
3249
By default, tests are executed in parallel using all available cores, pass
3350
a specific -jN value to limit.
3451

35-
To drop into an Autotest-like shell, run:
52+
To drop into an interactive Autotest-like shell, run:
3653

3754
make atshell
3855

39-
See the printed help for details on how to use it.
56+
This is like a singular, empty `RPMTEST_CHECK()` with a shell running in it and
57+
a writable tree available at the path stored in `$RPMTEST`. From this shell,
58+
you can run the same commands as a normal test would, such as `runroot rpm`.
59+
This can be used to quickly prototype (or debug) a test.
4060

41-
You can also run a containerized shell with your RPM checkout:
61+
You can also drop straight into the `$RPMTEST` container like so:
4262

4363
make shell
4464

45-
To factory-reset the container, run:
65+
This is just a shorthand for `make atshell` followed by `runroot_other bash`.
66+
67+
To factory-reset the `$RPMTEST` container, run:
4668

4769
make reset

tests/mktree.fedora

-195
This file was deleted.

tests/mktree.podman

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#!/bin/bash
22
#
3-
# Podman-based mktree backend using an OCI image to build and run RPM.
4-
# Works standalone (outside of a build directory) too.
3+
# Podman-based mktree backend using OCI images.
4+
#
5+
# If a Dockerfile matching the host distribution is found, it is built and then
6+
# combined with the local RPM build to produce the final image ("native" mode).
7+
# Otherwise, the default Dockerfile is used and RPM is built as part of the
8+
# image ("non-native" mode).
9+
#
10+
# This script can also be invoked directly from the source directory, in which
11+
# case it performs a non-native build (useful for CI purposes). If invoked via
12+
# the mktree.docker symlink, docker is used instead of podman.
513

614
PROGRAM=$(basename $0)
715
if [ "$PROGRAM" == "mktree" ]; then

0 commit comments

Comments
 (0)