You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sdk/resourcemanager/azure-resourcemanager-test/README.md
+139-1Lines changed: 139 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,13 +22,151 @@ For documentation on how to use this package, please see [Azure Management Libra
22
22
```
23
23
[//]: #({x-version-update-end})
24
24
25
+
### (Optional) Install TestProxy
26
+
27
+
TestProxy will be automatically downloaded when running tests. Though you may need to install it to push the recordings to remote repository.
28
+
Refer to [TestProxy documentation](https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md).
29
+
25
30
## Key concepts
26
31
32
+
The Azure Resource Manager Test library provides a specialized test base class and utilities for testing Azure Resource Manager SDKs. It extends the core testing framework with ARM-specific functionality.
33
+
34
+
### Core Components
35
+
36
+
***ResourceManagerTestProxyTestBase**: The main test base class that provides Azure Resource Manager-specific testing capabilities. It extends `TestProxyTestBase` from azure-core-test and adds:
37
+
- Azure credential management using `DefaultAzureCredential`
38
+
- Azure profile configuration with tenant, subscription, and environment
39
+
- HTTP pipeline configuration with Azure-specific policies
40
+
- Built-in sanitizers for common Azure secrets and sensitive data
41
+
- Resource naming utilities for generating unique test resource names
42
+
43
+
***Test Modes**: Like the core test framework, supports three test modes:
44
+
-**LIVE**: Tests run against actual Azure resources
45
+
-**RECORD**: Tests run against Azure resources and HTTP interactions are recorded
46
+
-**PLAYBACK**: Tests use recorded HTTP interactions without hitting Azure services
47
+
48
+
***Azure-specific Sanitization**: Automatically sanitizes common Azure secrets including:
49
+
- Subscription IDs, tenant IDs, and client IDs
50
+
- Storage account keys and connection strings
51
+
- Database passwords and connection strings
52
+
- Service principal secrets and certificates
53
+
- API keys and access tokens
54
+
55
+
### Test Environment Setup
56
+
57
+
For LIVE/RECORD tests, you need:
58
+
1. Azure CLI authentication (`az login`)
59
+
2. Environment variables:
60
+
-`AZURE_TENANT_ID`: Your Azure tenant ID
61
+
-`AZURE_SUBSCRIPTION_ID`: Your target subscription ID
62
+
63
+
### Utility Methods
64
+
65
+
The base class provides several utility methods:
66
+
-`generateRandomResourceName(prefix, maxLen)`: Creates unique resource names for tests
67
+
-`generateRandomUuid()`: Generates random UUIDs
68
+
-`password()`: Generates random passwords for test resources
69
+
-`sshPublicKey()`: Generates SSH public keys for VM tests
70
+
-`profile()`: Access to the Azure profile being used
71
+
-`isPlaybackMode()`: Check if running in playback mode
72
+
-`skipInPlayback()`: Skip test execution in playback mode
73
+
27
74
## Examples
28
75
76
+
Here's how to create a test class for RECORD/PLAYBACK using ResourceManagerTestProxyTestBase:
// Set up correct delay configuration for recording/playback. In RECORD mode, LROs (long-running operations) need a configured delay between each polling. While in PLAYBACK, no delay is needed.
// Set up namer context for recording/playback, in case random names are used for implicit resource creation. Otherwise, PLAYBACK won't be able to pick up the names during RECORD.
0 commit comments