зеркало из https://github.com/microsoft/azure-cli.git
Batch enum bug fix + more tests (#2015)
* Added job tests * Enum bug fix * Added enum test * fixed force revert * Style fixes * Reformat test exceptions
This commit is contained in:
Родитель
b6d037f2d4
Коммит
8b22ba4a02
|
@ -122,6 +122,7 @@
|
|||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\tests\test_batch_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\tests\test_batch_data_plane_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\tests\test_batch_data_plane_command_base.py" />
|
||||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\tests\test_batch_job_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\tests\test_batch_pool_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-batch\azure\cli\command_modules\batch\_command_type.py" />
|
||||
<Compile Include="command_modules\azure-cli-cloud\azure\cli\command_modules\cloud\commands.py" />
|
||||
|
|
|
@ -166,6 +166,13 @@ def find_return_type(model):
|
|||
return re.sub(r"\n\s*", "", return_type.group(1))
|
||||
|
||||
|
||||
def enum_value(enum_str):
|
||||
"""Strip chars around enum value str.
|
||||
:param str enum_str: Enum value.
|
||||
"""
|
||||
return enum_str.strip(' \'')
|
||||
|
||||
|
||||
def class_name(type_str):
|
||||
"""Extract class name from type docstring.
|
||||
:param str type_str: Parameter type docstring.
|
||||
|
@ -752,7 +759,8 @@ class AzureBatchDataPlaneCommand(object):
|
|||
values_index = options['help'].find(' Possible values include')
|
||||
if values_index >= 0:
|
||||
choices = options['help'][values_index + 25:].split(', ')
|
||||
options['choices'] = [c for c in choices if c != "'unmapped'"]
|
||||
options['choices'] = [enum_value(c) \
|
||||
for c in choices if enum_value(c) != "unmapped"]
|
||||
options['help'] = options['help'][0:values_index]
|
||||
self._resolve_conflict(param_attr, param_attr, path, options,
|
||||
details['type'], required_attrs, conflict_names)
|
||||
|
|
|
@ -0,0 +1,290 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: '{"vmSize": "small", "cloudServiceConfiguration": {"osFamily": "4"}, "id":
|
||||
"azure-cli-test-paas"}'
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['96']
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e3c749d4-ee46-11e6-a33d-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:11 GMT']
|
||||
method: POST
|
||||
uri: https://test1.westus.batch.azure.com/pools?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: ''}
|
||||
headers:
|
||||
DataServiceId: ['https://test1.westus.batch.azure.com/pools/azure-cli-test-paas']
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:12 GMT']
|
||||
ETag: ['0x8D4506AC8C286F8']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
Location: ['https://test1.westus.batch.azure.com/pools/azure-cli-test-paas']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [ef22a3a2-8c22-4c49-bc18-be1e5d443e8a]
|
||||
status: {code: 201, message: Created}
|
||||
- request:
|
||||
body: '{"metadata": [{"name": "test", "value": "value"}], "jobManagerTask": {"environmentSettings":
|
||||
[{"name": "CLI_TEST_VAR", "value": "CLI_TEST_VAR_VALUE"}], "runElevated": true,
|
||||
"id": "JobManager", "commandLine": "cmd /c set AZ_BATCH_TASK_ID"}, "poolInfo":
|
||||
{"poolId": "azure-cli-test-paas"}, "id": "cli-test-job-1", "constraints": {"maxTaskRetryCount":
|
||||
5}}'
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['351']
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e4721f10-ee46-11e6-8a4a-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:12 GMT']
|
||||
method: POST
|
||||
uri: https://test1.westus.batch.azure.com/jobs?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: ''}
|
||||
headers:
|
||||
DataServiceId: ['https://test1.westus.batch.azure.com/jobs/job-1']
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:11 GMT']
|
||||
ETag: ['0x8D4506AC8AFDDC7']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:12 GMT']
|
||||
Location: ['https://test1.westus.batch.azure.com/jobs/job-1']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [1fa09551-0e22-4141-af65-9d3764d28ff6]
|
||||
status: {code: 201, message: Created}
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e4c2664a-ee46-11e6-8cb5-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
method: GET
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: "{\r\n \"odata.metadata\":\"https://test1.westus.batch.azure.com/$metadata#jobs/@Element\"\
|
||||
,\"id\":\"cli-test-job-1\",\"url\":\"https://test1.westus.batch.azure.com/jobs/cli-test-job-1\"\
|
||||
,\"eTag\":\"0x8D4506AC8AFDDC7\",\"lastModified\":\"2017-02-08T21:38:12.9806791Z\"\
|
||||
,\"creationTime\":\"2017-02-08T21:38:12.9027025Z\",\"state\":\"active\",\"\
|
||||
stateTransitionTime\":\"2017-02-08T21:38:12.9806791Z\",\"priority\":0,\"usesTaskDependencies\"\
|
||||
:false,\"constraints\":{\r\n \"maxWallClockTime\":\"P10675199DT2H48M5.4775807S\"\
|
||||
,\"maxTaskRetryCount\":5\r\n },\"jobManagerTask\":{\r\n \"id\":\"JobManager\"\
|
||||
,\"commandLine\":\"cmd /c set AZ_BATCH_TASK_ID\",\"environmentSettings\":[\r\
|
||||
\n {\r\n \"name\":\"CLI_TEST_VAR\",\"value\":\"CLI_TEST_VAR_VALUE\"\
|
||||
\r\n }\r\n ],\"constraints\":{\r\n \"maxWallClockTime\":\"P10675199DT2H48M5.4775807S\"\
|
||||
,\"retentionTime\":\"P10675199DT2H48M5.4775807S\",\"maxTaskRetryCount\":5\r\
|
||||
\n },\"runElevated\":true,\"runExclusive\":true,\"killJobOnCompletion\"\
|
||||
:true\r\n },\"poolInfo\":{\r\n \"poolId\":\"azure-cli-test-paas\"\r\n\
|
||||
\ },\"metadata\":[\r\n {\r\n \"name\":\"test\",\"value\":\"value\"\
|
||||
\r\n }\r\n ],\"executionInfo\":{\r\n \"startTime\":\"2017-02-08T21:38:12.9806791Z\"\
|
||||
,\"poolId\":\"azure-cli-test-paas\"\r\n },\"onAllTasksComplete\":\"noaction\"\
|
||||
,\"onTaskFailure\":\"noaction\"\r\n}"}
|
||||
headers:
|
||||
Content-Type: [application/json;odata=minimalmetadata]
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:11 GMT']
|
||||
ETag: ['0x8D4506AC8AFDDC7']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:12 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [139b03af-faf1-4ebe-ade0-335b30fa8837]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '{"constraints": {"maxWallClockTime": "P3Y6M4DT12H30M5S"}, "onAllTasksComplete":
|
||||
"terminateJob"}'
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['95']
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e5074734-ee46-11e6-906c-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
method: PATCH
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: ''}
|
||||
headers:
|
||||
DataServiceId: ['https://test1.westus.batch.azure.com/jobs/cli-test-job-1']
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
ETag: ['0x8D4506AC938D753']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [1bc56a8d-83a9-4157-98fe-e4c73ce3d9e5]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e54dbdee-ee46-11e6-baf4-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:14 GMT']
|
||||
method: GET
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: "{\r\n \"odata.metadata\":\"https://test1.westus.batch.azure.com/$metadata#jobs/@Element\"\
|
||||
,\"id\":\"cli-test-job-1\",\"url\":\"https://test1.westus.batch.azure.com/jobs/cli-test-job-1\"\
|
||||
,\"eTag\":\"0x8D4506AC938D753\",\"lastModified\":\"2017-02-08T21:38:13.8783571Z\"\
|
||||
,\"creationTime\":\"2017-02-08T21:38:12.9027025Z\",\"state\":\"active\",\"\
|
||||
stateTransitionTime\":\"2017-02-08T21:38:12.9806791Z\",\"priority\":0,\"usesTaskDependencies\"\
|
||||
:false,\"constraints\":{\r\n \"maxWallClockTime\":\"P1279DT12H30M5S\",\"\
|
||||
maxTaskRetryCount\":0\r\n },\"jobManagerTask\":{\r\n \"id\":\"JobManager\"\
|
||||
,\"commandLine\":\"cmd /c set AZ_BATCH_TASK_ID\",\"environmentSettings\":[\r\
|
||||
\n {\r\n \"name\":\"CLI_TEST_VAR\",\"value\":\"CLI_TEST_VAR_VALUE\"\
|
||||
\r\n }\r\n ],\"constraints\":{\r\n \"maxWallClockTime\":\"P10675199DT2H48M5.4775807S\"\
|
||||
,\"retentionTime\":\"P10675199DT2H48M5.4775807S\",\"maxTaskRetryCount\":5\r\
|
||||
\n },\"runElevated\":true,\"runExclusive\":true,\"killJobOnCompletion\"\
|
||||
:true\r\n },\"poolInfo\":{\r\n \"poolId\":\"azure-cli-test-paas\"\r\n\
|
||||
\ },\"metadata\":[\r\n {\r\n \"name\":\"test\",\"value\":\"value\"\
|
||||
\r\n }\r\n ],\"executionInfo\":{\r\n \"startTime\":\"2017-02-08T21:38:12.9806791Z\"\
|
||||
,\"poolId\":\"azure-cli-test-paas\"\r\n },\"onAllTasksComplete\":\"terminatejob\"\
|
||||
,\"onTaskFailure\":\"noaction\"\r\n}"}
|
||||
headers:
|
||||
Content-Type: [application/json;odata=minimalmetadata]
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:12 GMT']
|
||||
ETag: ['0x8D4506AC938D753']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [e14b2955-e45b-48e7-bfaf-36e92a9e795f]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '{"poolInfo": {"poolId": "azure-cli-test-paas"}, "onAllTasksComplete": "terminateJob"}'
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['85']
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
If-Unmodified-Since: ['Wed, 08 Feb 2017 13:38:12 GMT']
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e5811fba-ee46-11e6-8a07-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:14 GMT']
|
||||
method: PUT
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: "{\r\n \"odata.metadata\":\"https://test1.westus.batch.azure.com/$metadata#Microsoft.Azure.Batch.Protocol.Entities.Container.errors/@Element\"\
|
||||
,\"code\":\"ConditionNotMet\",\"message\":{\r\n \"lang\":\"en-US\",\"value\"\
|
||||
:\"The condition specified using HTTP conditional header(s) is not met.\\\
|
||||
nRequestId:39832922-88f7-426d-b9a4-b944e8099a57\\nTime:2017-02-08T21:38:13.7493928Z\"\
|
||||
\r\n }\r\n}"}
|
||||
headers:
|
||||
Content-Length: ['376']
|
||||
Content-Type: [application/json;odata=minimalmetadata]
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [39832922-88f7-426d-b9a4-b944e8099a57]
|
||||
status: {code: 412, message: The condition specified using HTTP conditional header(s)
|
||||
is not met.}
|
||||
- request:
|
||||
body: '{"poolInfo": {"poolId": "azure-cli-test-paas"}, "onAllTasksComplete": "terminateJob"}'
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['85']
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e5c222d8-ee46-11e6-a7fe-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:15 GMT']
|
||||
method: PUT
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: ''}
|
||||
headers:
|
||||
DataServiceId: ['https://test1.westus.batch.azure.com/jobs/cli-test-job-1']
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:15 GMT']
|
||||
ETag: ['0x8D4506AC9EDB09C']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:15 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [fd599e48-ba28-49b6-829c-5ad9f451a719]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; odata=minimalmetadata; charset=utf-8]
|
||||
User-Agent: [python/3.5.1 (Windows-8.1-6.3.9600-SP0) requests/2.9.1 msrest/0.4.4
|
||||
msrest_azure/0.4.7 batchserviceclient/1.1.0 Azure-SDK-For-Python]
|
||||
accept-language: [en-US]
|
||||
client-request-id: [e5f67a3e-ee46-11e6-bf0e-54ee750f2fc7]
|
||||
ocp-date: ['Wed, 08 Feb 2017 21:38:15 GMT']
|
||||
method: GET
|
||||
uri: https://test1.westus.batch.azure.com/jobs/cli-test-job-1?api-version=2016-07-01.3.1&timeout=30
|
||||
response:
|
||||
body: {string: "{\r\n \"odata.metadata\":\"https://test1.westus.batch.azure.com/$metadata#jobs/@Element\"\
|
||||
,\"id\":\"cli-test-job-1\",\"url\":\"https://test1.westus.batch.azure.com/jobs/cli-test-job-1\"\
|
||||
,\"eTag\":\"0x8D4506AC9EDB09C\",\"lastModified\":\"2017-02-08T21:38:15.0635676Z\"\
|
||||
,\"creationTime\":\"2017-02-08T21:38:12.9027025Z\",\"state\":\"active\",\"\
|
||||
stateTransitionTime\":\"2017-02-08T21:38:12.9806791Z\",\"priority\":0,\"usesTaskDependencies\"\
|
||||
:false,\"constraints\":{\r\n \"maxWallClockTime\":\"P10675199DT2H48M5.4775807S\"\
|
||||
,\"maxTaskRetryCount\":0\r\n },\"jobManagerTask\":{\r\n \"id\":\"JobManager\"\
|
||||
,\"commandLine\":\"cmd /c set AZ_BATCH_TASK_ID\",\"environmentSettings\":[\r\
|
||||
\n {\r\n \"name\":\"CLI_TEST_VAR\",\"value\":\"CLI_TEST_VAR_VALUE\"\
|
||||
\r\n }\r\n ],\"constraints\":{\r\n \"maxWallClockTime\":\"P10675199DT2H48M5.4775807S\"\
|
||||
,\"retentionTime\":\"P10675199DT2H48M5.4775807S\",\"maxTaskRetryCount\":5\r\
|
||||
\n },\"runElevated\":true,\"runExclusive\":true,\"killJobOnCompletion\"\
|
||||
:true\r\n },\"poolInfo\":{\r\n \"poolId\":\"azure-cli-test-paas\"\r\n\
|
||||
\ },\"executionInfo\":{\r\n \"startTime\":\"2017-02-08T21:38:12.9806791Z\"\
|
||||
,\"poolId\":\"azure-cli-test-paas\"\r\n },\"onAllTasksComplete\":\"terminatejob\"\
|
||||
,\"onTaskFailure\":\"noaction\"\r\n}"}
|
||||
headers:
|
||||
Content-Type: [application/json;odata=minimalmetadata]
|
||||
DataServiceVersion: ['3.0']
|
||||
Date: ['Wed, 08 Feb 2017 21:38:13 GMT']
|
||||
ETag: ['0x8D4506AC9EDB09C']
|
||||
Last-Modified: ['Wed, 08 Feb 2017 21:38:15 GMT']
|
||||
Server: [Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Transfer-Encoding: [chunked]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
request-id: [1aeb8ba4-ee1a-4857-8151-642e54c87c13]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
|
@ -0,0 +1,101 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from azure.cli.core._util import CLIError
|
||||
from azure.cli.command_modules.batch.tests.test_batch_data_plane_command_base import (
|
||||
BatchDataPlaneTestBase)
|
||||
|
||||
|
||||
class BatchJobTest(BatchDataPlaneTestBase):
|
||||
|
||||
def __init__(self, test_method):
|
||||
super(BatchJobTest, self).__init__(__file__, test_method)
|
||||
self.pool_paas = "azure-cli-test-paas"
|
||||
self.job1 = "cli-test-job-1"
|
||||
self.data_dir = os.path.join(
|
||||
os.path.dirname(__file__), 'data', 'batch-job-{}.json').replace('\\', '\\\\')
|
||||
|
||||
def tear_down(self):
|
||||
# Clean up any running pools in case the test exited early
|
||||
try:
|
||||
self.cmd('batch pool delete --pool-id {} --yes'.format(self.pool_paas))
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
try:
|
||||
self.cmd('batch job delete --job-id {} --yes'.format(self.job1))
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
def test_batch_jobs(self):
|
||||
self.execute()
|
||||
|
||||
def body(self):
|
||||
# pylint: disable=too-many-statements
|
||||
# test create paas pool using parameters
|
||||
self.cmd('batch pool create --id {} --vm-size small --os-family 4'.format(
|
||||
self.pool_paas))
|
||||
|
||||
start_time = datetime.datetime.now().isoformat()
|
||||
# test create job with missing parameters
|
||||
with self.assertRaises(SystemExit):
|
||||
self.cmd('batch job create --id {} --metadata test=value '
|
||||
'--job-max-task-retry-count 5 '
|
||||
'--job-manager-task-run-elevated'.format(self.job1))
|
||||
|
||||
# test create job
|
||||
self.cmd('batch job create --id {} --metadata test=value --job-max-task-retry-count 5 '
|
||||
'--job-manager-task-run-elevated --job-manager-task-id JobManager '
|
||||
'--job-manager-task-command-line "cmd /c set AZ_BATCH_TASK_ID" '
|
||||
'--job-manager-task-environment-settings '
|
||||
'CLI_TEST_VAR=CLI_TEST_VAR_VALUE --pool-id {}'.format(self.job1, self.pool_paas))
|
||||
|
||||
# test get job
|
||||
job1 = self.cmd('batch job show --job-id {}'.format(self.job1))
|
||||
self.assertEqual(job1['metadata'][0]['name'], 'test')
|
||||
self.assertEqual(job1['metadata'][0]['value'], 'value')
|
||||
self.assertEqual(job1['jobManagerTask']['environmentSettings'][0]['name'],
|
||||
'CLI_TEST_VAR')
|
||||
self.assertEqual(job1['jobManagerTask']['environmentSettings'][0]['value'],
|
||||
'CLI_TEST_VAR_VALUE')
|
||||
self.assertEqual(job1['jobManagerTask']['id'], 'JobManager')
|
||||
self.assertEqual(job1['constraints']['maxTaskRetryCount'], 5)
|
||||
self.assertEqual(job1['onAllTasksComplete'], 'noAction')
|
||||
|
||||
# test bad enum value
|
||||
with self.assertRaises(SystemExit):
|
||||
self.cmd('batch job set --job-id {} '
|
||||
'--on-all-tasks-complete badValue '.format(self.job1))
|
||||
|
||||
# test patch job
|
||||
self.cmd('batch job set --job-id {} --job-max-wall-clock-time P3Y6M4DT12H30M5S '
|
||||
'--on-all-tasks-complete terminateJob'.format(self.job1))
|
||||
job1 = self.cmd('batch job show --job-id {}'.format(self.job1))
|
||||
self.assertEqual(job1['metadata'][0]['name'], 'test')
|
||||
self.assertEqual(job1['metadata'][0]['value'], 'value')
|
||||
self.assertEqual(job1['jobManagerTask']['environmentSettings'][0]['name'],
|
||||
'CLI_TEST_VAR')
|
||||
self.assertEqual(job1['jobManagerTask']['environmentSettings'][0]['value'],
|
||||
'CLI_TEST_VAR_VALUE')
|
||||
self.assertEqual(job1['jobManagerTask']['id'], 'JobManager')
|
||||
self.assertEqual(job1['constraints']['maxTaskRetryCount'], 0)
|
||||
self.assertEqual(job1['constraints']['maxWallClockTime'], '1279 days, 12:30:05')
|
||||
self.assertEqual(job1['onAllTasksComplete'], 'terminateJob')
|
||||
|
||||
# test filter/header argument
|
||||
with self.assertRaises(CLIError):
|
||||
self.cmd('batch job reset --job-id {} --pool-id {} '
|
||||
'--on-all-tasks-complete terminateJob '
|
||||
'--if-unmodified-since {}'.format(self.job1, self.pool_paas, start_time))
|
||||
|
||||
# test reset job
|
||||
self.cmd('batch job reset --job-id {} --pool-id {} '
|
||||
'--on-all-tasks-complete terminateJob '.format(self.job1, self.pool_paas))
|
||||
job1 = self.cmd('batch job show --job-id {}'.format(self.job1))
|
||||
self.assertEqual(job1['metadata'], None)
|
||||
self.assertEqual(job1['constraints']['maxTaskRetryCount'], 0)
|
||||
self.assertNotEqual(job1['constraints']['maxWallClockTime'], '1279 days, 12:30:05')
|
|
@ -10,10 +10,10 @@ from azure.cli.command_modules.batch.tests.test_batch_data_plane_command_base im
|
|||
BatchDataPlaneTestBase)
|
||||
|
||||
|
||||
class BatchPoolScenarioTest(BatchDataPlaneTestBase):
|
||||
class BatchPoolTest(BatchDataPlaneTestBase):
|
||||
|
||||
def __init__(self, test_method):
|
||||
super(BatchPoolScenarioTest, self).__init__(__file__, test_method)
|
||||
super(BatchPoolTest, self).__init__(__file__, test_method)
|
||||
self.pool_paas = "azure-cli-test-paas"
|
||||
self.pool_iaas = "azure-cli-test-iaas"
|
||||
self.pool_json = "azure-cli-test-json"
|
||||
|
|
Загрузка…
Ссылка в новой задаче