You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/11/03 14:20:07 UTC
jclouds git commit: Fix Google Compute Engine live tests
Repository: jclouds
Updated Branches:
refs/heads/master 1fc9b0e25 -> 667252d9e
Fix Google Compute Engine live tests
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/667252d9
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/667252d9
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/667252d9
Branch: refs/heads/master
Commit: 667252d9e87d9eb3c5bd55ab0c6666c1d0a7a2f7
Parents: 1fc9b0e
Author: Ignasi Barrera <na...@apache.org>
Authored: Mon Nov 2 23:09:00 2015 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Nov 3 00:16:40 2015 +0100
----------------------------------------------------------------------
.../GlobalForwardingRuleApiLiveTest.java | 24 ++++-----
.../features/InstanceApiLiveTest.java | 6 ++-
.../features/TargetInstanceApiLiveTest.java | 54 +++++++++++++++++++-
3 files changed, 68 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/667252d9/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
index 6245309..7aefc25 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
@@ -56,27 +56,24 @@ public class GlobalForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiL
@Test(groups = "live")
public void testInsertGlobalForwardingRule() {
-
assertOperationDoneSuccessfully(api.httpHeathChecks().insert(GLOBAL_FORWARDING_RULE_HEALTH_CHECK_NAME));
-
List<URI> healthChecks = ImmutableList.of(getHealthCheckUrl(GLOBAL_FORWARDING_RULE_HEALTH_CHECK_NAME));
BackendServiceOptions b = new BackendServiceOptions.Builder(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME, healthChecks).build();
assertOperationDoneSuccessfully(api.backendServices()
.create(b));
UrlMapOptions map = new UrlMapOptions.Builder().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)
- .description("simple url map")
- .defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)).build();
- assertOperationDoneSuccessfully(api.urlMaps()
- .create(map));
- assertOperationDoneSuccessfully(api.targetHttpProxies()
- .create(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME,
- getUrlMapUrl(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)));
- assertOperationDoneSuccessfully(
- api().create(GLOBAL_FORWARDING_RULE_NAME,
- new ForwardingRuleCreationOptions.Builder().target(getTargetHttpProxyUrl(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME))
- .portRange(PORT_RANGE).build()));
+ .description("simple url map")
+ .defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)).build();
+ assertOperationDoneSuccessfully(api.urlMaps().create(map));
+ assertOperationDoneSuccessfully(api.targetHttpProxies().create(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME,
+ getUrlMapUrl(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)));
+ assertOperationDoneSuccessfully(api().create(
+ GLOBAL_FORWARDING_RULE_NAME,
+ new ForwardingRuleCreationOptions.Builder()
+ .target(getTargetHttpProxyUrl(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME))
+ .description("jclodus-test").portRange(PORT_RANGE).build()));
}
@Test(groups = "live", dependsOnMethods = "testInsertGlobalForwardingRule")
@@ -87,6 +84,7 @@ public class GlobalForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiL
.target(getTargetHttpProxyUrl(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME))
.portRange("80-80")
.ipProtocol(IPProtocol.TCP)
+ .description("jclodus-test")
.build();
assertGlobalForwardingRuleEquals(forwardingRule, expected);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/667252d9/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
index e29633b..148ecb3 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
@@ -53,6 +53,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Ordering;
import com.google.inject.Module;
@Test(groups = "live", testName = "InstanceApiLiveTest")
@@ -347,7 +348,10 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private void assertInstanceEquals(Instance result, NewInstance expected) {
assertEquals(result.name(), expected.name());
assertEquals(result.metadata().asMap(), expected.metadata().asMap()); // ignore fingerprint!
- assertEquals(result.tags().items(), expected.tags().items());
+ // Do not assume tags come in the same order
+ List<String> resultTags = Ordering.from(String.CASE_INSENSITIVE_ORDER).sortedCopy(result.tags().items());
+ List<String> expectedTags = Ordering.from(String.CASE_INSENSITIVE_ORDER).sortedCopy(expected.tags().items());
+ assertEquals(resultTags, expectedTags);
}
@AfterClass(groups = { "integration", "live" })
http://git-wip-us.apache.org/repos/asf/jclouds/blob/667252d9/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetInstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetInstanceApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetInstanceApiLiveTest.java
index 3b25b40..9780d45 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetInstanceApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetInstanceApiLiveTest.java
@@ -20,25 +20,73 @@ import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+
import org.jclouds.googlecloud.domain.ListPage;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.NewInstance;
import org.jclouds.googlecomputeengine.domain.NewTargetInstance;
import org.jclouds.googlecomputeengine.domain.TargetInstance;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
+import com.google.inject.Module;
public class TargetInstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
- public static final String TARGET_INSTANCE_NAME = "test-target-instance-1";
+ private static final String INSTANCE_NAME = "test-target-instance-source-1";
+ private static final String INSTANCE_NETWORK_NAME = "test-target-instance-test-network";
+ private static final String IPV4_RANGE = "10.0.0.0/8";
+ private static final String TARGET_INSTANCE_NAME = "test-target-instance-1";
+
+ private Instance instance;
+
+ @Override
+ protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
+ GoogleComputeEngineApi api = super.create(props, modules);
+ List<Image> list = api.images().listInProject("centos-cloud", filter("name eq centos.*")).next();
+ URI imageUri = FluentIterable.from(list)
+ .filter(new Predicate<Image>() {
+ @Override
+ public boolean apply(Image input) {
+ // filter out all deprecated images
+ return !(input.deprecated() != null && input.deprecated().state() != null);
+ }
+ })
+ .first()
+ .get()
+ .selfLink();
+
+ NewInstance newInstance = NewInstance.create(
+ INSTANCE_NAME, // name
+ getDefaultMachineTypeUrl(), // machineType
+ getNetworkUrl(INSTANCE_NETWORK_NAME), // network
+ imageUri);
+
+ // need to insert the network first
+ assertOperationDoneSuccessfully(api.networks().createInIPv4Range
+ (INSTANCE_NETWORK_NAME, IPV4_RANGE));
+ assertOperationDoneSuccessfully(api.instancesInZone(DEFAULT_ZONE_NAME).create(newInstance));
+ instance = api.instancesInZone(DEFAULT_ZONE_NAME).get(INSTANCE_NAME);
+ assertNotNull(instance);
+
+ return api;
+ }
@Test(groups = "live")
public void testInsertTargetInstance(){
-
NewTargetInstance newTargetInstance = new NewTargetInstance.Builder()
.name(TARGET_INSTANCE_NAME)
.description("A test Target Instance")
+ .instance(instance.selfLink())
.build();
assertOperationDoneSuccessfully(api.targetInstancesInZone(DEFAULT_ZONE_NAME).create(newTargetInstance));
@@ -66,6 +114,8 @@ public class TargetInstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
@Test(groups = "live", dependsOnMethods = {"testListTargetInstance", "testGetTargetInstance"}, alwaysRun = true)
public void testDeleteTargetInstance(){
assertOperationDoneSuccessfully(api.targetInstancesInZone(DEFAULT_ZONE_NAME).delete(TARGET_INSTANCE_NAME));
+ assertOperationDoneSuccessfully(api.instancesInZone(DEFAULT_ZONE_NAME).delete(INSTANCE_NAME));
+ assertOperationDoneSuccessfully(api.networks().delete(INSTANCE_NETWORK_NAME));
}
private void assertTargetInstanceEquals(TargetInstance targetInstance){