smoketest: run sibling projects' scenarios with --with
A sibling project is a working copy beside CoreDesktop's with a smoketest/project.conf (NAME, PARENT, URLS), as in miniserver-dev. `run`, `list`, `shell` and `images installed` take --with NAME to add it to the chain; its scenarios are named Project/file, and run along with CoreDesktop's. Images are layered: installed+HamPack is the installed image after `sibling add HamPack`, and rebuilding a layer deletes those on it. The installed image keeps its name, and one built before this (with installed.ref) is still used. A CoreDesktop whose scenario.sh predates sibling projects still builds its installed image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+142
-1
@@ -41,7 +41,14 @@ setup() {
|
||||
mkdir -p "$SC" "$WC/smoketest/lib"
|
||||
cat > "$WC/smoketest/lib/scenario.sh" << 'EOF'
|
||||
SKIP_STATUS=3
|
||||
smoketest_prepare() { echo "prepare $IMAGE $SMOKETEST_REF $IMAGE_REF"; }
|
||||
smoketest_prepare() {
|
||||
echo "prepare $IMAGE $SMOKETEST_REF $IMAGE_REF"
|
||||
[ -z "${SMOKETEST_CHAIN_FILE:-}" ] || cp "$SMOKETEST_CHAIN_FILE" "$HOME/run-chain"
|
||||
}
|
||||
smoketest_build_layer() {
|
||||
echo "build_layer $1 $2" >> "$HOME/layers"
|
||||
cp "$SMOKETEST_CHAIN_FILE" "$HOME/layer-chain-$1"
|
||||
}
|
||||
fail() { echo "FAIL: $*"; exit 1; }
|
||||
skip() { echo "SKIP: $*"; exit 3; }
|
||||
EOF
|
||||
@@ -181,3 +188,137 @@ last_run() {
|
||||
[[ "${lines[3]}" == " done after "*s ]]
|
||||
[ "${#lines[@]}" -eq 4 ]
|
||||
}
|
||||
|
||||
# --- Sibling projects ---
|
||||
|
||||
# A sibling project, HamPack, beside the working copy, with scenarios 10 and 20
|
||||
make_sibling() {
|
||||
SIB="$HOME/Projects/HamPack"
|
||||
mkdir -p "$SIB/smoketest/scenarios"
|
||||
printf '%s\n' NAME=HamPack PARENT=CoreDesktop 'URLS=(https://example.com/HamPack.git)' \
|
||||
> "$SIB/smoketest/project.conf"
|
||||
printf '%s\n' 'DESCRIPTION="HamPack updates"' TIER=pr IMAGE=installed 'scenario() {' 'echo hampack scenario' '}' \
|
||||
> "$SIB/smoketest/scenarios/20-update.sh"
|
||||
printf '%s\n' 'DESCRIPTION="HamPack installs"' TIER=nightly IMAGE=base 'scenario() {' 'true' '}' \
|
||||
> "$SIB/smoketest/scenarios/15-install.sh"
|
||||
git -C "$SIB" init -q
|
||||
git -C "$SIB" add -A
|
||||
git -C "$SIB" commit -qm HamPack
|
||||
SIB_SHA="$(git -C "$SIB" rev-parse HEAD)"
|
||||
# Building an image shuts its VM down with sudo systemctl poweroff
|
||||
stub sudo '[ "$*" = "systemctl poweroff" ] || exit 0
|
||||
for f in "$HOME"/.cache/coredesktop-dev/smoketest/build-*/qemu.pid; do kill "$(cat "$f")"; done'
|
||||
}
|
||||
|
||||
@test "list --with adds a sibling's scenarios, as Project/file" {
|
||||
make_sibling
|
||||
run cdd smoketest list
|
||||
[[ "$output" != *HamPack* ]]
|
||||
run cdd smoketest list --with hampack
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"10-passes"* ]]
|
||||
[[ "$output" == *"HamPack/20-update"*"pr"*"installed"*"HamPack updates"* ]]
|
||||
}
|
||||
|
||||
@test "run --with builds the sibling's image on the installed one, and runs every project's scenarios in it" {
|
||||
make_sibling
|
||||
root="$(cat "$STATE/images/installed.ref")"
|
||||
run cdd smoketest run --with HamPack 10 HamPack/20
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$HOME/layers")" = "build_layer HamPack $SIB_SHA" ]
|
||||
# The layer is built with CoreDesktop as it is in the installed image
|
||||
[ "$(cat "$HOME/layer-chain-HamPack")" = "$(printf 'CoreDesktop\t%s\t%s\t%s\t\nHamPack\t%s\t%s\t\t%s' \
|
||||
"$WC" "$root" "$root" "$SIB" "$SIB_SHA" https://example.com/HamPack.git)" ]
|
||||
[ "$(cat "$STATE/images/installed+HamPack.refs")" = "$(printf 'CoreDesktop %s\nHamPack %s' "$root" "$SIB_SHA")" ]
|
||||
[[ "$output" == *"PASS 10-passes"* ]]
|
||||
[[ "$output" == *"PASS HamPack/20-update"* ]]
|
||||
[[ "$output" == *"hampack scenario"* ]]
|
||||
[ "$(grep -c "^qemu-img create -q -f qcow2 -b $STATE/images/installed+HamPack.qcow2 " "$STUB_LOG")" -eq 2 ]
|
||||
# Scenarios get the chain, with each project's commit under test and in the image
|
||||
[ "$(cat "$HOME/run-chain")" = "$(printf 'CoreDesktop\t%s\t%s\t%s\t\nHamPack\t%s\t%s\t%s\t%s' \
|
||||
"$WC" "$(git -C "$WC" rev-parse HEAD)" "$root" "$SIB" "$SIB_SHA" "$SIB_SHA" https://example.com/HamPack.git)" ]
|
||||
|
||||
# The next run uses it
|
||||
: > "$HOME/layers"
|
||||
run cdd smoketest run --with HamPack HamPack/20
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -s "$HOME/layers" ]
|
||||
}
|
||||
|
||||
@test "a scenario number two projects share must be named with its project" {
|
||||
make_sibling
|
||||
scenario_file 20-update pr installed true
|
||||
run cdd smoketest run --with HamPack 20
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"20 could be any of:"*"20-update"*"HamPack/20-update"* ]]
|
||||
[[ "$output" == *"Name it as Project/file, e.g. CoreDesktop/20."* ]]
|
||||
not_called qemu-system-x86_64
|
||||
|
||||
run cdd smoketest run --with HamPack CoreDesktop/20
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Name it by its whole file name."* ]]
|
||||
|
||||
run cdd smoketest run --with HamPack CoreDesktop/20-update hampack/20
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"PASS 20-update"*"PASS HamPack/20-update"* ]]
|
||||
}
|
||||
|
||||
@test "--with needs a sibling of a project already in the chain" {
|
||||
make_sibling
|
||||
run cdd smoketest list --with Nope
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"No sibling project called Nope"* ]]
|
||||
|
||||
sed -i 's/PARENT=CoreDesktop/PARENT=MiniServer/' "$SIB/smoketest/project.conf"
|
||||
run cdd smoketest list --with HamPack
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"HamPack is a sibling of MiniServer: add --with MiniServer before it."* ]]
|
||||
}
|
||||
|
||||
@test "rebuilding the installed image deletes the images built on it" {
|
||||
make_sibling
|
||||
cdd smoketest run --with HamPack HamPack/20
|
||||
[ -f "$STATE/images/installed+HamPack.qcow2" ]
|
||||
run cdd smoketest images installed
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$HOME/layers" | tail -n 1)" = "build_layer CoreDesktop $(git -C "$WC" rev-parse HEAD)" ]
|
||||
[ ! -e "$STATE/images/installed+HamPack.qcow2" ]
|
||||
[ ! -e "$STATE/images/installed.ref" ]
|
||||
[ "$(cat "$STATE/images/installed.refs")" = "CoreDesktop $(git -C "$WC" rev-parse HEAD)" ]
|
||||
}
|
||||
|
||||
@test "images installed builds siblings at the commits given" {
|
||||
make_sibling
|
||||
first="$SIB_SHA"
|
||||
git -C "$SIB" commit -q --allow-empty -m second
|
||||
run cdd smoketest images installed --with HamPack "HamPack=$first"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$HOME/layers")" = "build_layer HamPack $first" ]
|
||||
|
||||
run cdd smoketest images
|
||||
[[ "$output" == *"installed+HamPack built"*"HamPack ${first:0:7} HamPack"* ]]
|
||||
|
||||
run cdd smoketest images installed --with HamPack "CoreDesktop=nosuch"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"CoreDesktop has no commit nosuch"* ]]
|
||||
}
|
||||
|
||||
@test "a CoreDesktop from before sibling projects still builds its installed image, but not a sibling's" {
|
||||
make_sibling
|
||||
sed -i '/^smoketest_build_layer() {/,/^}/d' "$WC/smoketest/lib/scenario.sh"
|
||||
printf '%s\n' 'smoketest_install_image() { echo "install_image $1" >> "$HOME/layers"; }' \
|
||||
>> "$WC/smoketest/lib/scenario.sh"
|
||||
stub ssh 'echo "ssh $*" >> "$HOME/ssh.log"; while [ $# -gt 0 ]; do
|
||||
case "$1" in -i | -o | -p) shift 2 ;; *@*) shift; break ;; *) shift ;; esac
|
||||
done
|
||||
[ $# -gt 0 ] || exit 0
|
||||
case "$*" in *boot_id*) echo "boot-$RANDOM" ; exit 0 ;; esac
|
||||
cd "$HOME" && exec setsid -w bash -c "$*"'
|
||||
run cdd smoketest images installed
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$HOME/layers")" = "install_image $(git -C "$WC" rev-parse HEAD)" ]
|
||||
|
||||
run cdd smoketest images installed --with HamPack
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"can't add sibling projects"* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user