-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* Added env tests. * Added ingress tests. * Added ingress traffic tests. * Fixed small issue. * Added remove test for dapr components. * Removed live_only from containerapp commands. Added recordings. * Removed live_only from env commands. * Removed sleep 60 since we use poll for delete anyways. * Wrote better dapr-component tests. Fixed old tests that required live only. Co-authored-by: Haroon Feisal <[email protected]>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
import time | ||
import yaml | ||
|
||
from azure.cli.testsdk.scenario_tests import AllowLargeResponse | ||
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, live_only) | ||
|
||
TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) | ||
|
||
class ContainerappEnvScenarioTest(ScenarioTest): | ||
@AllowLargeResponse(8192) | ||
@ResourceGroupPreparer(location="northeurope") | ||
def test_containerapp_env_e2e(self, resource_group): | ||
env_name = self.create_random_name(prefix='containerapp-e2e-env', length=24) | ||
logs_workspace_name = self.create_random_name(prefix='containerapp-env', length=24) | ||
|
||
logs_workspace_id = self.cmd('monitor log-analytics workspace create -g {} -n {}'.format(resource_group, logs_workspace_name)).get_output_in_json()["customerId"] | ||
logs_workspace_key = self.cmd('monitor log-analytics workspace get-shared-keys -g {} -n {}'.format(resource_group, logs_workspace_name)).get_output_in_json()["primarySharedKey"] | ||
|
||
self.cmd('containerapp env create -g {} -n {} --logs-workspace-id {} --logs-workspace-key {}'.format(resource_group, env_name, logs_workspace_id, logs_workspace_key)) | ||
|
||
containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env_name)).get_output_in_json() | ||
|
||
while containerapp_env["properties"]["provisioningState"].lower() == "waiting": | ||
time.sleep(5) | ||
containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env_name)).get_output_in_json() | ||
|
||
self.cmd('containerapp env list -g {}'.format(resource_group), checks=[ | ||
JMESPathCheck('length(@)', 1), | ||
JMESPathCheck('[0].name', env_name), | ||
]) | ||
|
||
self.cmd('containerapp env show -n {} -g {}'.format(env_name, resource_group), checks=[ | ||
JMESPathCheck('name', env_name), | ||
]) | ||
|
||
# Sleep in case containerapp create takes a while | ||
self.cmd('containerapp env delete -g {} -n {} --yes'.format(resource_group, env_name)) | ||
|
||
# Sleep in case env delete takes a while | ||
self.cmd('containerapp env list -g {}'.format(resource_group), checks=[ | ||
JMESPathCheck('length(@)', 0), | ||
]) | ||
|
||
@AllowLargeResponse(8192) | ||
@ResourceGroupPreparer(location="northeurope") | ||
def test_containerapp_env_dapr_components(self, resource_group): | ||
env_name = self.create_random_name(prefix='containerapp-e2e-env', length=24) | ||
dapr_comp_name = self.create_random_name(prefix='dapr-component', length=24) | ||
logs_workspace_name = self.create_random_name(prefix='containerapp-env', length=24) | ||
|
||
logs_workspace_id = self.cmd('monitor log-analytics workspace create -g {} -n {}'.format(resource_group, logs_workspace_name)).get_output_in_json()["customerId"] | ||
logs_workspace_key = self.cmd('monitor log-analytics workspace get-shared-keys -g {} -n {}'.format(resource_group, logs_workspace_name)).get_output_in_json()["primarySharedKey"] | ||
|
||
self.cmd('containerapp env create -g {} -n {} --logs-workspace-id {} --logs-workspace-key {}'.format(resource_group, env_name, logs_workspace_id, logs_workspace_key)) | ||
|
||
import tempfile | ||
|
||
file_ref, dapr_file = tempfile.mkstemp(suffix=".yml") | ||
|
||
dapr_yaml = """ | ||
name: statestore | ||
componentType: state.azure.blobstorage | ||
version: v1 | ||
metadata: | ||
- name: accountName | ||
secretRef: storage-account-name | ||
secrets: | ||
- name: storage-account-name | ||
value: storage-account-name | ||
""" | ||
|
||
daprloaded = yaml.safe_load(dapr_yaml) | ||
|
||
with open(dapr_file, 'w') as outfile: | ||
yaml.dump(daprloaded, outfile, default_flow_style=False) | ||
|
||
containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env_name)).get_output_in_json() | ||
|
||
while containerapp_env["properties"]["provisioningState"].lower() == "waiting": | ||
time.sleep(5) | ||
containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env_name)).get_output_in_json() | ||
|
||
self.cmd('containerapp env dapr-component set -n {} -g {} --dapr-component-name {} --yaml {}'.format(env_name, resource_group, dapr_comp_name, dapr_file.replace(os.sep, os.sep + os.sep)), checks=[ | ||
JMESPathCheck('name', dapr_comp_name), | ||
]) | ||
|
||
os.close(file_ref) | ||
|
||
self.cmd('containerapp env dapr-component list -n {} -g {}'.format(env_name, resource_group), checks=[ | ||
JMESPathCheck('length(@)', 1), | ||
JMESPathCheck('[0].name', dapr_comp_name), | ||
]) | ||
|
||
self.cmd('containerapp env dapr-component show -n {} -g {} --dapr-component-name {}'.format(env_name, resource_group, dapr_comp_name), checks=[ | ||
JMESPathCheck('name', dapr_comp_name), | ||
JMESPathCheck('properties.version', 'v1'), | ||
JMESPathCheck('properties.secrets[0].name', 'storage-account-name'), | ||
JMESPathCheck('properties.metadata[0].name', 'accountName'), | ||
JMESPathCheck('properties.metadata[0].secretRef', 'storage-account-name'), | ||
]) | ||
|
||
self.cmd('containerapp env dapr-component remove -n {} -g {} --dapr-component-name {}'.format(env_name, resource_group, dapr_comp_name)) | ||
|
||
self.cmd('containerapp env dapr-component list -n {} -g {}'.format(env_name, resource_group), checks=[ | ||
JMESPathCheck('length(@)', 0), | ||
]) |