-
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
Merged
Merged
some mesh tests #251
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9b00979
renamed the command in the example readme
a339da7
Merge remote-tracking branch 'upstream/master'
4e95a23
incremented version for previous PR
e6a2970
updated mesh in the index.json
cb356ee
fixed command name for deployment
921fee0
added version change to table
5831f0a
pasted in latest -h
f849716
improved readme.rst with all of the current -h output
975853f
fixed project url for mesh extensions
6354038
Merge remote-tracking branch 'upstream/master'
7c10c28
added tests
9e5a59c
Merge remote-tracking branch 'upstream/master'
7df390f
Merge branch 'master' into mesh-testing
9ee5c13
fixed tests
9ae10fa
added proper license header
bf20e90
added a test for log
d6abff8
added logging command test and changed output handling
af83b56
increased version and history and read me
e8fb5ec
fixed history version and new line
00a6b3e
added history change
57437be
added what file to delete for recordings
c6bfeae
removed recordings
da75837
Merge branch 'master' into mesh-testing
jeffj6123 647a0b1
changed text and fixed history date
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')]" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
|
||
@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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add the test for container log as well?