mirror of
https://github.com/clearlinux/micro-config-drive.git
synced 2026-09-04 12:41:41 +00:00
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.
24 lines
542 B
Bash
Executable File
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
|