diff --git a/tests/fm-azure-pilot.test.sh b/tests/fm-azure-pilot.test.sh index 61911b4daaa..859e8292a07 100755 --- a/tests/fm-azure-pilot.test.sh +++ b/tests/fm-azure-pilot.test.sh @@ -1883,6 +1883,13 @@ urllib.request.urlopen = urlopen ''', encoding="utf-8") PY + set -- + # shellcheck source=bin/fm-azure-pilot.sh + . "$sourceable" + SCRIPT_DIR=$(dirname "$SCRIPT") + export FM_HOME="$tmp/home" PYTHONPATH="$hook" FM_PRICE_TEST_CALLS="$calls" + export FM_PRICE_TEST_MODE=throttle + python3 - "$cache" <<'PY' import json from pathlib import Path @@ -1892,17 +1899,8 @@ Path(sys.argv[1]).write_text(json.dumps({ "Standard_D4as_v6": {"rate": 0.25, "fetched_at": time.time()}, }) + "\n", encoding="utf-8") PY - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=throttle - retail_price Standard_D4as_v6 - ) - ) || fail "a fresh cached retail rate was refused: $output" + output=$(retail_price Standard_D4as_v6) || \ + fail "a fresh cached retail rate was refused: $output" [ "$output" = 0.25 ] || fail "the fresh cached retail rate changed: $output" [ ! -e "$calls" ] || fail "a fresh retail-rate cache entry still called prices.azure.com" @@ -1914,39 +1912,20 @@ Path(sys.argv[1]).write_text(json.dumps({ "Standard_D4as_v6": {"rate": 0.25, "fetched_at": 0}, }) + "\n", encoding="utf-8") PY - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=throttle - retail_price Standard_D4as_v6 - ) - ) || fail "a throttled live lookup did not fall back to the stale validated rate: $output" + output=$(retail_price Standard_D4as_v6) || \ + fail "a throttled live lookup did not fall back to the stale validated rate: $output" [ "$output" = 0.25 ] || fail "the stale fallback retail rate changed: $output" [ "$(wc -l <"$calls" | tr -d ' ')" = 1 ] || fail "the stale rate did not make exactly one live refresh attempt" rm -f "$cache" "$calls" set +e - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=throttle - CAPACITY_PROFILE=full - SUPERVISOR_SKU=Standard_D2as_v6 - WORKER_SKUS_JSON='[]' - COMMISSIONING_BUDGET_CEILING_USD=1500 - WORKER_HOUR_PLANNING_THRESHOLD=3500 - AUTHOR_CAPACITY_MODE=mixed-current - cost_gate - ) 2>&1 - ) + CAPACITY_PROFILE=full + SUPERVISOR_SKU=Standard_D2as_v6 + WORKER_SKUS_JSON='[]' + COMMISSIONING_BUDGET_CEILING_USD=1500 + WORKER_HOUR_PLANNING_THRESHOLD=3500 + AUTHOR_CAPACITY_MODE=mixed-current + output=$(cost_gate 2>&1) status=$? set -e expect_code 2 "$status" "a missing cache plus throttled live rate must refuse admission: $output" @@ -1964,57 +1943,30 @@ Path(sys.argv[1]).write_text(json.dumps({ PY rm -f "$calls" set +e - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=throttle - retail_price Standard_D4as_v6 - ) 2>&1 - ) + output=$(retail_price Standard_D4as_v6 2>&1) status=$? set -e [ "$status" -ne 0 ] || fail "a malformed cached retail rate bypassed the failed live lookup: $output" rm -f "$cache" "$calls" - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=exact - retail_price Standard_D4as_v6 - ) - ) || fail "the exact Linux on-demand primary meter was refused: $output" + FM_PRICE_TEST_MODE=exact + output=$(retail_price Standard_D4as_v6) || \ + fail "the exact Linux on-demand primary meter was refused: $output" [ "$output" = 0.25 ] || fail "the exact live meter returned an unexpected rate: $output" rm -f "$cache" "$calls" set +e - output=$( - ( - set -- - # shellcheck source=bin/fm-azure-pilot.sh - . "$sourceable" - SCRIPT_DIR=$(dirname "$SCRIPT") - export FM_HOME="$tmp/home" PYTHONPATH="$hook" - export FM_PRICE_TEST_CALLS="$calls" FM_PRICE_TEST_MODE=ambiguous - retail_price Standard_D4as_v6 - ) 2>&1 - ) + FM_PRICE_TEST_MODE=ambiguous + output=$(retail_price Standard_D4as_v6 2>&1) status=$? set -e [ "$status" -ne 0 ] || fail "ambiguous eligible on-demand meters were accepted: $output" pass "pilot retail admission reuses fresh and stale exact-meter cache entries and fails closed without one" } -run_retail_rate_cache_check run_create_replay_idempotence_check run_provider_action_bound_check run_worker_power_gate_check +run_retail_rate_cache_check echo "# fm-azure-pilot.test.sh: all assertions passed"