Skip to content

Commit

Permalink
Merge branch 'main' into support-queue-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengfeiwang committed Mar 17, 2023
2 parents 4eafdcb + 7957864 commit 8e723b6
Show file tree
Hide file tree
Showing 1,424 changed files with 246,582 additions and 43,063 deletions.
8 changes: 8 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@
"Phong"
]
},
{
"filename": "tools/azure-sdk-tools/ci_tools/deps.html.j2",
"words": [
"isfork",
"ISFORK",
"thead"
]
},
{
"filename": "sdk/core/azure-core/tests/test_serialization.py",
"words": [
Expand Down
24 changes: 22 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Mypy install and run.
```

#### `sphinx` environment
Generate shpinx doc for this package.
Generate sphinx doc for this package.

```
\> tox -e sphinx -c <path to tox.ini>
Expand All @@ -117,7 +117,7 @@ Generate shpinx doc for this package.

`tox` supports custom arguments, and the defined pytest environments within the common `tox.ini` also allow these. Essentially, separate the arguments you want passed to `pytest` by a `--` in your tox invocation.

[Tox Documentation on Positional Arguments](https://tox.readthedocs.io/en/latest/example/general.html#interactively-passing-positional-arguments)
[Tox Documentation on Positional Arguments](https://tox.wiki/en/latest/config.html#substitutions-for-positional-arguments-in-commands)

**Example: Invoke tox, breaking into the debugger on failure**
`tox -e whl -c ../../../eng/tox/tox.ini -- --pdb`
Expand Down Expand Up @@ -155,6 +155,26 @@ b. run tox environment devtest

This tox test( devtest) will fail if installed dependent packages are not dev build version.

## Samples

### Third-party dependencies

Third party libraries should only be included in samples when necessary to demonstrate usage of an Azure SDK package; they should not be suggested or endorsed as alternatives to the Azure SDK.

When code samples take dependencies, readers should be able to use the material without significant license burden or research on terms. This goal requires restricting dependencies to certain types of open source or commercial licenses.

Samples may take the following categories of dependencies:

- **Open-source** : Open source offerings that use an [Open Source Initiative (OSI) approved license](https://opensource.org/licenses). Any component whose license isn't OSI-approved is considered a commercial offering. Prefer OSS projects that are members of any of the [OSS foundations that Microsoft is part of](https://opensource.microsoft.com/ecosystem/). Prefer permissive licenses for libraries, like [MIT](https://opensource.org/licenses/MIT) and [Apache 2](https://opensource.org/licenses/Apache-2.0). Copy-left licenses like [GPL](https://opensource.org/licenses/gpl-license) are acceptable for tools, and OSs. [Kubernetes](https://github.com/kubernetes/kubernetes), [Linux](https://github.com/torvalds/linux), and [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) are examples of this license type. Links to open source components should be to where the source is hosted, including any applicable license, such as a GitHub repository (or similar).

- **Commercial**: Commercial offerings that enable readers to learn from our content without unnecessary extra costs. Typically, the offering has some form of a community edition, or a free trial sufficient for its use in content. A commercial license may be a form of dual-license, or tiered license. Links to commercial components should be to the commercial site for the software, even if the source software is hosted publicly on GitHub (or similar).

- **Dual licensed**: Commercial offerings that enable readers to choose either license based on their needs. For example, if the offering has an OSS and commercial license, readers can choose between them. [MySql](https://github.com/mysql/mysql-server) is an example of this license type.

- **Tiered licensed**: Offerings that enable readers to use the license tier that corresponds to their characteristics. For example, tiers may be available for students, hobbyists, or companies with defined revenue thresholds. For offerings with tiered licenses, strive to limit our use in tutorials to the features available in the lowest tier. This policy enables the widest audience for the article. [Docker](https://www.docker.com/), [IdentityServer](https://duendesoftware.com/products/identityserver), [ImageSharp](https://sixlabors.com/products/imagesharp/), and [Visual Studio](https://visualstudio.com) are examples of this license type.

In general, we prefer taking dependencies on licensed components in the order of the listed categories. In cases where the category may not be well known, we'll document the category so that readers understand the choice that they're making by using that dependency.

## Code of Conduct
This project's code of conduct can be found in the
[CODE_OF_CONDUCT.md file](https://github.com/Azure/azure-sdk-for-python/blob/main/CODE_OF_CONDUCT.md)
Expand Down
10 changes: 4 additions & 6 deletions doc/dev/mgmt/multiapi.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multi-api packaging and ARM SDK

Several SDKs on this repository are able to support multi-api in a single package. If you're a SDK maintener, this documentation explains the rational of it, and the technical details.
Several SDKs on this repository are able to support multi-api in a single package. If you're a SDK maintainer, this documentation explains the rational of it, and the technical details.

## Overview and rationale

Expand All @@ -10,7 +10,7 @@ It means a given specific package is able to do calls to several different API v

### Why would I need to call anything else than the latest API version?

Because there is different flavors of Azure that are not necessarly provided with the same set of API versions. For example Azure Governement, Azure Stack usually needs a few months to get the latest available API version.
Because there is different flavors of Azure that are not necessarily provided with the same set of API versions. For example Azure Government, Azure Stack usually needs a few months to get the latest available API version.

### Why a multi-api package?

Expand Down Expand Up @@ -66,9 +66,9 @@ Main design guidelines:
- For people that want a specific API version for a specific need, specifying API version should be possible
e.g. `client = ComputeManagementClient(credentials, sub_id, api_version='2018-06-01')`
- For people who target a single Azure Profile, specifying it should be be possible
e.g. `client = ComputeManagementClient(credentials, sub_id, profile=KnownProfile.v2018_06_01_bybrid)`
e.g. `client = ComputeManagementClient(credentials, sub_id, profile=KnownProfile.v2018_06_01_hybrid)`

The first condition has impact on models loading, by default they should load the latest API vesion transparently:
The first condition has impact on models loading, by default they should load the latest API version transparently:
```python
# Loads the latest version of the model
from azure.mgmt.compute.models import VirtualMachineCreateParameter
Expand Down Expand Up @@ -118,5 +118,3 @@ If this is not the same API version, then we need to bend the rules a little: we
## Possible improvements

Current implementation assumes operation group are unique, and as discussed it's not always the case. Also, this limitation has impact on intellisense right now. Example, if a user types `compute_client.virtual_machines.` and hit the intellisense shortcut, users won't see any suggestions. It's because the `virtual_machines` property is dynamic and can change depending of dynamic configuration.

To improve intellisense and allow operation level profile, the concept would be to make the [operation mixin multi-api concept](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/network/azure-mgmt-network/azure/mgmt/network/_operations_mixin.py) applicable to operation groups as well. I estimate this work to a week of dev-ish.
4 changes: 2 additions & 2 deletions doc/dev/static_type_checking.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ environment run in CI and brings in the third party stub packages necessary. To

### Run mypy

mypy is currently pinned to version [0.931](https://pypi.org/project/mypy/0.931/).
mypy is currently pinned to version [1.0.0](https://pypi.org/project/mypy/1.0.0/).

To run mypy on your library, run the tox mypy env at the package level:

`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e mypy -c ../../../eng/tox/tox.ini`

If you don't want to use `tox` you can also install and run mypy on its own:

`pip install mypy==0.931`
`pip install mypy==1.0.0`

`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>mypy azure`

Expand Down
26 changes: 15 additions & 11 deletions doc/dev/test_proxy_troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ Documentation of the motivations and goals of the test proxy can be found [here]
GitHub repository, and documentation of how to set up and use the proxy can be found [here][detailed_docs].

## Table of contents
- [General troubleshooting tip](#general-troubleshooting-tip)
- [Test collection failure](#test-collection-failure)
- [Errors in tests using resource preparers](#errors-in-tests-using-resource-preparers)
- [Playback failures from body matching errors](#playback-failures-from-body-matching-errors)
- [Recordings not being produced](#recordings-not-being-produced)
- [KeyError during container startup](#keyerror-during-container-startup)
- [ConnectionError during test startup](#connectionerror-during-test-startup)
- [Different error than expected when using proxy](#different-error-than-expected-when-using-proxy)
- [Test setup failure in test pipeline](#test-setup-failure-in-test-pipeline)
- [Fixture not found error](#fixture-not-found-error)
- [Guide for test proxy troubleshooting](#guide-for-test-proxy-troubleshooting)
- [Table of contents](#table-of-contents)
- [General troubleshooting tip](#general-troubleshooting-tip)
- [Test collection failure](#test-collection-failure)
- [Errors in tests using resource preparers](#errors-in-tests-using-resource-preparers)
- [Playback failures from body matching errors](#playback-failures-from-body-matching-errors)
- [Recordings not being produced](#recordings-not-being-produced)
- [KeyError during container startup](#keyerror-during-container-startup)
- [ConnectionError during test startup](#connectionerror-during-test-startup)
- [Different error than expected when using proxy](#different-error-than-expected-when-using-proxy)
- [Test setup failure in test pipeline](#test-setup-failure-in-test-pipeline)
- [Fixture not found error](#fixture-not-found-error)

## General troubleshooting tip

Expand Down Expand Up @@ -107,6 +109,7 @@ Tests that aren't recorded should omit the `recorded_by_proxy` decorator. Howeve
parameters that are provided by a preparer like the `devtools_testutils` [EnvironmentVariableLoader][env_var_loader],
you may see a new test setup error after migrating to the test proxy. For example, imagine a test is decorated with a
preparer that provides a Key Vault URL as a `azure_keyvault_url` parameter:

```python
class TestExample(AzureRecordedTestCase):

Expand All @@ -115,6 +118,7 @@ class TestExample(AzureRecordedTestCase):
```

The above would work in the old test setup, but with the test proxy, running the test will yield

```text
_______ ERROR at setup of TestExample.test_example _______
...
Expand All @@ -134,7 +138,7 @@ expected in either case.
[detailed_docs]: https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
[env_var_loader]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/envvariable_loader.py
[env_var_section]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md#fetch-environment-variables
[general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/README.md
[general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/documentation/test-proxy/initial-investigation.md
[mgmt_recorded_test_case]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/mgmt_recorded_testcase.py
[migration_guide]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md
[proxy_pipelines]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md#enable-the-test-proxy-in-pipelines
Expand Down
21 changes: 11 additions & 10 deletions doc/dev/tests-advanced.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Setup Python Development Environment - Advanced
In this document we will provide additional information about the test environments:

- [Test Mixin Classes](#test-mixin-classes)
- [Resource Preparers](#preparers)
- [Examples with Preparers](#examples-with-preparers)
- [mgmt_settings_real.py](#mgmt_settings_real-file)
- [Setup Python Development Environment - Advanced](#setup-python-development-environment---advanced)
- [Test Mixin Classes](#test-mixin-classes)
- [Preparers](#preparers)
- [Examples with Preparers](#examples-with-preparers)
- [Example 2: Basic Preparer Usage with Storage](#example-2-basic-preparer-usage-with-storage)
- [Example 3: Cached Preparer Usage](#example-3-cached-preparer-usage)
- [mgmt\_settings\_real file](#mgmt_settings_real-file)

## Test Mixin Classes
Many of our test suites use a mixin class to reduce re-writing code in multiple test files. For example, in the Tables test suite there is a `_shared` directory containing two of these mixin classes, a [sync one](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/tables/azure-data-tables/tests/_shared/testcase.py) and an [async version](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/tables/azure-data-tables/tests/_shared/asynctestcase.py). These classes will often have ways to create connection strings from an account name and key, formulate the account url, configure logging, or validate service responses. In order for these mixin classes to be used by both the functional and unit tests they should inherit from `object`. For example:
Expand Down Expand Up @@ -74,8 +77,8 @@ class TestTablesUnit(TablesTestMixin):
assert client.account_url == "https://{}.tables.core.windows.net/".format(account)
```


## Preparers

The Azure SDK team has created some in house tools to help with easier testing. These additional tools are located in the `devtools_testutils` package that was installed with your `dev_requirements.txt`. In this package are the preparers that will be commonly used throughout the repository to test various resources. A preparer is a way to programmatically create fresh resources to run our tests against and then deleting them after running a test suite. These help guarantee standardized behavior by starting each test group from a fresh resource and account.

If this situation is a requirement for your tests, you can opt to create a new preparer for your service from the management plane library for a service. There are already a few preparers built in the [devtools_testutils](https://github.com/Azure/azure-sdk-for-python/tree/main/tools/azure-sdk-tools/devtools_testutils). Most prepares will start with the [`ResourceGroupPreparer`](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py#L29-L99) to first create a resource group for your service.
Expand All @@ -86,8 +89,6 @@ To build your own preparer you will need to use the management plane library to
|-|-|-|
| Resource Group | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py#L57-L85) | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py#L87-L99) |
| Storage Account | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py#L53-L102) | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/storage_testcase.py#L104-L107) |
| KeyVault | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/keyvault_preparer.py#L84-L131) | [link](https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/keyvault_preparer.py#L133-L138) |


## Examples with Preparers

Expand All @@ -107,7 +108,7 @@ from devtools_testutils import (
class ExampleStorageTestCase(AzureTestCase):

@ResourceGroupPreparer()
@StorageAcountPreparer()
@StorageAccountPreparer()
def test_create_table(self, resource_group, location, storage_account, storage_account_key):
account_url = self.account_url(storage_account, "table")
client = self.create_client_from_credential(TableServiceClient, storage_account_key, account_url=account_url)
Expand Down Expand Up @@ -141,7 +142,7 @@ from devtools_testutils import (
class ExampleStorageTestCase(AzureTestCase):

@CachedResourceGroupPreparer(name_prefix="storagetest")
@CachedStorageAcountPreparer(name_prefix="storagetest")
@CachedStorageAccountPreparer(name_prefix="storagetest")
def test_create_table(self, resource_group, location, storage_account, storage_account_key):
account_url = self.account_url(storage_account, "table")
client = self.create_client_from_credential(TableServiceClient, storage_account_key, account_url=account_url)
Expand All @@ -152,7 +153,7 @@ class ExampleStorageTestCase(AzureTestCase):
assert valid_table_name == table.table_name

@CachedResourceGroupPreparer(name_prefix="storagetest")
@CachedStorageAcountPreparer(name_prefix="storagetest")
@CachedStorageAccountPreparer(name_prefix="storagetest")
def test_create_table_if_exists (self, resource_group, location, storage_account, storage_account_key):
account_url = self.account_url(storage_account, "table")
client = self.create_client_from_credential(TableServiceClient, storage_account_key, account_url=account_url)
Expand Down
11 changes: 6 additions & 5 deletions doc/dev/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,13 @@ ServicePreparer = functools.partial(
```

The parameters for the `functools.partial` method are:
* The EnvironmentVariableLoader class
* The service folder that holds your code (in this example, `sdk/testservice`). This value is used to search your

- The EnvironmentVariableLoader class
- The service folder that holds your code (in this example, `sdk/testservice`). This value is used to search your
environment variables for the appropriate values.
* The remaining arguments are key-value kwargs, with the keys being the environment variables needed for the tests, and
- The remaining arguments are key-value kwargs, with the keys being the environment variables needed for the tests, and
the value being a fake value to use in recordings.
* These values should have the same formatting as the real values because they are used in playback mode and will need
- These values should have the same formatting as the real values because they are used in playback mode and will need
to pass any client side validation. The fake value should also be a unique value to the other key-value pairs.

A method that's decorated by the ServicePreparer from the example would be called with `testservice_endpoint` and
Expand Down Expand Up @@ -733,7 +734,7 @@ Tests that use the Shared Access Signature (SAS) to authenticate a client should
[packaging]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/packaging.md
[podman]: https://podman.io/
[proxy_cert_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/documentation/test-proxy/trusting-cert-per-language.md
[proxy_general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/README.md
[proxy_general_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
[proxy_migration_guide]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md
[py_sanitizers]: https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/sanitizers.py
[pytest_invocation]: https://pytest.org/latest/how-to/usage.html
Expand Down
4 changes: 4 additions & 0 deletions doc/eng_sys_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ This is the most useful skip, but the following skip variables are also supporte
- Omit `bandit` checks in `analyze` job.
- `Skip.Pylint`
- Omit linting checks in `analyze` job.
- `Skip.VerifyTypes`
- Omit `VerifyTypes` check in `analyze` job.
- `Skip.Pyright`
- Omit `Pyright` check in `analyze` job.
- `Skip.BreakingChanges`
- Don't verify if a changeset includes breaking changes.
- `Skip.MyPy`
Expand Down
Loading

0 comments on commit 8e723b6

Please sign in to comment.