Files
micro-config-drive/tests/fetch_test
T
Brett T. Warden 1ac420e18b Add a fetch test
To improve package test capabilities, introduce a test target that will
attempt to fetch SSH keys and user data from a locally-spawned test
server. Add other bits in ucd-data-fetch.c to support testing.

Add fetch_test, which spawns an HTTP server to serve some sample
user-data and cloud-config files, and verify that ucd-data-fetch can
retrieve them.
2022-10-21 11:02:18 -07:00

24 lines
542 B
Bash
Executable File

#!/bin/bash -x
set -euo pipefail
SCRIPT_PATH="$(dirname "$(readlink -f "${BASH_SOURCE}")")"
# Launch a lightweight HTTP server and attempt to fetch cloud config from it
# Uses the "test" template in ucd-fetch-data
cd "${SCRIPT_PATH}/fetch_data"
python -m http.server 8123 --bind 127.0.0.254 &
HTTP_PID=$!
trap "sleep 1; kill ${HTTP_PID}" EXIT
cd "${SCRIPT_PATH}"
sleep 2
../ucd-data-fetch test
# Compare what we got/generated with what we expect
cmp -b fetch_data/expected test-user-data
# Cleanup the test data file
rm test-user-data