Skip to content

Commit

Permalink
merge #4475
Browse files Browse the repository at this point in the history
  • Loading branch information
zpoint committed Dec 19, 2024
1 parent 67d4b90 commit 3f25d0b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,34 @@ def test_use_spot(generic_cloud: str):
run_one_test(test)


@pytest.mark.azure
def test_azure_spot_instance_verification():
"""Test Azure spot instance provisioning with explicit verification.
This test verifies that when --use-spot is specified for Azure:
1. The cluster launches successfully
2. The instances are actually provisioned as spot instances
"""
name = _get_cluster_name()
test = Test(
'azure-spot-verification',
[
f'sky launch -c {name} --cloud azure tests/test_yamls/minimal.yaml --use-spot -y',
f'sky logs {name} 1 --status', f'TARGET_VM_NAME="{name}"; '
'VM_INFO=$(az vm list --query "[?contains(name, \'$TARGET_VM_NAME\')].{Name:name, ResourceGroup:resourceGroup}" -o tsv); '
'[[ -z "$VM_INFO" ]] && exit 1; '
'FULL_VM_NAME=$(echo "$VM_INFO" | awk \'{print $1}\'); '
'RESOURCE_GROUP=$(echo "$VM_INFO" | awk \'{print $2}\'); '
'VM_DETAILS=$(az vm list --resource-group "$RESOURCE_GROUP" '
'--query "[?name==\'$FULL_VM_NAME\'].{Name:name, Location:location, Priority:priority}" -o table); '
'[[ -z "$VM_DETAILS" ]] && exit 1; '
'echo "VM Details:"; echo "$VM_DETAILS"; '
'echo "$VM_DETAILS" | grep -qw "Spot" && exit 0 || exit 1'
],
f'sky down -y {name}',
)
run_one_test(test)


@pytest.mark.gcp
def test_stop_gcp_spot():
"""Test GCP spot can be stopped, autostopped, restarted."""
Expand Down

0 comments on commit 3f25d0b

Please sign in to comment.