Files
connector-popos/smoketest/run
T
davidandClaude Opus 5.5 bc07e1d3e3 Set up Pop!_OS for a Federated Core, like CoreDesktop's configure
A port of CoreDesktop's configure to Pop!_OS 24.04 with COSMIC, in the shape
of connector-macos: its own install.sh, update and configure, installed in
~/.local/share/federated-connector/connector.

Every configure item is ported: the Core (email, calendars and contacts
through GNOME Online Accounts and Evolution, as COSMIC has no accounts of its
own; Superpanel; files over davfs2; Element; Tally; the email watcher),
Tailscale, backups, AI agents in the sandbox and their sign-ins, languages
with mise, AI servers, printers, network storage and the agent sandbox.
Folders go in the COSMIC Files sidebar. Each item installs what it needs
from apt, Flathub or the tool's own apt repository when you set it up.

smoketest/run checks it in Ubuntu 24.04 containers with Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:20:47 -07:00

112 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
#
# Purpose : Run the smoketest scenarios, each in a fresh Ubuntu 24.04
# container (Pop!_OS 24.04's base) with Docker. See README.md.
#
# Usage: smoketest/run [--tier quick|all] [--keep] [scenario...]
# smoketest/run --list
# Wrapped in { ...; exit; } so bash reads the whole script up front
{
SMOKETEST="$(cd "$(dirname "$0")" && pwd)"
REPO="$(dirname "$SMOKETEST")"
IMAGE="federated-connector-popos-smoketest"
TIER=quick
KEEP=0
SCENARIOS=()
usage() {
cat << EOF
Usage: smoketest/run [options] [scenario...]
--tier quick|all quick leaves out the slow scenarios (default: quick)
--keep Leave each container afterwards, to look around in it
--list List the scenarios and their tier
Scenarios are named by file name or number, e.g. 40-backup or 40.
EOF
}
scenario_var() {
sed -nE "s/^$2=\"?([^\"]*)\"?.*/\\1/p" "$1" | head -n 1
}
list() {
local file
for file in "$SMOKETEST"/scenarios/*.sh; do
printf '%-20s %-6s %s\n' "$(basename "$file" .sh)" "$(scenario_var "$file" TIER)" \
"$(scenario_var "$file" DESCRIPTION)"
done
}
while [ $# -gt 0 ]; do
case "$1" in
--tier) TIER="$2"; shift 2 ;;
--keep) KEEP=1; shift ;;
--list) list; exit 0 ;;
-h|--help) usage; exit 0 ;;
-*) usage; exit 2 ;;
*) SCENARIOS+=("$1"); shift ;;
esac
done
command -v docker > /dev/null || { echo "Docker isn't installed."; exit 1; }
# The scenario files to run
pick() {
local file name want
for file in "$SMOKETEST"/scenarios/*.sh; do
name="$(basename "$file" .sh)"
if [ ${#SCENARIOS[@]} -eq 0 ]; then
[ "$TIER" = all ] || [ "$(scenario_var "$file" TIER)" = quick ] || continue
echo "$file"
else
for want in "${SCENARIOS[@]}"; do
case "$name" in "$want"|"$want"-*) echo "$file" ;; esac
done
fi
done
}
mapfile -t FILES < <(pick)
if [ ${#FILES[@]} -eq 0 ]; then
echo "No scenarios to run. smoketest/run --list shows them."
exit 2
fi
echo "Building the image..."
docker build -q -t "$IMAGE" "$SMOKETEST" > /dev/null || exit 1
RESULTS="$SMOKETEST/results/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$RESULTS"
PASSED=() FAILED=()
for file in "${FILES[@]}"; do
scenario="$(basename "$file" .sh)"
log="$RESULTS/$scenario.log"
echo
echo "== $scenario: $(scenario_var "$file" DESCRIPTION)"
# The sandbox needs to make user namespaces, which Docker's defaults forbid
extra=()
[ "$(scenario_var "$file" PRIVILEGED)" = 1 ] && extra=(--privileged)
rm_flag=(--rm)
[ $KEEP -eq 1 ] && rm_flag=(--name "fc-smoke-$scenario-$$")
# The working copy, as it is now, read-only at /src and copied to ~/connector
docker run "${rm_flag[@]}" "${extra[@]}" -v "$REPO:/src:ro" "$IMAGE" bash -c '
mkdir ~/connector && tar -C /src --exclude ./.git --exclude .claude --exclude ./smoketest/results -cf - . \
| tar -xf - -C ~/connector && bash ~/connector/smoketest/lib/runner.sh ~/connector/smoketest/scenarios/'"$scenario"'.sh' \
2>&1 | tee "$log"
status=${PIPESTATUS[0]}
[ $KEEP -eq 1 ] && echo " Kept the container: docker start -ai fc-smoke-$scenario-$$ (docker rm it afterwards)"
if [ "$status" -eq 0 ]; then PASSED+=("$scenario"); else FAILED+=("$scenario"); fi
done
echo
echo "Passed: ${PASSED[*]:-none}"
echo "Failed: ${FAILED[*]:-none}"
echo "Logs: $RESULTS"
[ ${#FAILED[@]} -eq 0 ]
exit
}