-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{CI} Fix Content-Length
header's value in recordings
#20541
Conversation
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: |
Content-Length
header's value Content-Length
header's value in recordings
# 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
@jiasli does this script have to be run on the recording files every time tests are re-recorded, or will the |
Every time you re-record tests, the |
Description
An alternative solution for #20533 to pass the check introduced by Azure/azure-sdk-for-python#20888. This time fix
Content-Length
header'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