@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 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 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")); }
@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()); } } }
@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()); } } }
@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 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 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 testGet() { 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).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_with_host_details.json")).build()) .getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.get("1"), exampleHostAggregateWithHost()); }