forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Spring]validate path exist before all steps (Azure#7725)
- Loading branch information
1 parent
e750e0f
commit 57461c1
Showing
12 changed files
with
1,746 additions
and
5 deletions.
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
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
204 changes: 204 additions & 0 deletions
204
src/spring/azext_spring/tests/latest/jobs/recordings/test_asa_job_deploy.yaml
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,204 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
CommandName: | ||
- spring job create | ||
Connection: | ||
- keep-alive | ||
ParameterSetName: | ||
- -n -g -s | ||
User-Agent: | ||
- AZURECLI/2.61.0 azsdk-python-core/1.30.1 Python/3.11.9 (Windows-10-10.0.22631-SP0) | ||
method: GET | ||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002?api-version=2024-05-01-preview | ||
response: | ||
body: | ||
string: '{"properties":{"provisioningState":"Succeeded","zoneRedundant":false,"version":3,"serviceId":"9b9e547a4196418d96427d7fe1421e91","networkProfile":{"outboundIPs":{"publicIPs":["20.162.177.38","20.254.82.240"]},"outboundType":"loadBalancer"},"powerState":"Running","fqdn":"clitest000002.azuremicroservices.io","marketplaceResource":{"plan":"asa-ent-hr-mtr","publisher":"vmware-inc","product":"azure-spring-cloud-vmware-tanzu-2"}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"E0","tier":"Enterprise"},"location":"uksouth","tags":null,"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002","name":"clitest000002","systemData":{"createdBy":"[email protected]","createdByType":"User","createdAt":"2024-06-19T04:54:54.0896323Z","lastModifiedBy":"[email protected]","lastModifiedByType":"User","lastModifiedAt":"2024-06-19T04:54:54.0896323Z"}}' | ||
headers: | ||
cache-control: | ||
- no-cache | ||
content-length: | ||
- '947' | ||
content-type: | ||
- application/json | ||
date: | ||
- Wed, 19 Jun 2024 05:01:38 GMT | ||
expires: | ||
- '-1' | ||
pragma: | ||
- no-cache | ||
request-context: | ||
- appId=cid-v1:797d7e4e-8180-497e-a254-780fbd39ba4d | ||
strict-transport-security: | ||
- max-age=31536000; includeSubDomains | ||
x-cache: | ||
- CONFIG_NOCACHE | ||
x-content-type-options: | ||
- nosniff | ||
x-ms-ratelimit-remaining-subscription-resource-requests: | ||
- '11999' | ||
x-msedge-ref: | ||
- 'Ref A: 4CA6CB34EF2D4906A7F467EED45E16F4 Ref B: TYO201151006034 Ref C: 2024-06-19T05:01:37Z' | ||
x-rp-server-mvid: | ||
- 16f8ed7c-99fe-42f5-98dc-7ba9e82d32d1 | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
CommandName: | ||
- spring job create | ||
Connection: | ||
- keep-alive | ||
ParameterSetName: | ||
- -n -g -s | ||
User-Agent: | ||
- AZURECLI/2.61.0 azsdk-python-core/1.30.1 Python/3.11.9 (Windows-10-10.0.22631-SP0) | ||
method: GET | ||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob?api-version=2024-05-01-preview | ||
response: | ||
body: | ||
string: '{"error":{"code":"NotFound","message":"Job not found.","target":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob","details":null}}' | ||
headers: | ||
cache-control: | ||
- no-cache | ||
content-length: | ||
- '230' | ||
content-type: | ||
- application/json | ||
date: | ||
- Wed, 19 Jun 2024 05:01:40 GMT | ||
expires: | ||
- '-1' | ||
pragma: | ||
- no-cache | ||
request-context: | ||
- appId=cid-v1:797d7e4e-8180-497e-a254-780fbd39ba4d | ||
strict-transport-security: | ||
- max-age=31536000; includeSubDomains | ||
x-cache: | ||
- CONFIG_NOCACHE | ||
x-content-type-options: | ||
- nosniff | ||
x-msedge-ref: | ||
- 'Ref A: 58002E6001B742868F4DD3B1F661E7BA Ref B: TYO201151004034 Ref C: 2024-06-19T05:01:39Z' | ||
x-rp-server-mvid: | ||
- 16f8ed7c-99fe-42f5-98dc-7ba9e82d32d1 | ||
status: | ||
code: 404 | ||
message: Not Found | ||
- request: | ||
body: '{"properties": {"template": {"environmentVariables": [], "resourceRequests": | ||
{"cpu": "1", "memory": "2Gi"}}, "managedComponentReferences": [], "triggerConfig": | ||
{"triggerType": "Manual"}}}' | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
CommandName: | ||
- spring job create | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '187' | ||
Content-Type: | ||
- application/json | ||
ParameterSetName: | ||
- -n -g -s | ||
User-Agent: | ||
- AZURECLI/2.61.0 azsdk-python-core/1.30.1 Python/3.11.9 (Windows-10-10.0.22631-SP0) | ||
method: PUT | ||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob?api-version=2024-05-01-preview | ||
response: | ||
body: | ||
string: '{"properties":{"provisioningState":"Succeeded","triggerConfig":{"triggerType":"Manual"},"template":{"environmentVariables":[],"resourceRequests":{"cpu":"1","memory":"2Gi"}},"managedComponentReferences":[]},"type":"Microsoft.AppPlatform/Spring/jobs","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob","name":"myjob","systemData":{"createdBy":"[email protected]","createdByType":"User","createdAt":"2024-06-19T05:01:42.0072873Z","lastModifiedBy":"[email protected]","lastModifiedByType":"User","lastModifiedAt":"2024-06-19T05:01:42.0072873Z"}}' | ||
headers: | ||
cache-control: | ||
- no-cache | ||
content-length: | ||
- '661' | ||
content-type: | ||
- application/json | ||
date: | ||
- Wed, 19 Jun 2024 05:01:43 GMT | ||
expires: | ||
- '-1' | ||
pragma: | ||
- no-cache | ||
request-context: | ||
- appId=cid-v1:797d7e4e-8180-497e-a254-780fbd39ba4d | ||
strict-transport-security: | ||
- max-age=31536000; includeSubDomains | ||
x-cache: | ||
- CONFIG_NOCACHE | ||
x-content-type-options: | ||
- nosniff | ||
x-ms-ratelimit-remaining-subscription-writes: | ||
- '1199' | ||
x-msedge-ref: | ||
- 'Ref A: 7DE6AE5D3AED45DB9D3EBB3A8D500705 Ref B: TYO201100115025 Ref C: 2024-06-19T05:01:41Z' | ||
x-rp-server-mvid: | ||
- 16f8ed7c-99fe-42f5-98dc-7ba9e82d32d1 | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
CommandName: | ||
- spring job create | ||
Connection: | ||
- keep-alive | ||
ParameterSetName: | ||
- -n -g -s | ||
User-Agent: | ||
- AZURECLI/2.61.0 azsdk-python-core/1.30.1 Python/3.11.9 (Windows-10-10.0.22631-SP0) | ||
method: GET | ||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob?api-version=2024-05-01-preview | ||
response: | ||
body: | ||
string: '{"properties":{"provisioningState":"Succeeded","triggerConfig":{"triggerType":"Manual"},"template":{"environmentVariables":[],"resourceRequests":{"cpu":"1","memory":"2Gi"}},"managedComponentReferences":[]},"type":"Microsoft.AppPlatform/Spring/jobs","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.AppPlatform/Spring/clitest000002/jobs/myjob","name":"myjob","systemData":{"createdBy":"[email protected]","createdByType":"User","createdAt":"2024-06-19T05:01:42.0072873Z","lastModifiedBy":"[email protected]","lastModifiedByType":"User","lastModifiedAt":"2024-06-19T05:01:42.0072873Z"}}' | ||
headers: | ||
cache-control: | ||
- no-cache | ||
content-length: | ||
- '661' | ||
content-type: | ||
- application/json | ||
date: | ||
- Wed, 19 Jun 2024 05:01:45 GMT | ||
expires: | ||
- '-1' | ||
pragma: | ||
- no-cache | ||
request-context: | ||
- appId=cid-v1:797d7e4e-8180-497e-a254-780fbd39ba4d | ||
strict-transport-security: | ||
- max-age=31536000; includeSubDomains | ||
x-cache: | ||
- CONFIG_NOCACHE | ||
x-content-type-options: | ||
- nosniff | ||
x-msedge-ref: | ||
- 'Ref A: 8121A5E1437D4652AAB3271D1AB24773 Ref B: TYO201151005060 Ref C: 2024-06-19T05:01:44Z' | ||
x-rp-server-mvid: | ||
- 16f8ed7c-99fe-42f5-98dc-7ba9e82d32d1 | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
34 changes: 34 additions & 0 deletions
34
src/spring/azext_spring/tests/latest/jobs/test_asa_job_deploy_scenario.py
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,34 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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 knack.util import CLIError | ||
from azure.cli.testsdk import (ScenarioTest, record_only) | ||
from ..custom_preparers import (SpringPreparer, SpringResourceGroupPreparer) | ||
from ..custom_dev_setting_constant import SpringTestEnvironmentEnum | ||
|
||
|
||
class JobDeploy(ScenarioTest): | ||
|
||
@SpringResourceGroupPreparer(dev_setting_name=SpringTestEnvironmentEnum.ENTERPRISE['resource_group_name']) | ||
@SpringPreparer(**SpringTestEnvironmentEnum.ENTERPRISE['spring']) | ||
def test_asa_job_deploy(self, resource_group, spring): | ||
py_path = os.path.abspath(os.path.dirname(__file__)) | ||
file_path = os.path.join(py_path, 'files/test1.jar').replace("\\", "/") | ||
self.kwargs.update({ | ||
'job': 'myjob', | ||
'serviceName': spring, | ||
'rg': resource_group, | ||
'file': file_path | ||
}) | ||
|
||
self.cmd('spring job create -n {job} -g {rg} -s {serviceName}', checks=[ | ||
self.check('name', '{job}') | ||
]) | ||
|
||
# deploy unexist file, the fail is expected | ||
with self.assertRaisesRegexp(CLIError, "artifact path {} does not exist.".format(file_path)): | ||
self.cmd('spring job deploy -n {job} -g {rg} -s {serviceName} --artifact-path {file}') |
Oops, something went wrong.