Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/quantum/azext_quantum/operations/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
DEFAULT_STORAGE_KIND = 'Storage'
SUPPORTED_STORAGE_SKU_TIERS = ['Standard']
SUPPORTED_STORAGE_KINDS = ['Storage', 'StorageV2']
DEPLOYMENT_NAME_PREFIX = 'Microsoft.AzureQuantum-'

POLLING_TIME_DURATION = 3 # Seconds
MAX_RETRIES_ROLE_ASSIGNMENT = 20
Expand Down Expand Up @@ -253,7 +254,7 @@ def create(cmd, resource_group_name=None, workspace_name=None, location=None, st

deployment_async_operation = arm_client.deployments.begin_create_or_update(
info.resource_group,
workspace_name, # Note: This is actually specifying a the deployment name, but workspace_name is used here in test_quantum_workspace.py
(DEPLOYMENT_NAME_PREFIX + workspace_name)[:64],
{'properties': deployment_properties}
)

Expand Down
24 changes: 18 additions & 6 deletions src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from azure.cli.testsdk.scenario_tests import AllowLargeResponse, live_only
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)
from azure.cli.core.azclierror import RequiredArgumentMissingError, ResourceNotFoundError, InvalidArgumentValueError
from .utils import get_test_resource_group, get_test_workspace, get_test_workspace_location, get_test_workspace_storage, get_test_workspace_storage_grs, get_test_workspace_random_name, get_test_capabilities, get_test_workspace_provider_sku_list, all_providers_are_in_capabilities
from .utils import get_test_resource_group, get_test_workspace, get_test_workspace_location, get_test_workspace_storage, get_test_workspace_storage_grs, get_test_workspace_random_name, get_test_workspace_random_long_name, get_test_capabilities, get_test_workspace_provider_sku_list, all_providers_are_in_capabilities
from ..._version_check_helper import check_version
from datetime import datetime
from ...__init__ import CLI_REPORTED_VERSION
from ...operations.workspace import _validate_storage_account, SUPPORTED_STORAGE_SKU_TIERS, SUPPORTED_STORAGE_KINDS
from ...operations.workspace import _validate_storage_account, SUPPORTED_STORAGE_SKU_TIERS, SUPPORTED_STORAGE_KINDS, DEPLOYMENT_NAME_PREFIX

TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))

Expand Down Expand Up @@ -77,8 +77,7 @@ def test_workspace_create_destroy(self):

# create
self.cmd(f'az quantum workspace create -g {test_resource_group} -w {test_workspace_temp} -l {test_location} -a {test_storage_account} -r {test_provider_sku_list} -o json', checks=[
self.check("name", test_workspace_temp),
# >>>>>self.check("provisioningState", "Succeeded") # Status is "Succeeded" since we are linking the storage account this time.
self.check("name", DEPLOYMENT_NAME_PREFIX + test_workspace_temp),
])

# delete
Expand All @@ -92,8 +91,21 @@ def test_workspace_create_destroy(self):

# create
self.cmd(f'az quantum workspace create -g {test_resource_group} -w {test_workspace_temp} -l {test_location} -a {test_storage_account_grs} -r {test_provider_sku_list} -o json', checks=[
self.check("name", DEPLOYMENT_NAME_PREFIX + test_workspace_temp),
])

# delete
self.cmd(f'az quantum workspace delete -g {test_resource_group} -w {test_workspace_temp} -o json', checks=[
self.check("name", test_workspace_temp),
# >>>>>self.check("provisioningState", "Succeeded") # Status is "Succeeded" since we are linking the storage account this time.
self.check("provisioningState", "Deleting")
])

# Create a workspace with a maximum length name, but make sure the deployment name was truncated to a valid length
test_workspace_temp = get_test_workspace_random_long_name()

# create
self.cmd(f'az quantum workspace create -g {test_resource_group} -w {test_workspace_temp} -l {test_location} -a {test_storage_account_grs} -r {test_provider_sku_list} -o json', checks=[
self.check("name", (DEPLOYMENT_NAME_PREFIX + test_workspace_temp)[:64]),
])

# delete
Expand Down Expand Up @@ -140,7 +152,7 @@ def test_version_check(self):
# No message is generated if either version number is unavailable.

message = check_version(test_config, test_old_reported_version, test_old_date)
assert message is None
assert message == f"\nVersion {test_old_reported_version} of the quantum extension is installed locally, but version {test_current_reported_version} is now available.\nYou can use 'az extension update -n quantum' to upgrade.\n"

message = check_version(test_config, test_none_version, test_today)
assert message is None
Expand Down
3 changes: 3 additions & 0 deletions src/quantum/azext_quantum/tests/latest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def get_test_workspace_random_name():
import random
return "e2e-test-w" + str(random.randint(1000000, 9999999))

def get_test_workspace_random_long_name():
return get_test_workspace_random_name() + "-54-char-name123456789012345678901234"

def all_providers_are_in_capabilities(provider_sku_string, capabilities_string):
for provide_sku_pair in provider_sku_string.split(';'):
provider = "new." + provide_sku_pair.split('/')[0].lower()
Expand Down