Skip to content

Commit

Permalink
Fixed comments for pr#42311 and add code for register providers.
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 committed Oct 15, 2024
1 parent 85b65af commit 433ccd4
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.azure.core.test.annotation.LiveOnly;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.identity.AzurePowerShellCredentialBuilder;
import com.azure.resourcemanager.computefleet.models.ApiEntityReference;
import com.azure.resourcemanager.computefleet.models.BaseVirtualMachineProfile;
import com.azure.resourcemanager.computefleet.models.CachingTypes;
Expand Down Expand Up @@ -72,26 +72,26 @@ public class ComputeFleetManagerTests extends TestProxyTestBase {

@Override
public void beforeTest() {
final TokenCredential credential = new DefaultAzureCredentialBuilder().build();
final TokenCredential credential = new AzurePowerShellCredentialBuilder().build();
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);

computeFleetManager = ComputeFleetManager
.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

networkManager = NetworkManager
.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile);

resourceManager = ResourceManager
.configure()
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC))
.authenticate(credential, profile)
.withDefaultSubscription();

canRegisterProviders(Arrays.asList("Microsoft.Resources", "Microsoft.Network", "Microsoft.AzureFleet"));
canRegisterProviders(Arrays.asList("Microsoft.AzureFleet"));

// use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI
String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME");
Expand All @@ -117,8 +117,6 @@ protected void afterTest() {
@LiveOnly
public void testCreateComputeFleet() {
Fleet fleet = null;
Network network = null;
LoadBalancer loadBalancer = null;
try {
String fleetName = "fleet" + randomPadding();
String vmName = "vm" + randomPadding();
Expand All @@ -127,7 +125,7 @@ public void testCreateComputeFleet() {
String adminUser = "adminUser" + randomPadding();
String adminPwd = UUID.randomUUID().toString().replace("-", "@").substring(0, 13);
// @embedStart
network = networkManager.networks()
Network network = networkManager.networks()
.define(vnetName)
.withRegion(REGION)
.withExistingResourceGroup(resourceGroupName)
Expand All @@ -137,7 +135,7 @@ public void testCreateComputeFleet() {
.attach()
.create();

loadBalancer = networkManager.loadBalancers()
LoadBalancer loadBalancer = networkManager.loadBalancers()
.define(loadBalancerName)
.withRegion(REGION)
.withExistingResourceGroup(resourceGroupName)
Expand Down Expand Up @@ -240,7 +238,7 @@ public void testCreateComputeFleet() {
)
)
)
.withNetworkApiVersion(NetworkApiVersion.fromString("2022-07-01"))
.withNetworkApiVersion(NetworkApiVersion.fromString("2024-03-01"))
)
)
.withComputeApiVersion("2024-03-01")
Expand All @@ -262,12 +260,6 @@ public void testCreateComputeFleet() {
if (fleet != null) {
computeFleetManager.fleets().deleteById(fleet.id());
}
if (loadBalancer != null) {
networkManager.loadBalancers().deleteById(loadBalancer.id());
}
if (network != null) {
networkManager.networks().deleteById(network.id());
}
}
}

Expand Down

0 comments on commit 433ccd4

Please sign in to comment.