Skip to content

Commit 3750f4d

Browse files
authored
[Identity] Allow integration test request retries (Azure#38648)
Some managed identity integration tests occasionally fail with gateway timeouts. This ensures that the requests to the app endpoints are retried in these cases by adding the RetryPolicy to the PipelineClient. Signed-off-by: Paul Van Eck <[email protected]>
1 parent f766df7 commit 3750f4d

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

sdk/identity/azure-identity/tests/integration/test_azure_functions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import os
66
import pytest
77

8-
from azure.core import PipelineClient
98
from azure.core.rest import HttpRequest, HttpResponse
109

10+
from utils import get_pipeline_client
11+
1112

1213
@pytest.fixture(scope="module")
1314
def base_url():
@@ -24,7 +25,7 @@ class TestAzureFunctionsIntegration:
2425
)
2526
def test_azure_functions_integration_sync(self, base_url):
2627
"""Test the Azure Functions endpoint where the sync MI credential is used."""
27-
client = PipelineClient(base_url)
28+
client = get_pipeline_client(base_url)
2829
request = HttpRequest("GET", f"{base_url}RunTest")
2930
response: HttpResponse = client.send_request(request)
3031
assert response.status_code == 200
@@ -35,7 +36,7 @@ def test_azure_functions_integration_sync(self, base_url):
3536
)
3637
def test_azure_functions_integration_async(self, base_url):
3738
"""Test the Azure Functions endpoint where the async MI credential is used."""
38-
client = PipelineClient(base_url)
39+
client = get_pipeline_client(base_url)
3940
request = HttpRequest("GET", f"{base_url}RunAsyncTest")
4041
response: HttpResponse = client.send_request(request)
4142
assert response.status_code == 200

sdk/identity/azure-identity/tests/integration/test_azure_web_apps.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import os
66
import pytest
77

8-
from azure.core import PipelineClient
98
from azure.core.rest import HttpRequest, HttpResponse
109

10+
from utils import get_pipeline_client
11+
1112

1213
@pytest.fixture(scope="module")
1314
def base_url():
@@ -24,7 +25,7 @@ class TestAzureWebAppsIntegration:
2425
)
2526
def test_azure_web_app_integration_sync(self, base_url):
2627
"""Test the Azure Web App endpoint where the sync MI credential is used."""
27-
client = PipelineClient(base_url)
28+
client = get_pipeline_client(base_url)
2829
request = HttpRequest("GET", f"{base_url}sync")
2930
response: HttpResponse = client.send_request(request)
3031
assert response.status_code == 200
@@ -35,7 +36,7 @@ def test_azure_web_app_integration_sync(self, base_url):
3536
)
3637
def test_azure_web_app_integration_async(self, base_url):
3738
"""Test the Azure Web App endpoint where the async MI credential is used."""
38-
client = PipelineClient(base_url)
39+
client = get_pipeline_client(base_url)
3940
request = HttpRequest("GET", f"{base_url}async")
4041
response: HttpResponse = client.send_request(request)
4142
assert response.status_code == 200

sdk/identity/azure-identity/tests/integration/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import subprocess
66
import sys
77

8+
from azure.core import PipelineClient
9+
from azure.core.pipeline import policies
10+
811

912
def run_command(command, exit_on_failure=True) -> str:
1013
try:
@@ -16,3 +19,11 @@ def run_command(command, exit_on_failure=True) -> str:
1619
print(result)
1720
sys.exit(1)
1821
return result
22+
23+
24+
def get_pipeline_client(base_url: str) -> PipelineClient:
25+
policy_list = [
26+
policies.RetryPolicy(),
27+
policies.ContentDecodePolicy(),
28+
]
29+
return PipelineClient(base_url, policies=policy_list)

sdk/identity/test-resources-post.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ Write-Host "Deploying Azure Container Instance"
131131
az container create -g $($DeploymentOutputs['IDENTITY_RESOURCE_GROUP']) -n $($DeploymentOutputs['IDENTITY_CONTAINER_INSTANCE_NAME']) --image $image `
132132
--acr-identity $($DeploymentOutputs['IDENTITY_USER_DEFINED_IDENTITY']) `
133133
--assign-identity [system] $($DeploymentOutputs['IDENTITY_USER_DEFINED_IDENTITY']) `
134+
--cpu 1 `
135+
--memory 1.0 `
136+
--os-type Linux `
134137
--role "Storage Blob Data Reader" `
135138
--scope $($DeploymentOutputs['IDENTITY_STORAGE_ID_1']) `
136139
-e IDENTITY_STORAGE_NAME=$($DeploymentOutputs['IDENTITY_STORAGE_NAME_1']) `

0 commit comments

Comments
 (0)