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

{containerapp} Improve tests: Use same name foo for compose tests #6853

Merged
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

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.

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
Expand Up @@ -22,10 +22,9 @@ class ContainerappComposeBaseScenarioTest(ContainerappComposePreviewScenarioTest
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_basic_no_existing_resources(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='compose', length=24)
compose_text = f"""
services:
{app}:
foo:
image: smurawski/printenv:latest
"""
compose_file_name = f"{self._testMethodName}_compose.yml"
Expand All @@ -42,8 +41,8 @@ def test_containerapp_compose_create_basic_no_existing_resources(self, resource_
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check('[].name', [app]),
self.check('[].name', ['foo']),
self.check('[] | length(@)', 1),
])

self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)
clean_up_test_file(compose_file_name)
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class ContainerappComposePreviewCommandScenarioTest(ContainerappComposePreviewSc
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_with_command_string(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composecommandstr', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
command: echo "hello world"
expose:
Expand All @@ -44,7 +43,7 @@ def test_containerapp_compose_with_command_string(self, resource_group):
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].command[0]', "['echo \"hello world\"']"),
self.check(f'[?name==`foo`].properties.template.containers[0].command[0]', "['echo \"hello world\"']"),
])

clean_up_test_file(compose_file_name)
Expand All @@ -53,10 +52,9 @@ def test_containerapp_compose_with_command_string(self, resource_group):
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_with_command_list(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composecommandlist', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
command: ["echo", "hello world"]
expose:
Expand All @@ -75,7 +73,7 @@ def test_containerapp_compose_with_command_list(self, resource_group):
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].command[0]', "['echo \"hello world\"']"),
self.check(f'[?name==`foo`].properties.template.containers[0].command[0]', "['echo \"hello world\"']"),
])

clean_up_test_file(compose_file_name)
Expand All @@ -84,10 +82,9 @@ def test_containerapp_compose_with_command_list(self, resource_group):
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_with_command_list_and_entrypoint(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composeentry', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
command: ["echo", "hello world"]
entrypoint: /code/entrypoint.sh
Expand All @@ -107,8 +104,9 @@ def test_containerapp_compose_with_command_list_and_entrypoint(self, resource_gr
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].command[0]', "['/code/entrypoint.sh']"),
self.check(f'[?name==`{app}`].properties.template.containers[0].args[0]', "['echo \"hello world\"']"),
self.check(f'[?name==`foo`].properties.template.containers[0].command[0]', "['/code/entrypoint.sh']"),
self.check(f'[?name==`foo`].properties.template.containers[0].args[0]', "['echo \"hello world\"']"),
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
])

self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)
clean_up_test_file(compose_file_name)
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class ContainerappComposePreviewEnvironmentSettingsScenarioTest(ContainerappComp
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_environment(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composewithenv', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
environment:
- RACK_ENV=development
Expand All @@ -45,14 +44,15 @@ def test_containerapp_compose_create_with_environment(self, resource_group):
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].env[0].name', ["RACK_ENV"]),
self.check(f'[?name==`{app}`].properties.template.containers[0].env[0].value', ["development"]),
self.check(f'[?name==`{app}`].properties.template.containers[0].env[1].name', ["SHOW"]),
self.check(f'[?name==`{app}`].properties.template.containers[0].env[1].value', ["true"]),
self.check(f'[?name==`{app}`].properties.template.containers[0].env[2].name', ["BAZ"]),
self.check(f'[?name==`{app}`].properties.template.containers[0].env[2].value', ['"snafu"'])
self.check(f'[?name==`foo`].properties.template.containers[0].env[0].name', ["RACK_ENV"]),
self.check(f'[?name==`foo`].properties.template.containers[0].env[0].value', ["development"]),
self.check(f'[?name==`foo`].properties.template.containers[0].env[1].name', ["SHOW"]),
self.check(f'[?name==`foo`].properties.template.containers[0].env[1].value', ["true"]),
self.check(f'[?name==`foo`].properties.template.containers[0].env[2].name', ["BAZ"]),
self.check(f'[?name==`foo`].properties.template.containers[0].env[2].value', ['"snafu"'])
])

self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)
clean_up_test_file(compose_file_name)


Expand All @@ -62,10 +62,9 @@ class ContainerappComposePreviewEnvironmentSettingsExpectedExceptionScenarioTest
def test_containerapp_compose_create_with_environment_prompt(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))

app = self.create_random_name(prefix='composewithenv', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
environment:
- LOREM=
Expand All @@ -85,5 +84,6 @@ def test_containerapp_compose_create_with_environment_prompt(self, resource_grou

# This test fails because prompts are not supported in NoTTY environments
self.cmd(command_string, expect_failure=True)
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class ContainerappComposePreviewIngressScenarioTest(ContainerappComposePreviewSc
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_ingress_external(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composeingress', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports: 8080:80
"""
Expand All @@ -41,9 +40,10 @@ def test_containerapp_compose_create_with_ingress_external(self, resource_group)
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.configuration.ingress.targetPort', [80]),
self.check(f'[?name==`{app}`].properties.configuration.ingress.external', [True]),
self.check(f'[?name==`foo`].properties.configuration.ingress.targetPort', [80]),
self.check(f'[?name==`foo`].properties.configuration.ingress.external', [True]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

Expand All @@ -52,10 +52,9 @@ class ContainerappComposePreviewIngressInternalScenarioTest(ContainerappComposeP
@serial_test()
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_ingress_internal(self, resource_group):
app = self.create_random_name(prefix='composeingress', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
expose:
- "3000"
Expand All @@ -73,9 +72,10 @@ def test_containerapp_compose_create_with_ingress_internal(self, resource_group)
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.configuration.ingress.targetPort', [3000]),
self.check(f'[?name==`{app}`].properties.configuration.ingress.external', [False]),
self.check(f'[?name==`foo`].properties.configuration.ingress.targetPort', [3000]),
self.check(f'[?name==`foo`].properties.configuration.ingress.external', [False]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

Expand All @@ -85,10 +85,9 @@ class ContainerappComposePreviewIngressBothScenarioTest(ContainerappComposePrevi
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_ingress_both(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composeingress', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports: 4000:3000
expose:
Expand All @@ -107,9 +106,10 @@ def test_containerapp_compose_create_with_ingress_both(self, resource_group):
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.configuration.ingress.targetPort', [3000]),
self.check(f'[?name==`{app}`].properties.configuration.ingress.external', [True]),
self.check(f'[?name==`foo`].properties.configuration.ingress.targetPort', [3000]),
self.check(f'[?name==`foo`].properties.configuration.ingress.external', [True]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

Expand All @@ -119,10 +119,9 @@ class ContainerappComposePreviewIngressPromptScenarioTest(ContainerappComposePre
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_ingress_prompt(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composeingress', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports:
- 4000:3000
Expand All @@ -148,5 +147,6 @@ def test_containerapp_compose_create_with_ingress_prompt(self, resource_group):

# This test fails because prompts are not supported in NoTTY environments
self.cmd(command_string, expect_failure=True)
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class ContainerappComposePreviewRegistryAllArgsScenarioTest(ContainerappComposeP
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_registry_all_args(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composewithreg', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports: 8080:80
"""
Expand All @@ -48,10 +47,11 @@ def test_containerapp_compose_create_with_registry_all_args(self, resource_group
command_string += ' --registry-password {registry_pass}'

self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.configuration.registries[0].server', ["foobar.azurecr.io"]),
self.check(f'[?name==`{app}`].properties.configuration.registries[0].username', ["foobar"]),
self.check(f'[?name==`{app}`].properties.configuration.registries[0].passwordSecretRef', ["foobarazurecrio-foobar"]), # pylint: disable=C0301
self.check(f'[?name==`foo`].properties.configuration.registries[0].server', ["foobar.azurecr.io"]),
self.check(f'[?name==`foo`].properties.configuration.registries[0].username', ["foobar"]),
self.check(f'[?name==`foo`].properties.configuration.registries[0].passwordSecretRef', ["foobarazurecrio-foobar"]), # pylint: disable=C0301
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

Expand All @@ -61,10 +61,9 @@ class ContainerappComposePreviewRegistryServerArgOnlyScenarioTest(ContainerappCo
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_registry_server_arg_only(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composewithreg', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports: 8080:80
"""
Expand All @@ -86,5 +85,6 @@ def test_containerapp_compose_create_with_registry_server_arg_only(self, resourc

# This test fails because prompts are not supported in NoTTY environments
self.cmd(command_string, expect_failure=True)
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class ContainerappComposePreviewResourceSettingsScenarioTest(ContainerappCompose
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_resources_from_service_cpus(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composewithres', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
cpus: 1.25
expose:
Expand All @@ -44,8 +43,9 @@ def test_containerapp_compose_create_with_resources_from_service_cpus(self, reso
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].resources.cpu', [1.25]),
self.check(f'[?name==`foo`].properties.template.containers[0].resources.cpu', [1.25]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

Expand All @@ -56,7 +56,7 @@ def test_containerapp_compose_create_with_resources_from_deploy_cpu(self, resour
app = self.create_random_name(prefix='composewithres', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
deploy:
resources:
Expand All @@ -79,19 +79,19 @@ def test_containerapp_compose_create_with_resources_from_deploy_cpu(self, resour
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].resources.cpu', [1.25]),
self.check(f'[?name==`foo`].properties.template.containers[0].resources.cpu', [1.25]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)

@serial_test()
@ResourceGroupPreparer(name_prefix='cli_test_containerapp_preview', location='eastus')
def test_containerapp_compose_create_with_resources_from_both_cpus_and_deploy_cpu(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
app = self.create_random_name(prefix='composewithres', length=24)
compose_text = f"""
services:
{app}:
foo:
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
cpus: 0.75
deploy:
Expand All @@ -115,7 +115,8 @@ def test_containerapp_compose_create_with_resources_from_both_cpus_and_deploy_cp
command_string += ' --resource-group {rg}'
command_string += ' --environment {environment}'
self.cmd(command_string, checks=[
self.check(f'[?name==`{app}`].properties.template.containers[0].resources.cpu', [1.25]),
self.check(f'[?name==`foo`].properties.template.containers[0].resources.cpu', [1.25]),
])
self.cmd(f'containerapp delete -n foo -g {resource_group} --yes', expect_failure=False)

clean_up_test_file(compose_file_name)
Loading