Skip to content

Commit eaa1098

Browse files
authored
Add azure-core-test-v2 (Azure#44154)
Add azure-core-test-v2
1 parent 77aebd8 commit eaa1098

File tree

81 files changed

+7385
-4
lines changed

Some content is hidden

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

81 files changed

+7385
-4
lines changed

eng/versioning/version_client.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ com.azure:azure-compute-batch;1.0.0-beta.3;1.0.0-beta.4
8181
com.azure:azure-containers-containerregistry;1.2.14;1.3.0-beta.1
8282
com.azure:azure-containers-containerregistry-perf;1.0.0-beta.1;1.0.0-beta.1
8383
com.azure:azure-core;1.55.0;1.56.0-beta.1
84-
com.azure:azure-core-v2;1.0.0-beta.1;1.0.0-beta.1
84+
com.azure:azure-core-v2;2.0.0-beta.1;2.0.0-beta.1
8585
com.azure:azure-core-amqp;2.9.13;2.10.0-beta.1
8686
com.azure:azure-core-amqp-experimental;1.0.0-beta.1;1.0.0-beta.1
8787
com.azure:azure-core-experimental;1.0.0-beta.57;1.0.0-beta.58
@@ -97,6 +97,7 @@ com.azure:azure-core-serializer-avro-jackson;1.0.0-beta.1;1.0.0-beta.2
9797
com.azure:azure-core-serializer-json-gson;1.3.5;1.4.0-beta.1
9898
com.azure:azure-core-serializer-json-jackson;1.5.5;1.6.0-beta.1
9999
com.azure:azure-core-test;1.27.0-beta.5;1.27.0-beta.6
100+
com.azure:azure-core-test-v2;2.0.0-beta.1;2.0.0-beta.1
100101
com.azure:azure-core-tracing-opentelemetry;1.0.0-beta.53;1.0.0-beta.54
101102
com.azure:azure-core-tracing-opentelemetry-samples;1.0.0-beta.1;1.0.0-beta.1
102103
com.azure:azure-core-version-tests;1.0.0-beta.1;1.0.0-beta.1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Release History
2+
3+
## 2.0.0-beta.1 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Azure Core Test V2 shared library for Java
2+
3+
This library contains core classes used to test Azure SDK client libraries.
4+
5+
Newer SDK tests utilize the [Azure SDK Tools Test Proxy][test-proxy-readme] to record and playback HTTP interactions.
6+
To migrate from existing [TestBase][TestBase.java] to use the test proxy, or to learn more about using the test proxy,
7+
refer to the [test proxy migration guide][test-proxy-migration-guide].
8+
9+
## Table of contents
10+
11+
- [Getting started](#getting-started)
12+
- [Key concepts](#key-concepts)
13+
- [Troubleshooting](#troubleshooting)
14+
- [Next steps](#next-steps)
15+
- [Contributing](#contributing)
16+
17+
## Getting started
18+
19+
To use this package, add the following to your _pom.xml_.
20+
21+
[//]: # ({x-version-update-start;com.azure:azure-core-test-v2;current})
22+
23+
```xml
24+
25+
<dependency>
26+
<groupId>com.azure</groupId>
27+
<artifactId>azure-core-test-v2</artifactId>
28+
<version>2.0.0-beta.1</version>
29+
</dependency>
30+
```
31+
32+
[//]: # ({x-version-update-end})
33+
34+
## Key concepts
35+
36+
## Examples
37+
38+
## Troubleshooting
39+
40+
If you encounter any bugs with these SDKs, please file issues via
41+
[Issues](https://github.com/Azure/azure-sdk-for-java/issues) or checkout
42+
[StackOverflow for Azure Java SDK](https://stackoverflow.com/questions/tagged/azure-java-sdk).
43+
44+
## Next steps
45+
46+
Other useful packages are:
47+
48+
* [azure-core](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core): Contains core classes and
49+
functionality used by all client libraries.
50+
51+
## Contributing
52+
53+
For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).
54+
55+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit <https://cla.microsoft.com>.
56+
57+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
58+
59+
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact <[email protected]> with any additional questions or comments.
60+
61+
[azure_portal]: https://portal.azure.com/
62+
[azure_cli_service_principal]: https://learn.microsoft.com/cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create-for-rbac
63+
[default_sanitizers]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java#L259
64+
[git_setup]: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
65+
[git_token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
66+
[powershell]: https://learn.microsoft.com/powershell/scripting/install/installing-powershell?view=powershell-latest
67+
[recording-migration]: https://github.com/Azure/azure-sdk-for-java/blob/64de460d8080127a1e0c58fbfc7ab9e95f70a2c7/sdk/core/azure-core-test/RecordingMigrationGuide.md
68+
[sanitize-secrets]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md#session-and-test-level-transforms-sanitizers-and-matchers
69+
[test-proxy-readme]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
70+
[test-proxy-migration-guide]: https://github.com/Azure/azure-sdk-for-java/blob/64de460d8080127a1e0c58fbfc7ab9e95f70a2c7/sdk/core/azure-core-test/TestProxyMigrationGuide.md
71+
[InterceptorManager.java]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/InterceptorManager.java
72+
[TestProxyPlaybackClient.java]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/http/TestProxyPlaybackClient.java
73+
[TestProxyRecordPolicy.java]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/policy/TestProxyRecordPolicy.java
74+
[TestBase.java]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/TestProxyTestBase.java
75+
[TestProxyTestBase.java]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/TestProxyTestBase.java
76+
[TableClientTestBase]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java#L61
77+
[tables-test-resources]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/tables/test-resources.json
78+
[tables-test-resources-resources]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/tables/test-resources.json#L42
79+
[tables-test-resources-outputs]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/tables/test-resources.json#L115
80+
[test-resources]: https://github.com/Azure/azure-sdk-for-java/tree/main/eng/common/TestResources#readme
81+
[test_proxy_sanitizer]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-test/src/main/java/com/azure/core/test/models/TestProxySanitizer.java
82+
[coc]: https://opensource.microsoft.com/codeofconduct/
83+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
84+
85+
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Guide for migrating test recordings out of the `azure-sdk-for-java` repository
2+
3+
The Azure SDK test proxy enables tests to run recorded tests, even when these test recordings are outside the
4+
`azure-sdk-for-java` repository. Migrating to this out-of-repo recording setup requires an initial recording move,
5+
and after this the flow to update recordings will be slightly different. This guide describes the first stage of this
6+
process and links to updated recording instructions.
7+
8+
More technical documentation of the test proxy's out-of-repo recording support can be found [here][detailed_docs] in
9+
the `azure-sdk-tools` repository.
10+
11+
## Table of contents
12+
13+
- [Guide for migrating test recordings out of the `azure-sdk-for-java` repository](#guide-for-migrating-test-recordings-out-of-the-azure-sdk-for-java-repository)
14+
- [Table of contents](#table-of-contents)
15+
- [Current recording setup](#current-recording-setup)
16+
- [New recording setup](#new-recording-setup)
17+
- [Initial recording migration](#initial-recording-migration)
18+
- [Migration script prerequisites](#migration-script-prerequisites)
19+
- [Execute the migration script](#execute-the-migration-script)
20+
- [Run tests with out-of-repo recordings](#run-tests-with-out-of-repo-recordings)
21+
22+
## Current recording setup
23+
24+
Currently, test recordings live in the `azure-sdk-for-java` repository (or "language repo"), under a given package's
25+
`src/test/resources/session-records/` directory. The test proxy loads recordings from this local directory and can be
26+
done entirely offline.
27+
28+
Storing recordings in the language repository significantly contributes to the repository's large size, which is its
29+
main drawback. Recording file updates are also included in pull requests, which can make them more tedious to review
30+
and difficult to load.
31+
32+
## New recording setup
33+
34+
With the test proxy, we can instead store recordings in a completely different git repository (called
35+
[`azure-sdk-assets`][azure_sdk_assets], or the "assets repo"). The test proxy creates a sparse clone of only the
36+
recordings for the package being tested, stores them locally in a git-excluded language repo directory, and runs
37+
playback tests in the same way as before.
38+
39+
The out-of-repo recording system requires a connection to fetch recordings but frees up considerable space in the
40+
language repo. Additionally, pull requests that update recordings now update a single pointer to new recordings instead
41+
of full recording files.
42+
43+
The pointer to test recordings is stored in a new `assets.json` file that will be created for each package during the
44+
initial migration.
45+
46+
## Initial recording migration
47+
48+
A [PowerShell script][transition_script] in the `azure-sdk-tools` repository will assist in pushing recordings to the
49+
assets repo, removing recordings from the language repo, and creating an `assets.json` file for the package you're
50+
migrating.
51+
52+
This script -- [`generate-assets-json.ps1`][generate_assets_json] -- should be run once per package, and can be used
53+
either directly from an `azure-sdk-tools` repo clone or with a local download of the script. To download the script to
54+
your current working directory, use the following PowerShell command:
55+
56+
```PowerShell
57+
Invoke-WebRequest -OutFile "generate-assets-json.ps1" https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/eng/common/testproxy/onboarding/generate-assets-json.ps1
58+
```
59+
60+
### Migration script prerequisites
61+
62+
- The targeted library is already migrated to use the test proxy.
63+
- Git version > 2.25.0 is to on the machine and in the path. Git is used by the script and test proxy.
64+
- [PowerShell Core][powershell] >= 7.0 is installed.
65+
- Global [git config settings][git_setup] are configured for `user.name` and `user.email`.
66+
- These settings can be overridden with environment variables `GIT_COMMIT_OWNER` and `GIT_COMMIT_EMAIL`, respectively.
67+
- Membership in the `azure-sdk-write` GitHub group.
68+
69+
### Execute the migration script
70+
71+
In a PowerShell window:
72+
73+
1. Set your working directory to the root of the package you're migrating (`sdk/{service}/{package}`) -- for example:
74+
75+
```PowerShell
76+
cd C:\azure-sdk-for-java\sdk\textanalytics\azure-ai-textanalytics
77+
```
78+
79+
2. Run the following command:
80+
81+
```PowerShell
82+
<path-to-script>/generate-assets-json.ps1 -InitialPush
83+
```
84+
85+
If you run `git status` from within the language repo, you should see:
86+
87+
- Deleted files for each test recording in the package
88+
- A new `assets.json` file under the root of your package
89+
90+
The `assets.json` file will have the form:
91+
92+
```json
93+
{
94+
"AssetsRepo": "Azure/azure-sdk-assets",
95+
"AssetsRepoPrefixPath": "java",
96+
"TagPrefix": "java/{service}/{package}",
97+
"Tag": "java/{service}/{package}_<10-character-commit-SHA>"
98+
}
99+
```
100+
101+
The `Tag` field matches the name of a tag that's been created in the assets repo and contains the uploaded recordings.
102+
Before creating a PR to cement the recording move, it's a good idea to check out that tag in the assets repo and make
103+
sure the recordings that you expect to see are there.
104+
105+
## Run tests with out-of-repo recordings
106+
107+
After moving recordings to the asset repo, live and playback testing will be the same as it was in the past. The test
108+
proxy automatically pulls down the correct set of recordings based on the `Tag` in your package's `assets.json` file.
109+
110+
The process for updating test recordings is slightly different from it was with in-repo recordings, and differs in two
111+
primary ways:
112+
113+
1. When tests are run in recording mode, recording changes won't be visible in the language repo and will instead be
114+
tracked in a separate git ignored `.assets` directory.
115+
2. When updated recordings are pushed to the assets repo, the `Tag` field in your package's `assets.json` file will be
116+
updated to point to these new recordings. This `assets.json` change is what you'll include in a pull request to update
117+
recordings in the language repo.
118+
119+
[azure_sdk_assets]: https://github.com/Azure/azure-sdk-assets
120+
[detailed_docs]: https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/documentation/asset-sync/README.md
121+
[generate_assets_json]: https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/testproxy/onboarding/generate-assets-json.ps1
122+
[git_setup]: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
123+
[git_token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
124+
[powershell]: https://learn.microsoft.com/powershell/scripting/install/installing-powershell?view=powershell-latest
125+
[transition_script]: https://github.com/Azure/azure-sdk-for-java/blob/main/eng/common/testproxy/onboarding/README.md
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "java",
4+
"TagPrefix": "java/core/azure-core-test",
5+
"Tag": "java/core/azure-core-test_6eeebc92d3"
6+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
6+
<suppressions>
7+
<suppress checks="com.azure.tools.checkstyle.checks.DenyListedWords" files="com.azure.v2.core.test.utils.HttpUrlConnectionHttpClient.java" />
8+
9+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.AzureTestWatcher.java" />
10+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.core.test.SyncAsyncExtension.java" />
11+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.TestBase.java" />
12+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.junitextensions.LiveOnlyExtension.java" />
13+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.junitextensions.PlaybackOnlyExtension.java" />
14+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.junitextensions.TestContextManagerParameterResolver.java" />
15+
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposed" files="com.azure.v2.core.test.ThreadDumper.java" />
16+
17+
<suppress checks="com.azure.tools.checkstyle.checks.GoodLogging" files="com.azure.v2.core.test.AzureTestWatcher.java" />
18+
<suppress checks="com.azure.tools.checkstyle.checks.GoodLogging" files="com.azure.v2.core.test.TestBase.java" />
19+
<suppress checks="com.azure.tools.checkstyle.checks.GoodLogging" files="com.azure.v2.core.test.ThreadDumper.java" />
20+
21+
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientBuilder" files="com.azure.core.test.http.AssertingHttpClientBuilder.java" />
22+
23+
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger" files="com.azure.core.test.http.AssertingClient.java" />
24+
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger" files="com.azure.v2.core.test.http.TestProxyPlaybackClient.java" />
25+
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger" files="com.azure.v2.core.test.InterceptorManager.java" />
26+
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger" files="com.azure.v2.core.test.policy.TestProxyRecordPolicy.java" />
27+
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger" files="com.azure.v2.core.test.utils.HttpUrlConnectionHttpClient.java" />
28+
</suppressions>

0 commit comments

Comments
 (0)