#!/usr/bin/env bash # Test: `warpgate speed-test` uploads/downloads a test file and reports speeds # # Speed-test uses rclone copyto directly against the remote, so it needs the # rclone config (generated at deploy/preflight time) but not necessarily a # running mount. We start the full stack to ensure rclone.conf is in place. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" source "$SCRIPT_DIR/../harness/helpers.sh" source "$SCRIPT_DIR/../harness/mock-nas.sh" require_root setup_test_env trap teardown_test_env EXIT # Start mock NAS so rclone can reach the SFTP endpoint start_mock_nas # Generate config gen_config # Start warpgate so that rclone.conf is generated by the preflight phase start_warpgate wait_for_mount 60 wait_for_rc_api 30 # Run speed-test (captures both stdout and stderr since rclone progress goes to stderr) output=$("$WARPGATE_BIN" speed-test -c "$TEST_CONFIG" 2>&1) || true # Verify output contains upload and download speed reports assert_output_contains "$output" "Upload:" assert_output_contains "$output" "Download:" # Verify the test completed if echo "$output" | grep -qi "Done\|Complete\|Finished"; then true else echo "FAIL: speed-test output missing completion indicator (Done/Complete/Finished)" >&2 echo " output: $output" >&2 exit 1 fi # Check NAS_ROOT for leftover test files from speed-test and assert they're gone. # speed-test creates temporary files for upload/download benchmarking — # they should be cleaned up after the test completes. leftover=$(find "$NAS_ROOT" -name "*speed*" -o -name "*benchmark*" -o -name "*test-upload*" 2>/dev/null | head -5) if [[ -n "$leftover" ]]; then echo "FAIL: speed-test left behind temporary files on NAS:" >&2 echo " $leftover" >&2 exit 1 fi echo "PASS: $(basename "$0" .sh)"