Repository: jclouds-labs Updated Branches: refs/heads/2.0.x 5261cba28 -> 9f5825656
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiLiveTest.java new file mode 100644 index 0000000..69014a5 --- /dev/null +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiLiveTest.java @@ -0,0 +1,460 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.features; + +import static org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions.Builder.availabilitySet; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.collect.Iterables.any; +import static com.google.common.collect.Iterables.getLast; +import static com.google.common.collect.Iterables.transform; +import static com.google.common.collect.Lists.newArrayList; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; +import static org.jclouds.azurecompute.arm.domain.InboundNatRuleProperties.Protocol.Tcp; +import static org.jclouds.compute.predicates.NodePredicates.inGroup; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.jclouds.azurecompute.arm.AzureComputeApi; +import org.jclouds.azurecompute.arm.compute.config.AzureComputeServiceContextModule.PublicIpAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.domain.AvailabilitySet; +import org.jclouds.azurecompute.arm.domain.BackendAddressPool; +import org.jclouds.azurecompute.arm.domain.BackendAddressPoolProperties; +import org.jclouds.azurecompute.arm.domain.FrontendIPConfigurations; +import org.jclouds.azurecompute.arm.domain.FrontendIPConfigurationsProperties; +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.InboundNatRule; +import org.jclouds.azurecompute.arm.domain.InboundNatRuleProperties; +import org.jclouds.azurecompute.arm.domain.IpConfiguration; +import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties; +import org.jclouds.azurecompute.arm.domain.LoadBalancer; +import org.jclouds.azurecompute.arm.domain.LoadBalancerProperties; +import org.jclouds.azurecompute.arm.domain.LoadBalancingRule; +import org.jclouds.azurecompute.arm.domain.LoadBalancingRuleProperties; +import org.jclouds.azurecompute.arm.domain.LoadBalancingRuleProperties.Protocol; +import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard; +import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties; +import org.jclouds.azurecompute.arm.domain.Probe; +import org.jclouds.azurecompute.arm.domain.ProbeProperties; +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.azurecompute.arm.domain.PublicIPAddress; +import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties; +import org.jclouds.azurecompute.arm.domain.RegionAndId; +import org.jclouds.azurecompute.arm.domain.ResourceGroup; +import org.jclouds.azurecompute.arm.domain.VirtualMachine; +import org.jclouds.azurecompute.arm.domain.AvailabilitySet.AvailabilitySetProperties; +import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils; +import org.jclouds.compute.RunNodesException; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.domain.Location; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Splitter; +import com.google.common.base.Supplier; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; + +// We extend the BaseComputeServiceContextLiveTest to create nodes using the abstraction, which is much easier +@Test(groups = "live", singleThreaded = true) +public class LoadBalancerApiLiveTest extends BaseComputeServiceContextLiveTest { + + private static final String lbName = String.format("lb-%s-%s", LoadBalancerApiLiveTest.class.getSimpleName() + .toLowerCase(), System.getProperty("user.name")); + + private LoadingCache<String, ResourceGroup> resourceGroupMap; + private Predicate<URI> resourceDeleted; + private PublicIpAvailablePredicateFactory publicIpAvailable; + private Predicate<Supplier<Provisionable>> resourceAvailable; + private AzureComputeApi api; + + private String resourceGroupName; + private String location; + private LoadBalancerApi lbApi; + private NetworkInterfaceCardApi nicApi; + + private LoadBalancer lb; + private String group; + private List<String> nicNames; + + public LoadBalancerApiLiveTest() { + provider = "azurecompute-arm"; + group = getClass().getSimpleName().toLowerCase(); + } + + @Override + protected Properties setupProperties() { + Properties properties = super.setupProperties(); + AzureLiveTestUtils.defaultProperties(properties); + checkNotNull(setIfTestSystemPropertyPresent(properties, "oauth.endpoint"), "test.oauth.endpoint"); + return properties; + } + + @Override + protected void initializeContext() { + super.initializeContext(); + resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() { + }, Names.named(TIMEOUT_RESOURCE_DELETED))); + resourceGroupMap = context.utils().injector() + .getInstance(Key.get(new TypeLiteral<LoadingCache<String, ResourceGroup>>() { + })); + publicIpAvailable = context.utils().injector().getInstance(PublicIpAvailablePredicateFactory.class); + resourceAvailable = context.utils().injector() + .getInstance(Key.get(new TypeLiteral<Predicate<Supplier<Provisionable>>>() { + })); + api = view.unwrapApi(AzureComputeApi.class); + } + + @Override + @BeforeClass + public void setupContext() { + super.setupContext(); + // Use the resource name conventions used in the abstraction so the nodes + // can see the load balancer + ResourceGroup resourceGroup = createResourceGroup(); + resourceGroupName = resourceGroup.name(); + location = resourceGroup.location(); + lbApi = api.getLoadBalancerApi(resourceGroupName); + nicApi = api.getNetworkInterfaceCardApi(resourceGroupName); + } + + @Override + @AfterClass(alwaysRun = true) + protected void tearDownContext() { + try { + view.getComputeService().destroyNodesMatching(inGroup(group)); + } finally { + try { + URI uri = api.getResourceGroupApi().delete(resourceGroupName); + assertResourceDeleted(uri); + } finally { + super.tearDownContext(); + } + } + } + + @Test + public void testDeleteLoadBalancerDoesNotExist() { + URI uri = lbApi.delete(lbName); + assertNull(uri); + } + + @Test(dependsOnMethods = "testDeleteLoadBalancerDoesNotExist") + public void testCreateLoadBalancer() { + LoadBalancer createLB = newLoadBalancer(lbName, location); + + PublicIPAddress publicIP = createPublicIPAddress("Ip4LoadBalancer"); + FrontendIPConfigurationsProperties fronendProps = FrontendIPConfigurationsProperties.builder() + .publicIPAddress(IdReference.create(publicIP.id())).build(); + FrontendIPConfigurations frontendIps = FrontendIPConfigurations.create("ipConfigs", null, fronendProps, null); + LoadBalancerProperties props = LoadBalancerProperties.builder() + .frontendIPConfigurations(ImmutableList.of(frontendIps)).build(); + + lb = lbApi.createOrUpdate(lbName, createLB.location(), createLB.tags(), props); + assertNotNull(lb); + } + + @Test(dependsOnMethods = "testCreateLoadBalancer") + public void testListLoadBalancers() { + List<LoadBalancer> result = lbApi.list(); + + // Verify we have something + assertNotNull(result); + assertTrue(result.size() > 0); + + // Check that the load balancer matches the one we originally passed in + assertTrue(any(result, new Predicate<LoadBalancer>() { + @Override + public boolean apply(LoadBalancer input) { + return lb.name().equals(input.name()); + } + })); + } + + @Test(dependsOnMethods = "testCreateLoadBalancer") + public void testGetLoadBalancer() { + lb = lbApi.get(lbName); + assertNotNull(lb); + } + + @Test(dependsOnMethods = "testGetLoadBalancer") + public void testAddProbe() { + ProbeProperties probeProps = ProbeProperties.builder().protocol(ProbeProperties.Protocol.Http).port(80) + .requestPath("/").intervalInSeconds(5).numberOfProbes(2).build(); + + Probe probe = Probe.create("probetest", null, probeProps, null); + LoadBalancerProperties props = lb.properties().toBuilder().probes(ImmutableList.of(probe)).build(); + + lb = updateLoadBalancer(lbName, props); + + assertEquals(lb.properties().probes().size(), 1); + assertEquals(lb.properties().probes().get(0).name(), probe.name()); + } + + @Test(dependsOnMethods = "testGetLoadBalancer") + public void testAddBackendPool() throws Exception { + List<IdReference> rules = newArrayList(transform(lb.properties().loadBalancingRules(), ToIdReference)); + BackendAddressPool pool = BackendAddressPool.create("backpools", null, BackendAddressPoolProperties.builder() + .loadBalancingRules(rules).build(), null); + + LoadBalancerProperties props = lb.properties().toBuilder().backendAddressPools(ImmutableList.of(pool)).build(); + + lb = updateLoadBalancer(lbName, props); + + assertEquals(lb.properties().backendAddressPools().size(), 1); + assertEquals(lb.properties().backendAddressPools().get(0).name(), pool.name()); + } + + @Test(dependsOnMethods = { "testAddProbe", "testAddBackendPool" }) + public void testAddLoadBalancingRule() { + IdReference frontendIp = IdReference.create(lb.properties().frontendIPConfigurations().get(0).id()); + IdReference probe = IdReference.create(lb.properties().probes().get(0).id()); + IdReference backendPool = IdReference.create(lb.properties().backendAddressPools().get(0).id()); + + LoadBalancingRuleProperties ruleProperties = LoadBalancingRuleProperties.builder() + .frontendIPConfiguration(frontendIp).backendAddressPool(backendPool).frontendPort(80).backendPort(80) + .protocol(Protocol.Tcp).probe(probe).build(); + + LoadBalancingRule rule = LoadBalancingRule.create("lbRule1", null, ruleProperties, null); + LoadBalancerProperties props = lb.properties().toBuilder().loadBalancingRules(ImmutableList.of(rule)).build(); + + lb = updateLoadBalancer(lbName, props); + + assertEquals(lb.properties().loadBalancingRules().size(), 1); + assertEquals(lb.properties().loadBalancingRules().get(0).name(), rule.name()); + } + + @Test(dependsOnMethods = { "testAddBackendPool", "testAddProbe", "testAddLoadBalancingRule" }) + public void testAttachNodesToBackendPool() throws Exception { + nicNames = createVirtualMachinesInGroupAndGetNicRefs(group, 2); + + // Add the first IP of each node to the pool + List<NetworkInterfaceCard> attachedNics = new ArrayList<NetworkInterfaceCard>(); + BackendAddressPool targetPool = lb.properties().backendAddressPools().get(0); + for (String nicName : nicNames) { + attachedNics.add(attachNicToBackendPool(nicName, targetPool)); + } + + // Refresh the LB after having attached NICs to the pool + lb = lbApi.get(lbName); + List<BackendAddressPool> pools = lb.properties().backendAddressPools(); + assertEquals(pools.size(), 1); + + List<IdReference> backendIps = pools.get(0).properties().backendIPConfigurations(); + assertEquals(backendIps.size(), attachedNics.size()); + assertTrue(backendIps.containsAll(newArrayList(transform(attachedNics, ToFirstIpReference)))); + } + + @Test(dependsOnMethods = "testAttachNodesToBackendPool") + public void testAddInboundNatRule() { + IdReference frontendIp = IdReference.create(lb.properties().frontendIPConfigurations().get(0).id()); + + InboundNatRuleProperties natProps = InboundNatRuleProperties.builder().frontendIPConfiguration(frontendIp) + .frontendPort(5679).backendPort(56710).protocol(Tcp).build(); + + InboundNatRule natRule = InboundNatRule.create("inboundnat", null, natProps, null); + LoadBalancerProperties props = lb.properties().toBuilder().inboundNatRules(ImmutableList.of(natRule)).build(); + + lb = updateLoadBalancer(lbName, props); + + assertEquals(lb.properties().inboundNatRules().size(), 1); + assertEquals(lb.properties().inboundNatRules().get(0).name(), natRule.name()); + + InboundNatRule createdRule = lb.properties().inboundNatRules().get(0); + NetworkInterfaceCard updatedNic = attachNicToNatRule(nicNames.get(0), createdRule); + List<IdReference> natRulesInNic = updatedNic.properties().ipConfigurations().get(0).properties() + .loadBalancerInboundNatRules(); + + assertEquals(natRulesInNic.size(), 1); + assertEquals(natRulesInNic.get(0), IdReference.create(createdRule.id())); + + // Refresh the LB after having attached NICs to the pool + lb = lbApi.get(lbName); + + IdReference backendIpRef = IdReference.create(updatedNic.properties().ipConfigurations().get(0).id()); + assertEquals(lb.properties().inboundNatRules().size(), 1); + assertEquals(lb.properties().inboundNatRules().get(0).properties().backendIPConfiguration(), backendIpRef); + + } + + @Test(dependsOnMethods = { "testCreateLoadBalancer", "testListLoadBalancers", "testGetLoadBalancer", "testAddProbe", + "testAddLoadBalancingRule", "testAddBackendPool", "testAttachNodesToBackendPool", "testAddInboundNatRule" }, alwaysRun = true) + public void deleteLoadBalancer() { + URI uri = lbApi.delete(lbName); + assertResourceDeleted(uri); + } + + private PublicIPAddress createPublicIPAddress(final String publicIpAddressName) { + final PublicIPAddressApi ipApi = view.unwrapApi(AzureComputeApi.class).getPublicIPAddressApi(resourceGroupName); + PublicIPAddress publicIPAddress = ipApi.get(publicIpAddressName); + + if (publicIPAddress == null) { + final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue"); + PublicIPAddressProperties properties = PublicIPAddressProperties.builder().publicIPAllocationMethod("Static") + .idleTimeoutInMinutes(4).build(); + publicIPAddress = ipApi.createOrUpdate(publicIpAddressName, location, tags, properties); + + checkState(publicIpAvailable.create(resourceGroupName).apply(publicIpAddressName), + "Public IP was not provisioned in the configured timeout"); + } + + return publicIPAddress; + } + + private LoadBalancer newLoadBalancer(final String lbName, final String locationName) { + FrontendIPConfigurationsProperties frontendIPConfigurationsProperties = FrontendIPConfigurationsProperties + .builder().build(); + FrontendIPConfigurations frontendIPConfigurations = FrontendIPConfigurations.create("ipConfigs", null, + frontendIPConfigurationsProperties, null); + return LoadBalancer.create(lbName, locationName, null, + LoadBalancerProperties.builder().frontendIPConfigurations(ImmutableList.of(frontendIPConfigurations)) + .build(), null); + } + + private void assertResourceDeleted(final URI uri) { + if (uri != null) { + assertTrue(resourceDeleted.apply(uri), + String.format("Resource %s was not terminated in the configured timeout", uri)); + } + } + + private List<String> createVirtualMachinesInGroupAndGetNicRefs(final String group, final int count) + throws RunNodesException { + + // To add multiple nodes in a LB they must belong to the same availability + // set + AvailabilitySetProperties props = AvailabilitySetProperties.builder().platformUpdateDomainCount(count) + .platformFaultDomainCount(count).build(); + AvailabilitySet as = AvailabilitySet.builder().name(group).properties(props).build(); + + Set<? extends NodeMetadata> nodes = view.getComputeService() + .createNodesInGroup(group, count, availabilitySet(as)); + + List<String> nicNames = new ArrayList<String>(); + for (NodeMetadata node : nodes) { + RegionAndId regionAndId = RegionAndId.fromSlashEncoded(node.getId()); + VirtualMachine vm = api.getVirtualMachineApi(resourceGroupName).get(regionAndId.id()); + + String nicName = getLast(Splitter.on("/").split( + vm.properties().networkProfile().networkInterfaces().get(0).id())); + nicNames.add(nicName); + } + + return nicNames; + } + + private NetworkInterfaceCard attachNicToBackendPool(final String nicName, BackendAddressPool pool) { + List<IdReference> poolRefs = ImmutableList.of(IdReference.create(pool.id())); + + // Assume we are attaching the first IP to the Load Balancer + NetworkInterfaceCard nic = nicApi.get(nicName); + + IpConfigurationProperties ipProps = nic.properties().ipConfigurations().get(0).properties().toBuilder() + .loadBalancerBackendAddressPools(poolRefs).build(); + List<IpConfiguration> ips = ImmutableList.of(nic.properties().ipConfigurations().get(0).toBuilder() + .properties(ipProps).build()); + + NetworkInterfaceCardProperties nicProps = nic.properties().toBuilder().ipConfigurations(ips).build(); + + nicApi.createOrUpdate(nicName, location, nicProps, null); + + resourceAvailable.apply(new Supplier<Provisionable>() { + @Override + public Provisionable get() { + NetworkInterfaceCard updated = nicApi.get(nicName); + return updated == null ? null : updated.properties(); + } + }); + + return nicApi.get(nicName); + } + + private NetworkInterfaceCard attachNicToNatRule(final String nicName, InboundNatRule rule) { + List<IdReference> natRuleRefs = ImmutableList.of(IdReference.create(rule.id())); + + // Assume we are attaching the first IP to the NAT rule + NetworkInterfaceCard nic = nicApi.get(nicName); + + IpConfigurationProperties ipProps = nic.properties().ipConfigurations().get(0).properties().toBuilder() + .loadBalancerInboundNatRules(natRuleRefs).build(); + List<IpConfiguration> ips = ImmutableList.of(nic.properties().ipConfigurations().get(0).toBuilder() + .properties(ipProps).build()); + + NetworkInterfaceCardProperties nicProps = nic.properties().toBuilder().ipConfigurations(ips).build(); + + nicApi.createOrUpdate(nicName, location, nicProps, null); + + resourceAvailable.apply(new Supplier<Provisionable>() { + @Override + public Provisionable get() { + NetworkInterfaceCard updated = nicApi.get(nicName); + return updated == null ? null : updated.properties(); + } + }); + + return nicApi.get(nicName); + } + + private ResourceGroup createResourceGroup() { + Location location = view.getComputeService().templateBuilder().build().getLocation(); + return resourceGroupMap.getUnchecked(location.getId()); + } + + private LoadBalancer updateLoadBalancer(final String name, LoadBalancerProperties props) { + lbApi.createOrUpdate(name, location, null, props); + resourceAvailable.apply(new Supplier<Provisionable>() { + @Override + public Provisionable get() { + LoadBalancer updated = lbApi.get(name); + return updated == null ? null : updated.properties(); + } + }); + return lbApi.get(name); + } + + private static final Function<LoadBalancingRule, IdReference> ToIdReference = new Function<LoadBalancingRule, IdReference>() { + @Override + public IdReference apply(LoadBalancingRule input) { + return IdReference.create(input.id()); + } + }; + + private static final Function<NetworkInterfaceCard, IdReference> ToFirstIpReference = new Function<NetworkInterfaceCard, IdReference>() { + @Override + public IdReference apply(NetworkInterfaceCard input) { + return IdReference.create(input.properties().ipConfigurations().get(0).id()); + } + }; + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiMockTest.java new file mode 100644 index 0000000..49e88db --- /dev/null +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LoadBalancerApiMockTest.java @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.features; + +import static com.google.common.collect.Iterables.isEmpty; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.FrontendIPConfigurations; +import org.jclouds.azurecompute.arm.domain.FrontendIPConfigurationsProperties; +import org.jclouds.azurecompute.arm.domain.LoadBalancer; +import org.jclouds.azurecompute.arm.domain.LoadBalancerProperties; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "LoadBalancerApiMockTest", singleThreaded = true) +public class LoadBalancerApiMockTest extends BaseAzureComputeApiMockTest { + private final String subscriptionid = "SUBSCRIPTIONID"; + private final String resourcegroup = "myresourcegroup"; + private final String apiVersion = "api-version=2016-03-30"; + private final String lbName = "testLoadBalancer"; + + public void createLoadBalancer() throws InterruptedException { + LoadBalancer nsg = newLoadBalancer(); + + server.enqueue(jsonResponse("/loadbalancercreate.json").setResponseCode(200)); + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers/%s?%s", + subscriptionid, resourcegroup, lbName, apiVersion); + + String json = "{\"location\":\"westeurope\",\"properties\":{\"frontendIPConfigurations\":[{\"name\":\"ipConfigs\",\"properties\":{}}]}}"; + + LoadBalancer result = nsgApi.createOrUpdate(lbName, "westeurope", null, nsg.properties()); + assertSent(server, "PUT", path, json); + + assertEquals(result.name(), lbName); + assertEquals(result.location(), "westeurope"); + } + + public void getLoadBalancer() throws InterruptedException { + server.enqueue(jsonResponse("/loadbalancerget.json").setResponseCode(200)); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + LoadBalancer result = nsgApi.get(lbName); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers/%s?%s", + subscriptionid, resourcegroup, lbName, apiVersion); + assertSent(server, "GET", path); + + assertEquals(result.name(), lbName); + assertEquals(result.location(), "westeurope"); + assertEquals(result.properties().loadBalancingRules().size(), 1); + assertEquals(result.properties().loadBalancingRules().get(0).name(), "lbRule1"); + } + + public void getLoadBalancerReturns404() throws InterruptedException { + server.enqueue(response404()); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + LoadBalancer result = nsgApi.get(lbName); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers/%s?%s", + subscriptionid, resourcegroup, lbName, apiVersion); + assertSent(server, "GET", path); + + assertNull(result); + } + + public void listLoadBalancers() throws InterruptedException { + server.enqueue(jsonResponse("/loadbalancerlist.json").setResponseCode(200)); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + List<LoadBalancer> result = nsgApi.list(); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertNotNull(result); + assertTrue(result.size() > 0); + } + + public void listLoadBalancersReturns404() throws InterruptedException { + server.enqueue(response404()); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + List<LoadBalancer> result = nsgApi.list(); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertTrue(isEmpty(result)); + } + + public void deleteLoadBalancer() throws InterruptedException { + server.enqueue(response202WithHeader()); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + URI uri = nsgApi.delete(lbName); + + assertEquals(server.getRequestCount(), 1); + assertNotNull(uri); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers/%s?%s", + subscriptionid, resourcegroup, lbName, apiVersion); + assertSent(server, "DELETE", path); + + assertTrue(uri.toString().contains("api-version")); + assertTrue(uri.toString().contains("operationresults")); + } + + public void deleteLoadBalancerDoesNotExist() throws InterruptedException { + server.enqueue(response404()); + + final LoadBalancerApi nsgApi = api.getLoadBalancerApi(resourcegroup); + URI uri = nsgApi.delete(lbName); + assertNull(uri); + + String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/loadBalancers/%s?%s", + subscriptionid, resourcegroup, lbName, apiVersion); + assertSent(server, "DELETE", path); + } + + private LoadBalancer newLoadBalancer() { + FrontendIPConfigurationsProperties frontendIPConfigurationsProperties = FrontendIPConfigurationsProperties + .builder().build(); + FrontendIPConfigurations frontendIPConfigurations = FrontendIPConfigurations.create("ipConfigs", null, + frontendIPConfigurationsProperties, null); + return LoadBalancer.create(lbName, "westus", null, LoadBalancerProperties.builder() + .frontendIPConfigurations(ImmutableList.of(frontendIPConfigurations)).build(), null); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java index 0614d99..cd95a2c 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java @@ -16,6 +16,10 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import java.net.URI; import java.util.Arrays; import java.util.List; @@ -28,20 +32,14 @@ import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard; import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties; import org.jclouds.azurecompute.arm.domain.Subnet; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private String subnetId; private String nicName; @@ -49,7 +47,7 @@ public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); + createTestResourceGroup(); assertNotNull(api.getResourceGroupApi().create(resourceGroupName, LOCATION, ImmutableMap.<String, String>of())); String virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); nicName = String.format("nic-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); @@ -65,13 +63,6 @@ public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest subnetId = subnet.id(); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - deleteResourceGroup(resourceGroupName); - } - @Test public void createNetworkInterfaceCard() { //Create properties object http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiMockTest.java index bda8cad..e0f0ed4 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiMockTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiMockTest.java @@ -103,13 +103,9 @@ public class NetworkInterfaceCardApiMockTest extends BaseAzureComputeApiMockTest final String SubnetID = "/subscriptions/" + subscriptionid + "/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"; //Create properties object - final NetworkInterfaceCardProperties networkInterfaceCardProperties = - NetworkInterfaceCardProperties.create(null, null, null, - Arrays.asList(IpConfiguration.create("myipconfig", null, null, null, - IpConfigurationProperties.create(null, null, "Dynamic", IdReference.create(SubnetID), null)) - ), - null - ); + final NetworkInterfaceCardProperties networkInterfaceCardProperties = NetworkInterfaceCardProperties.create(null, + null, null, Arrays.asList(IpConfiguration.create("myipconfig", null, null, null, IpConfigurationProperties + .create(null, null, "Dynamic", IdReference.create(SubnetID), null, null, null))), null); final Map<String, String> tags = ImmutableMap.of("mycustomtag", "foobar"); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiLiveTest.java index b66b150..3a2f4eb 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiLiveTest.java @@ -16,44 +16,33 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + import java.net.URI; import java.util.List; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class NetworkSecurityGroupApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private static String nsgName = "testNetworkSecurityGroup"; @BeforeClass @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); + createTestResourceGroup(); nsgName = String.format("nsg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - URI uri = deleteResourceGroup(resourceGroupName); - assertResourceDeleted(uri); - } - @Test public void deleteNetworkSecurityGroupDoesNotExist() { URI uri = api().delete(nsgName); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java index dba7063..821dbe3 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java @@ -16,6 +16,11 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + import java.net.URI; import java.util.List; @@ -26,22 +31,15 @@ import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class NetworkSecurityRuleApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private static String UNKNOWN_RULE_NAME = "ruledoesntexist"; private String nsgName; @@ -49,8 +47,7 @@ public class NetworkSecurityRuleApiLiveTest extends BaseAzureComputeApiLiveTest @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); + createTestResourceGroup(); nsgName = String.format("nsg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); // a network security group is needed @@ -61,14 +58,6 @@ public class NetworkSecurityRuleApiLiveTest extends BaseAzureComputeApiLiveTest nsg.properties())); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - URI uri = deleteResourceGroup(resourceGroupName); - assertResourceDeleted(uri); - } - @Test public void deleteNetworkSecurityRuleDoesNotExist() { URI uri = api().delete(UNKNOWN_RULE_NAME); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java index 98819c1..9519ed6 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java @@ -16,7 +16,12 @@ */ package org.jclouds.azurecompute.arm.features; -import java.net.URI; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + import java.util.List; import java.util.Map; @@ -24,23 +29,15 @@ import org.jclouds.azurecompute.arm.domain.PublicIPAddress; import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.jclouds.util.Predicates2; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class PublicIPAddressApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private final String publicIpAddressName = "myipaddress"; private String subscriptionid; @@ -48,19 +45,10 @@ public class PublicIPAddressApiLiveTest extends BaseAzureComputeApiLiveTest { @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); + createTestResourceGroup(); subscriptionid = getSubscriptionId(); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - URI uri = deleteResourceGroup(resourceGroupName); - assertResourceDeleted(uri); - } - @Test(groups = "live") public void deletePublicIPAddressResourceDoesNotExist() { final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java index c88ebdc..d01a972 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java @@ -16,6 +16,12 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + import java.net.URI; import java.util.List; @@ -25,41 +31,23 @@ import org.jclouds.azurecompute.arm.domain.StorageServiceUpdateParams; import org.jclouds.azurecompute.arm.functions.ParseJobStatus; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.jclouds.util.Predicates2; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", testName = "StorageAccountApiLiveTest") public class StorageAccountApiLiveTest extends BaseAzureComputeApiLiveTest { private static final String NAME = String.format("%3.24s", RAND + StorageAccountApiLiveTest.class.getSimpleName().toLowerCase()); - private String resourceGroupName; - @BeforeClass @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); - } - - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - URI uri = deleteResourceGroup(resourceGroupName); - assertResourceDeleted(uri); + createTestResourceGroup(); } @Test(dependsOnMethods = "testCreate") http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java index 8d1d505..8144001 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java @@ -16,24 +16,22 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import java.util.List; import org.jclouds.azurecompute.arm.domain.Subnet; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class SubnetApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private String virtualNetworkName; private String subnetName; @@ -41,9 +39,9 @@ public class SubnetApiLiveTest extends BaseAzureComputeApiLiveTest { @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); - virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); + createTestResourceGroup(); + virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), + System.getProperty("user.name")); subnetName = "jclouds-" + RAND; // Subnets belong to a virtual network so that needs to be created first @@ -52,13 +50,6 @@ public class SubnetApiLiveTest extends BaseAzureComputeApiLiveTest { assertNotNull(vn); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - deleteResourceGroup(resourceGroupName); - } - @Test public void deleteSubnetResourceDoesNotExist() { assertFalse(api().delete(subnetName)); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java index a11ff71..8bc25c2 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java @@ -47,11 +47,10 @@ import org.jclouds.azurecompute.arm.domain.Subnet; import org.jclouds.azurecompute.arm.domain.VHD; import org.jclouds.azurecompute.arm.domain.VirtualMachine; import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance; -import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance.VirtualMachineStatus.PowerState; +import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance.PowerState; import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.testng.Assert; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -63,7 +62,6 @@ import com.google.common.collect.Iterables; public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest { private String subscriptionid; - private String resourceGroupName; private String storageServiceName; private String vmName; private String nicName; @@ -77,8 +75,7 @@ public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest { super.setup(); subscriptionid = getSubscriptionId(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); + createTestResourceGroup(); virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); storageServiceName = String.format("st%s%s", System.getProperty("user.name"), RAND); @@ -101,14 +98,6 @@ public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest { vmName = String.format("%3.24s", System.getProperty("user.name") + RAND + this.getClass().getSimpleName()).toLowerCase().substring(0, 15); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - URI deleteResourceGroupURI = deleteResourceGroup(resourceGroupName); - assertResourceDeleted(deleteResourceGroupURI); - } - @Test public void testCreate() { String blob = storageService.storageServiceProperties().primaryEndpoints().get("blob"); @@ -253,11 +242,11 @@ public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest { protected NetworkInterfaceCard createNetworkInterfaceCard(final String resourceGroupName, String networkInterfaceCardName, String locationName, String ipConfigurationName) { //Create properties object - final NetworkInterfaceCardProperties networkInterfaceCardProperties = - NetworkInterfaceCardProperties.builder() - .ipConfigurations(Arrays.asList(IpConfiguration.create(ipConfigurationName, null, null, null, - IpConfigurationProperties.create(null, null, "Dynamic", IdReference.create(subnetId), null)) - )).build(); + final NetworkInterfaceCardProperties networkInterfaceCardProperties = NetworkInterfaceCardProperties + .builder() + .ipConfigurations( + Arrays.asList(IpConfiguration.create(ipConfigurationName, null, null, null, IpConfigurationProperties + .create(null, null, "Dynamic", IdReference.create(subnetId), null, null, null)))).build(); final Map<String, String> tags = ImmutableMap.of("jclouds", "livetest"); return api.getNetworkInterfaceCardApi(resourceGroupName).createOrUpdate(networkInterfaceCardName, locationName, networkInterfaceCardProperties, tags); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java index 5b034a0..65bdeb3 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java @@ -43,6 +43,7 @@ import org.jclouds.azurecompute.arm.domain.VHD; import org.jclouds.azurecompute.arm.domain.VirtualMachine; import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance; import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties; +import org.jclouds.azurecompute.arm.domain.Status; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; import org.testng.annotations.Test; @@ -288,7 +289,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest { } private VirtualMachineInstance getVMInstance() { - List<VirtualMachineInstance.VirtualMachineStatus> statuses = new ArrayList<VirtualMachineInstance.VirtualMachineStatus>(); + List<Status> statuses = new ArrayList<Status>(); String testDate = "Wed May 04 01:38:52 PDT 2016"; DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); Date date = null; @@ -297,11 +298,11 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest { } catch (Exception e) { e.printStackTrace(); } - VirtualMachineInstance.VirtualMachineStatus vmStatus = VirtualMachineInstance.VirtualMachineStatus.create( - "ProvisioningState/succeeded", "Info", "Provisioning succeeded", date); + Status vmStatus = Status.create( + "ProvisioningState/succeeded", "Info", "Provisioning succeeded", null, date); statuses.add(vmStatus); - VirtualMachineInstance.VirtualMachineStatus vmStatus1 = VirtualMachineInstance.VirtualMachineStatus.create( - "PowerState/running", "Info", "VM running", null); + Status vmStatus1 = Status.create( + "PowerState/running", "Info", "VM running", null, null); statuses.add(vmStatus1); VirtualMachineInstance machineInstance = VirtualMachineInstance http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java index 7f59678..4459a1e 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java @@ -16,42 +16,32 @@ */ package org.jclouds.azurecompute.arm.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import java.util.Arrays; import java.util.List; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - @Test(groups = "live", singleThreaded = true) public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest { - private String resourceGroupName; private String virtualNetworkName; @BeforeClass @Override public void setup() { super.setup(); - resourceGroupName = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); - assertNotNull(createResourceGroup(resourceGroupName)); + createTestResourceGroup(); virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); } - @AfterClass - @Override - protected void tearDown() { - super.tearDown(); - deleteResourceGroup(resourceGroupName); - } - @Test public void deleteVirtualNetworkResourceDoesNotExist() { boolean status = api().delete(virtualNetworkName); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java index 125e11a..8cd662a 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java @@ -17,6 +17,7 @@ package org.jclouds.azurecompute.arm.internal; import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; +import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; @@ -36,6 +37,7 @@ public class AzureLiveTestUtils { properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString()); properties.put(PROPERTY_REGIONS, "eastus"); properties.put(IMAGE_PUBLISHERS, "Canonical"); + properties.put(RESOURCENAME_PREFIX, "jcloudstest"); String defaultTimeout = String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES)); properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, defaultTimeout); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java index c3c6aa7..0633294 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java @@ -16,6 +16,13 @@ */ package org.jclouds.azurecompute.arm.internal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; +import static org.jclouds.util.Predicates2.retry; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import java.net.URI; import java.util.Arrays; import java.util.List; @@ -24,17 +31,21 @@ import java.util.Random; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.azurecompute.arm.AzureComputeApi; +import org.jclouds.azurecompute.arm.compute.config.AzureComputeServiceContextModule.PublicIpAvailablePredicateFactory; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties; +import org.jclouds.azurecompute.arm.domain.Provisionable; import org.jclouds.azurecompute.arm.domain.ResourceGroup; import org.jclouds.azurecompute.arm.domain.StorageService; import org.jclouds.azurecompute.arm.domain.Subnet; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.jclouds.azurecompute.arm.functions.ParseJobStatus; +import org.testng.annotations.AfterClass; import com.google.common.base.Predicate; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.inject.Injector; @@ -43,13 +54,6 @@ import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi> { protected static final int RAND = new Random().nextInt(999); @@ -59,10 +63,26 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi protected Predicate<URI> imageAvailablePredicate; protected Predicate<URI> resourceDeleted; + protected PublicIpAvailablePredicateFactory publicIpAvailable; + protected Predicate<Supplier<Provisionable>> resourceAvailable; + + protected String resourceGroupName; public BaseAzureComputeApiLiveTest() { provider = "azurecompute-arm"; } + + @Override + @AfterClass(groups = "live") + protected void tearDown() { + try { + if (resourceGroupName != null) { + deleteResourceGroup(resourceGroupName); + } + } finally { + super.tearDown(); + } + } @Override protected AzureComputeApi create(Properties props, Iterable<Module> modules) { Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); @@ -70,6 +90,9 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi }, Names.named(TIMEOUT_IMAGE_AVAILABLE))); resourceDeleted = injector.getInstance(Key.get(new TypeLiteral<Predicate<URI>>() { }, Names.named(TIMEOUT_RESOURCE_DELETED))); + publicIpAvailable = injector.getInstance(PublicIpAvailablePredicateFactory.class); + resourceAvailable = injector.getInstance(Key.get(new TypeLiteral<Predicate<Supplier<Provisionable>>>() { + })); return injector.getInstance(AzureComputeApi.class); } @@ -82,18 +105,20 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi } protected void assertResourceDeleted(URI uri) { - assertNotNull(uri); - assertTrue(resourceDeleted.apply(uri), String.format("Resource %s was not terminated in the configured timeout", uri)); + if (uri != null) { + assertTrue(resourceDeleted.apply(uri), + String.format("Resource %s was not terminated in the configured timeout", uri)); + } } - protected VirtualNetwork createDefaultVirtualNetwork(final String resourceGroupName, String virtualNetworkName, String virtualnetworkAddressPrefix, String location) { + protected VirtualNetwork createDefaultVirtualNetwork(final String resourceGroupName, final String virtualNetworkName, final String virtualnetworkAddressPrefix, final String location) { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.create(null, null, VirtualNetwork.AddressSpace.create(Arrays.asList(virtualnetworkAddressPrefix)), null); VirtualNetwork virtualNetwork = api.getVirtualNetworkApi(resourceGroupName).createOrUpdate(virtualNetworkName, location, virtualNetworkProperties); retry(new Predicate<String>() { @Override - public boolean apply(String name) { + public boolean apply(final String name) { VirtualNetwork virtualNetwork = api.getVirtualNetworkApi(resourceGroupName).get(name); return virtualNetwork.properties().provisioningState().equals("Succeeded"); } @@ -101,12 +126,12 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi return virtualNetwork; } - protected Subnet createDefaultSubnet(final String resourceGroupName, String subnetName, final String virtualNetworkName, String subnetAddressSpace) { + protected Subnet createDefaultSubnet(final String resourceGroupName, final String subnetName, final String virtualNetworkName, final String subnetAddressSpace) { Subnet.SubnetProperties properties = Subnet.SubnetProperties.builder().addressPrefix(subnetAddressSpace).build(); Subnet subnet = api.getSubnetApi(resourceGroupName, virtualNetworkName).createOrUpdate(subnetName, properties); retry(new Predicate<String>() { @Override - public boolean apply(String name) { + public boolean apply(final String name) { Subnet subnet = api.getSubnetApi(resourceGroupName, virtualNetworkName).get(name); return subnet.properties().provisioningState().equals("Succeeded"); } @@ -114,7 +139,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi return subnet; } - protected StorageService createStorageService(String resourceGroupName, String storageServiceName, String location) { + protected StorageService createStorageService(final String resourceGroupName, final String storageServiceName, final String location) { URI uri = api.getStorageAccountApi(resourceGroupName).create(storageServiceName, location, ImmutableMap.of("property_name", "property_value"), ImmutableMap.of("accountType", StorageService.AccountType.Standard_LRS.toString())); if (uri != null) { @@ -122,7 +147,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi boolean jobDone = retry(new Predicate<URI>() { @Override - public boolean apply(URI uri) { + public boolean apply(final URI uri) { return ParseJobStatus.JobStatus.DONE == api.getJobApi().jobStatus(uri); } }, 60 * 1 * 1000 /* 1 minute timeout */).apply(uri); @@ -131,12 +156,17 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi return api.getStorageAccountApi(resourceGroupName).get(storageServiceName); } - protected ResourceGroup createResourceGroup(String resourceGroupName) { - return api.getResourceGroupApi().create(resourceGroupName, LOCATION, ImmutableMap.<String, String>of()); + protected void createTestResourceGroup() { + String name = String.format("rg-%s-%s", this.getClass().getSimpleName().toLowerCase(), + System.getProperty("user.name")); + ResourceGroup rg = api.getResourceGroupApi().create(name, LOCATION, ImmutableMap.<String, String> of()); + assertNotNull(rg); + resourceGroupName = rg.name(); } - protected URI deleteResourceGroup(String resourceGroupName) { - return api.getResourceGroupApi().delete(resourceGroupName); + protected void deleteResourceGroup(final String resourceGroupName) { + URI uri = api.getResourceGroupApi().delete(resourceGroupName); + assertResourceDeleted(uri); } protected NetworkSecurityGroup newNetworkSecurityGroup(String nsgName, String locationName) { http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/availabilitysetcreate.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/availabilitysetcreate.json b/azurecompute-arm/src/test/resources/availabilitysetcreate.json new file mode 100644 index 0000000..748f749 --- /dev/null +++ b/azurecompute-arm/src/test/resources/availabilitysetcreate.json @@ -0,0 +1,11 @@ +{ + "properties": { + "platformUpdateDomainCount": 2, + "platformFaultDomainCount": 3 + }, + "type": "Microsoft.Compute/availabilitySets", + "location": "westeurope", + "tags": {}, + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/Microsoft.Compute/availabilitySets/myas", + "name": "myas" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/availabilitysetget.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/availabilitysetget.json b/azurecompute-arm/src/test/resources/availabilitysetget.json new file mode 100644 index 0000000..97870cb --- /dev/null +++ b/azurecompute-arm/src/test/resources/availabilitysetget.json @@ -0,0 +1,12 @@ +{ + "properties": { + "platformUpdateDomainCount": 2, + "platformFaultDomainCount": 3, + "virtualMachines": [] + }, + "type": "Microsoft.Compute/availabilitySets", + "location": "westeurope", + "tags": {}, + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/Microsoft.Compute/availabilitySets/myas", + "name": "myas" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/availabilitysetlist.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/availabilitysetlist.json b/azurecompute-arm/src/test/resources/availabilitysetlist.json new file mode 100644 index 0000000..77b8fbf --- /dev/null +++ b/azurecompute-arm/src/test/resources/availabilitysetlist.json @@ -0,0 +1,16 @@ +{ + "value": [ + { + "properties": { + "platformUpdateDomainCount": 2, + "platformFaultDomainCount": 3, + "virtualMachines": [] + }, + "type": "Microsoft.Compute/availabilitySets", + "location": "westeurope", + "tags": {}, + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/Microsoft.Compute/availabilitySets/myas", + "name": "myas" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/listvirtualnetworks.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/listvirtualnetworks.json b/azurecompute-arm/src/test/resources/listvirtualnetworks.json index e85c883..38b9b39 100644 --- a/azurecompute-arm/src/test/resources/listvirtualnetworks.json +++ b/azurecompute-arm/src/test/resources/listvirtualnetworks.json @@ -2,7 +2,7 @@ "value": [ { "name": "mockvirtualnetwork", - "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/mockvirtualnetwork", + "id": "/subscriptions/6b6748c8-3e69-4e27-9b71-df97a81c0bbc/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/mockvirtualnetwork", "etag": "W/\"0dcd223f-670c-49ca-abe7-5978d127c131\"", "type": "Microsoft.Network/virtualNetworks", "location": "westeurope", http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/loadbalancercreate.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/loadbalancercreate.json b/azurecompute-arm/src/test/resources/loadbalancercreate.json new file mode 100644 index 0000000..b3fa339 --- /dev/null +++ b/azurecompute-arm/src/test/resources/loadbalancercreate.json @@ -0,0 +1,28 @@ +{ + "name": "testLoadBalancer", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer", + "etag": "W/\"406af4e7-b24b-4c00-b42f-b3c4399bf61d\"", + "type": "Microsoft.Network/loadBalancers", + "location": "westeurope", + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "112b7e75-f287-4789-9f6a-9a55a6fbe47c", + "frontendIPConfigurations": [ + { + "name": "ipConfigs", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs", + "etag": "W/\"406af4e7-b24b-4c00-b42f-b3c4399bf61d\"", + "properties": { + "provisioningState": "Succeeded", + "privateIPAllocationMethod": "Dynamic" + } + } + ], + "backendAddressPools": [], + "loadBalancingRules": [], + "probes": [], + "inboundNatRules": [], + "outboundNatRules": [], + "inboundNatPools": [] + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/loadbalancerget.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/loadbalancerget.json b/azurecompute-arm/src/test/resources/loadbalancerget.json new file mode 100644 index 0000000..ef4e390 --- /dev/null +++ b/azurecompute-arm/src/test/resources/loadbalancerget.json @@ -0,0 +1,54 @@ +{ + "name": "testLoadBalancer", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer", + "etag": "W/\"b2cfb60e-4ada-4546-a336-dd71e574ead6\"", + "type": "Microsoft.Network/loadBalancers", + "location": "westeurope", + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "0d53b121-95cc-47b5-bbc6-0391f5991028", + "frontendIPConfigurations": [ + { + "name": "ipConfigs", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs", + "etag": "W/\"b2cfb60e-4ada-4546-a336-dd71e574ead6\"", + "properties": { + "provisioningState": "Succeeded", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/Ip4LoadBalancer" + }, + "loadBalancingRules": [ + { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/loadBalancingRules/lbRule1" + } + ] + } + } + ], + "backendAddressPools": [], + "loadBalancingRules": [ + { + "name": "lbRule1", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/loadBalancingRules/lbRule1", + "etag": "W/\"b2cfb60e-4ada-4546-a336-dd71e574ead6\"", + "properties": { + "provisioningState": "Succeeded", + "frontendIPConfiguration": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs" + }, + "frontendPort": 80, + "backendPort": 80, + "enableFloatingIP": false, + "idleTimeoutInMinutes": 4, + "protocol": "Tcp", + "loadDistribution": "Default" + } + } + ], + "probes": [], + "inboundNatRules": [], + "outboundNatRules": [], + "inboundNatPools": [] + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9f582565/azurecompute-arm/src/test/resources/loadbalancerlist.json ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/resources/loadbalancerlist.json b/azurecompute-arm/src/test/resources/loadbalancerlist.json new file mode 100644 index 0000000..8272d39 --- /dev/null +++ b/azurecompute-arm/src/test/resources/loadbalancerlist.json @@ -0,0 +1,35 @@ +{ + "value": [ + { + "name": "testLoadBalancer", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer", + "etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"", + "type": "Microsoft.Network/loadBalancers", + "location": "westeurope", + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "383708b3-8d4e-474c-8908-9c4e311ac0bf", + "frontendIPConfigurations": [ + { + "name": "ipConfigs", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/loadBalancers/testLoadBalancer/frontendIPConfigurations/ipConfigs", + "etag": "W/\"1107154b-8717-486b-80c1-af99ec62897b\"", + "properties": { + "provisioningState": "Succeeded", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-loadbalancerapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/Ip4LoadBalancer" + } + } + } + ], + "backendAddressPools": [], + "loadBalancingRules": [], + "probes": [], + "inboundNatRules": [], + "outboundNatRules": [], + "inboundNatPools": [] + } + } + ] +} \ No newline at end of file
