Compatability fixed for Python 2 and 3. Ensure lease breaking operations are not truncated.

This commit is contained in:
Travis Prescott 2016-04-26 10:52:45 -07:00
Родитель 2a7db5c0d5
Коммит 6b5ec97019
5 изменённых файлов: 37 добавлений и 81 удалений

Просмотреть файл

@ -1,21 +1,6 @@
interactions: interactions:
- request: - request:
body: !!binary | body: client_id=04b07795-8ddb-461a-bbee-02f9e1bf7b46&refresh_token=AAABAAAAiL9Kn2Z27UubvWFPbm0gLQoucyuhWVsJeWlI9dGHcCp-UEliGxmPaPMbHACErdm4Huw62OZuSF7H7LLFXMN7fuIPFNqE7f_QF9QQyD5Ui8KRfhduYlulJGP7ST-diYbpFNIoleXt4T4ipguWePyAPoInxQaOmFUJ6NywQalErbaG9ld99xzQ-RDn4aoH_GtUy7E761e8HojR47texNpxUUn_fSDseHaOuH7NXjp9_5K8ssdZwXA2zutzFVnfVfrY1tfO1iXreBLruchA8iRpP_B-wesZuwYCZ0CT4-lOuaYTO59YeFn2I7Rk_zPWlLKQ7GRBAhXHcOqPjk6CpPTeO1qFKHwkX_yMUZAV7QwrlxEgcOASxf8dujZKGTZdqDrGkwfstijCCgGk6wmNpDU8TaR3gAc8KeOOd_8Q-RGUnLRtO3sq8iGUSpwxJxjHefwtZKRnKBHX2yuZVJUTyELIWEfUNbFY9IlRCdQfI1rm-n9tftUao-ibqOUO8E8v4s0W7U0X8iQG5h59FJn0DT8CURJyFUseayuVEui5pZ75wC-wQUkkyh7ugHXU5GyfzE5HeeTUUsIeHG7k5MJhelX0_VEBCCFFxHdee4e75BUhr_TyGqYrJaxEdA9GfCIzN6-NFXGc2A_2oQ6i6Nhjai5WQiAA&grant_type=refresh_token&resource=https%3A%2F%2Fmanagement.core.windows.net%2F
Y2xpZW50X2lkPTA0YjA3Nzk1LThkZGItNDYxYS1iYmVlLTAyZjllMWJmN2I0NiZyZWZyZXNoX3Rv
a2VuPUFBQUJBQUFBaUw5S24yWjI3VXVidldGUGJtMGdMUW91Y3l1aFdWc0plV2xJOWR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 interactions:
X-Powered-By: [ASP.NET] X-Powered-By: [ASP.NET]
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"name": "teststorageomega", "type": "Microsoft.Storage/storageAccounts"}'
eyJuYW1lIjogInRlc3RzdG9yYWdlb21lZ2EiLCAidHlwZSI6ICJNaWNyb3NvZnQuU3RvcmFnZS9z
dG9yYWdlQWNjb3VudHMifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -81,9 +64,7 @@ interactions:
Vary: [Accept-Encoding] Vary: [Accept-Encoding]
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"name": "travistestresourcegr3014", "type": "Microsoft.Storage/storageAccounts"}'
eyJuYW1lIjogInRyYXZpc3Rlc3RyZXNvdXJjZWdyMzAxNCIsICJ0eXBlIjogIk1pY3Jvc29mdC5T
dG9yYWdlL3N0b3JhZ2VBY2NvdW50cyJ9
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -285,8 +266,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"keyName": "key1"}'
eyJrZXlOYW1lIjogImtleTEifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -320,8 +300,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"keyName": "key2"}'
eyJrZXlOYW1lIjogImtleTIifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -355,8 +334,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"keyName": "key2"}'
eyJrZXlOYW1lIjogImtleTIifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -390,8 +368,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"tags": {"foo": "bar", "cat": ""}}'
eyJ0YWdzIjogeyJmb28iOiAiYmFyIiwgImNhdCI6ICIifX0=
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -422,8 +399,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"tags": {"none": ""}}'
eyJ0YWdzIjogeyJub25lIjogIiJ9fQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -454,8 +430,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"properties": {"accountType": "Standard_GRS"}}'
eyJwcm9wZXJ0aWVzIjogeyJhY2NvdW50VHlwZSI6ICJTdGFuZGFyZF9HUlMifX0=
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -486,8 +461,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"properties": {"accountType": "Standard_LRS"}}'
eyJwcm9wZXJ0aWVzIjogeyJhY2NvdW50VHlwZSI6ICJTdGFuZGFyZF9MUlMifX0=
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']

Просмотреть файл

@ -23,9 +23,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 204, message: No Content} status: {code: 204, message: No Content}
- request: - request:
body: !!binary | body: '{"name": "testcreatedelete", "type": "Microsoft.Storage/storageAccounts"}'
eyJuYW1lIjogInRlc3RjcmVhdGVkZWxldGUiLCAidHlwZSI6ICJNaWNyb3NvZnQuU3RvcmFnZS9z
dG9yYWdlQWNjb3VudHMifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -55,9 +53,7 @@ interactions:
Vary: [Accept-Encoding] Vary: [Accept-Encoding]
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"properties": {"accountType": "Standard_LRS"}, "location": "westus"}'
eyJwcm9wZXJ0aWVzIjogeyJhY2NvdW50VHlwZSI6ICJTdGFuZGFyZF9MUlMifSwgImxvY2F0aW9u
IjogIndlc3R1cyJ9
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -88,9 +84,7 @@ interactions:
Vary: [Accept-Encoding] Vary: [Accept-Encoding]
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"name": "testcreatedelete", "type": "Microsoft.Storage/storageAccounts"}'
eyJuYW1lIjogInRlc3RjcmVhdGVkZWxldGUiLCAidHlwZSI6ICJNaWNyb3NvZnQuU3RvcmFnZS9z
dG9yYWdlQWNjb3VudHMifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']
@ -146,9 +140,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes: ['1199'] x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: '{"name": "testcreatedelete", "type": "Microsoft.Storage/storageAccounts"}'
eyJuYW1lIjogInRlc3RjcmVhdGVkZWxldGUiLCAidHlwZSI6ICJNaWNyb3NvZnQuU3RvcmFnZS9z
dG9yYWdlQWNjb3VudHMifQ==
headers: headers:
Accept: [application/json] Accept: [application/json]
Accept-Encoding: ['gzip, deflate'] Accept-Encoding: ['gzip, deflate']

Просмотреть файл

@ -262,9 +262,7 @@ interactions:
x-ms-version: ['2015-04-05'] x-ms-version: ['2015-04-05']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: This is a test file for performance of automated tests. DO NOT MOVE OR DELETE!
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE
TyBOT1QgTU9WRSBPUiBERUxFVEUh
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]
@ -335,16 +333,19 @@ interactions:
x-ms-version: ['2015-04-05'] x-ms-version: ['2015-04-05']
status: {code: 201, message: Created} status: {code: 201, message: Created}
- request: - request:
body: !!binary | body: "This is a test file for performance of automated tests. DO NOT MOVE OR\
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE \ DELETE!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
T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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]
@ -434,9 +435,7 @@ interactions:
x-ms-version: ['2015-04-05'] x-ms-version: ['2015-04-05']
status: {code: 201, message: Created} status: {code: 201, message: Created}
- request: - request:
body: !!binary | body: This is a test file for performance of automated tests. DO NOT MOVE OR DELETE!
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE
TyBOT1QgTU9WRSBPUiBERUxFVEUh
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]
@ -486,9 +485,7 @@ interactions:
x-ms-write-protection: ['false'] x-ms-write-protection: ['false']
status: {code: 200, message: OK} status: {code: 200, message: OK}
- request: - request:
body: !!binary | body: This is a test file for performance of automated tests. DO NOT MOVE OR DELETE!
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE
TyBOT1QgTU9WRSBPUiBERUxFVEUh
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]

Просмотреть файл

@ -329,9 +329,7 @@ interactions:
x-ms-version: ['2015-04-05'] x-ms-version: ['2015-04-05']
status: {code: 201, message: Created} status: {code: 201, message: Created}
- request: - request:
body: !!binary | body: This is a test file for performance of automated tests. DO NOT MOVE OR DELETE!
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE
TyBOT1QgTU9WRSBPUiBERUxFVEUh
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]
@ -746,9 +744,7 @@ interactions:
x-ms-version: ['2015-04-05'] x-ms-version: ['2015-04-05']
status: {code: 201, message: Created} status: {code: 201, message: Created}
- request: - request:
body: !!binary | body: This is a test file for performance of automated tests. DO NOT MOVE OR DELETE!
VGhpcyBpcyBhIHRlc3QgZmlsZSBmb3IgcGVyZm9ybWFuY2Ugb2YgYXV0b21hdGVkIHRlc3RzLiBE
TyBOT1QgTU9WRSBPUiBERUxFVEUh
headers: headers:
Accept-Encoding: [identity] Accept-Encoding: [identity]
Connection: [keep-alive] Connection: [keep-alive]

Просмотреть файл

@ -16,10 +16,8 @@ def _truncate_long_running_operation(data, lro_item):
method = item['request'].get('method') method = item['request'].get('method')
code = item['response']['status'].get('code') code = item['response']['status'].get('code')
if method == 'GET' and code == 202: if method == 'GET' and code == 202:
print('\t\tMETHOD: {} CODE: {} Discarding!'.format(method, code))
interactions.remove(item) interactions.remove(item)
elif method == 'GET' and code != 202: elif method == 'GET' and code != 202:
print('\t\tMETHOD: {} CODE: {} Updating LRO with eventual response.'.format(method, code))
lro_item['response'] = item['response'] lro_item['response'] = item['response']
interactions.remove(item) interactions.remove(item)
return return
@ -30,19 +28,18 @@ def _shorten_long_running_operations(test_name):
yaml_path = os.path.join(recording_dir, '{}.yaml'.format(test_name)) yaml_path = os.path.join(recording_dir, '{}.yaml'.format(test_name))
if not os.path.isfile(yaml_path): if not os.path.isfile(yaml_path):
return return
print('\n** Shortening LRO for test {} **\n'.format(test_name))
with open(yaml_path, 'r+b') as f: with open(yaml_path, 'r+b') as f:
data = yaml.load(f) data = yaml.load(f)
for item in data['interactions']: for item in data['interactions']:
method = item['request'].get('method') method = item['request'].get('method')
code = item['response']['status'].get('code') code = item['response']['status'].get('code')
if method == 'PUT' and code == 202: # breaking a lease produces this pattern but should NOT be modified
print('\tMETHOD: {} CODE: {} Submitted for truncation!'.format(method, code)) lease_action = item['request']['headers'].get('x-ms-lease-action')
lease_action = lease_action[0] if lease_action else None
if method == 'PUT' and code == 202 and lease_action != 'break':
_truncate_long_running_operation(data, item) _truncate_long_running_operation(data, item)
else:
print('\tMETHOD: {} CODE: {} Keeping unaltered'.format(method, code))
f.seek(0) f.seek(0)
f.write(bytes(yaml.dump(data), 'utf-8')) f.write(yaml.dump(data).encode('utf-8'))
f.truncate() f.truncate()
generator = CommandTestGenerator(recording_dir, TEST_DEF, ENV_VAR) generator = CommandTestGenerator(recording_dir, TEST_DEF, ENV_VAR)