Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Azure spot instance #4475

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/smoke_tests/test_cluster_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,34 @@ def test_use_spot(generic_cloud: str):
smoke_tests_utils.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 = smoke_tests_utils.get_cluster_name()
test = smoke_tests_utils.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}',
)
smoke_tests_utils.run_one_test(test)


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