{CI} Fix Content-Length header's value in recordings#20541
Merged
Conversation
Member
Author
|
The script to fix import yaml
import glob
import os
affected_modules = ['appservice']
command_modules_path = r'D:\cli\azure-cli\src\azure-cli\azure\cli\command_modules'
yaml_files = []
for module in affected_modules:
module_path = os.path.join(command_modules_path, module)
glob_result = glob.glob(os.path.join(command_modules_path, module, "**/*.yaml"), recursive=True)
yaml_files.extend(glob_result)
yaml_files += [
r'D:\cli\azure-cli\src\azure-cli\azure\cli\command_modules\monitor\tests\latest\recordings\test_metric_alert_v2_scenario.yaml',
r'D:\cli\azure-cli\src\azure-cli\azure\cli\command_modules\network\tests\latest\recordings\test_private_link_resource_webapp.yaml'
]
print("YAML files to patch:")
print('\n'.join(yaml_files))
# exit(0)
for yaml_file in yaml_files:
print("Fixing file:", yaml_file)
# Read from file
with open(yaml_file) as f:
content = yaml.safe_load(f)
for transaction in content['interactions']:
print(' Fixing request:', transaction['request']['uri'])
if 'content-length' not in transaction['response']['headers']:
print('No Content-Length, skipping')
continue
literal_len = transaction['response']['headers']['content-length'][0]
actual_len = len(transaction['response']['body']['string'])
print(f' Literal Content-Length: {literal_len}; Actual Content-Length: {actual_len}')
transaction['response']['headers']['content-length'][0] = str(actual_len)
# Save to file
with open(yaml_file, 'w') as f:
yaml.dump(content, f, Dumper=yaml.CDumper)Note: |
calvinhzy
approved these changes
Nov 30, 2021
Content-Length header's value Content-Length header's value in recordings
wangzelin007
approved these changes
Nov 30, 2021
kairu-ms
approved these changes
Dec 1, 2021
# Conflicts: # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_acr_create_function_app.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_acr_deployment_function_app.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_acr_integration_function_app.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_app_service_plan.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_assign_system_identity.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_assign_user_identity.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_consumption_e2e.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_consumption_linux_dotnet_isolated.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_consumption_linux_java.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_consumption_linux_powershell.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_consumption_ragrs_storage_e2e.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_vnetE2E.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_by_subnet_rid.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_by_vnet_rid.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_no_subnet.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_no_vnet.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_wrong_location.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_wrong_rg.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_create_with_vnet_wrong_sku.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_e2e.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_elastic_plan.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_keys_set.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_keys_set_slot.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_local_context.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_app_service_dotnet_isolated.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_app_service_java.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_app_service_java_with_runtime_version.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_app_service_powershell.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_app_service_powershell_with_runtime_version.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_consumption_python_39.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_custom_handler.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_functions_version.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_functions_version_consumption.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_version.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_on_linux_version_consumption.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_remove_identity.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_reserved_instance.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_slot_appsetting_update.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_slot_swap.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_vnetE2E.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime_custom_handler.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime_dotnet_isolated.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime_java.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime_powershell.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_runtime_version.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_windows_without_runtime.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_with_app_insights_key.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_with_default_app_insights.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_functionapp_with_no_default_app_insights.yaml # src/azure-cli/azure/cli/command_modules/appservice/tests/latest/recordings/test_move_plan_to_elastic.yaml
This was referenced Dec 9, 2021
zhoxing-ms
approved these changes
Dec 10, 2021
Contributor
|
@jiasli does this script have to be run on the recording files every time tests are re-recorded, or will the |
Member
Author
|
Every time you re-record tests, the |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
An alternative solution for #20533 to pass the check introduced by Azure/azure-sdk-for-python#20888. This time fix
Content-Lengthheader's value in recordings instead.Failed tests
https://dev.azure.com/azure-sdk/public/_build/results?buildId=1216795&view=logs&j=771f6cdf-8d98-5d9b-2fb9-d3a6e9554788&t=0a182f1d-9946-580d-467e-4d4ebd6af32d&l=15587