diff --git a/hack/provision-derived.sh b/hack/provision-derived.sh index 9bdc1b808..a4e403994 100755 --- a/hack/provision-derived.sh +++ b/hack/provision-derived.sh @@ -1,9 +1,24 @@ #!/bin/bash set -xeu -case "$1" in +variant=$1 +# I'm a big fan of nushell for interactive use, and I want to support +# using it in our test suite because it's better than bash. First, +# enable EPEL to get it. +. /usr/lib/os-release +if echo $ID_LIKE $ID | grep -q centos; then + dnf config-manager --set-enabled crb + dnf -y install epel-release epel-next-release +fi +# Ensure this is pre-created +mkdir -p -m 0700 /var/roothome +mkdir -p ~/.config/nushell +echo '$env.config = { show_banner: false, }' > ~/.config/nushell/config.nu +touch ~/.config/nushell/env.nu +dnf -y install nu +case "$variant" in tmt) # tmt wants rsync - dnf -y install cloud-init rsync && dnf clean all + dnf -y install cloud-init rsync ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants # And tmt wants to write to /usr/local/bin rm /usr/local -rf && ln -sr /var/usrlocal /usr/local && mkdir -p /var/usrlocal/bin @@ -14,3 +29,4 @@ case "$1" in echo "Unknown variant: $1" exit 1 ;; esac +dnf clean all && rm /var/log/* -rf diff --git a/plans/integration.fmf b/plans/integration.fmf index ce98bac56..4e2ce98df 100644 --- a/plans/integration.fmf +++ b/plans/integration.fmf @@ -1,12 +1,18 @@ -# This tmt test just demonstrates local tmt usage. -# We'll hopefully expand it to do more interesting things in the -# future and unify with the other test plans. +# Run this via `make test-tmt` which will build a container, +# and a disk image from it. provision: how: virtual - # Generated by `cargo xtask ` + # Generated by make test-tmt image: file://./target/testvm/disk.qcow2 disk: 20 -summary: Basic smoke test +summary: Execute booted tests execute: how: tmt - script: bootc status + # This just turns around and runs tests which are written in nushell. + # I don't like "fully dynamic" languages like bash or python. nushell + # is a really good "glue" language for running subprocesses but also e.g. + # parsing JSON, *and* it has a "compilation" phase with some static checks + # and a language server, etc. + script: | + set -xeu + ls tests/booted/*-test-*.nu |sort -n | while read t; do nu $t; done diff --git a/tests/booted/001-test-status.nu b/tests/booted/001-test-status.nu new file mode 100644 index 000000000..49ce8c469 --- /dev/null +++ b/tests/booted/001-test-status.nu @@ -0,0 +1,8 @@ +use std assert +use tap.nu + +tap begin "verify bootc status --json looks sane" + +let st = bootc status --json | from json +assert equal $st.apiVersion org.containers.bootc/v1alpha1 +tap ok diff --git a/tests/booted/tap.nu b/tests/booted/tap.nu new file mode 100644 index 000000000..096638fa0 --- /dev/null +++ b/tests/booted/tap.nu @@ -0,0 +1,15 @@ +# A simple nushell "library" for the +# "Test anything protocol": +# https://testanything.org/tap-version-14-specification.html +export def begin [description] { + print "TAP version 14" + print $description +} + +export def ok [] { + print "ok" +} + +export def fail [] { + print "not ok" +}