diff options
author | EuAndreh <eu@euandre.org> | 2023-03-20 14:37:34 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-21 07:34:35 -0300 |
commit | 58167062f674cbc5ac97991a921a1ac92118101c (patch) | |
tree | d39312ce189e459a46b0d1d41ffedf1e1c1063fa /tests/vm-check.sh | |
parent | queue.scm: Remove (mail-in-home? ...) option from Postfix and Dovecot (diff) | |
download | package-repository-58167062f674cbc5ac97991a921a1ac92118101c.tar.gz package-repository-58167062f674cbc5ac97991a921a1ac92118101c.tar.xz |
Big revamp of paku(1): now in Perl, genating Debian packages
Diffstat (limited to 'tests/vm-check.sh')
-rwxr-xr-x | tests/vm-check.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/vm-check.sh b/tests/vm-check.sh new file mode 100755 index 0000000..d6684ed --- /dev/null +++ b/tests/vm-check.sh @@ -0,0 +1,86 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + vm-check.sh [-x] -t TYPE -H HOST -r REMOTE + vm-check.sh -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -x shutdown the VM before running checks + -t TYPE the type of VM being tested + -H HOST the name of the host to SSH into + -r REMOTE the base address of the remote package-repository + -h, --help show this message + + + + Run end-to-end tests of the package repository. + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +SHUTDOWN=false +while getopts 'xt:H:r:h' flag; do + case "$flag" in + x) + SHUTDOWN=true + ;; + t) + TYPE="$OPTARG" + ;; + H) + HOST="$OPTARG" + ;; + r) + REMOTE="$OPTARG" + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +eval "$(assert-arg -- "${TYPE:-}" '-t TYPE')" +eval "$(assert-arg -- "${HOST:-}" '-H HOST')" +eval "$(assert-arg -- "${REMOTE:-}" '-r REMOTE')" + + + +if [ "$SHUTDOWN" = true ]; then + vm down "$HOST" +fi +vm up "$HOST" + +untill -m5 -n5 ssh "$HOST" uptime +scp tests/checks/"$TYPE".sh "$HOST":check.sh +ssh "$HOST" sh check.sh "$REMOTE" |