Skip to content

Commit 7a46088

Browse files
committed
* 'main' of https://github.com/Azure/azure-sdk-for-python: (63 commits) check only once whether artifact extension exists (Azure#29594) code and test (Azure#29530) fix: support data binding expression for resources.xxx (Azure#29559) code and test (Azure#29558) [ServiceBus] enable sovereign cloud testing (Azure#29202) [AutoRelease] t2-communication-2023-03-20-22792(can only be merged by SDK owner) (Azure#29453) [Identity] Allow configurable process timeouts (Azure#28290) Increment package version after release of azure-containerregistry (Azure#29582) Update optional (Azure#28435) [Monitor][Query] Add sample notebook for large queries (Azure#28148) Update CHANGELOG.md (Azure#29580) [ServiceBus] remove msrest (Azure#29324) Explicitly set PSNativeCommandArgumentPassing to Legacy for git push script (Azure#29554) [ML][Pipelines] Support queue settings in pipeline job (Azure#29209) add experimental decorator for datatransfer (Azure#29562) Featurestore/online store crud new pr (Azure#29546) switch tooling over to typespec (Azure#29501) set up base path for feature set in load function (Azure#29544) Address credential description in docstring (Azure#29549) [Monitor] Regen query and ingestion (Azure#29504) ...
2 parents 1c157de + e1f4348 commit 7a46088

2,169 files changed

Lines changed: 135729 additions & 30926 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@
917917
#/<NotInRepo>/ @ccmshowbackdevs
918918

919919
# ServiceLabel: %Monitor - Exporter %Service Attention
920-
#/<NotInRepo>/ @@cijothomas @@reyang @@rajkumar-rangaraj @@TimothyMothra @@vishweshbankwar @@ramthi
920+
#/<NotInRepo>/ @lzchen @jeremydvoss
921921

922922

923923
# Management Plane

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ _azci_*.log
5353
.artifacts
5454
.tmp_whl_dir
5555
.logs
56+
.proxy
5657

5758
# tox environment folders
5859
.tox/
@@ -147,4 +148,4 @@ sdk/cosmos/azure-cosmos/test/test_config.py
147148
*_python.json
148149

149150
# temporary folder to refresh SDK with cadl
150-
TempCadlFiles/
151+
TempTypeSpecFiles/

.vscode/cspell.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,25 @@
392392
"whls"
393393
],
394394
"overrides": [
395+
{
396+
"filename": "doc/dev/test_proxy_migration_guide.md",
397+
"words": [
398+
"pytestmarkparametrize"
399+
]
400+
},
401+
{
402+
"filename": "tools/azure-sdk-tools/devtools_testutils/proxy_startup.py",
403+
"words": [
404+
"certifi",
405+
"passenv"
406+
]
407+
},
408+
{
409+
"filename": "tools/azure-sdk-tools/tests/integration/test_proxy_startup.py",
410+
"words": [
411+
"spinup"
412+
]
413+
},
395414
{
396415
"filename": "sdk/remoterendering/**",
397416
"words": [
@@ -603,7 +622,8 @@
603622
"ierr",
604623
"mymodel",
605624
"heif",
606-
"racwd"
625+
"racwd",
626+
"rrggbb"
607627
]
608628
},
609629
{

doc/dev/issues/resolve_issues_effectively.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Most issues can be classified into 3 categories. They are
1111
## Usage error (For users)
1212
If you are not familiar with the SDK usage of a service, you can find relevant examples in [this repo][sample repo] in most cases.
1313

14-
For some common errors, you can check [here](#Summary-Of-Common-Errors).
14+
For some common errors, you can check [here](#summary-of-common-errors).
1515

1616
## Feature Request(For users)
1717

doc/dev/static_type_checking_cheat_sheet.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@ def foo(
164164
...
165165
```
166166

167+
- Do use `Optional` if a parameter can be typed as `Any` or `None`. `Optional[Any]`, or `Union[Any, None]`, is __not__ equal to `Any`.
168+
169+
```python
170+
from typing import Optional, Any
171+
172+
# Yes
173+
def foo(
174+
bar: Optional[Any] = None,
175+
) -> None:
176+
bar.append(1) # error caught at type checking time: Item "None" of "Optional[Any]" has no attribute "append"
177+
178+
# No
179+
def foo(
180+
bar: Any = None,
181+
) -> None:
182+
bar.append(1) # error caught at runtime: AttributeError: 'NoneType' object has no attribute 'append'
183+
```
184+
167185
### Collections
168186

169187
- Do familiarize yourself with the supported operations of various abstract collections in the [collections.abc](https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes) docs.

doc/dev/test_proxy_migration_guide.md

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Please refer to the [troubleshooting guide][troubleshooting] if you have any iss
2424
- [Advanced details](#advanced-details)
2525
- [What does the test proxy do?](#what-does-the-test-proxy-do)
2626
- [How does the test proxy know when and what to record or play back?](#how-does-the-test-proxy-know-when-and-what-to-record-or-play-back)
27-
- [Start the proxy manually](#start-the-proxy-manually)
27+
- [Use pytest.mark.parametrize with migrated tests](#use-pytestmarkparametrize-with-migrated-tests)
2828

2929
## Update existing tests
3030

@@ -96,10 +96,7 @@ Resource preparers need a management client to function, so test classes that us
9696

9797
### Perform one-time setup
9898

99-
1. Docker (or Podman) is a requirement for using the test proxy. You can install Docker from [docs.docker.com][docker_install], or install Podman at [podman.io][podman]. To use Podman, set an alias for `podman` to replace the `docker` command.
100-
2. After installing, make sure Docker/Podman is running and is using Linux containers before running tests.
101-
3. Follow the instructions [here][proxy_cert_docs] to complete setup. You need to trust a certificate on your machine in
102-
order to communicate with the test proxy over a secure connection.
99+
The test proxy uses a self-signed certificate to communicate with HTTPS. Follow the general setup instructions [here][proxy_cert_docs] to trust this certificate locally.
103100

104101
### Start the proxy server
105102

@@ -120,8 +117,8 @@ def start_proxy(test_proxy):
120117
return
121118
```
122119

123-
The `test_proxy` fixture will fetch the test proxy Docker image and create a new container called
124-
`ambitious_azsdk_test_proxy`, which will be deleted after test execution unless interrupted.
120+
The `test_proxy` fixture will download a test proxy executable if one isn't available locally, start the tool, and stop
121+
it after tests complete.
125122

126123
If your tests already use an `autouse`d, session-level fixture for tests, you can accept the `test_proxy` parameter in
127124
that existing fixture instead of adding a new one. For an example, see the [Register sanitizers](#register-sanitizers)
@@ -141,6 +138,9 @@ Recordings for a given package will end up in that package's `/tests/recordings`
141138
do. Recordings that use the test proxy are `.json` files instead of `.yml` files, so migrated test suites no longer
142139
need old `.yml` recordings.
143140

141+
After migrating to use the test proxy, libraries can and are encouraged to use out-of-repo recordings. For more
142+
information, refer to the [recording migration guide][recording_migration].
143+
144144
> **Note:** support for configuring live or playback tests with a `testsettings_local.cfg` file has been
145145
> deprecated in favor of using just `AZURE_TEST_RUN_LIVE`.
146146
@@ -153,7 +153,7 @@ Instead, sanitizers (as well as matchers and transforms) can be registered on th
153153
`add_general_string_sanitizer`. Other sanitizers are available for more specific scenarios and can be found at
154154
[devtools_testutils/sanitizers.py][py_sanitizers].
155155

156-
Sanitizers, matchers, and transforms remain registered until the proxy container is stopped, so for any sanitizers that
156+
Sanitizers, matchers, and transforms remain registered until the proxy tool is stopped, so for any sanitizers that
157157
are shared by different tests, using a session fixture declared in a `conftest.py` file is recommended. Please refer to
158158
[pytest's scoped fixture documentation][pytest_fixtures] for more details.
159159

@@ -403,36 +403,6 @@ Running tests in playback follows the same pattern, except that requests will be
403403
The `recorded_by_proxy` and `recorded_by_proxy_async` decorators send the appropriate requests at the start and end of
404404
each test case.
405405

406-
### Start the proxy manually
407-
408-
There are two options for manually starting and stopping the test proxy: one uses a PowerShell command, and one uses
409-
methods from `devtools_testutils`.
410-
411-
#### PowerShell
412-
413-
There is a [PowerShell script][docker_start_proxy] in `eng/common/testproxy` that will fetch the proxy Docker image if
414-
you don't already have it, and will start or stop a container running the image for you. You can run the following
415-
command from the root of the `azure-sdk-for-python` directory to start the container whenever you want to make the test
416-
proxy available for running tests:
417-
418-
```powershell
419-
.\eng\common\testproxy\docker-start-proxy.ps1 "start"
420-
```
421-
422-
Note that the proxy is available as long as the container is running. In other words, you don't need to start and
423-
stop the container for each test run or between tests for different SDKs. You can run the above command in the morning
424-
and just stop the container whenever you'd like. To stop the container, run the same command but with `"stop"` in place
425-
of `"start"`.
426-
427-
#### Python
428-
429-
There are two methods in `devtools_testutils`, [start_test_proxy][start_test_proxy] and
430-
[stop_test_proxy][stop_test_proxy], that can be used to manually start and stop the test proxy. Like
431-
`docker-start-proxy.ps1`, `start_test_proxy` will automatically fetch the proxy Docker image for you and start the
432-
container if it's not already running.
433-
434-
For more details on proxy startup, please refer to the [proxy documentation][detailed_docs].
435-
436406
### Use `pytest.mark.parametrize` with migrated tests
437407

438408
Migrating tests to use basic `pytest` tools allows us to take advantage of helpful features such as
@@ -493,12 +463,10 @@ client to the test.
493463

494464

495465
[detailed_docs]: https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
496-
[docker_install]: https://docs.docker.com/get-docker/
497-
[docker_start_proxy]: https://github.com/Azure/azure-sdk-for-python/blob/main/eng/common/testproxy/docker-start-proxy.ps1
498466

499467
[env_var_loader]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/envvariable_loader.py
500468

501-
[general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/README.md
469+
[general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
502470

503471
[mgmt_recorded_test_case]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/mgmt_recorded_testcase.py
504472

@@ -507,7 +475,6 @@ client to the test.
507475
[parametrize_class]: https://github.com/Azure/azure-sdk-for-python/blob/d92b63b9976b0025b274016c49a250fb7c4d7333/sdk/keyvault/azure-keyvault-keys/tests/_test_case.py#L59
508476
[pipelines_ci]: https://github.com/Azure/azure-sdk-for-python/blob/5ba894966ed6b0e1ee8d854871f8c2da36a73d79/sdk/eventgrid/ci.yml#L30
509477
[pipelines_live]: https://github.com/Azure/azure-sdk-for-python/blob/e2b5852deaef04752c1323d2ab0958f83b98858f/sdk/textanalytics/tests.yml#L26-L27
510-
[podman]: https://podman.io/
511478
[proxy_cert_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/documentation/test-proxy/trusting-cert-per-language.md
512479
[py_sanitizers]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/sanitizers.py
513480
[pytest_collection]: https://docs.pytest.org/latest/goodpractices.html#test-discovery

doc/dev/test_proxy_troubleshooting.md

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@ GitHub repository, and documentation of how to set up and use the proxy can be f
1010
## Table of contents
1111
- [Guide for test proxy troubleshooting](#guide-for-test-proxy-troubleshooting)
1212
- [Table of contents](#table-of-contents)
13-
- [General troubleshooting tip](#general-troubleshooting-tip)
1413
- [Test collection failure](#test-collection-failure)
1514
- [Errors in tests using resource preparers](#errors-in-tests-using-resource-preparers)
1615
- [Playback failures from body matching errors](#playback-failures-from-body-matching-errors)
1716
- [Recordings not being produced](#recordings-not-being-produced)
18-
- [KeyError during container startup](#keyerror-during-container-startup)
19-
- [ConnectionError during test startup](#connectionerror-during-test-startup)
17+
- [ConnectionError during tests](#connectionerror-during-tests)
2018
- [Different error than expected when using proxy](#different-error-than-expected-when-using-proxy)
2119
- [Test setup failure in test pipeline](#test-setup-failure-in-test-pipeline)
2220
- [Fixture not found error](#fixture-not-found-error)
2321

24-
## General troubleshooting tip
25-
26-
For any issue that may come up, it's generally a good idea to first try deleting any existing proxy container (which
27-
will be called `ambitious_azsdk_test_proxy`) and creating a new one by running tests. This will fetch the latest tag of
28-
the test proxy Docker container, meaning the latest version of the proxy tool will be used.
29-
3022
## Test collection failure
3123

3224
Because tests are now using pure `pytest` conventions without `unittest.TestCase` components, discovering tests with
@@ -56,22 +48,14 @@ matching enabled by default.
5648

5749
## Recordings not being produced
5850

59-
First, make sure that the environment variable `AZURE_SKIP_LIVE_RECORDING` isn't set to "true". If it's not and live
60-
tests still aren't producing recordings, try deleting the `ambitious_azsdk_test_proxy` Docker container and re-running
61-
tests. The recording storage location is determined when the test proxy Docker container is created. If there are
62-
multiple local copies of the `azure-sdk-for-python` repo on your machine, the container could be storing recordings in
63-
the wrong repo.
64-
65-
## KeyError during container startup
66-
67-
Try updating your machine's version of Docker. Older versions of Docker may not return a status to indicate whether or
68-
not the proxy container is running, which the [proxy_startup.py][proxy_startup] script needs to determine.
51+
Ensure the environment variable `AZURE_SKIP_LIVE_RECORDING` **isn't** set to "true", and that `AZURE_TEST_RUN_LIVE`
52+
**is** set to "true".
6953

70-
## ConnectionError during test startup
54+
## ConnectionError during tests
7155

72-
For example, you may see a `requests.exceptions.ConnectionError` when trying to contact URL `/Info/Available`. This
73-
means that the test proxy tool wasn't started up properly, so requests to the tool are failing. Make sure Docker is
74-
installed and is up to date, and ensure that Linux containers are being used.
56+
For example, you may see a `requests.exceptions.ConnectionError` when trying to make service or sanitizer setup
57+
requests. This means that the test proxy tool never started correctly; ensure the `test_proxy` fixture is being invoked
58+
during test startup so that the tool is available during tests.
7559

7660
## Different error than expected when using proxy
7761

doc/dev/tests.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ To migrate an existing test suite to use the test proxy, or to learn more about
169169

170170
### Perform one-time test proxy setup
171171

172-
1. Docker (or Podman) is a requirement for using the test proxy. You can install Docker from [docs.docker.com][docker_install], or install Podman at [podman.io][podman]. To use Podman, set an alias for `podman` to replace the `docker` command.
173-
2. After installing, make sure Docker/Podman is running and is using Linux containers before running tests.
174-
3. Follow the instructions [here][proxy_cert_docs] to complete setup. You need to trust a certificate on your machine in
175-
order to communicate with the test proxy over a secure connection.
172+
The test proxy uses a self-signed certificate to communicate with HTTPS. Follow the general setup instructions [here][proxy_cert_docs] to trust this certificate locally.
176173

177174
### Set up test resources
178175

@@ -383,11 +380,8 @@ to the process of updating recordings.
383380

384381
- The targeted library is already migrated to use the test proxy.
385382
- Git version > 2.25.0 is to on the machine and in the path. Git is used by the script and test proxy.
386-
- [Docker][docker_install] or [Podman][podman] is installed.
387383
- Global [git config settings][git_setup] are configured for `user.name` and `user.email`.
388384
- These settings are also set with environment variables `GIT_COMMIT_OWNER` and `GIT_COMMIT_EMAIL`, respectively (in your environment or your local `.env` file).
389-
- The environment variable `GIT_TOKEN` is set to a valid [personal access token][git_token] for your user (in your environment or your local `.env` file).
390-
- This token is necessary for authenticating git requests made in a Docker/Podman container.
391385
- Membership in the `azure-sdk-write` GitHub group.
392386

393387
Test recordings will be updated if tests are run while `AZURE_TEST_RUN_LIVE` is set to "true" and
@@ -409,15 +403,16 @@ The recording directory in this case is `2Km2Z8755`, the string between the two
409403

410404
After verifying that your recording updates look correct, you can use the [`manage_recordings.py`][manage_recordings]
411405
script from `azure-sdk-for-python/scripts` to push these recordings to the `azure-sdk-assets` repo. This script accepts
412-
a verb and a **relative** path to your package's `assets.json` file. For example, from the root of the
413-
`azure-sdk-for-python` repo:
406+
a verb and a **relative** path to your package's `assets.json` file (this path is optional, and simply `assets.json`
407+
by default). For example, from the root of the `azure-sdk-for-python` repo:
414408
```
415-
python scripts/manage_recordings.py push sdk/{service}/{package}/assets.json
409+
python scripts/manage_recordings.py push -p sdk/{service}/{package}/assets.json
416410
```
417411

418412
The verbs that can be provided to this script are "push", "restore", and "reset":
419413
- **push**: pushes recording updates to a new assets repo tag and updates the tag pointer in `assets.json`.
420414
- **restore**: fetches recordings from the assets repo, based on the tag pointer in `assets.json`.
415+
- **reset**: discards any pending changes to recordings, based on the tag pointer in `assets.json`.
421416

422417
After pushing your recordings, the `assets.json` file for your package will be updated to point to a new `Tag` that
423418
contains the updates. Include this `assets.json` update in any pull request to update the recordings pointer in the
@@ -714,8 +709,6 @@ Tests that use the Shared Access Signature (SAS) to authenticate a client should
714709
[azure_portal]: https://portal.azure.com/
715710
[azure_recorded_test_case]: https://github.com/Azure/azure-sdk-for-python/blob/7e66e3877519a15c1d4304eb69abf0a2281773/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py#L44
716711

717-
[docker_install]: https://docs.docker.com/get-docker/
718-
719712
[engsys_wiki]: https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/48/Create-a-new-Live-Test-pipeline?anchor=test-resources.json
720713
[env_var_loader]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/envvariable_loader.py
721714

@@ -732,7 +725,6 @@ Tests that use the Shared Access Signature (SAS) to authenticate a client should
732725
[mgmt_settings_fake]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/mgmt_settings_fake.py
733726

734727
[packaging]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/packaging.md
735-
[podman]: https://podman.io/
736728
[proxy_cert_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/documentation/test-proxy/trusting-cert-per-language.md
737729
[proxy_general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
738730
[proxy_migration_guide]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md

0 commit comments

Comments
 (0)