refactored openstack-nova expect tests so that they don't mask zone ids from subclasses

This commit is contained in:
Adrian Cole 2012-09-29 18:35:03 -07:00
parent 1f4e22c6c9
commit de9185ff01
16 changed files with 39 additions and 28 deletions

View File

@ -68,7 +68,7 @@ public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends Ba
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -68,7 +68,7 @@ public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -63,7 +63,7 @@ public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiEx
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -63,7 +63,7 @@ public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiE
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
@ -160,4 +161,12 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
public Injector apply(ComputeServiceContext input) { public Injector apply(ComputeServiceContext input) {
return input.utils().injector(); return input.utils().injector();
} }
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
// only specify one zone so that we don't have to configure requests for multiple zones
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1");
return overrides;
}
} }

View File

@ -26,6 +26,7 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -53,6 +54,16 @@ import com.google.inject.TypeLiteral;
@Test(groups = "unit", testName = "NovaComputeServiceExpectTest") @Test(groups = "unit", testName = "NovaComputeServiceExpectTest")
public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest { public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest {
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
// only specify limited zones so that we don't have to configure requests for multiple zones.
// since we are doing tests with keystone responses from hpcloud and also trystack, we have
// to whitelist one zone from each
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1,RegionOne");
return overrides;
}
public void testListLocationsWhenResponseIs2xx() throws Exception { public void testListLocationsWhenResponseIs2xx() throws Exception {
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder() Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
@ -316,4 +327,5 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
// we don't have access to this private key // we don't have access to this private key
assertEquals(node.getCredentials().getPrivateKey(), null); assertEquals(node.getCredentials().getPrivateKey(), null);
} }
} }

View File

@ -45,7 +45,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent()); assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
@ -56,7 +56,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent()); assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
@ -76,7 +76,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list() assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list()
.toString(), new ParseFloatingIPListTest().expected().toString()); .toString(), new ParseFloatingIPListTest().expected().toString());

View File

@ -46,7 +46,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent()); assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
@ -57,7 +57,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent()); assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
@ -77,7 +77,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().get() assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().get()
.toString(), new ParseFloatingIPListTest().expected().toString()); .toString(), new ParseFloatingIPListTest().expected().toString());

View File

@ -53,7 +53,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse); responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
// NOTE this required a change to the KeyPair domain object toString method // NOTE this required a change to the KeyPair domain object toString method
assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().toString(), assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().toString(),

View File

@ -59,7 +59,7 @@ public class SecurityGroupApiExpectTest extends BaseNovaApiExpectTest {
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
listResponse); listResponse);
assertEquals(apiWhenSecurityGroupsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenSecurityGroupsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get() assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
.list().toString(), new ParseSecurityGroupListTest().expected().toString()); .list().toString(), new ParseSecurityGroupListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class ExtensionApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, listExtensions, listExtensionsResponse); responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
assertEquals(apiWhenExtensionsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenExtensionsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").list().toString(), assertEquals(apiWhenExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").list().toString(),
new ParseExtensionListTest().expected().toString()); new ParseExtensionListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class FlavorApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, listFlavors, listFlavorsResponse); responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
assertEquals(apiWhenFlavorsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenFlavorsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseFlavorListTest().expected().toString()); new ParseFlavorListTest().expected().toString());

View File

@ -57,7 +57,7 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, list, listResponse); responseWithKeystoneAccess, list, listResponse);
assertEquals(apiWhenImagesExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenImagesExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenImagesExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenImagesExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseImageListTest().expected().toString()); new ParseImageListTest().expected().toString());

View File

@ -59,7 +59,7 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, listServers, listServersResponse); responseWithKeystoneAccess, listServers, listServersResponse);
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
new ParseServerListTest().expected().toString()); new ParseServerListTest().expected().toString());

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.openstack.nova.v2_0.internal; package org.jclouds.openstack.nova.v2_0.internal;
import java.util.Properties;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -74,14 +72,6 @@ public class BaseNovaExpectTest<T> extends BaseRestApiExpectTest<T> {
.payload(payloadFromResource("/extension_list.json")).build(); .payload(payloadFromResource("/extension_list.json")).build();
} }
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
// hpcloud or trystack
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1,RegionOne");
return overrides;
}
@Override @Override
protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) { protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
return HttpRequestComparisonType.JSON; return HttpRequestComparisonType.JSON;