waft.framework_unit_tests.test_cli.test_vm_cli_e2e module

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.assert_command_fails(result, command_name: str) None

Helper to verify commands properly fail for errors.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.assert_vm_inspect_success(system_name: str, config_file: str, system_param: str = '-@') None

Helper to run VM inspect and verify it succeeds with health checks.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.create_test_vm(vm_image: str, system_name: str, config_file: str, **kwargs) None

Helper to create VM with optional parameters.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.destroy_test_vm(system_name: str, config_file: str, system_param: str = '-@') None

Helper to destroy VM and verify success.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.get_config_json(config_file: str) dict

Retrieve the current config as a JSON object.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.get_systems_dict(config_file: str) dict

Helper to get systems as a name-indexed dictionary.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.normalize_output(output: str) str

Normalize output for multi-line error message matching.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.run_cli_command(command: list[str], config_file: str) Result

Run a CLI command with config file.

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_auto_generated_system_name_collision_detection(waft_env)

Test collision detection when auto-generated system name matches existing config entry.

Command scenarios tested: 1. Manually add system with name ‘ubuntu_22_04_multiarch_intel’ to config 2. waft vm create ubuntu_22_04_multiarch_intel –config {config_file} (should fail)

Verifies: - Auto-generated system names (using VM spec as name) detect collisions - Error message suggests using –force flag to override - Collision detection works when system name matches VM spec name

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_custom_parameters(waft_env)

Test VM creation with custom parameters.

Command scenarios tested: 1. `waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-custom –username testuser

–config {config_file}`

  1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-azure –cloud-provider azure –config {config_file}

  2. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-combined –username combineduser –cloud-provider azure –resource-group waft-ci –config {config_file}

  3. waft vm destroy -@ {system_name}-custom –config {config_file}

  4. waft vm destroy -@ {system_name}-azure –config {config_file}

  5. waft vm destroy -@ {system_name}-combined –config {config_file}

Verifies: - Custom username parameter is applied and stored - Cloud provider parameter is properly configured - Multiple custom parameters can be combined - All custom parameters are persisted in configuration

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_force_create_parameter(waft_env)

Test that –force parameter removes existing system and creates new VM.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –config {config_file} 2. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –config {config_file} (should fail) 3. waft vm destroy -@ {system_name} –config {config_file} 4. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –force –config {config_file} 5. waft vm destroy -@ {system_name} –config {config_file}

Verifies: - Duplicate system creation fails without –force - –force flag allows overriding existing systems

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_full_lifecycle_with_config_tracking(waft_env)

Test the full lifecycle of a VM and verify config file changes.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –config {config_file} 2. waft vm inspect {system_name} –config {config_file} 3. waft vm destroy -@ {system_name} –config {config_file}

Verifies: - VM creation adds system and auto-discovers proxy in config - Inspect command shows healthy VM with SSH connectivity - Destroy command clears hostname but preserves system config

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_images_command(waft_env)

Test the vm images command to list available VM specifications.

Command scenarios tested: 1. waft vm images

Verifies: - Images command lists available VM specifications - Output contains expected VM specs like ubuntu_22_04_multiarch_intel - Command succeeds without requiring config file

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_inspect_basic(waft_env)

Basic inspect flow.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –config {config_file} 2. waft vm inspect {system_name} –config {config_file} 3. waft vm destroy -@ {system_name} –config {config_file}

Verifies: - Inspect command shows VM health status and SSH connectivity - Connection test returns success with proper output

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_invalid_vm_spec_fails_fast(waft_env)

Ensure creating a VM with an invalid spec fails fast with a clear error.

Command scenarios tested: 1. waft vm create this_spec_does_not_exist -@ {system_name}-invalid –config {config_file} (should fail)

Verifies: - Invalid VM specifications are rejected immediately - Error message clearly indicates the invalid spec name - Command fails fast without attempting Terraform operations

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_negative_scenarios(waft_env)

Test negative scenarios and error handling.

Command scenarios tested: 1. waft vm create invalid_vm_image -@ {system_name} –config {config_file} (should fail) 2. waft vm inspect -@ nonexistent-system –config {config_file} (should fail) 3. waft vm destroy -@ nonexistent-system –config {config_file} (should fail) 4. waft vm redeploy -@ nonexistent-system –config {config_file} (should fail) 5. waft vm inspect –config {config_file} (should fail - missing system)

Verifies: - All commands properly fail with appropriate error messages - Invalid VM specs are rejected - Non-existent systems are handled gracefully

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_parameter_variations(waft_env)

Test that -@ and –system parameters work equivalently.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-short –config {config_file} 2. waft vm inspect {system_name}-short –config {config_file} 3. waft vm destroy -@ {system_name}-short –config {config_file} 4. waft vm create ubuntu_22_04_multiarch_intel –system {system_name}-long –config {config_file} 5. waft vm inspect –system {system_name}-long –config {config_file} 6. waft vm destroy –system {system_name}-long –config {config_file}

Verifies: - Short form (-@) and long form (–system) parameters work identically - Both parameter styles work across create, inspect, and destroy commands

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_redeploy_command(waft_env)

Test the vm redeploy command functionality.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name} –config {config_file} 2. waft vm destroy -@ {system_name} –config {config_file} 3. waft vm redeploy -@ {system_name} –config {config_file} 4. waft vm destroy -@ {system_name} –config {config_file}

Verifies: - Redeploy command recreates VM from existing system configuration - System retains all original configuration after redeploy - New hostname is assigned after successful redeploy

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.test_vm_resource_group_scenarios(waft_env)

Test VM creation with different resource groups.

Command scenarios tested: 1. waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-ci –resource-group waft-ci –config {config_file} 2. `waft vm create ubuntu_22_04_multiarch_intel -@ {system_name}-vms –resource-group waft-vms

–config {config_file}` (may fail)

  1. waft vm destroy -@ {system_name}-ci –config {config_file}

  2. waft vm destroy -@ {system_name}-vms –config {config_file} (if created)

Verifies: - VMs can be created in different Azure resource groups - Resource group parameter is properly stored in configuration - Handles permission failures gracefully for restricted resource groups

waft.framework_unit_tests.test_cli.test_vm_cli_e2e.waft_env(tmp_path: Path) Generator[dict, None, None]

Set up a temporary WAFT environment for testing.