Skip to content

Commit 50297c7

Browse files
authored
mgmt update test base by azure-resourcemanager-test (Azure#14654)
* refactor tests in resources * refactor tests in storage * refactor tests in authorization * refactor tests in keyvault * refactor tests in msi * refactor tests in network * refactor tests in compute * refactor tests in sql * refactor tests in dns * refactor tests in appservice * refactor tests in cosmos * refactor tests in containerservice * refactor tests in monitor * refactor tests in containerregistry * refactor tests in appplatform * refactor tests in containerinstance * refactor tests in privatedns * refactor tests in redis * refactor tests in eventhubs * refactor tests in azure resourcemanager * update azure resourcemanager samples * update dns manager and test deplay provider * reformat code
1 parent 8baef5d commit 50297c7

File tree

296 files changed

+1632
-2396
lines changed

Some content is hidden

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

296 files changed

+1632
-2396
lines changed

sdk/resourcemanager/azure-resourcemanager-appplatform/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
<scope>test</scope>
8585
</dependency>
8686
<dependency>
87-
<groupId>com.azure</groupId>
88-
<artifactId>azure-identity</artifactId>
89-
<version>1.1.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
87+
<groupId>com.azure.resourcemanager</groupId>
88+
<artifactId>azure-resourcemanager-test</artifactId>
89+
<version>2.0.0-beta.4</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-test;current} -->
9090
<scope>test</scope>
9191
</dependency>
9292
<dependency>

sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/AppPlatformManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.azure.resourcemanager.resources.fluentcore.arm.AzureConfigurable;
1111
import com.azure.resourcemanager.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
1212
import com.azure.resourcemanager.resources.fluentcore.arm.implementation.Manager;
13-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
13+
import com.azure.core.management.profile.AzureProfile;
1414
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
1515
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
1616

@@ -87,8 +87,8 @@ private AppPlatformManager(HttpPipeline httpPipeline, AzureProfile profile, SdkC
8787
profile,
8888
new AppPlatformManagementClientBuilder()
8989
.pipeline(httpPipeline)
90-
.endpoint(profile.environment().getResourceManagerEndpoint())
91-
.subscriptionId(profile.subscriptionId())
90+
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
91+
.subscriptionId(profile.getSubscriptionId())
9292
.buildClient(),
9393
sdkContext);
9494
}

sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,60 @@
33

44
package com.azure.resourcemanager.appplatform;
55

6+
import com.azure.core.credential.TokenCredential;
7+
import com.azure.core.http.HttpClient;
68
import com.azure.core.http.HttpPipeline;
9+
import com.azure.core.http.policy.HttpLogOptions;
10+
import com.azure.core.http.policy.HttpPipelinePolicy;
11+
import com.azure.core.http.policy.RetryPolicy;
12+
import com.azure.core.management.profile.AzureProfile;
713
import com.azure.resourcemanager.appservice.AppServiceManager;
814
import com.azure.resourcemanager.dns.DnsZoneManager;
915
import com.azure.resourcemanager.keyvault.KeyVaultManager;
10-
import com.azure.resourcemanager.resources.core.TestBase;
11-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
16+
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
1217
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
18+
import com.azure.resourcemanager.test.ResourceManagerTestBase;
19+
import com.azure.resourcemanager.test.utils.TestDelayProvider;
1320

1421
import java.io.IOException;
1522
import java.net.HttpURLConnection;
1623
import java.net.URL;
24+
import java.time.temporal.ChronoUnit;
25+
import java.util.List;
1726

18-
public class AppPlatformTest extends TestBase {
27+
public class AppPlatformTest extends ResourceManagerTestBase {
1928
protected AppPlatformManager appPlatformManager;
2029
protected AppServiceManager appServiceManager;
2130
protected DnsZoneManager dnsZoneManager;
2231
protected KeyVaultManager keyVaultManager;
2332
protected String rgName = "";
2433

25-
public AppPlatformTest() {
26-
}
27-
28-
AppPlatformTest(RunCondition runCondition) {
29-
super(runCondition);
34+
@Override
35+
protected HttpPipeline buildHttpPipeline(
36+
TokenCredential credential,
37+
AzureProfile profile,
38+
HttpLogOptions httpLogOptions,
39+
List<HttpPipelinePolicy> policies,
40+
HttpClient httpClient) {
41+
return HttpPipelineProvider.buildHttpPipeline(
42+
credential,
43+
profile,
44+
null,
45+
httpLogOptions,
46+
null,
47+
new RetryPolicy("Retry-After", ChronoUnit.SECONDS),
48+
policies,
49+
httpClient);
3050
}
3151

3252
@Override
33-
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) throws IOException {
53+
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
54+
SdkContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
3455
rgName = generateRandomResourceName("rg", 20);
35-
appPlatformManager = AppPlatformManager.authenticate(httpPipeline, profile, sdkContext);
36-
appServiceManager = AppServiceManager.authenticate(httpPipeline, profile, sdkContext);
37-
dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile, sdkContext);
38-
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile, sdkContext);
56+
appPlatformManager = AppPlatformManager.authenticate(httpPipeline, profile);
57+
appServiceManager = AppServiceManager.authenticate(httpPipeline, profile);
58+
dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile);
59+
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
3960
}
4061

4162
@Override

sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudLiveOnlyTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package com.azure.resourcemanager.appplatform;
55

6+
import com.azure.core.test.annotation.DoNotRecord;
67
import com.azure.resourcemanager.appplatform.models.RuntimeVersion;
78
import com.azure.resourcemanager.appplatform.models.SpringApp;
89
import com.azure.resourcemanager.appplatform.models.SpringAppDeployment;
@@ -48,12 +49,13 @@ public class SpringCloudLiveOnlyTest extends AppPlatformTest {
4849

4950
private static final String SPRING_CLOUD_SERVICE_PRINCIPAL = "03b39d0f-4213-4864-a245-b1476ec03169";
5051

51-
SpringCloudLiveOnlyTest() {
52-
super(RunCondition.LIVE_ONLY); // need storage data-plane and url check
53-
}
54-
5552
@Test
53+
@DoNotRecord
5654
public void canCRUDDeployment() throws Exception {
55+
if (skipInPlayback()) {
56+
return;
57+
}
58+
5759
String serviceName = generateRandomResourceName("springsvc", 15);
5860
String appName = "gateway";
5961
String deploymentName = generateRandomResourceName("deploy", 15);
@@ -134,7 +136,12 @@ public void canCRUDDeployment() throws Exception {
134136
}
135137

136138
@Test
139+
@DoNotRecord
137140
public void canCreateCustomDomainWithSsl() throws Exception {
141+
if (skipInPlayback()) {
142+
return;
143+
}
144+
138145
String domainName = generateRandomResourceName("jsdkdemo-", 20) + ".com";
139146
String certOrderName = generateRandomResourceName("cert", 15);
140147
String vaultName = generateRandomResourceName("vault", 15);

sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void canCRUDApp() throws Exception {
8484
Assertions.assertEquals("/tmp", app.temporaryDisk().mountPath());
8585
Assertions.assertEquals(4, app.temporaryDisk().sizeInGB());
8686

87-
if (isRecordMode()) {
87+
if (!isPlaybackMode()) {
8888
Assertions.assertTrue(requestSuccess(app.url()));
8989
}
9090

sdk/resourcemanager/azure-resourcemanager-appservice/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
<scope>test</scope>
100100
</dependency>
101101
<dependency>
102-
<groupId>com.azure</groupId>
103-
<artifactId>azure-identity</artifactId>
104-
<version>1.1.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
102+
<groupId>com.azure.resourcemanager</groupId>
103+
<artifactId>azure-resourcemanager-test</artifactId>
104+
<version>2.0.0-beta.4</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-test;current} -->
105105
<scope>test</scope>
106106
</dependency>
107107
<dependency>

sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/AppServiceManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.azure.resourcemanager.resources.fluentcore.arm.AzureConfigurable;
2424
import com.azure.resourcemanager.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
2525
import com.azure.resourcemanager.resources.fluentcore.arm.implementation.Manager;
26-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
26+
import com.azure.core.management.profile.AzureProfile;
2727
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
2828
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
2929
import com.azure.resourcemanager.storage.StorageManager;
@@ -112,8 +112,8 @@ private AppServiceManager(HttpPipeline httpPipeline, AzureProfile profile, SdkCo
112112
profile,
113113
new WebSiteManagementClientBuilder()
114114
.pipeline(httpPipeline)
115-
.endpoint(profile.environment().getResourceManagerEndpoint())
116-
.subscriptionId(profile.subscriptionId())
115+
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
116+
.subscriptionId(profile.getSubscriptionId())
117117
.buildClient(),
118118
sdkContext);
119119
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile, sdkContext);

sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServicePlansTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.azure.resourcemanager.appservice.models.OperatingSystem;
1111
import com.azure.resourcemanager.appservice.models.PricingTier;
1212
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
13-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
13+
import com.azure.core.management.profile.AzureProfile;
1414
import org.junit.jupiter.api.Assertions;
1515
import org.junit.jupiter.api.Disabled;
1616
import org.junit.jupiter.api.Test;

sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
import com.azure.core.annotation.PathParam;
1212
import com.azure.core.annotation.Post;
1313
import com.azure.core.annotation.ServiceInterface;
14+
import com.azure.core.credential.TokenCredential;
15+
import com.azure.core.http.HttpClient;
1416
import com.azure.core.http.HttpPipeline;
1517
import com.azure.core.http.HttpPipelineBuilder;
1618
import com.azure.core.http.policy.HttpLogDetailLevel;
1719
import com.azure.core.http.policy.HttpLogOptions;
1820
import com.azure.core.http.policy.HttpLoggingPolicy;
21+
import com.azure.core.http.policy.HttpPipelinePolicy;
1922
import com.azure.core.http.policy.RetryPolicy;
2023
import com.azure.core.http.rest.Response;
2124
import com.azure.core.http.rest.RestProxy;
@@ -25,54 +28,72 @@
2528
import com.azure.resourcemanager.appservice.models.AppServiceDomain;
2629
import com.azure.resourcemanager.appservice.models.PublishingProfile;
2730
import com.azure.resourcemanager.keyvault.KeyVaultManager;
28-
import com.azure.resourcemanager.resources.core.TestBase;
31+
import com.azure.resourcemanager.msi.MSIManager;
2932
import com.azure.resourcemanager.resources.fluentcore.arm.CountryIsoCode;
3033
import com.azure.resourcemanager.resources.fluentcore.arm.CountryPhoneCode;
3134
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
32-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
35+
import com.azure.core.management.profile.AzureProfile;
3336
import com.azure.resourcemanager.resources.ResourceManager;
3437
import java.io.IOException;
3538
import java.io.InputStream;
3639
import java.net.MalformedURLException;
3740
import java.nio.ByteBuffer;
3841
import java.nio.charset.StandardCharsets;
3942
import java.time.temporal.ChronoUnit;
43+
import java.util.List;
4044

45+
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
46+
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
4147
import com.azure.resourcemanager.resources.fluentcore.utils.Utils;
48+
import com.azure.resourcemanager.test.ResourceManagerTestBase;
49+
import com.azure.resourcemanager.test.utils.TestDelayProvider;
50+
import com.azure.resourcemanager.test.utils.TestIdentifierProvider;
4251
import org.apache.commons.net.ftp.FTP;
4352
import org.apache.commons.net.ftp.FTPClient;
4453
import org.junit.jupiter.api.Assertions;
4554
import reactor.core.publisher.Flux;
4655
import reactor.core.publisher.Mono;
4756

4857
/** The base for app service tests. */
49-
public class AppServiceTest extends TestBase {
58+
public class AppServiceTest extends ResourceManagerTestBase {
5059
protected ResourceManager resourceManager;
5160
protected KeyVaultManager keyVaultManager;
5261
protected AppServiceManager appServiceManager;
62+
protected MSIManager msiManager;
5363

5464
protected AppServiceDomain domain;
5565
protected AppServiceCertificateOrder certificateOrder;
5666
protected String rgName = "";
5767

58-
// private static OkHttpClient httpClient = new OkHttpClient.Builder().readTimeout(3, TimeUnit.MINUTES).build();
59-
60-
public AppServiceTest() {
61-
}
62-
63-
AppServiceTest(RunCondition runCondition) {
64-
super(runCondition);
68+
@Override
69+
protected HttpPipeline buildHttpPipeline(
70+
TokenCredential credential,
71+
AzureProfile profile,
72+
HttpLogOptions httpLogOptions,
73+
List<HttpPipelinePolicy> policies,
74+
HttpClient httpClient) {
75+
return HttpPipelineProvider.buildHttpPipeline(
76+
credential,
77+
profile,
78+
null,
79+
httpLogOptions,
80+
null,
81+
new RetryPolicy("Retry-After", ChronoUnit.SECONDS),
82+
policies,
83+
httpClient);
6584
}
6685

6786
@Override
6887
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
6988
rgName = generateRandomResourceName("javacsmrg", 20);
89+
SdkContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
90+
SdkContext sdkContext = new SdkContext();
91+
sdkContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
7092
resourceManager =
71-
ResourceManager.authenticate(httpPipeline, profile).withSdkContext(sdkContext).withDefaultSubscription();
72-
73-
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile, sdkContext);
74-
93+
ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
94+
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
7595
appServiceManager = AppServiceManager.authenticate(httpPipeline, profile, sdkContext);
96+
msiManager = MSIManager.authenticate(httpPipeline, profile, sdkContext);
7697

7798
// useExistingDomainAndCertificate();
7899
// createNewDomainAndCertificate();

sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AuthenticationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.azure.resourcemanager.appservice.models.PricingTier;
1010
import com.azure.resourcemanager.appservice.models.WebApp;
1111
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
12-
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
12+
import com.azure.core.management.profile.AzureProfile;
1313
import org.junit.jupiter.api.Assertions;
1414
import org.junit.jupiter.api.Disabled;
1515
import org.junit.jupiter.api.Test;

0 commit comments

Comments
 (0)