This commit is contained in:
Travis Prescott 2016-04-26 09:01:49 -07:00
Родитель 244f020776
Коммит 2a7db5c0d5
2 изменённых файлов: 6 добавлений и 27 удалений

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

@ -69,32 +69,6 @@ interactions:
accept-language: [en-US]
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/travistestresourcegroup/providers/Microsoft.Storage/storageAccounts/testcreatedelete?api-version=2015-06-15
response:
body: {string: ''}
headers:
Cache-Control: [no-cache]
Content-Length: ['0']
Date: ['Tue, 26 Apr 2016 15:35:46 GMT']
Expires: ['-1']
Location: ['https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/providers/Microsoft.Storage/operations/0388ac18-e499-4767-9434-7ce499c427df?monitor=true&api-version=2015-06-15']
Pragma: [no-cache]
Retry-After: ['25']
Server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0]
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 202, message: Accepted}
- request:
body: null
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Type: [application/json; charset=utf-8]
User-Agent: [python/3.5.1 requests/2.9.1 msrest/0.2.0 msrest_azure/0.2.1 storagemanagementclient/2015-06-15
Azure-SDK-For-Python AZURECLI_0.0.32]
accept-language: [en-US]
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/operations/0388ac18-e499-4767-9434-7ce499c427df?monitor=true&api-version=2015-06-15
response:
body:
string: !!binary |

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

@ -16,8 +16,10 @@ def _truncate_long_running_operation(data, lro_item):
method = item['request'].get('method')
code = item['response']['status'].get('code')
if method == 'GET' and code == 202:
print('\t\tMETHOD: {} CODE: {} Discarding!'.format(method, code))
interactions.remove(item)
elif method == 'GET' and code != 202:
print('\t\tMETHOD: {} CODE: {} Updating LRO with eventual response.'.format(method, code))
lro_item['response'] = item['response']
interactions.remove(item)
return
@ -28,14 +30,17 @@ def _shorten_long_running_operations(test_name):
yaml_path = os.path.join(recording_dir, '{}.yaml'.format(test_name))
if not os.path.isfile(yaml_path):
return
print('\n** Shortening LRO for test {} **\n'.format(test_name))
with open(yaml_path, 'r+b') as f:
data = yaml.load(f)
for item in data['interactions']:
method = item['request'].get('method')
code = item['response']['status'].get('code')
if method == 'PUT' and code == 202:
print('\tMETHOD: {} CODE: {} Submitted for truncation!'.format(method, code))
_truncate_long_running_operation(data, item)
else:
print('\tMETHOD: {} CODE: {} Keeping unaltered'.format(method, code))
f.seek(0)
f.write(bytes(yaml.dump(data), 'utf-8'))
f.truncate()