-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
some mesh tests #251
some mesh tests #251
Changes from 22 commits
9b00979
a339da7
4e95a23
e6a2970
cb356ee
921fee0
5831f0a
f849716
975853f
6354038
7c10c28
9e5a59c
7df390f
9ee5c13
9ae10fa
bf20e90
d6abff8
af83b56
e8fb5ec
00a6b3e
57437be
c6bfeae
da75837
647a0b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
Microsoft Azure CLI 'mesh' Command Module | ||
============================================================== | ||
Official doc https://docs.microsoft.com/en-us/azure/service-fabric-mesh/ | ||
|
||
Run tests using | ||
python tests/latest/test_mesh_commands.py | ||
Delete the recordings file to run live tests instead of through vcr by deleting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this line can be deleted as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reworded it to make more sense. |
||
mesh\azext_mesh\tests\latest\recordings | ||
For more info on testing see | ||
https://github.com/Azure/azure-cli/blob/dev/doc/authoring_tests.md | ||
|
||
Commands to manage Azure Service Fabric Mesh resources | ||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
:: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"location": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Location of the resources." | ||
}, | ||
"defaultValue": "eastus" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"apiVersion": "2018-07-01-preview", | ||
"name": "helloWorldNetwork", | ||
"type": "Microsoft.ServiceFabricMesh/networks", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [], | ||
"properties": { | ||
"addressPrefix": "10.0.0.4/22", | ||
"ingressConfig": { | ||
"layer4": [ | ||
{ | ||
"name": "helloWorldIngress", | ||
"publicPort": "80", | ||
"applicationName": "helloWorldApp", | ||
"serviceName": "helloWorldService", | ||
"endpointName": "helloWorldListener" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"apiVersion": "2018-07-01-preview", | ||
"name": "helloWorldApp", | ||
"type": "Microsoft.ServiceFabricMesh/applications", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [ | ||
"Microsoft.ServiceFabricMesh/networks/helloWorldNetwork" | ||
], | ||
"properties": { | ||
"description": "Service Fabric Mesh HelloWorld Application!", | ||
"services": [ | ||
{ | ||
"type": "Microsoft.ServiceFabricMesh/services", | ||
"location": "[parameters('location')]", | ||
"name": "helloWorldService", | ||
"properties": { | ||
"description": "Service Fabric Mesh Hello World Service.", | ||
"osType": "linux", | ||
"codePackages": [ | ||
{ | ||
"name": "helloWorldCode", | ||
"image": "seabreeze/azure-mesh-helloworld:1.1-alpine", | ||
"endpoints": [ | ||
{ | ||
"name": "helloWorldListener", | ||
"port": "80" | ||
} | ||
], | ||
"resources": { | ||
"requests": { | ||
"cpu": "1", | ||
"memoryInGB": "1" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "helloWorldSideCar", | ||
"image": "seabreeze/azure-mesh-helloworld-sidecar:1.0-alpine", | ||
"resources": { | ||
"requests": { | ||
"cpu": "1", | ||
"memoryInGB": "1" | ||
} | ||
} | ||
} | ||
], | ||
"replicaCount": "1", | ||
"networkRefs": [ | ||
{ | ||
"name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'helloWorldNetwork')]" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=line-too-long,unused-argument | ||
|
||
import unittest | ||
from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer | ||
import os | ||
import urllib.request | ||
|
||
|
||
def _get_test_data_file(filename): | ||
curr_dir = os.path.dirname(os.path.realpath(__file__)) | ||
return os.path.join(curr_dir, 'data', filename).replace('\\', '\\\\') | ||
|
||
|
||
class AzureMeshServiceScenarioTest(ScenarioTest): | ||
@ResourceGroupPreparer(random_name_length=20) | ||
def test_app_commands(self, resource_group): | ||
app_name = 'helloWorldApp' | ||
self.kwargs.update({ | ||
'resource_id': '', | ||
'resource_group': resource_group, | ||
'deployment_name': self.create_random_name(prefix='cli', length=24), | ||
'app_name': app_name, | ||
'template_location': _get_test_data_file('template1.json') | ||
}) | ||
|
||
# Test create | ||
self.cmd('az mesh deployment create -g {rg} --template-file {template_location} --name {deployment_name}') | ||
|
||
# Test list | ||
app_list = self.cmd('az mesh app list --resource-group {rg}', checks=[ | ||
self.check('[0].name', app_name) | ||
]).get_output_in_json() | ||
assert len(app_list) == 1 | ||
|
||
# Test show resource group/name | ||
data = self.cmd('az mesh app show --resource-group {rg} --name {app_name}', checks=[ | ||
self.exists('description'), | ||
self.check('healthState', 'Ok'), | ||
self.exists('id'), | ||
self.exists('location'), | ||
self.check('name', app_name), | ||
self.check('provisioningState', 'Succeeded'), | ||
self.exists('serviceNames'), | ||
self.check('resourceGroup', resource_group), | ||
self.check('status', 'Ready'), | ||
self.exists('type') | ||
]).get_output_in_json() | ||
resource_id = data['id'] | ||
|
||
# Test show resource id | ||
show_data = self.cmd('az mesh app show --id {0}'.format(resource_id)).get_output_in_json() | ||
|
||
assert data == show_data | ||
|
||
# Test delete | ||
self.cmd('az mesh app delete -g {rg} --name {app_name} --yes') | ||
|
||
app_list = self.cmd('az mesh app list --resource-group {rg}').get_output_in_json() | ||
assert len(app_list) == 0 | ||
|
||
@ResourceGroupPreparer(random_name_length=20) | ||
def test_service_commands(self, resource_group): | ||
app_name = 'helloWorldApp' | ||
|
||
self.kwargs.update({ | ||
'resource_id': '', | ||
'resource_group': resource_group, | ||
'deployment_name': self.create_random_name(prefix='cli', length=24), | ||
'app_name': app_name, | ||
'service_name': 'helloWorldService', | ||
'template_location': _get_test_data_file('template1.json') | ||
|
||
}) | ||
|
||
self.cmd('az mesh deployment create -g {rg} --template-file {template_location} --name {deployment_name}') | ||
|
||
app_list = self.cmd('az mesh app list --resource-group {rg}', checks=[ | ||
self.check('[0].name', app_name) | ||
]).get_output_in_json() | ||
assert len(app_list) == 1 | ||
|
||
# Test list | ||
service_list = self.cmd('az mesh service list --resource-group {rg} --app-name {app_name}', checks=[ | ||
|
||
]).get_output_in_json() | ||
assert len(service_list) == 1 | ||
|
||
# Test show | ||
self.cmd('az mesh service show --resource-group {rg} --app-name {app_name} --name {service_name}', checks=[]) | ||
|
||
self.cmd('az mesh app delete -g {rg} --name {app_name} --yes') | ||
|
||
@ResourceGroupPreparer(random_name_length=20) | ||
def test_service_replica_commands(self, resource_group): | ||
app_name = 'helloWorldApp' | ||
|
||
self.kwargs.update({ | ||
'resource_group': resource_group, | ||
'deployment_name': self.create_random_name(prefix='cli', length=24), | ||
'app_name': app_name, | ||
'service_name': 'helloWorldService', | ||
'replica_name': 0, | ||
'template_location': _get_test_data_file('template1.json') | ||
}) | ||
|
||
self.cmd('az mesh deployment create -g {rg} --template-file {template_location} --name {deployment_name}') | ||
|
||
app_list = self.cmd('az mesh app list --resource-group {rg}', checks=[ | ||
self.check('[0].name', app_name) | ||
]).get_output_in_json() | ||
assert len(app_list) == 1 | ||
|
||
# Test list | ||
service_list = self.cmd('az mesh service-replica list --resource-group {rg} --app-name {app_name} --service-name {service_name}',).get_output_in_json() | ||
assert len(service_list) == 1 | ||
|
||
# Test show | ||
self.cmd('az mesh service-replica show --resource-group {rg} --app-name {app_name} --service-name {service_name} --replica-name {replica_name}', checks=[ | ||
self.exists('codePackages'), | ||
self.exists('networkRefs'), | ||
self.exists('osType'), | ||
self.exists('replicaName'), | ||
]) | ||
|
||
self.cmd('az mesh app delete -g {rg} --name {app_name} --yes') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add the test for container log as well? |
||
@ResourceGroupPreparer(random_name_length=20) | ||
def test_code_package_log_commands(self, resource_group): | ||
app_name = 'helloWorldApp' | ||
|
||
self.kwargs.update({ | ||
'resource_group': resource_group, | ||
'deployment_name': self.create_random_name(prefix='cli', length=24), | ||
'app_name': app_name, | ||
'service_name': 'helloWorldService', | ||
'replica_name': 0, | ||
'template_location': _get_test_data_file('template1.json'), | ||
'code_package_name': 'helloWorldCode', | ||
'network_name': 'helloWorldNetwork' | ||
}) | ||
|
||
self.cmd('az mesh deployment create -g {rg} --template-file {template_location} --name {deployment_name}') | ||
|
||
network_info = self.cmd('az mesh network show -g {rg} -n {network_name}').get_output_in_json() | ||
ip = network_info["ingressConfig"]["publicIpAddress"] | ||
urllib.request.urlopen('http://' + ip) | ||
|
||
# Test log | ||
self.cmd('az mesh code-package-log get --app-name {app_name} --code-package-name helloWorldCode --replica-name {replica_name} --resource-group {rg} --service-name {service_name} ', checks=[ | ||
self.exists('content') | ||
]) | ||
|
||
self.cmd('az mesh app delete -g {rg} --name {app_name} --yes') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not fixed