-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the
bootc
provision plugin (#3161)
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. When the podman connection is rootless=True, this will automatically start a new rootful podman-machine to be used for the bootc disk creation. An additional parameter "add-tmt-dependencies" toggles building a derived container image with the tmt test requirements. Signed-off-by: Chris Kyrouac <[email protected]> Co-authored-by: Petr Šplíchal <[email protected]>
- Loading branch information
Showing
14 changed files
with
595 additions
and
1 deletion.
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
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
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: | | ||
Verify functionality of the bootc provision plugin. | ||
|
||
discover: | ||
how: fmf | ||
filter: 'tag:provision-bootc' | ||
|
||
prepare+: | ||
- name: start-libvirtd | ||
script: | | ||
systemctl start libvirtd | ||
systemctl status libvirtd | ||
|
||
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 |
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
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 |
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,45 @@ | ||
discover: | ||
how: fmf | ||
provision: | ||
how: bootc | ||
disk: 20 | ||
execute: | ||
how: tmt | ||
|
||
|
||
/image: | ||
|
||
/needs-deps: | ||
summary: "Image that needs dependencies" | ||
provision+: | ||
add-tmt-dependencies: true | ||
container-image: localhost/tmt-bootc-needs-deps | ||
environment: | ||
PATTERN: localhost/tmtmodified | ||
|
||
/includes-deps: | ||
summary: "Image that already includes dependencies" | ||
provision+: | ||
add-tmt-dependencies: false | ||
container-image: localhost/tmt-bootc-includes-deps | ||
environment: | ||
PATTERN: localhost/tmt-bootc-includes-deps | ||
|
||
/containerfile: | ||
|
||
/needs-deps: | ||
summary: "Containerfile that needs dependencies" | ||
provision+: | ||
add-tmt-dependencies: true | ||
container-file: needs-deps.containerfile | ||
environment: | ||
PATTERN: localhost/tmtmodified | ||
|
||
/includes-deps: | ||
summary: "Containerfile that already includes dependencies" | ||
provision: | ||
how: bootc | ||
add-tmt-dependencies: false | ||
container-file: includes-deps.containerfile | ||
environment: | ||
PATTERN: localhost/tmtbase |
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,2 @@ | ||
summary: Check that booted image matches expected pattern | ||
test: "bootc status && bootc status | grep $PATTERN" |
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 @@ | ||
summary: Make sure that bootc provision method works | ||
tag+: | ||
- provision-only | ||
- provision-bootc | ||
require: | ||
- tmt+provision-virtual | ||
duration: 40m | ||
|
||
# As for now there is an expected AVC failure: | ||
# https://github.com/osbuild/bootc-image-builder/issues/645 | ||
check: | ||
- how: avc | ||
result: xfail |
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,47 @@ | ||
#!/bin/bash | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
IMAGE_NEEDS_DEPS="localhost/tmt-bootc-needs-deps" | ||
IMAGE_INCLUDES_DEPS="localhost/tmt-bootc-includes-deps" | ||
|
||
TESTCLOUD_IMAGE="/var/tmp/tmt/testcloud/images/disk.qcow2" | ||
|
||
|
||
rlJournalStart | ||
rlPhaseStartSetup | ||
# Use /var/tmp/tmt so the temp directories are accessible | ||
# in the podman machine mount | ||
rlRun "mkdir -p /var/tmp/tmt" | ||
rlRun "run=\$(mktemp -d --tmpdir=/var/tmp/tmt)" 0 "Create run directory" | ||
rlRun "pushd data" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Image that needs dependencies" | ||
rlRun "podman build . -f needs-deps.containerfile -t $IMAGE_NEEDS_DEPS" | ||
rlRun "tmt -vvv run --scratch -i $run plan --name /plans/image/needs-deps" | ||
rlRun "rm -rf $TESTCLOUD_IMAGE" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Image that already includes dependencies" | ||
rlRun "podman build . -f includes-deps.containerfile -t $IMAGE_INCLUDES_DEPS" | ||
rlRun "tmt -vvv run --scratch -i $run plan --name /plans/image/includes-deps" | ||
rlRun "rm -rf $TESTCLOUD_IMAGE" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Containerfile that needs dependencies" | ||
rlRun "tmt -vvv run --scratch -i $run plan --name /plans/containerfile/needs-deps" | ||
rlRun "rm -rf $TESTCLOUD_IMAGE" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Containerfile that already includes dependencies" | ||
rlRun "tmt -vvv run --scratch -i $run plan --name /plans/containerfile/includes-deps" | ||
rlRun "rm -rf $TESTCLOUD_IMAGE" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
rlRun "rm -r $run" 0 "Remove run directory" | ||
rlRun "podman rmi $IMAGE_INCLUDES_DEPS" 0,1 | ||
rlRun "podman rmi $IMAGE_NEEDS_DEPS" 0,1 | ||
rlPhaseEnd | ||
rlJournalEnd |
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
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,71 @@ | ||
--- | ||
|
||
# | ||
# JSON Schema definition for `bootc` provision plugin | ||
# | ||
# https://tmt.readthedocs.io/en/stable/spec/plans.html#bootc | ||
# | ||
|
||
$id: /schemas/provision/bootc | ||
$schema: https://json-schema.org/draft-07/schema | ||
|
||
type: object | ||
additionalProperties: false | ||
|
||
properties: | ||
|
||
how: | ||
type: string | ||
enum: | ||
- bootc | ||
|
||
name: | ||
type: string | ||
|
||
image: | ||
type: string | ||
|
||
user: | ||
type: string | ||
|
||
become: | ||
type: boolean | ||
|
||
key: | ||
$ref: "/schemas/common#/definitions/one_or_more_strings" | ||
|
||
memory: | ||
type: integer | ||
|
||
disk: | ||
type: integer | ||
|
||
connection: | ||
type: string | ||
enum: | ||
- session | ||
- system | ||
|
||
arch: | ||
$ref: "/schemas/common#/definitions/arch" | ||
|
||
role: | ||
$ref: "/schemas/common#/definitions/role" | ||
|
||
container-file: | ||
type: string | ||
|
||
container-file-workdir: | ||
type: string | ||
|
||
container-image: | ||
type: string | ||
|
||
add-tmt-dependencies: | ||
type: boolean | ||
|
||
image-builder: | ||
type: string | ||
|
||
required: | ||
- how |
Oops, something went wrong.