@@ -15,6 +15,7 @@ GitHub repository, and documentation of how to set up and use the proxy can be f
1515- [ Recordings not being produced] ( #recordings-not-being-produced )
1616- [ KeyError during container startup] ( #keyerror-during-container-startup )
1717- [ ConnectionError during test startup] ( #connectionerror-during-test-startup )
18+ - [ Different error than expected when using proxy] ( #different-error-than-expected-when-using-proxy )
1819
1920## General troubleshooting tip
2021
@@ -60,19 +61,41 @@ the wrong repo.
6061## KeyError during container startup
6162
6263Try updating your machine's version of Docker. Older versions of Docker may not return a status to indicate whether or
63- not the proxy container is running, which the
64- [ proxy_startup.py] ( https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py )
65- script needs to determine.
64+ not the proxy container is running, which the [ proxy_startup.py] [ proxy_startup ] script needs to determine.
6665
6766## ConnectionError during test startup
6867
6968For example, you may see a ` requests.exceptions.ConnectionError ` when trying to contact URL ` /Info/Available ` . This
7069means that the test proxy tool wasn't started up properly, so requests to the tool are failing. Make sure Docker is
7170installed and is up to date, and ensure that Linux containers are being used.
7271
72+ ## Different error than expected when using proxy
73+
74+ Some tests intentionally trigger exceptions in order to validate error behavior. There are a few known cases where
75+ the exception returned will be different when using the test proxy vs. when sending requests to the service directly.
76+
77+ One such instance is in the case of a DNS lookup failure, which can occur when trying to contact a nonexistent
78+ endpoint. [ This issue] [ wrong_exception ] describes an instance of this behavior. As described in the issue, the best
79+ way to work around this for the time being is to have tests expect either of two potential errors, to cover both
80+ cases. For example:
81+
82+ ``` python
83+ with pytest.raises((ServiceRequestError, HttpResponseError)) as exc_info:
84+ # This request will raise a ServiceRequestError when sent directly
85+ # When using the test proxy, we get an HttpResponseError instead
86+ ... # Request that triggers DNS lookup failure
87+
88+ # Make sure the HttpResponseError is raised for the same reason: DNS lookup failure
89+ if exc_info.type is HttpResponseError:
90+ response_content = json.loads(exc_info.value.response.content)
91+ assert " Name does not resolve" in response_content[" Message" ]
92+ ```
93+
7394[ detailed_docs ] : https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
7495[ general_docs ] : https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/README.md
7596[ mgmt_recorded_test_case ] : https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/mgmt_recorded_testcase.py
7697[ migration_guide ] : https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md
98+ [ proxy_startup ] : https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py
7799[ py_sanitizers ] : https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/sanitizers.py
78100[ pytest_collection ] : https://docs.pytest.org/latest/goodpractices.html#test-discovery
101+ [ wrong_exception ] : https://github.com/Azure/azure-sdk-tools/issues/2907
0 commit comments