-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This creates a new provision plugin that is built on top of the existing TestCloud (virtual) plugin. It adds new parameters to pass a Containerfile or container image. The plugin will then build a container image (if necessary) then build a bootc disk image from the container image using bootc image builder. Currently, bootc requires podman to be run as root when building a disk image. This is typically handled by running a podman machine as root. An additional parameter "add-deps" toggles building a derived container image with the tmt test requirements. Signed-off-by: Chris Kyrouac <ckyrouac@redhat.com>
- Loading branch information
Showing
11 changed files
with
393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
summary: Bootc virtual machine via testcloud | ||
|
||
description: | | ||
bootc tests | ||
|
||
discover: | ||
how: fmf | ||
filter: 'tag:provision-bootc' | ||
|
||
|
||
environment: | ||
PROVISION_HOW: virtual | ||
|
||
adjust+: | ||
- enabled: true | ||
when: how == provision | ||
|
||
- provision: | ||
hardware: | ||
virtualization: | ||
is-supported: true | ||
memory: ">= 4 GB" | ||
when: trigger == commit | ||
|
||
- prepare+: | ||
- name: Disable IPv6 | ||
how: shell | ||
script: | ||
- sysctl -w net.ipv6.conf.all.disable_ipv6=1 | ||
- sysctl -w net.ipv6.conf.default.disable_ipv6=1 | ||
because: Disable IPv6 in CI to avoid IPv6 connections that are disabled in CI | ||
when: trigger == commit | ||
|
||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
13 changes: 13 additions & 0 deletions
13
tests/provision/bootc/data/containerfile_includes_deps.fmf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
execute: | ||
how: tmt | ||
discover: | ||
how: shell | ||
tests: | ||
- name: booted image | ||
test: bootc status && bootc status | grep localhost/tmtbase | ||
provision: | ||
how: bootc | ||
add-deps: false | ||
containerfile: "$TMT_BOOTC_CONTAINERFILE_RUNDIR/includes_deps.containerfile" | ||
containerfile-workdir: . | ||
disk: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
execute: | ||
how: tmt | ||
discover: | ||
how: shell | ||
tests: | ||
- name: booted image | ||
test: bootc status | grep localhost/tmtmodified | ||
provision: | ||
how: bootc | ||
add-deps: true | ||
containerfile: "$TMT_BOOTC_CONTAINERFILE_RUNDIR/needs_deps.containerfile" | ||
containerfile-workdir: . | ||
disk: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
execute: | ||
how: tmt | ||
discover: | ||
how: shell | ||
tests: | ||
- name: booted image | ||
test: bootc status | grep localhost/tmt-bootc-includes-deps | ||
provision: | ||
how: bootc | ||
add-deps: false | ||
containerimage: localhost/tmt-bootc-includes-deps | ||
disk: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
execute: | ||
how: tmt | ||
discover: | ||
how: shell | ||
tests: | ||
- name: booted image | ||
test: bootc status | grep localhost/tmtmodified | ||
provision: | ||
how: bootc | ||
add-deps: true | ||
containerimage: localhost/tmt-bootc-needs-deps | ||
disk: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM quay.io/centos-bootc/centos-bootc:stream9 | ||
|
||
RUN dnf -y install cloud-init rsync && \ | ||
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \ | ||
rm /usr/local -rf && ln -sr /var/usrlocal /usr/local && mkdir -p /var/usrlocal/bin && \ | ||
dnf clean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM quay.io/centos-bootc/centos-bootc:stream9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
summary: Make sure that bootc provision method works | ||
tag+: | ||
- provision-only | ||
- provision-bootc | ||
require: | ||
- tmt+provision-virtual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
IMAGE_NEEDS_DEPS="localhost/tmt-bootc-needs-deps" | ||
IMAGE_NEEDS_DEPS_PLAN="$(pwd)/data/image_needs_deps.fmf" | ||
IMAGE_INCLUDES_DEPS="localhost/tmt-bootc-includes-deps" | ||
IMAGE_INCLUDES_DEPS_PLAN="$(pwd)/data/image_includes_deps.fmf" | ||
|
||
CONTAINERFILE_NEEDS_DEPS="$(pwd)/data/needs_deps.containerfile" | ||
CONTAINERFILE_NEEDS_DEPS_PLAN="$(pwd)/data/containerfile_needs_deps.fmf" | ||
CONTAINERFILE_INCLUDES_DEPS="$(pwd)/data/includes_deps.containerfile" | ||
CONTAINERFILE_INCLUDES_DEPS_PLAN="$(pwd)/data/containerfile_includes_deps.fmf" | ||
|
||
|
||
rlJournalStart | ||
rlPhaseStartSetup | ||
# cleanup previous runs | ||
test -d /var/tmp/tmt/testcloud && rlRun "rm -rf /var/tmp/tmt/testcloud" | ||
|
||
# use /var/tmp/tmt so the temp directories are accessible | ||
# in the podman machine mount | ||
rlRun "tmp=\$(mktemp -d --tmpdir=/var/tmp/tmt)" 0 "Create tmp directory" | ||
rlRun "run=\$(mktemp -d --tmpdir=/var/tmp/tmt)" 0 "Create run directory" | ||
rlRun "pushd $tmp" | ||
rlRun "set -o pipefail" | ||
rlRun "tmt init" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Image that needs dependencies" | ||
rlRun "podman build . -f $CONTAINERFILE_NEEDS_DEPS -t $IMAGE_NEEDS_DEPS" | ||
rlRun "cp $IMAGE_NEEDS_DEPS_PLAN ." | ||
rlRun "tmt -vvvvv run -i $run" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Image that already includes dependencies" | ||
rlRun "podman build . -f $CONTAINERFILE_INCLUDES_DEPS -t $IMAGE_INCLUDES_DEPS" | ||
rlRun "cp $IMAGE_INCLUDES_DEPS_PLAN ." | ||
rlRun "tmt -vvvvv run -i $run" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Containerfile that needs dependencies" | ||
rlRun "cp $CONTAINERFILE_NEEDS_DEPS_PLAN ." | ||
rlRun "cp $CONTAINERFILE_NEEDS_DEPS $run" | ||
rlRun "tmt -vvvvv run --environment TMT_BOOTC_CONTAINERFILE_RUNDIR=$run -i $run" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Containerfile that already includes dependencies" | ||
rlRun "cp $CONTAINERFILE_INCLUDES_DEPS_PLAN ." | ||
rlRun "cp $CONTAINERFILE_INCLUDES_DEPS $run" | ||
rlRun "tmt -vvvvv run --environment TMT_BOOTC_CONTAINERFILE_RUNDIR=$run -i $run" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
rlRun "rm -r $tmp" 0 "Remove tmp directory" | ||
rlRun "rm -r $run" 0 "Remove run directory" | ||
|
||
rlRun "podman rmi $IMAGE_INCLUDES_DEPS" 0,1 | ||
rlRun "podman rmi $IMAGE_NEEDS_DEPS" 0,1 | ||
|
||
test -d /var/tmp/tmt/testcloud && rlRun "rm -rf /var/tmp/tmt/testcloud" | ||
rlPhaseEnd | ||
rlJournalEnd |
Oops, something went wrong.