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 add containerapp-preview extension #6419

Merged
merged 54 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d0c524e
init containerapp-preview
Greedygre Jun 1, 2023
f7be550
add GA extension dependency
Greedygre Jun 6, 2023
d6d8f7c
add --environment-type
Greedygre Jun 6, 2023
93c8960
fix bug for prompt
Greedygre Jun 7, 2023
62debc5
warning for update extension
Greedygre Jun 7, 2023
a98d7d3
remove useless code
Greedygre Jun 7, 2023
12820f4
fix
Greedygre Jun 7, 2023
d948cdf
remove
Greedygre Jun 8, 2023
1bb1cea
remove setup
Greedygre Jun 8, 2023
2afbe83
fix
Greedygre Jun 8, 2023
42ab370
fix lint
Greedygre Jun 8, 2023
d6beff8
fix test
Greedygre Jun 8, 2023
0cf803f
test tbd
Greedygre Jun 8, 2023
9b9b237
test 0.0.0
Greedygre Jun 8, 2023
7c34333
add create containerapp
Greedygre Jun 13, 2023
1e81de8
fix
Greedygre Jun 13, 2023
ec88eb3
add env and environment type
Greedygre Jun 13, 2023
ac2c33c
set is preview
Greedygre Jun 13, 2023
bd96ab5
fix
Greedygre Jun 14, 2023
724a381
support --yaml with extended-location
Greedygre Jun 14, 2023
88eaa6a
fix extend
Greedygre Jun 15, 2023
94eebe4
add show/delete/list containerapp in preview
Greedygre Jun 16, 2023
6a4fb88
fix preview
Greedygre Jun 19, 2023
2a4a168
fix error
Greedygre Jun 19, 2023
8b17806
fix error
Greedygre Jun 19, 2023
c7410b7
rebase main
Greedygre Jun 19, 2023
4c9f52e
fix delete
Greedygre Jun 19, 2023
8cf2fc8
refactor client and make constants
Greedygre Jun 29, 2023
368fae6
add test for environment type on arc
Greedygre Jul 3, 2023
2618e94
set version
Greedygre Jul 3, 2023
22bb79a
add test yaml
Greedygre Jul 3, 2023
0f0ffb4
fix error
Greedygre Jul 3, 2023
958e075
fix containerapp preview test
Greedygre Jul 3, 2023
c8662e2
add rely GA extension in test
Greedygre Jul 3, 2023
5cd3762
fix test
Greedygre Jul 3, 2023
44e6078
remove useless code
Greedygre Jul 4, 2023
94be4f6
fix install for loading
Greedygre Jul 5, 2023
8cf778f
Update verify_linter.py
wangzelin007 Jul 4, 2023
5446f32
fix recording and set version to 1.0.0b1
Greedygre Jul 5, 2023
52533f7
fix static analysis: blank line at the end
Greedygre Jul 5, 2023
eb2b6e6
Update verify_linter.py
wangzelin007 Jul 5, 2023
fd55f66
fix comments
Greedygre Jul 6, 2023
2e799d9
remove blank line
Greedygre Jul 6, 2023
5faa2ca
remove python 3.6 support in setup and add more comments for command …
Greedygre Jul 6, 2023
37147a9
add test for managed, add helps, parse resource type and compare
Greedygre Jul 7, 2023
8ae8319
add blank line
Greedygre Jul 7, 2023
18f613d
remove prompt logic
Greedygre Jul 10, 2023
fd90a41
fix
Greedygre Jul 10, 2023
c592553
fix
Greedygre Jul 10, 2023
99e67f9
fix help
Greedygre Jul 10, 2023
03aa729
raise error in _get_azext_module
Greedygre Jul 11, 2023
26cf02c
fix comments
Greedygre Jul 11, 2023
a6d4f0d
add a blank line
Greedygre Jul 11, 2023
acecec6
rename _get_azext_containerapp_module
Greedygre Jul 11, 2023
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
Prev Previous commit
Next Next commit
add test for environment type on arc
  • Loading branch information
Greedygre committed Jul 10, 2023
commit 368fae66add91c7b43ca191de324945cf12a12a6
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(
):
super().__init__(cmd, client, raw_parameters, models)
self.azext_decorator_utils = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp._decorator_utils")
self.azext_default_utils = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp._utils")

def construct_containerapp(self):
containerapp_def = super().construct_containerapp()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import os
from azure.cli.testsdk import (ScenarioTest)

TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
TEST_LOCATION = os.getenv("CLITestLocation") if os.getenv("CLITestLocation") else "eastus"


def write_test_file(filename, content):
test_file = open(filename, "w", encoding='utf-8')
_ = test_file.write(content)
test_file.close()


def clean_up_test_file(filename):
if os.path.exists(filename):
os.remove(filename)


class ContainerappComposePreviewScenarioTest(ScenarioTest):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,80 @@
# --------------------------------------------------------------------------------------------

import os
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
import time
from azext_containerapp.tests.latest.common import (write_test_file, clean_up_test_file)
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, live_only)

from .common import TEST_LOCATION

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


class ContainerappScenarioTest(ScenarioTest):

@AllowLargeResponse(8192)
def test_containerapp_preview(self):
self.cmd('az containerapp create --name "ghrunnersaca" --resource-group "arc-appint-forxinyu12-rg0" --environment "my-environment2" --image "mcr.microsoft.com/k8se/quickstart:latest" --bind postgres:postgres_binding redis')
return
@ResourceGroupPreparer(location="eastus", random_name_length=15)
@live_only()
def test_containerapp_preview_environment_type(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
aks_name = "my-aks-cluster"
connected_cluster_name = "my-connected-cluster"
self.cmd(
f'aks create --resource-group {resource_group} --name {aks_name} --enable-aad --generate-ssh-keys --enable-cluster-autoscaler --min-count 4 --max-count 10 --node-count 4')
self.cmd(
f'aks get-credentials --resource-group {resource_group} --name {aks_name} --overwrite-existing --admin')
self.cmd(f'connectedk8s connect --resource-group {resource_group} --name {connected_cluster_name}')
connected_cluster = self.cmd(
f'az connectedk8s show --resource-group {resource_group} --name {connected_cluster_name}').get_output_in_json()
connected_cluster_id = connected_cluster['id']
extension = self.cmd(f'az k8s-extension create'
f' --resource-group {resource_group}'
f' --name containerapp-ext'
f' --cluster-type connectedClusters'
f' --cluster-name {connected_cluster["name"]}'
f' --extension-type "Microsoft.App.Environment" '
f' --release-train stable'
f' --auto-upgrade-minor-version true'
f' --scope cluster'
f' --release-namespace appplat-ns'
f' --configuration-settings "Microsoft.CustomLocation.ServiceAccount=default"'
f' --configuration-settings "appsNamespace=appplat-ns"'
f' --configuration-settings "clusterName={connected_cluster["name"]}"'
f' --configuration-settings "envoy.annotations.service.beta.kubernetes.io/azure-load-balancer-resource-group={resource_group}"').get_output_in_json()
custom_location_name = "my-custom-location"
custom_location_id = self.cmd(
f'az customlocation create -g {resource_group} -n {custom_location_name} -l {TEST_LOCATION} --host-resource-id {connected_cluster_id} --namespace appplat-ns -c {extension["id"]}') \
.get_output_in_json()['id']
# create connected environment with client or create a command for connected?
sub_id = self.cmd('az account show').get_output_in_json()['id']

connected_env_name = 'my-connected-env'
connected_env_resource_id = f"/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.App/connectedEnvironments/{connected_env_name}"
file = f"{resource_group}.json"
env_payload = '{{ "location": "{location}", "extendedLocation": {{ "name": "{custom_location_id}", "type": "CustomLocation" }}, "Properties": {{}}}}' \
.format(location=TEST_LOCATION, custom_location_id=custom_location_id)
write_test_file(file, env_payload)
self.cmd(
f'az rest --method put --uri "{connected_env_resource_id}?api-version=2022-06-01-preview" --body "@{file}"')
containerapp_env = self.cmd(
f'az rest --method get --uri "{connected_env_resource_id}?api-version=2022-06-01-preview"').get_output_in_json()
while containerapp_env["properties"]["provisioningState"].lower() != "succeeded":
time.sleep(5)
containerapp_env = self.cmd(
f'az rest --method get --uri "{connected_env_resource_id}?api-version=2022-06-01-preview"').get_output_in_json()

ca_name = self.create_random_name(prefix='containerapp', length=24)
self.cmd(
f'az containerapp create --name {ca_name} --resource-group {resource_group} --environment {connected_env_name} --image "mcr.microsoft.com/k8se/quickstart:latest" --environment-type connected',
checks=[
JMESPathCheck('properties.environmentId', connected_env_resource_id),
JMESPathCheck('properties.provisioningState', "Succeeded"),
JMESPathCheck('extendedLocation.name', custom_location_id)
])
ca_name2 = self.create_random_name(prefix='containerapp', length=24)
self.cmd(
f'az containerapp create --name {ca_name2} --resource-group {resource_group} --environment {connected_env_resource_id} --image "mcr.microsoft.com/k8se/quickstart:latest" --environment-type connected',
checks=[
JMESPathCheck('properties.environmentId', connected_env_resource_id),
JMESPathCheck('properties.provisioningState', "Succeeded"),
JMESPathCheck('extendedLocation.name', custom_location_id)
])