@Test(enabled = false, dependsOnMethods = "testCreateAggregate") public void testModifyHosts() { if (apiOption.isPresent() && hostAdminOption.isPresent()) { HostAggregateApi api = apiOption.get(); Host host = Iterables.getFirst(hostAdminOption.get().list(), null); assertNotNull(host); String host_id = host.getName(); assertNotNull(host_id); HostAggregate details; try { details = api.addHost(testAggregate.getId(), host_id); assertEquals(details.getHosts(), ImmutableSet.of(host_id)); // re-fetch to double-check details = api.get(testAggregate.getId()); assertEquals(details.getHosts(), ImmutableSet.of(host_id)); // TODO wait until status of aggregate isn't CHANGING (hostAdministration.shutdown?) } finally { details = api.removeHost(testAggregate.getId(), host_id); } assertEquals(details.getHosts(), ImmutableSet.of()); } } }
public void testCreateAggregate() { if (apiOption.isPresent()) { // TODO assuming "nova" availability zone is present testAggregate = apiOption.get().createInAvailabilityZone("jclouds-test-a", "nova"); } }
@AfterClass(groups = { "integration", "live" }) @Override protected void tearDown() { if (testAggregate != null) { assertTrue(apiOption.get().delete(testAggregate.getId())); } super.tearDown(); }
@Test(dependsOnMethods = "testCreateAggregate") public void testModifyMetadata() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); for (Map<String, String> theMetaData : ImmutableSet.of( ImmutableMap.of("somekey", "somevalue"), ImmutableMap.of("somekey", "some other value", "anotherkey", "another val") )) { // Apply changes HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData); // bug in openstack - metadata values are never removed, so we just checking what we've set for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } // Re-fetch to double-check details = api.get(testAggregate.getId()); for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } } } }
@Test(dependsOnMethods = "testCreateAggregate") public void testListAndGetAggregate() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); Set<? extends HostAggregate> aggregates = api.list().toSet(); for (HostAggregate aggregate : aggregates) { assertNotNull(aggregate.getId()); assertNotNull(aggregate.getName()); assertNotNull(aggregate.getAvailabilityZone()); HostAggregate details = api.get(aggregate.getId()); assertEquals(details.getId(), aggregate.getId()); assertEquals(details.getName(), aggregate.getName()); assertEquals(details.getAvailabilityZone(), aggregate.getAvailabilityZone()); assertEquals(details.getHosts(), aggregate.getHosts()); } } }
public void testGetFailNotFound() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(404).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertNull(api.get("1")); }
public void testUpdateAvailabilityZone() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"aggregate\":{\"availability_zone\":\"zone1\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.updateAvailabilityZone("1", "zone1"), exampleHostAggregate()); }
public void testRemoveHost() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"remove_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.removeHost("1", "ubuntu"), exampleHostAggregate()); }
public void testUpdateName() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"newaggregatename\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.updateName("1", "newaggregatename"), exampleHostAggregate()); }
public void testList() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_list.json")).build()) .getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); HostAggregate result = Iterables.getOnlyElement(api.list()); assertEquals(result, exampleHostAggregate()); }
public void testAddHost() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"add_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.addHost("1", "ubuntu"), exampleHostAggregate()); }
public void testSetMetadata() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate()); }
@Test(dependsOnMethods = "testCreateAggregate") public void testListAndGetAggregate() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); Set<? extends HostAggregate> aggregates = api.list().toSet(); for (HostAggregate aggregate : aggregates) { assertNotNull(aggregate.getId()); assertNotNull(aggregate.getName()); assertNotNull(aggregate.getAvailabilityZone()); HostAggregate details = api.get(aggregate.getId()); assertEquals(details.getId(), aggregate.getId()); assertEquals(details.getName(), aggregate.getName()); assertEquals(details.getAvailabilityZone(), aggregate.getAvailabilityZone()); assertEquals(details.getHosts(), aggregate.getHosts()); } } }
@Test(dependsOnMethods = "testCreateAggregate") public void testModifyMetadata() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); for (Map<String, String> theMetaData : ImmutableSet.of( ImmutableMap.of("somekey", "somevalue"), ImmutableMap.of("somekey", "some other value", "anotherkey", "another val") )) { // Apply changes HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData); // bug in openstack - metadata values are never removed, so we just checking what we've set for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } // Re-fetch to double-check details = api.get(testAggregate.getId()); for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } } } }
public void testGet() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_with_host_details.json")).build()) .getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.get("1"), exampleHostAggregateWithHost()); }
public void testUpdateAvailabilityZone() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"aggregate\":{\"availability_zone\":\"zone1\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.updateAvailabilityZone("1", "zone1"), exampleHostAggregate()); }
public void testRemoveHost() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"remove_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.removeHost("1", "ubuntu"), exampleHostAggregate()); }
public void testUpdateName() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"newaggregatename\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.updateName("1", "newaggregatename"), exampleHostAggregate()); }
public void testList() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_list.json")).build()) .getHostAggregateApi("az-1.region-a.geo-1").get(); HostAggregate result = Iterables.getOnlyElement(api.list()); assertEquals(result, exampleHostAggregate()); }
public void testAddHost() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"add_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.addHost("1", "ubuntu"), exampleHostAggregate()); }