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 2014/12/09 21:50:02 UTC
[1/2] jclouds-labs-google git commit: Added targetPool:AggregatedList,
getHealth. Updated HttpHealthCheck
Repository: jclouds-labs-google
Updated Branches:
refs/heads/master 8e4a17f57 -> 672b94269
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHealthStatusTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHealthStatusTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHealthStatusTest.java
new file mode 100644
index 0000000..b425db9
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHealthStatusTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+import java.net.URI;
+import javax.ws.rs.Consumes;
+
+import org.jclouds.googlecomputeengine.domain.HealthStatus;
+import org.jclouds.googlecomputeengine.domain.HealthStatus.HealthStatusInternal;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit")
+public class ParseHealthStatusTest extends BaseGoogleComputeEngineParseTest<HealthStatus> {
+
+ @Override
+ public String resource() {
+ return "/health_status_get_health.json";
+ }
+
+ @Override
+ @Consumes(APPLICATION_JSON)
+ public HealthStatus expected() {
+ return expected(BASE_URL);
+ }
+
+ @Consumes(APPLICATION_JSON)
+ public HealthStatus expected(String baseUrl) {
+ URI uri = URI.create(baseUrl + "/party/zones/us-central1-a/instances/"
+ + "jclouds-test");
+ return HealthStatus.create(
+ ImmutableList.of(HealthStatusInternal.create(
+ null, // ipAddress
+ 80, // port
+ uri, // instance
+ "HEALTHY" //healthState
+ )) //healthStatuses
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolListTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolListTest.java
index c4071e2..b53f805 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolListTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolListTest.java
@@ -38,8 +38,13 @@ public class ParseTargetPoolListTest extends BaseGoogleComputeEngineParseTest<Li
@Override @Consumes(APPLICATION_JSON)
public ListPage<TargetPool> expected() {
+ return expected(BASE_URL);
+ }
+
+ @Consumes(APPLICATION_JSON)
+ public ListPage<TargetPool> expected(String baseUrl) {
return ForwardingListPage.create( //
- ImmutableList.of(new ParseTargetPoolTest().expected()), // items
+ ImmutableList.of(new ParseTargetPoolTest().expected(baseUrl)), // items
null // nextPageToken
);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolTest.java
index 81f357c..efa2ee9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetPoolTest.java
@@ -36,12 +36,17 @@ public class ParseTargetPoolTest extends BaseGoogleComputeEngineParseTest<Target
@Override @Consumes(MediaType.APPLICATION_JSON)
public TargetPool expected() {
+ return expected(BASE_URL);
+ }
+
+ @Consumes(MediaType.APPLICATION_JSON)
+ public TargetPool expected(String baseUrl) {
return TargetPool.create( //
"5199309593612841404", // id
- URI.create(BASE_URL + "/party/regions/us-central1/targetPools/test-targetpool"), // selfLink
+ URI.create(baseUrl + "/party/regions/us-central1/targetPools/test-targetpool"), // selfLink
"test-targetpool", // name
null, // description
- URI.create(BASE_URL + "/party/regions/us-central1"), // region
+ URI.create(baseUrl + "/party/regions/us-central1"), // region
null, // healthChecks
null, // instances
SessionAffinityValue.NONE, // sessionAffinity
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/aggregated_target_pool_list.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/aggregated_target_pool_list.json b/google-compute-engine/src/test/resources/aggregated_target_pool_list.json
new file mode 100644
index 0000000..60fc7c6
--- /dev/null
+++ b/google-compute-engine/src/test/resources/aggregated_target_pool_list.json
@@ -0,0 +1,46 @@
+{
+ "kind": "compute#targetPoolAggregatedList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/party/aggregated/targetPools",
+ "id": "projects/party/aggregated/targetPools",
+ "items": {
+ "regions/asia-east1": {
+ "warning": {
+ "code": "NO_RESULTS_ON_PAGE",
+ "message": "There are no results for scope 'regions/asia-east1' on this page.",
+ "data": [
+ {
+ "key": "scope",
+ "value": "regions/asia-east1"
+ }
+ ]
+ }
+ },
+ "regions/europe-west1": {
+ "warning": {
+ "code": "NO_RESULTS_ON_PAGE",
+ "message": "There are no results for scope 'regions/europe-west1' on this page.",
+ "data": [
+ {
+ "key": "scope",
+ "value": "regions/europe-west1"
+ }
+ ]
+ }
+ },
+ "regions/us-central1": {
+ "targetPools": [
+ {
+
+ "kind": "compute#targetPool",
+ "id": "17592955481805765508",
+ "creationTimestamp": "2014-12-01T11:51:15.611-08:00",
+ "name": "test",
+ "description": "a Pool!",
+ "region": "https://www.googleapis.com/compute/v1/projects/party/regions/us-central1",
+ "sessionAffinity": "NONE",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/party/regions/us-central1/targetPools/test"
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/aggregated_target_pool_list_empty.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/aggregated_target_pool_list_empty.json b/google-compute-engine/src/test/resources/aggregated_target_pool_list_empty.json
new file mode 100644
index 0000000..9c10a7b
--- /dev/null
+++ b/google-compute-engine/src/test/resources/aggregated_target_pool_list_empty.json
@@ -0,0 +1,43 @@
+{
+ "kind": "compute#targetPoolAggregatedList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/party/aggregated/targetPools",
+ "id": "projects/party/aggregated/targetPools",
+ "items": {
+ "regions/asia-east1": {
+ "warning": {
+ "code": "NO_RESULTS_ON_PAGE",
+ "message": "There are no results for scope 'regions/asia-east1' on this page.",
+ "data": [
+ {
+ "key": "scope",
+ "value": "regions/asia-east1"
+ }
+ ]
+ }
+ },
+ "regions/europe-west1": {
+ "warning": {
+ "code": "NO_RESULTS_ON_PAGE",
+ "message": "There are no results for scope 'regions/europe-west1' on this page.",
+ "data": [
+ {
+ "key": "scope",
+ "value": "regions/europe-west1"
+ }
+ ]
+ }
+ },
+ "regions/us-central1": {
+ "warning": {
+ "code": "NO_RESULTS_ON_PAGE",
+ "message": "There are no results for scope 'regions/us-central1' on this page.",
+ "data": [
+ {
+ "key": "scope",
+ "value": "regions/us-central1"
+ }
+ ]
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/backend_service_get_health.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/backend_service_get_health.json b/google-compute-engine/src/test/resources/backend_service_get_health.json
deleted file mode 100644
index 7e01eed..0000000
--- a/google-compute-engine/src/test/resources/backend_service_get_health.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "kind": "compute#backendServiceGroupHealth",
- "healthStatus": [
- {
- "port": 80,
- "instance": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/jclouds-test",
- "healthState": "HEALTHY"
- }
- ]
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/health_status_get_health.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/health_status_get_health.json b/google-compute-engine/src/test/resources/health_status_get_health.json
new file mode 100644
index 0000000..62dcc0d
--- /dev/null
+++ b/google-compute-engine/src/test/resources/health_status_get_health.json
@@ -0,0 +1,10 @@
+{
+ "kind": "compute#backendServiceGroupHealth",
+ "healthStatus": [
+ {
+ "port": 80,
+ "instance": "https://www.googleapis.com/compute/v1/projects/party/zones/us-central1-a/instances/jclouds-test",
+ "healthState": "HEALTHY"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/httphealthcheck_insert.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/httphealthcheck_insert.json b/google-compute-engine/src/test/resources/httphealthcheck_insert.json
index 0564f1d..6ad0077 100644
--- a/google-compute-engine/src/test/resources/httphealthcheck_insert.json
+++ b/google-compute-engine/src/test/resources/httphealthcheck_insert.json
@@ -1 +1 @@
-{"name":"http-health-check","timeoutSec":0,"unhealthyThreshold":0}
+{"name":"http-health-check","requestPath":"/","port":80,"checkIntervalSec":5,"timeoutSec":0,"unhealthyThreshold":0,"healthyThreshold":2}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/resources/httphealthcheck_patch.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/httphealthcheck_patch.json b/google-compute-engine/src/test/resources/httphealthcheck_patch.json
new file mode 100644
index 0000000..65c089b
--- /dev/null
+++ b/google-compute-engine/src/test/resources/httphealthcheck_patch.json
@@ -0,0 +1 @@
+{"name":"http-health-check","timeoutSec":0,"unhealthyThreshold":0}
\ No newline at end of file
[2/2] jclouds-labs-google git commit: Added targetPool:AggregatedList,
getHealth. Updated HttpHealthCheck
Posted by na...@apache.org.
Added targetPool:AggregatedList, getHealth. Updated HttpHealthCheck
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/672b9426
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/672b9426
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/672b9426
Branch: refs/heads/master
Commit: 672b94269038f5fd6a3ddbd5514ff7cd9b7b6cac
Parents: 8e4a17f
Author: Daniel Broudy <br...@google.com>
Authored: Mon Dec 1 12:24:03 2014 -0800
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Dec 9 21:46:11 2014 +0100
----------------------------------------------------------------------
.../binders/HttpHealthCheckCreationBinder.java | 4 +-
.../domain/BackendServiceGroupHealth.java | 56 ----
.../domain/HealthStatus.java | 56 ++++
.../domain/HttpHealthCheck.java | 24 +-
.../features/AggregatedListApi.java | 51 ++++
.../features/BackendServiceApi.java | 4 +-
.../features/HttpHealthCheckApi.java | 2 +-
.../features/TargetPoolApi.java | 22 +-
.../options/HttpHealthCheckCreationOptions.java | 289 ++++++++++---------
.../HttpHealthCheckCreationBinderTest.java | 16 +-
.../features/AggregatedListApiLiveTest.java | 18 ++
.../features/AggregatedListApiMockTest.java | 34 ++-
.../features/BackendServiceApiMockTest.java | 6 +-
.../features/HttpHealthCheckApiExpectTest.java | 4 +-
.../features/HttpHealthCheckApiLiveTest.java | 43 +--
.../features/HttpHealthCheckApiMockTest.java | 8 +-
.../features/TargetPoolApiExpectTest.java | 263 -----------------
.../features/TargetPoolApiLiveTest.java | 73 +++--
.../features/TargetPoolApiMockTest.java | 178 ++++++++++++
.../parse/ParseBackendServiceGetHealthTest.java | 58 ----
.../parse/ParseHealthStatusTest.java | 58 ++++
.../parse/ParseTargetPoolListTest.java | 7 +-
.../parse/ParseTargetPoolTest.java | 9 +-
.../resources/aggregated_target_pool_list.json | 46 +++
.../aggregated_target_pool_list_empty.json | 43 +++
.../resources/backend_service_get_health.json | 10 -
.../resources/health_status_get_health.json | 10 +
.../test/resources/httphealthcheck_insert.json | 2 +-
.../test/resources/httphealthcheck_patch.json | 1 +
29 files changed, 773 insertions(+), 622 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinder.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinder.java
index 7b23a33..636cced 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinder.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinder.java
@@ -38,7 +38,7 @@ public class HttpHealthCheckCreationBinder extends BindToJsonPayload {
HttpHealthCheckBinderHelper helper = new HttpHealthCheckBinderHelper(name, options);
return super.bindToRequest(request, helper);
}
-
+
private class HttpHealthCheckBinderHelper{
/**
@@ -62,7 +62,7 @@ public class HttpHealthCheckCreationBinder extends BindToJsonPayload {
private Integer healthyThreshold;
@SuppressWarnings("unused")
private String description;
-
+
private HttpHealthCheckBinderHelper(String name, HttpHealthCheckCreationOptions httpHealthCheckCreationOptions){
this.name = name;
this.host = httpHealthCheckCreationOptions.host();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
deleted file mode 100644
index c31f64c..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.domain;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.json.SerializedNames;
-
-import com.google.auto.value.AutoValue;
-
-@AutoValue
-public abstract class BackendServiceGroupHealth {
-
- public abstract List<HealthStatus> healthStatus();
-
- @SerializedNames({"healthStatus"})
- public static BackendServiceGroupHealth create(List<HealthStatus> healthStatus){
- return new AutoValue_BackendServiceGroupHealth(healthStatus);
- }
-
- BackendServiceGroupHealth(){
- }
-
- @AutoValue
- public abstract static class HealthStatus {
-
- @Nullable public abstract String ipAddress();
- public abstract Integer port();
- public abstract URI instance();
- public abstract String healthState();
-
- @SerializedNames({"ipAddress", "port", "instance", "healthState"})
- public static HealthStatus create(String ipAddress, int port, URI instance, String healthState) {
- return new AutoValue_BackendServiceGroupHealth_HealthStatus(ipAddress, port, instance, healthState);
- }
-
- HealthStatus(){
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HealthStatus.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HealthStatus.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HealthStatus.java
new file mode 100644
index 0000000..9d8f65b
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HealthStatus.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class HealthStatus {
+
+ public abstract List<HealthStatusInternal> healthStatus();
+
+ @SerializedNames({"healthStatus"})
+ public static HealthStatus create(List<HealthStatusInternal> healthStatus){
+ return new AutoValue_HealthStatus(healthStatus);
+ }
+
+ HealthStatus(){
+ }
+
+ @AutoValue
+ public abstract static class HealthStatusInternal {
+
+ @Nullable public abstract String ipAddress();
+ public abstract Integer port();
+ public abstract URI instance();
+ public abstract String healthState();
+
+ @SerializedNames({"ipAddress", "port", "instance", "healthState"})
+ public static HealthStatusInternal create(String ipAddress, int port, URI instance, String healthState) {
+ return new AutoValue_HealthStatus_HealthStatusInternal(ipAddress, port, instance, healthState);
+ }
+
+ HealthStatusInternal(){
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HttpHealthCheck.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HttpHealthCheck.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HttpHealthCheck.java
index 0d49756..00553f7 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HttpHealthCheck.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/HttpHealthCheck.java
@@ -40,31 +40,23 @@ public abstract class HttpHealthCheck {
*/
@Nullable public abstract String host();
- public abstract String requestPath();
+ @Nullable public abstract String requestPath();
/** The TCP port number for the HTTP health check request. */
- public abstract int port();
+ @Nullable public abstract Integer port();
/** How often (in seconds) to send a health check. */
- public abstract int checkIntervalSec();
+ @Nullable public abstract Integer checkIntervalSec();
/** How long (in seconds) to wait before claiming failure. */
- public abstract int timeoutSec();
+ @Nullable public abstract Integer timeoutSec();
/** A so-far healthy VM will be marked unhealthy after this many consecutive failures. */
- public abstract int unhealthyThreshold();
+ @Nullable public abstract Integer unhealthyThreshold();
/** An unhealthy VM will be marked healthy after this many consecutive successes. */
- public abstract int healthyThreshold();
+ @Nullable public abstract Integer healthyThreshold();
- /**
- * @param requestPath Defaults to "/" when null.
- * @param port Defaults to 80 when null.
- * @param checkIntervalSec Defaults to 5 when null.
- * @param timeoutSec Defaults to 5 when null.
- * @param unhealthyThreshold Defaults to 2 when null.
- * @param healthyThreshold Defaults to 2 when null.
- */
@SerializedNames(
{ "id", "selfLink", "name", "description", "host", "requestPath", "port", "checkIntervalSec", "timeoutSec",
"unhealthyThreshold", "healthyThreshold" })
@@ -72,9 +64,7 @@ public abstract class HttpHealthCheck {
String requestPath, Integer port, Integer checkIntervalSec, Integer timeoutSec, Integer unhealthyThreshold,
Integer healthyThreshold) {
return new AutoValue_HttpHealthCheck(id, selfLink, name, description, host,
- requestPath != null ? requestPath : "/", port != null ? port : 80,
- checkIntervalSec != null ? checkIntervalSec : 5, timeoutSec != null ? timeoutSec : 5,
- unhealthyThreshold != null ? unhealthyThreshold : 2, healthyThreshold != null ? healthyThreshold : 2);
+ requestPath, port, checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold);
}
HttpHealthCheck() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java
index 55ff6b2..a663e42 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java
@@ -37,6 +37,7 @@ import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.TargetInstance;
+import org.jclouds.googlecomputeengine.domain.TargetPool;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
@@ -447,4 +448,54 @@ public interface AggregatedListApi {
};
}
}
+
+ /**
+ * Retrieves the list of TargetPool resources available to the
+ * specified project. By default the list as a maximum size of 100, if no
+ * options are provided or ListOptions#getMaxResults() has not been set.
+ *
+ * @param pageToken
+ * marks the beginning of the next list page
+ * @param listOptions
+ * listing options
+ * @return a page of the list
+ */
+ @Named("TargetPool:aggregatedList")
+ @GET
+ @Path("/targetPools")
+ ListPage<TargetPool> pageOfTargetPools(@Nullable @QueryParam("pageToken") String pageToken,
+ ListOptions listOptions);
+
+ /** @see #pageOfTargetPools(String, ListOptions) */
+ @Named("TargetPool:aggregatedList")
+ @GET
+ @Path("/targetPools")
+ @Transform(TargetPoolPages.class)
+ Iterator<ListPage<TargetPool>> targetPools();
+
+ /** @see #pageOfTargetPools(String, ListOptions) */
+ @Named("TargetPool:aggregatedList")
+ @GET
+ @Path("/targetPools")
+ @Transform(TargetPoolPages.class)
+ Iterator<ListPage<TargetPool>> targetPools(ListOptions options);
+
+ static final class TargetPoolPages extends BaseToIteratorOfListPage<TargetPool, TargetPoolPages> {
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ TargetPoolPages(GoogleComputeEngineApi api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<String, ListPage<TargetPool>> fetchNextPage(final ListOptions options) {
+ return new Function<String, ListPage<TargetPool>>() {
+ @Override
+ public ListPage<TargetPool> apply(String pageToken) {
+ return api.aggregatedList().pageOfTargetPools(pageToken, options);
+ }
+ };
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/BackendServiceApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/BackendServiceApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/BackendServiceApi.java
index f1e3776..629a342 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/BackendServiceApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/BackendServiceApi.java
@@ -37,7 +37,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecloud.domain.ListPage;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.BackendService;
-import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth;
+import org.jclouds.googlecomputeengine.domain.HealthStatus;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.BackendServiceOptions;
@@ -136,7 +136,7 @@ public interface BackendServiceApi {
@Produces(APPLICATION_JSON)
@Path("/{backendService}/getHealth")
@MapBinder(BindToJsonPayload.class)
- BackendServiceGroupHealth getHealth(@PathParam("backendService") String backendServiceName,
+ HealthStatus getHealth(@PathParam("backendService") String backendServiceName,
@PayloadParam("group") URI group);
/**
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
index c1153b1..17be678 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
@@ -122,7 +122,7 @@ public interface HttpHealthCheckApi {
/**
* Updates a HttpHealthCheck resource in the specified project using the data included in the request.
* Any options left blank will be overwritten!
- *
+ *
* @param name the name of the forwarding rule.
* @param options the options to set for the healthCheck
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
index 206a66b..e623c12 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
@@ -39,6 +39,7 @@ import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
import org.jclouds.googlecomputeengine.binders.TargetPoolCreationBinder;
+import org.jclouds.googlecomputeengine.domain.HealthStatus;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.TargetPool;
import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage;
@@ -105,7 +106,6 @@ public interface TargetPoolApi {
@POST
@Path("/{targetPool}/addInstance")
@MapBinder(TargetPoolChangeInstancesBinder.class)
- @Nullable
Operation addInstance(@PathParam("targetPool") String targetPool, @PayloadParam("instances") List<URI> instances);
/**
@@ -121,7 +121,6 @@ public interface TargetPoolApi {
@POST
@Path("/{targetPool}/removeInstance")
@MapBinder(TargetPoolChangeInstancesBinder.class)
- @Nullable
Operation removeInstance(@PathParam("targetPool") String targetPool, @PayloadParam("instances") List<URI> instances);
/**
@@ -137,7 +136,6 @@ public interface TargetPoolApi {
@POST
@Path("/{targetPool}/addHealthCheck")
@MapBinder(TargetPoolChangeHealthChecksBinder.class)
- @Nullable
Operation addHealthCheck(@PathParam("targetPool") String targetPool, @PayloadParam("healthChecks") List<URI> healthChecks);
@@ -150,13 +148,27 @@ public interface TargetPoolApi {
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
- @Named("TargetPools:removeHealthChek")
+ @Named("TargetPools:removeHealthCheck")
@POST
@Path("/{targetPool}/removeHealthCheck")
@MapBinder(TargetPoolChangeHealthChecksBinder.class)
- @Nullable
Operation removeHealthCheck(@PathParam("targetPool") String targetPool, @PayloadParam("healthChecks") List<URI> healthChecks);
+ /**
+ * Gets the HealthStatus of an instance in a targetPool.
+ *
+ * @param targetPool the name of the target pool.
+ * @param healthChecks the self-links of the health checks to be removed from the targetPool.
+ *
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("TargetPools:getHealth")
+ @POST
+ @Path("/{targetPool}/getHealth")
+ @MapBinder(BindToJsonPayload.class)
+ HealthStatus getHealth(@PathParam("targetPool") String targetPool, @PayloadParam("instance") URI instance);
+
/**
* Changes backup pool configurations.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
index 705b01b..a7af465 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
@@ -16,145 +16,154 @@
*/
package org.jclouds.googlecomputeengine.options;
-public class HttpHealthCheckCreationOptions {
-
- private String host;
- private String requestPath;
- private Integer port;
- private Integer checkIntervalSec;
- private Integer timeoutSec;
- private Integer unhealthyThreshold;
- private Integer healthyThreshold;
- private String description;
-
- /**
- * The value of the host header in the HTTP health check request.
- * @return host
- */
- public String host(){
- return host;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class HttpHealthCheckCreationOptions {
+
+ @Nullable public abstract String host();
+ @Nullable public abstract String requestPath();
+ @Nullable public abstract Integer port();
+ @Nullable public abstract Integer checkIntervalSec();
+ @Nullable public abstract Integer timeoutSec();
+ @Nullable public abstract Integer unhealthyThreshold();
+ @Nullable public abstract Integer healthyThreshold();
+ @Nullable public abstract String description();
+
+ static final String DEFAULT_REQUEST_PATH = "/";
+ static final Integer DEFAULT_PORT = 80;
+ static final Integer DEFAULT_CHECK_INTERVAL_SEC = 5;
+ static final Integer DEFAULT_TIMEOUT_SEC = 5;
+ static final Integer DEFAULT_UNHEALTHY_THRESHOLD = 2;
+ static final Integer DEFAULT_HEALTHY_THRESHOLD = 2;
+
+ /*
+ * Currently GCE is not setting the advertised defaults so we do so here.
+ * This only leads to trouble in the case of a PATCH operation which we now
+ * have a workaround for.
+ */
+ /**
+ * @param requestPath Defaults to {@value #DEFAULT_REQUEST_PATH} when null.
+ * @param port Defaults to {@value #DEFAULT_PORT} when null.
+ * @param checkIntervalSec Defaults to {@value #DEFAULT_CHECK_INTERVAL_SEC} when null.
+ * @param timeoutSec Defaults to {@value #DEFAULT_TIMEOUT_SEC} when null.
+ * @param unhealthyThreshold Defaults to {@value #DEFAULT_UNHEALTHY_THRESHOLD} when null.
+ * @param healthyThreshold Defaults to {@value #DEFAULT_HEALTHY_THRESHOLD} when null.
+ */
+ static HttpHealthCheckCreationOptions createWithDefaults(String host,
+ String requestPath, Integer port, Integer checkIntervalSec, Integer timeoutSec, Integer unhealthyThreshold,
+ Integer healthyThreshold, String description) {
+ return create(host, requestPath != null ? requestPath : DEFAULT_REQUEST_PATH, port != null ? port : DEFAULT_PORT,
+ checkIntervalSec != null ? checkIntervalSec : DEFAULT_CHECK_INTERVAL_SEC,
+ timeoutSec != null ? timeoutSec : DEFAULT_TIMEOUT_SEC,
+ unhealthyThreshold != null ? unhealthyThreshold : DEFAULT_UNHEALTHY_THRESHOLD,
+ healthyThreshold != null ? healthyThreshold : DEFAULT_HEALTHY_THRESHOLD, description);
+ }
+
+ @SerializedNames(
+ { "host", "requestPath", "port", "checkIntervalSec", "timeoutSec",
+ "unhealthyThreshold", "healthyThreshold", "description"})
+ static HttpHealthCheckCreationOptions create(String host, String requestPath, Integer port,
+ Integer checkIntervalSec, Integer timeoutSec, Integer unhealthyThreshold,
+ Integer healthyThreshold, String description) {
+ return new AutoValue_HttpHealthCheckCreationOptions(host, requestPath, port,
+ checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
+ }
+
+ HttpHealthCheckCreationOptions() {
+ }
+
+ public static class Builder {
+
+ private String host;
+ private String requestPath;
+ private Integer port;
+ private Integer checkIntervalSec;
+ private Integer timeoutSec;
+ private Integer unhealthyThreshold;
+ private Integer healthyThreshold;
+ private String description;
+
+
+ /** The value of the host header in the HTTP health check request. */
+ public Builder host(String host){
+ this.host = host;
+ return this;
+ }
+
+ /** The request path of the HTTP health check request. The default value is {@value #DEFAULT_REQUEST_PATH}. */
+ public Builder requestPath(String requestPath){
+ this.requestPath = requestPath;
+ return this;
+ }
+
+ /** The TCP port number for the HTTP health check request. The default value is {@value #DEFAULT_PORT}. */
+ public Builder port(Integer port){
+ this.port = port;
+ return this;
+ }
+
+ /** How often (in seconds) to send a health check. The default value is {@value #DEFAULT_CHECK_INTERVAL_SEC} seconds. */
+ public Builder checkIntervalSec(Integer checkIntervalSec){
+ this.checkIntervalSec = checkIntervalSec;
+ return this;
+ }
+
+ /** How long (in seconds) to wait before claiming failure. The default value is {@value #DEFAULT_TIMEOUT_SEC} seconds. */
+ public Builder timeoutSec(Integer timeoutSec){
+ this.timeoutSec = timeoutSec;
+ return this;
+ }
+
+ /**
+ * A so-far healthy VM will be marked unhealthy after this many consecutive failures.
+ * The default value is {@value #DEFAULT_UNHEALTHY_THRESHOLD}.
+ */
+ public Builder unhealthyThreshold(Integer unhealthyThreshold){
+ this.unhealthyThreshold = unhealthyThreshold;
+ return this;
+ }
+
+ /**
+ * An unhealthy VM will be marked healthy after this many consecutive successes.
+ * The default value is {@value #DEFAULT_HEALTHY_THRESHOLD}.
+ */
+ public Builder healthyThreshold(Integer healthyThreshold){
+ this.healthyThreshold = healthyThreshold;
+ return this;
+ }
+
+ /** An optional textual description of the TargetPool. */
+ public Builder description(String description){
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * Fields left as null will be replaced with their default before the request
+ * is made.
+ * @param requestPath Defaults to {@value #DEFAULT_REQUEST_PATH} when null.
+ * @param port Defaults to {@value #DEFAULT_PORT} when null.
+ * @param checkIntervalSec Defaults to {@value #DEFAULT_CHECK_INTERVAL_SEC} when null.
+ * @param timeoutSec Defaults to {@value #DEFAULT_TIMEOUT_SEC} when null.
+ * @param unhealthyThreshold Defaults to {@value #DEFAULT_UNHEALTHY_THRESHOLD} when null.
+ * @param healthyThreshold Defaults to {@value #DEFAULT_HEALTHY_THRESHOLD} when null.
+ */
+ public HttpHealthCheckCreationOptions buildWithDefaults() {
+ return HttpHealthCheckCreationOptions.createWithDefaults(host, requestPath, port,
+ checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
+ }
+
+ /**
+ * Useful when performing a PATCH operation and you do not want to overwrite
+ * unspecified values with the default values.
+ */
+ public HttpHealthCheckCreationOptions buildNoDefaults() {
+ return HttpHealthCheckCreationOptions.create(host, requestPath, port,
+ checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
+ }
}
-
- /**
- * The request path of the HTTP health check request. The default value is /.
- * @return requestPath
- */
- public String requestPath(){
- return requestPath;
- }
-
- /**
- * The TCP port number for the HTTP health check request. The default value is 80.
- * @return port
- */
- public Integer port(){
- return port;
- }
-
- /**
- * How often (in seconds) to send a health check. The default value is 5 seconds.
- * @return checkIntervalSec
- */
- public Integer checkIntervalSec(){
- return checkIntervalSec;
- }
-
- /**
- * How long (in seconds) to wait before claiming failure. The default value is 5 seconds.
- * @return timeoutSec
- */
- public Integer timeoutSec(){
- return timeoutSec;
- }
-
- /**
- * A so-far healthy VM will be marked unhealthy after this many consecutive failures.
- * The default value is 2.
- * @return unhealthyThreashold
- */
- public Integer unhealthyThreshold(){
- return unhealthyThreshold;
- }
-
- /**
- * An unhealthy VM will be marked healthy after this many consecutive successes.
- * The default value is 2.
- * @return healthyThreashold
- */
- public Integer healthyThreshold(){
- return healthyThreshold;
- }
-
- /**
- * An optional textual description of the TargetPool.
- * @return description, provided by the client.
- */
- public String description(){
- return description;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#host()
- */
- public HttpHealthCheckCreationOptions host(String host){
- this.host = host;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#requestPath()
- */
- public HttpHealthCheckCreationOptions requestPath(String requestPath){
- this.requestPath = requestPath;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#port()
- */
- public HttpHealthCheckCreationOptions port(Integer port){
- this.port = port;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#checkIntervalSec()
- */
- public HttpHealthCheckCreationOptions checkIntervalSec(Integer checkIntervalSec){
- this.checkIntervalSec = checkIntervalSec;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#timeoutSec()
- */
- public HttpHealthCheckCreationOptions timeoutSec(Integer timeoutSec){
- this.timeoutSec = timeoutSec;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#unhealthyThreshold()
- */
- public HttpHealthCheckCreationOptions unhealthyThreshold(Integer unhealthyThreshold){
- this.unhealthyThreshold = unhealthyThreshold;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#healthyThreshold()
- */
- public HttpHealthCheckCreationOptions healthyThreshold(Integer healthyThreshold){
- this.healthyThreshold = healthyThreshold;
- return this;
- }
-
- /**
- * @see HttpHealthCheckCreationOptions#description()
- */
- public HttpHealthCheckCreationOptions description(String description){
- this.description = description;
- return this;
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
index e9a8fe4..fa4466f 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
@@ -32,7 +32,7 @@ import com.google.gson.Gson;
@Test(groups = "unit", testName = "HttpHealthCheckCreationBinderTest")
public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
-
+
private String NAME = "testHttpHealthCheck";
private Integer TIMEOUTSEC = 3;
private Integer UNHEALTHYTHRESHOLD = 5;
@@ -40,15 +40,16 @@ public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineEx
private static String DESCRIPTION = "This is a test!";
Json json = new GsonWrapper(new Gson());
-
+
@Test
public void testMap() throws SecurityException, NoSuchMethodException {
HttpHealthCheckCreationBinder binder = new HttpHealthCheckCreationBinder(json);
- HttpHealthCheckCreationOptions httpHealthCheckCreationOptions = new HttpHealthCheckCreationOptions()
+ HttpHealthCheckCreationOptions httpHealthCheckCreationOptions = new HttpHealthCheckCreationOptions.Builder()
.timeoutSec(TIMEOUTSEC)
.unhealthyThreshold(UNHEALTHYTHRESHOLD)
.healthyThreshold(HEALTHYTHRESHOLD)
- .description(DESCRIPTION);
+ .description(DESCRIPTION)
+ .buildWithDefaults();
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
Map<String, Object> postParams = ImmutableMap.of("name", NAME, "options", httpHealthCheckCreationOptions);
@@ -56,8 +57,11 @@ public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineEx
binder.bindToRequest(request, postParams);
assertEquals(request.getPayload().getRawContent(),
- "{\""
- + "name\":\"" + NAME + "\","
+ "{"
+ + "\"name\":\"" + NAME + "\","
+ + "\"requestPath\":\"/\","
+ + "\"port\":80,"
+ + "\"checkIntervalSec\":5,"
+ "\"timeoutSec\":" + TIMEOUTSEC + ","
+ "\"unhealthyThreshold\":" + UNHEALTHYTHRESHOLD + ","
+ "\"healthyThreshold\":" + HEALTHYTHRESHOLD + ","
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
index c1e2f62..00bb650 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
@@ -31,6 +31,7 @@ import org.jclouds.googlecomputeengine.domain.ForwardingRule;
import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.TargetInstance;
+import org.jclouds.googlecomputeengine.domain.TargetPool;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.testng.SkipException;
import org.testng.annotations.Test;
@@ -147,4 +148,21 @@ public class AggregatedListApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
}
assertEquals(count, 2);
}
+
+ public void targetPools() {
+ Iterator<ListPage<TargetPool>> pageIterator = api().targetPools(maxResults(1));
+ // make sure that in spite of having only one result per page we get at
+ // least two results
+ int count = 0;
+ for (; count < 2 && pageIterator.hasNext();) {
+ ListPage<TargetPool> result = pageIterator.next();
+ if (!result.isEmpty()) {
+ count++;
+ }
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough target pools");
+ }
+ assertEquals(count, 2);
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
index a02ec07..1d8bf0a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
@@ -35,7 +35,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/machineTypes");
}
- public void machineTypesResponseIs4xx() throws Exception {
+ public void machineTypes_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_instance_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -55,7 +55,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/instances");
}
- public void instancesResponseIs4xx() throws Exception {
+ public void instances_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_instance_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -75,7 +75,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/addresses");
}
- public void addressesResponseIs4xx() throws Exception {
+ public void addresses_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_address_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -95,7 +95,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/disks");
}
- public void disksResponseIs4xx() throws Exception {
+ public void disks_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_disk_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -115,7 +115,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/diskTypes");
}
- public void diskTypesResponseIs4xx() throws Exception {
+ public void diskTypes_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_disktype_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -135,7 +135,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/operations");
}
- public void globalOperationsResponseIs4xx() throws Exception {
+ public void globalOperations_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_global_operation_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -175,7 +175,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/targetInstances");
}
- public void targetInstancesResponseIs4xx() throws Exception {
+ public void targetInstances_4xx() throws Exception {
server.enqueue(jsonResponse("/aggregated_target_instance_list_empty.json"));
AggregatedListApi aggregatedList = api().aggregatedList();
@@ -184,4 +184,24 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
assertSent(server, "GET", "/projects/party/aggregated/targetInstances");
}
+
+ public void targetPools() throws Exception {
+ server.enqueue(jsonResponse("/aggregated_target_pool_list.json"));
+
+ AggregatedListApi aggregatedList = api().aggregatedList();
+
+ assertTrue(aggregatedList.targetPools().hasNext());
+
+ assertSent(server, "GET", "/projects/party/aggregated/targetPools");
+ }
+
+ public void targetPools_4xx() throws Exception {
+ server.enqueue(jsonResponse("/aggregated_target_pool_list_empty.json"));
+
+ AggregatedListApi aggregatedList = api().aggregatedList();
+
+ assertFalse(aggregatedList.targetPools().hasNext());
+
+ assertSent(server, "GET", "/projects/party/aggregated/targetPools");
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
index 0434401..ba5bfe0 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
@@ -25,7 +25,7 @@ import java.util.List;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
import org.jclouds.googlecomputeengine.options.BackendServiceOptions;
-import org.jclouds.googlecomputeengine.parse.ParseBackendServiceGetHealthTest;
+import org.jclouds.googlecomputeengine.parse.ParseHealthStatusTest;
import org.jclouds.googlecomputeengine.parse.ParseBackendServiceListTest;
import org.jclouds.googlecomputeengine.parse.ParseBackendServiceTest;
import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
@@ -118,13 +118,13 @@ public class BackendServiceApiMockTest extends BaseGoogleComputeEngineApiMockTes
}
public void getHealth() throws Exception {
- server.enqueue(jsonResponse("/backend_service_get_health.json"));
+ server.enqueue(jsonResponse("/health_status_get_health.json"));
URI group = URI.create("https://www.googleapis.com/resourceviews/v1beta1/"
+ "projects/myproject/zones/us-central1-a/"
+ "resourceViews/jclouds-test");
assertEquals(backendServiceApi().getHealth("jclouds-test", group),
- new ParseBackendServiceGetHealthTest().expected(url("/projects")));
+ new ParseHealthStatusTest().expected(url("/projects")));
assertSent(server, "POST", "/projects/party/global/backendServices/jclouds-test/getHealth",
stringFromResource("/backend_service_get_health_request.json"));
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
index 1e1549a..2b50537 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
@@ -39,7 +39,7 @@ public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineExpectT
.endpoint(BASE_URL + "/party/global/httpHealthChecks/" + healthCheckName)
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/httphealthcheck_insert.json", MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/httphealthcheck_patch.json", MediaType.APPLICATION_JSON))
.build();
HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(200)
@@ -48,7 +48,7 @@ public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineExpectT
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, patch,
insertHttpHealthCheckResponse).httpHeathChecks();
- HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions().timeoutSec(0).unhealthyThreshold(0);
+ HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder().timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
assertEquals(api.patch(healthCheckName, options), new ParseGlobalOperationTest().expected());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
index e8863da..ec2cad8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
@@ -32,7 +32,7 @@ import com.google.common.collect.Iterables;
public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String HTTP_HEALTH_CHECK_NAME = "http-health-check-api-live-test";
- private static final int OFFSET = 2;
+ private static final Integer OFFSET = 2;
private HttpHealthCheckCreationOptions options;
@@ -42,13 +42,14 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live")
public void testInsertHttpHealthCheck() {
- options = new HttpHealthCheckCreationOptions()
+ options = new HttpHealthCheckCreationOptions.Builder()
.port(56)
.checkIntervalSec(40)
.timeoutSec(40)
.healthyThreshold(30)
.unhealthyThreshold(15)
- .description("A First Health Check!");
+ .description("A First Health Check!")
+ .buildWithDefaults();
assertOperationDoneSuccessfully(api().insert(HTTP_HEALTH_CHECK_NAME, options));
}
@@ -57,11 +58,11 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
assertNotNull(httpHealthCheck);
assertEquals(httpHealthCheck.name(), HTTP_HEALTH_CHECK_NAME);
- assertEquals(httpHealthCheck.port(), options.port().intValue());
- assertEquals(httpHealthCheck.checkIntervalSec(), options.checkIntervalSec().intValue());
- assertEquals(httpHealthCheck.timeoutSec(), options.timeoutSec().intValue());
- assertEquals(httpHealthCheck.healthyThreshold(), options.healthyThreshold().intValue());
- assertEquals(httpHealthCheck.unhealthyThreshold(), options.unhealthyThreshold().intValue());
+ assertEquals(httpHealthCheck.port(), options.port());
+ assertEquals(httpHealthCheck.checkIntervalSec(), options.checkIntervalSec());
+ assertEquals(httpHealthCheck.timeoutSec(), options.timeoutSec());
+ assertEquals(httpHealthCheck.healthyThreshold(), options.healthyThreshold());
+ assertEquals(httpHealthCheck.unhealthyThreshold(), options.unhealthyThreshold());
assertEquals(httpHealthCheck.description(), options.description());
}
@@ -73,44 +74,46 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live", dependsOnMethods = "testGetHttpHealthCheck")
public void testPatchHttpHealthCheck() {
- HttpHealthCheckCreationOptions newOptions = new HttpHealthCheckCreationOptions()
+ HttpHealthCheckCreationOptions newOptions = new HttpHealthCheckCreationOptions.Builder()
.port(options.port() + OFFSET)
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
- .timeoutSec(options.timeoutSec() + OFFSET);
+ .timeoutSec(options.timeoutSec() + OFFSET)
+ .buildNoDefaults();
assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
// Check changes happened and others unchanged.
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
assertNotNull(httpHealthCheck);
assertEquals(httpHealthCheck.name(), HTTP_HEALTH_CHECK_NAME);
- assertEquals(httpHealthCheck.port(), newOptions.port().intValue());
- assertEquals(httpHealthCheck.checkIntervalSec(), newOptions.checkIntervalSec().intValue());
- assertEquals(httpHealthCheck.timeoutSec(), newOptions.timeoutSec().intValue());
- assertEquals(httpHealthCheck.healthyThreshold(), options.healthyThreshold().intValue());
- assertEquals(httpHealthCheck.unhealthyThreshold(), options.unhealthyThreshold().intValue());
+ assertEquals(httpHealthCheck.port(), newOptions.port());
+ assertEquals(httpHealthCheck.checkIntervalSec(), newOptions.checkIntervalSec());
+ assertEquals(httpHealthCheck.timeoutSec(), newOptions.timeoutSec());
+ assertEquals(httpHealthCheck.healthyThreshold(), options.healthyThreshold());
+ assertEquals(httpHealthCheck.unhealthyThreshold(), options.unhealthyThreshold());
assertEquals(httpHealthCheck.description(), options.description());
}
@Test(groups = "live", dependsOnMethods = "testPatchHttpHealthCheck")
public void testUpdateHttpHealthCheck() {
- HttpHealthCheckCreationOptions newOptions = new HttpHealthCheckCreationOptions()
+ HttpHealthCheckCreationOptions newOptions = new HttpHealthCheckCreationOptions.Builder()
.checkIntervalSec(options.checkIntervalSec() - OFFSET)
- .timeoutSec(options.timeoutSec() - OFFSET);
+ .timeoutSec(options.timeoutSec() - OFFSET)
+ .buildWithDefaults();
assertOperationDoneSuccessfully(api().update(HTTP_HEALTH_CHECK_NAME, newOptions));
// Check changes happened.
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
assertNotNull(httpHealthCheck);
assertEquals(httpHealthCheck.name(), HTTP_HEALTH_CHECK_NAME);
- assertEquals(httpHealthCheck.checkIntervalSec(), newOptions.checkIntervalSec().intValue());
- assertEquals(httpHealthCheck.timeoutSec(), newOptions.timeoutSec().intValue());
+ assertEquals(httpHealthCheck.checkIntervalSec(), newOptions.checkIntervalSec());
+ assertEquals(httpHealthCheck.timeoutSec(), newOptions.timeoutSec());
// Update overwrites unspecified parameters to their defaults.
assertNotEquals(httpHealthCheck.healthyThreshold(), options.healthyThreshold());
assertNotEquals(httpHealthCheck.unhealthyThreshold(), options.unhealthyThreshold());
assertNotEquals(httpHealthCheck.description(), options.description());
}
- @Test(groups = "live", dependsOnMethods = {"testListHttpHealthCheck", "testUpdateHttpHealthCheck"})
+ @Test(groups = "live", dependsOnMethods = {"testListHttpHealthCheck", "testUpdateHttpHealthCheck"}, alwaysRun = true)
public void testDeleteHttpHealthCheck() {
assertOperationDoneSuccessfully(api().delete(HTTP_HEALTH_CHECK_NAME));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
index 35b4e03..2943a33 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
@@ -49,8 +49,8 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
public void insert() throws Exception {
server.enqueue(jsonResponse("/global_operation.json"));
- HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions()
- .timeoutSec(0).unhealthyThreshold(0);
+ HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
+ .timeoutSec(0).unhealthyThreshold(0).buildWithDefaults();
assertEquals(httpHealthCheckApi().insert("http-health-check", options),
new ParseGlobalOperationTest().expected(url("/projects")));
@@ -78,8 +78,8 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
public void update() throws Exception {
server.enqueue(jsonResponse("/global_operation.json"));
- HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions()
- .timeoutSec(0).unhealthyThreshold(0);
+ HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
+ .timeoutSec(0).unhealthyThreshold(0).buildWithDefaults();
assertEquals(httpHealthCheckApi().update("http-health-check", options),
new ParseGlobalOperationTest().expected(url("/projects")));
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
deleted file mode 100644
index 6d5c4a7..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.net.URI;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
-import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
-import org.jclouds.googlecomputeengine.parse.ParseTargetPoolListTest;
-import org.jclouds.googlecomputeengine.parse.ParseTargetPoolTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "TargetPoolApiExpectTest")
-public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
- private static final List<URI> INSTANCES = ImmutableList
- .of(URI.create(BASE_URL + "/party/zones/europe-west1-a/instances/test"));
-
- private static final List<URI> HEALTH_CHECKS = ImmutableList
- .of(URI.create(BASE_URL + "/party/global/httpHealthChecks/health-check-1"));
-
- private static final URI TARGET_POOL = URI.create(BASE_URL + "/party/regions/us-central1/targetPools/tpool");
-
- public void testGetTargetPoolResponseIs2xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/targetpool_get.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.get("test"), new ParseTargetPoolTest().expected());
- }
-
- public void testGetTargetPoolResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, response).targetPoolsInRegion("us-central1");
-
- assertNull(api.get("test"));
- }
-
- public void testInsertTargetPoolResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/targetpool_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertTargetPoolResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertTargetPoolResponse).targetPoolsInRegion("us-central1");
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
- assertEquals(api.create("test", targetPoolCreationOptions), new ParseRegionOperationTest().expected());
- }
-
- public void testDeleteTargetPoolResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/test-targetPool")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).targetPoolsInRegion("us-central1");
-
- assertEquals(api.delete("test-targetPool"),
- new ParseRegionOperationTest().expected());
- }
-
- public void testDeleteTargetPoolResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/test-targetPool")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).targetPoolsInRegion("us-central1");
-
- assertNull(api.delete("test-targetPool"));
- }
-
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public void list() {
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/targetpool_list.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.list().next(), new ParseTargetPoolListTest().expected());
- }
-
- public void listEmpty() {
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/list_empty.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, response).targetPoolsInRegion("us-central1");
-
- assertFalse(api.list().hasNext());
- }
-
- public void testAddInstanceResponseIs2xx() throws Exception {
- HttpRequest addInstance = makeGenericRequest("POST", "addInstance", "/targetpool_addinstance.json");
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, addInstance, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.addInstance("test", INSTANCES),
- new ParseRegionOperationTest().expected());
- }
-
- public void testRemoveInstanceResponseIs2xx(){
- HttpRequest removeInstance = makeGenericRequest("POST", "removeInstance", "/targetpool_addinstance.json");
-
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, removeInstance, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.removeInstance("test", INSTANCES),
- new ParseRegionOperationTest().expected());
- }
-
- public void testAddHealthCheckResponseIs2xx(){
- HttpRequest addHealthCheck = makeGenericRequest("POST", "addHealthCheck", "/targetpool_changehealthcheck.json");
-
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, addHealthCheck, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.addHealthCheck("test", HEALTH_CHECKS), new ParseRegionOperationTest().expected());
- }
-
- public void testRemoveHealthCheckResponseIs2xx(){
- HttpRequest removeHealthCheck = makeGenericRequest("POST", "removeHealthCheck", "/targetpool_changehealthcheck.json");
-
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, removeHealthCheck, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.removeHealthCheck("test", HEALTH_CHECKS), new ParseRegionOperationTest().expected());
- }
-
- public void testSetBackupResponseIs2xx(){
- HttpRequest SetBackup = HttpRequest
- .builder()
- .method("POST")
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/testpool/setBackup")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/targetpool_setbackup.json", MediaType.APPLICATION_JSON))
- .build();
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, SetBackup, response).targetPoolsInRegion("us-central1");
-
- assertEquals(api.setBackup("testpool", TARGET_POOL), new ParseRegionOperationTest().expected());
- }
-
- public void testSetBackupWithFailoverRatioResponseIs2xx(){
- HttpRequest SetBackup = HttpRequest
- .builder()
- .method("POST")
- .endpoint(BASE_URL + "/party/regions/"
- + "us-central1/targetPools/testpool/setBackup?failoverRatio=0.5")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/targetpool_setbackup.json", MediaType.APPLICATION_JSON))
- .build();
- HttpResponse response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, SetBackup, response).targetPoolsInRegion("us-central1");
-
- Float failoverRatio = Float.valueOf("0.5");
- assertEquals(api.setBackup("testpool", failoverRatio, TARGET_POOL), new ParseRegionOperationTest().expected());
- }
-
- public HttpRequest makeGenericRequest(String method, String endpoint, String requestPayloadFile){
- HttpRequest request = HttpRequest
- .builder()
- .method(method)
- .endpoint(BASE_URL + "/party/regions/us-central1/targetPools/test/" + endpoint)
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType(requestPayloadFile, MediaType.APPLICATION_JSON))
- .build();
- return request;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
index 1744076..d94a616 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
@@ -26,12 +26,15 @@ import java.util.ArrayList;
import java.util.List;
import org.jclouds.googlecloud.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.HealthStatus;
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.NewInstance;
import org.jclouds.googlecomputeengine.domain.TargetPool;
+import org.jclouds.googlecomputeengine.domain.ForwardingRule.IPProtocol;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
@@ -54,8 +57,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String INSTANCE_NAME = "target-pool-api-live-test-instance";
private static final String IPV4_RANGE = "10.0.0.0/8";
private static final String HEALTHCHECK_NAME = "target-pool-test-health-check";
-
- private static final int DEFAULT_DISK_SIZE_GB = 10;
+ private static final String FORWARDING_RULE_NAME = "target-pool-api-forwarding-rule";
private List<URI> instances;
private List<URI> httpHealthChecks;
@@ -64,7 +66,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
return api.targetPoolsInRegion(DEFAULT_REGION_NAME);
}
- @Test(groups = "live")
+ @Test(groups = "live", dependsOnMethods = "testInsertTargetPool2")
public void testCreateInstanceAndHealthCheck(){
InstanceApi instanceApi = api.instancesInZone(DEFAULT_ZONE_NAME);
HttpHealthCheckApi httpHealthCheckApi = api.httpHeathChecks();
@@ -99,14 +101,27 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
instances.add(instance.selfLink());
// Create a healthCheck
- HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions()
- .checkIntervalSec(30)
- .timeoutSec(20)
- .description("A test HealthCheck for adding to targetPools");
+ HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
+ .checkIntervalSec(3)
+ .timeoutSec(2)
+ .description("A test HealthCheck for adding to targetPools")
+ .buildWithDefaults();
assertOperationDoneSuccessfully(httpHealthCheckApi.insert(HEALTHCHECK_NAME, options));
HttpHealthCheck healthCheck = httpHealthCheckApi.get(HEALTHCHECK_NAME);
httpHealthChecks = new ArrayList<URI>();
httpHealthChecks.add(healthCheck.selfLink());
+
+ // Create a forwarding rule
+ TargetPool targetPool = api().get(TARGETPOOL_NAME);
+ URI target = targetPool.selfLink();
+
+ ForwardingRuleCreationOptions forwardingRuleOptions = new ForwardingRuleCreationOptions()
+ .ipProtocol(IPProtocol.TCP)
+ .portRange("80-80")
+ .target(target);
+
+ assertOperationDoneSuccessfully(api.forwardingRulesInRegion(DEFAULT_REGION_NAME)
+ .create(FORWARDING_RULE_NAME, forwardingRuleOptions));
}
@Test(groups = "live")
@@ -148,24 +163,13 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool", "testCreateInstanceAndHealthCheck"})
public void testAddInstanceTargetPool() {
- assertOperationDoneSuccessfully(api().addInstance(BACKUP_TARGETPOOL_NAME, instances));
- TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
+ assertOperationDoneSuccessfully(api().addInstance(TARGETPOOL_NAME, instances));
+ TargetPool targetPool = api().get(TARGETPOOL_NAME);
assertNotNull(targetPool);
- assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME);
+ assertEquals(targetPool.name(), TARGETPOOL_NAME);
assertEquals(targetPool.instances(), instances);
}
- @Test(groups = "live", dependsOnMethods = "testAddInstanceTargetPool")
- public void testRemoveInstanceTargetPool() {
- assertOperationDoneSuccessfully(api().removeInstance(BACKUP_TARGETPOOL_NAME, instances));
-
- TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
-
- assertNotNull(targetPool);
- assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME);
- assertNotEquals(targetPool.instances(), instances);
- }
-
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2", "testCreateInstanceAndHealthCheck"})
public void testAddHealthCheckTargetPool() {
assertOperationDoneSuccessfully(api().addHealthCheck(TARGETPOOL_NAME, httpHealthChecks));
@@ -175,7 +179,31 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
assertEquals(targetPool.healthChecks(), httpHealthChecks);
}
- @Test(groups = "live", dependsOnMethods = "testAddHealthCheckTargetPool")
+ @Test(groups = "live", dependsOnMethods = {"testAddHealthCheckTargetPool", "testAddInstanceTargetPool"} )
+ public void testGetHealthTargetPool() {
+ TargetPool targetPool = api().get(TARGETPOOL_NAME);
+ assertNotNull(targetPool);
+ assertEquals(targetPool.instances(), instances);
+ assertEquals(targetPool.healthChecks(), httpHealthChecks);
+
+ HealthStatus healthStatus = api().getHealth(TARGETPOOL_NAME, instances.get(0));
+ assertNotNull(healthStatus);
+ assertEquals(healthStatus.healthStatus().get(0).instance(), instances.get(0));
+ assertEquals(healthStatus.healthStatus().get(0).healthState(), "UNHEALTHY");
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetHealthTargetPool")
+ public void testRemoveInstanceTargetPool() {
+ assertOperationDoneSuccessfully(api().removeInstance(TARGETPOOL_NAME, instances));
+
+ TargetPool targetPool = api().get(TARGETPOOL_NAME);
+
+ assertNotNull(targetPool);
+ assertEquals(targetPool.name(), TARGETPOOL_NAME);
+ assertNotEquals(targetPool.instances(), instances);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetHealthTargetPool")
public void testRemoveHealthCheckTargetPool() {
assertOperationDoneSuccessfully(api().removeHealthCheck(TARGETPOOL_NAME, httpHealthChecks));
@@ -220,6 +248,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void testDeleteTargetPool() {
// Note: This ordering matters due one being the backup of the other ect.
assertOperationDoneSuccessfully(api().delete(THIRD_TARGETPOOL_NAME));
+ assertOperationDoneSuccessfully(api.forwardingRulesInRegion(DEFAULT_REGION_NAME).delete(FORWARDING_RULE_NAME));
assertOperationDoneSuccessfully(api().delete(TARGETPOOL_NAME));
assertOperationDoneSuccessfully(api().delete(BACKUP_TARGETPOOL_NAME));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
new file mode 100644
index 0000000..f45a384
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
+import org.jclouds.googlecomputeengine.parse.ParseHealthStatusTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseTargetPoolListTest;
+import org.jclouds.googlecomputeengine.parse.ParseTargetPoolTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "TargetPoolApiMockTest", singleThreaded = true)
+public class TargetPoolApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+ public void get() throws Exception {
+ server.enqueue(jsonResponse("/targetpool_get.json"));
+
+ assertEquals(targetPoolApi().get("test"),
+ new ParseTargetPoolTest().expected(url("/projects")));
+ assertSent(server, "GET", "/projects/party/regions/us-central1/targetPools/test");
+ }
+
+ public void get_4xx() throws Exception {
+ server.enqueue(response404());
+
+ assertNull(targetPoolApi().get("test"));
+ assertSent(server, "GET", "/projects/party/regions/us-central1/targetPools/test");
+ }
+
+ public void insert() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
+ assertEquals(targetPoolApi().create("test", targetPoolCreationOptions),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools",
+ stringFromResource("/targetpool_insert.json"));
+ }
+
+ public void delete() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ assertEquals(targetPoolApi().delete("test-targetPool"),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "DELETE", "/projects/party/regions/us-central1/targetPools/test-targetPool");
+ }
+
+ public void delete_4xx() throws Exception {
+ server.enqueue(response404());
+
+ assertNull(targetPoolApi().delete("test-targetPool"));
+ assertSent(server, "DELETE", "/projects/party/regions/us-central1/targetPools/test-targetPool");
+ }
+
+ public void list() throws Exception {
+ server.enqueue(jsonResponse("/targetpool_list.json"));
+
+ assertEquals(targetPoolApi().list().next(), new ParseTargetPoolListTest().expected(url("/projects")));
+ assertSent(server, "GET", "/projects/party/regions/us-central1/targetPools");
+ }
+
+ public void list_empty() throws Exception {
+ server.enqueue(jsonResponse("/list_empty.json"));
+
+ assertFalse(targetPoolApi().list().hasNext());
+ assertSent(server, "GET", "/projects/party/regions/us-central1/targetPools");
+ }
+
+ public void addInstance() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ List<URI> instances = ImmutableList
+ .of(URI.create(url("/projects/party/zones/europe-west1-a/instances/test")));
+
+ assertEquals(targetPoolApi().addInstance("test", instances),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test/addInstance",
+ stringFromResource("/targetpool_addinstance.json"));
+ }
+
+ public void removeInstance() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ List<URI> instances = ImmutableList
+ .of(URI.create(url("/projects/party/zones/europe-west1-a/instances/test")));
+
+ assertEquals(targetPoolApi().removeInstance("test", instances),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test/removeInstance",
+ stringFromResource("/targetpool_addinstance.json"));
+ }
+
+ public void addHealthCheck() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ List<URI> healthChecks = ImmutableList
+ .of(URI.create(url("/projects/party/global/httpHealthChecks/health-check-1")));
+
+ assertEquals(targetPoolApi().addHealthCheck("test", healthChecks),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test/addHealthCheck",
+ stringFromResource("/targetpool_changehealthcheck.json"));
+ }
+
+ public void removeHealthCheck() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ List<URI> healthChecks = ImmutableList
+ .of(URI.create(url("/projects/party/global/httpHealthChecks/health-check-1")));
+
+ assertEquals(targetPoolApi().removeHealthCheck("test", healthChecks),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test/removeHealthCheck",
+ stringFromResource("/targetpool_changehealthcheck.json"));
+ }
+
+ public void setBackup() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ URI backup = URI.create(url("/projects/party/regions/us-central1/targetPools/tpool"));
+
+ assertEquals(targetPoolApi().setBackup("test", backup),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test/setBackup",
+ stringFromResource("/targetpool_setbackup.json"));
+ }
+
+ public void setBackup_FailoverRatio() throws Exception {
+ server.enqueue(jsonResponse("/region_operation.json"));
+
+ URI backup = URI.create(url("/projects/party/regions/us-central1/targetPools/tpool"));
+
+ Float failoverRatio = Float.valueOf("0.5");
+ assertEquals(targetPoolApi().setBackup("test", failoverRatio, backup),
+ new ParseRegionOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/"
+ + "test/setBackup?failoverRatio=0.5",
+ stringFromResource("/targetpool_setbackup.json"));
+ }
+
+ public void getHealth() throws Exception {
+ server.enqueue(jsonResponse("/health_status_get_health.json"));
+
+ URI instance = URI.create(url("/party/zones/us-central1-a/instances/jclouds-test"));
+ assertEquals(targetPoolApi().getHealth("test-pool", instance),
+ new ParseHealthStatusTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools/test-pool/getHealth",
+ "{\"instance\": \"" + instance.toString() + "\"}");
+ }
+
+ public TargetPoolApi targetPoolApi() {
+ return api().targetPoolsInRegion("us-central1");
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/672b9426/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java
deleted file mode 100644
index 5eab529..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.parse;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-import java.net.URI;
-import javax.ws.rs.Consumes;
-
-import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth;
-import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth.HealthStatus;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit")
-public class ParseBackendServiceGetHealthTest extends BaseGoogleComputeEngineParseTest<BackendServiceGroupHealth> {
-
- @Override
- public String resource() {
- return "/backend_service_get_health.json";
- }
-
- @Override
- @Consumes(APPLICATION_JSON)
- public BackendServiceGroupHealth expected() {
- return expected(BASE_URL);
- }
-
- @Consumes(APPLICATION_JSON)
- public BackendServiceGroupHealth expected(String baseUrl) {
- URI uri = URI.create(baseUrl + "/myproject/zones/us-central1-a/instances/"
- + "jclouds-test");
- return BackendServiceGroupHealth.create(
- ImmutableList.of(HealthStatus.create(
- null, // ipAddress
- 80, // port
- uri, // instance
- "HEALTHY" //healthState
- )) //healthStatuses
- );
- }
-}