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,
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(),
new ParseServerListTest().expected().toString());

View File

@ -68,7 +68,7 @@ public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
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(),
new ParseServerListTest().expected().toString());

View File

@ -63,7 +63,7 @@ public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiEx
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
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(),
new ParseServerListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
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(),
new ParseServerListTest().expected().toString());

View File

@ -63,7 +63,7 @@ public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiE
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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(),
new ParseServerListTest().expected().toString());

View File

@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Map;
import java.util.Properties;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.ComputeServiceContext;
@ -160,4 +161,12 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
public Injector apply(ComputeServiceContext input) {
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 java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@ -52,7 +53,17 @@ import com.google.inject.TypeLiteral;
*/
@Test(groups = "unit", testName = "NovaComputeServiceExpectTest")
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 {
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
assertEquals(node.getCredentials().getPrivateKey(), null);
}
}

View File

@ -45,7 +45,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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());
@ -56,7 +56,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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());
@ -76,7 +76,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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()
.toString(), new ParseFloatingIPListTest().expected().toString());

View File

@ -46,7 +46,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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());
@ -57,7 +57,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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());
@ -77,7 +77,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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()
.toString(), new ParseFloatingIPListTest().expected().toString());

View File

@ -53,7 +53,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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
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,
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()
.list().toString(), new ParseSecurityGroupListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class ExtensionApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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(),
new ParseExtensionListTest().expected().toString());

View File

@ -54,7 +54,7 @@ public class FlavorApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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(),
new ParseFlavorListTest().expected().toString());

View File

@ -57,7 +57,7 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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(),
new ParseImageListTest().expected().toString());

View File

@ -59,7 +59,7 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
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(),
new ParseServerListTest().expected().toString());

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.openstack.nova.v2_0.internal;
import java.util.Properties;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpRequest;
@ -73,14 +71,6 @@ public class BaseNovaExpectTest<T> extends BaseRestApiExpectTest<T> {
unmatchedExtensionsOfNovaResponse = HttpResponse.builder().statusCode(200)
.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
protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {