Skip to content

Commit a9925c9

Browse files
Migrate to test-proxy (Azure#25181)
* save * WIP * GenerateAssetName * Fix build * Fix build * dev cert * Language settings * fix * Add env vars * don't trust * trust dev cert * Try something else * move CI, fix dev cert path * start test proxy * Update * Remove step * make ctor public again * Set logging env var * Add BodyRegexSanitizer * Revert csproj changes * Update test proxy version * pr fb * revert schemaregistry csproj * package ref * revert more * Add shared Operation classes * Fix Schema Registry build * Increase lines * Fix tables * Fix mismatch behavior * Fix synapse * Container Registry! * Exclude some Identity tests * Exclude IoT * Fix SB tests * revert unintentional change * Update search sanitizer * exclude sb and eh mgmt * Digital twins and object anchors * Use simpler regex * Anomaly Detector * Exclude * revert kusto recording * Make setup/teardown async * fix KV * More async usages * network tests * cert test * update to sdk * Rename
1 parent 1d5eb56 commit a9925c9

File tree

993 files changed

+5324
-5001
lines changed

Some content is hidden

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

993 files changed

+5324
-5001
lines changed

common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ public abstract class ManagementRecordedTestBase<TEnvironment> : RecordedTestBas
3434
private ArmClient _cleanupClient;
3535
private bool _waitForCleanup;
3636

37-
protected ManagementRecordedTestBase(bool isAsync) : base(isAsync)
37+
protected ManagementRecordedTestBase(bool isAsync, bool useLegacyTransport = false) : base(isAsync, useLegacyTransport: useLegacyTransport)
3838
{
3939
SessionEnvironment = new TEnvironment();
4040
SessionEnvironment.Mode = Mode;
4141
Initialize();
4242
}
4343

44-
protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode mode) : base(isAsync, mode)
44+
protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode mode, bool useLegacyTransport = false) : base(isAsync, mode, useLegacyTransport)
4545
{
4646
SessionEnvironment = new TEnvironment();
4747
SessionEnvironment.Mode = Mode;
@@ -130,7 +130,7 @@ protected void CleanupResourceGroups()
130130
}
131131
}
132132

133-
private void StartSessionRecording()
133+
private async Task StartSessionRecordingAsync()
134134
{
135135
// Only create test recordings for the latest version of the service
136136
TestContext.TestAdapter test = TestContext.CurrentContext.Test;
@@ -139,29 +139,33 @@ private void StartSessionRecording()
139139
{
140140
throw new IgnoreException((string)test.Properties.Get("SkipRecordings"));
141141
}
142-
SessionRecording = new TestRecording(Mode, GetSessionFilePath(), Sanitizer, Matcher);
142+
SessionRecording = await CreateTestRecordingAsync(Mode, GetSessionFilePath(), Sanitizer, Matcher);
143143
SessionEnvironment.SetRecording(SessionRecording);
144144
ValidateClientInstrumentation = SessionRecording.HasRequests;
145145
}
146146

147-
protected void StopSessionRecording()
147+
protected async Task StopSessionRecordingAsync()
148148
{
149149
if (ValidateClientInstrumentation)
150150
{
151151
throw new InvalidOperationException("The test didn't instrument any clients but had recordings. Please call InstrumentClient for the client being recorded.");
152152
}
153153

154-
SessionRecording?.Dispose(true);
154+
if (SessionRecording != null)
155+
{
156+
await SessionRecording.DisposeAsync(true);
157+
}
158+
155159
GlobalClient = null;
156160
}
157161

158162
[OneTimeSetUp]
159-
public void OneTimeSetUp()
163+
public async Task OneTimeSetUp()
160164
{
161165
if (!HasOneTimeSetup())
162166
return;
163167

164-
StartSessionRecording();
168+
await StartSessionRecordingAsync();
165169

166170
var options = InstrumentClientOptions(new ArmClientOptions(), SessionRecording);
167171
options.AddPolicy(OneTimeResourceGroupCleanupPolicy, HttpPipelinePosition.PerCall);

eng/Packages.Data.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
<PackageReference Update="System.Security.Cryptography.Primitives" Version="4.3.0" />
250250
<PackageReference Update="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
251251
<PackageReference Update="System.ValueTuple" Version="4.5.0" />
252+
<PackageDownload Include="Azure.Sdk.Tools.Testproxy" Version="[$(TestProxyVersion)]" />
252253
<PackageReference Update="WindowsAzure.ServiceBus" Version="5.1.0" />
253254
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.1" />
254255
<PackageReference Update="xunit" Version="2.4.1" />
@@ -258,4 +259,8 @@
258259
<PackageDownload Update="NETStandard.Library.Ref" Version="[2.1.0]" />
259260
</ItemGroup>
260261

262+
<PropertyGroup>
263+
<TestProxyVersion>1.0.0-dev.20211202.1</TestProxyVersion>
264+
</PropertyGroup>
265+
261266
</Project>

eng/pipelines/templates/jobs/ci.tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ jobs:
4040
# Add a default so the job doesn't fail when the matrix is empty
4141
container: $[ variables['Container'] ]
4242
steps:
43+
- pwsh: |
44+
$(Build.SourcesDirectory)/eng/common/scripts/trust-proxy-certificate.ps1
45+
displayName: 'Language Specific Certificate Trust'
46+
- pwsh: |
47+
Write-Host "##vso[task.setvariable variable=ASPNETCORE_Kestrel__Certificates__Default__Path]$(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.pfx"
48+
Write-Host "##vso[task.setvariable variable=ASPNETCORE_Kestrel__Certificates__Default__Password]password"
49+
displayName: 'Configure Kestrel Environment Variables'
4350
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
4451
parameters:
4552
AgentImage: $(OSVmImage)

eng/pipelines/templates/steps/install-dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ steps:
1818
condition: ne(variables['Agent.OS'], 'Windows_NT') # Windows supports MultiLevelLookup and doesn't need explicit framework installation
1919
displayName: 'Use .NET Core 5.0 runtime'
2020
inputs:
21-
packageType: runtime
21+
packageType: sdk
2222
performMultiLevelLookup: true
2323
version: "5.0.x"
2424
- task: UseDotNet@2

eng/scripts/Language-Settings.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,10 @@ function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
521521
}
522522
Set-Content -Path $DocConfigFile -Value $outputLines
523523
}
524+
525+
function Import-Dev-Cert-net
526+
{
527+
Write-Host "Importing dev certificate"
528+
dotnet dev-certs https --clean --import eng/common/testproxy/dotnet-devcert.pfx --password="password"
529+
dotnet dev-certs https --trust
530+
}

sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/Infrastructure/AnomalyDetectorRecordedTestSanitizer.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,7 @@ public AnomalyDetectorRecordedTestSanitizer()
1313
{
1414
AddJsonPathSanitizer("$..accessToken");
1515
AddJsonPathSanitizer("$..source");
16-
}
17-
18-
public override void SanitizeHeaders(IDictionary<string, string[]> headers)
19-
{
20-
if (headers.ContainsKey(Constants.AuthorizationHeader))
21-
{
22-
headers[Constants.AuthorizationHeader] = new[] { SanitizeValue };
23-
}
24-
25-
base.SanitizeHeaders(headers);
26-
}
27-
28-
public override string SanitizeVariable(string variableName, string environmentVariableValue)
29-
{
30-
return variableName switch
31-
{
32-
AnomalyDetectorTestEnvironment.ApiKeyEnvironmentVariableName => SanitizeValue,
33-
_ => base.SanitizeVariable(variableName, environmentVariableValue)
34-
};
16+
SanitizedHeaders.Add(Constants.AuthorizationHeader);
3517
}
3618
}
3719
}

sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/Infrastructure/AnomalyDetectorTestEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class AnomalyDetectorTestEnvironment: TestEnvironment
1818
/// <summary>The name of the environment variable from which the Anomaly Detector resource's data source will be extracted for the live tests.</summary>
1919
internal const string DataSourceEnvironmentVariableName = "ANOMALY_DETECTOR_DATASOURCE";
2020

21-
public string ApiKey => GetRecordedVariable(ApiKeyEnvironmentVariableName);
21+
public string ApiKey => GetRecordedVariable(ApiKeyEnvironmentVariableName, options => options.IsSecret());
2222
public string Endpoint => GetRecordedVariable(EndpointEnvironmentVariableName);
2323
public string DataSource => GetRecordedVariable(DataSourceEnvironmentVariableName);
2424
}

sdk/appconfiguration/Azure.Data.AppConfiguration/tests/SessionRecords/ConfigurationLiveTests/CanAddAndUpdateFeatureFlag.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/appconfiguration/Azure.Data.AppConfiguration/tests/SessionRecords/ConfigurationLiveTests/CanAddAndUpdateFeatureFlagAsync.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/appconfiguration/Azure.Data.AppConfiguration/tests/SessionRecords/ConfigurationLiveTests/CanAddAndUpdateSecretReference.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)