Skip to content

Added ServiceName #38

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

Merged
merged 3 commits into from
May 29, 2025
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
5 changes: 5 additions & 0 deletions src/service_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -933,5 +933,10 @@
"Command": "az lambda-test",
"AzureServiceName": "LambdaTest",
"URL": "https://learn.microsoft.com/en-us/azure/partner-solutions"
},
{
"Command": "az workload-orchestration",
"AzureServiceName": "Workload Orchestration Manager",
"URL": "https://learn.microsoft.com/en-us/azure/azure-arc/workload-orchestration"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,80 @@ def test_schema_lifecycle(self):
# f'az workload-orchestration schema delete --resource-group {self.rg} --name {self.schema_name}'
# )

@AllowLargeResponse()
def test_context_create_with_capabilities_and_hierarchies(self):
# Get existing context and update capabilities
context = self.cmd(
f'az workload-orchestration context show --subscription {self.context_subscription_id} --resource-group {self.context_rg} --name {self.context_name}'
).get_output_in_json()

# Add new capabilities
capabilities = context["properties"]["capabilities"] + [
{"name": f"{self.resource_prefix}-Shampoo", "description": f"{self.resource_prefix}-Shampoo"},
{"name": f"{self.resource_prefix}-Soap", "description": f"{self.resource_prefix}-Soap"}
]
# Remove duplicates by name/description
unique_capabilities = { (c["name"], c["description"]): c for c in capabilities }.values()

# Write capabilities to a JSON file
import json
capabilities_file = os.path.join(os.path.dirname(__file__), "context-capabilities.json")
with open(capabilities_file, "w") as f:
json.dump(list(unique_capabilities), f, separators=(',', ':'))

# Act: create context with updated capabilities and hierarchies
self.cmd(
f'az workload-orchestration context create '
f'--subscription {self.context_subscription_id} '
f'--resource-group {self.context_rg} '
f'--location {self.context_location} '
f'--name {self.context_name} '
f'--capabilities "@{capabilities_file}" '
f'--hierarchies [0].name=country [0].description=Country [1].name=region [1].description=Region [2].name=factory [2].description=Factory [3].name=line [3].description=Line'
@AllowLargeResponse()
def test_config_template_lifecycle(self):
import tempfile
import shutil

rg = "ConfigManager-CloudTest-Playground-Portal"
location = "eastus2euap"
config_template_name = self.create_random_name(prefix="CommonConfig", length=20)
version = "1.0.0"
description = "Common configuration settings"

# Prepare a temporary config template file
config_content = "configs:\n AppName: Hotmelt"
temp_dir = tempfile.mkdtemp()
config_template_file = os.path.join(
os.path.dirname(__file__),
"resources",
"hotmelt-config-template-hard.yaml"
)

# List contexts and check for created entry
result = self.cmd(
f'az workload-orchestration context list --subscription {self.context_subscription_id} --resource-group {self.context_rg}'
).get_output_in_json()
assert any(item.get("name") == self.context_name for item in result), f"{self.context_name} not found in context list"

# Clean up the capabilities file
os.remove(capabilities_file)
with open(config_template_file, "w") as f:
f.write(config_content)

try:
# Create config-template
create_result = self.cmd(
f"az workload-orchestration config-template create "
f"--resource-group {rg} "
f"--config-template-name '{config_template_name}' "
f"-l {location} "
f"--description '{description}' "
f"--config-template-file '{config_template_file}' "
f"--version {version}"
).get_output_in_json()
assert create_result["status"] == "Succeeded"
assert create_result["properties"]["id"].endswith(f"/{config_template_name}/versions/{version}")

# Show config-template
show_result = self.cmd(
f"az workload-orchestration config-template show "
f"--resource-group {rg} "
f"--config-template-name '{config_template_name}'"
).get_output_in_json()
assert show_result["name"] == config_template_name
assert show_result["properties"]["description"] == description
assert show_result["properties"]["provisioningState"] == "Succeeded"



# List config-templates and check for created entry
list_result = self.cmd(
f"az workload-orchestration config-template list "
f"--resource-group {rg}"
).get_output_in_json()
assert any(item["name"] == config_template_name for item in list_result), f"{config_template_name} not found in config-template list"

# Remove config-template version
remove_result = self.cmd(
f"az workload-orchestration config-template remove-version "
f"--resource-group {rg} "
f"--config-template-name '{config_template_name}' "
f"--version {version}"
).get_output_in_json()
assert remove_result["status"] == "Deletion Succeeded"

# Delete config-template (auto-confirm prompt)
self.cmd(
f"az workload-orchestration config-template delete "
f"--resource-group {rg} "
f"--config-template-name '{config_template_name}' --yes",
checks=None,
expect_failure=False,
)

finally:
shutil.rmtree(temp_dir)