You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/07/29 19:36:48 UTC
[4/8] JCLOUDS-192. Move GCE to API v1beta15 - no new APIs added other
than Zone/GlobalOperations, which are needed for zone-scoping changes.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
index 91e37ab..ef88eb8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
@@ -16,47 +16,62 @@
*/
package org.jclouds.googlecomputeengine.compute;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.domain.Location;
-import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
-import org.jclouds.googlecomputeengine.domain.Instance;
-import org.jclouds.googlecomputeengine.features.InstanceApiExpectTest;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineServiceExpectTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.jclouds.googlecomputeengine.features.FirewallApiExpectTest.GET_FIREWALL_REQUEST;
+import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_REQUEST;
+import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_GOOGLE_IMAGES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_GOOGLE_IMAGES_RESPONSE;
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_REQUEST;
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_CENTRAL1B_INSTANCES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_CENTRAL1B_INSTANCES_RESPONSE;
import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_INSTANCES_REQUEST;
import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_INSTANCES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_CENTRAL1B_MACHINE_TYPES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE;
import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_REQUEST;
import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_RESPONSE;
import static org.jclouds.googlecomputeengine.features.NetworkApiExpectTest.GET_NETWORK_REQUEST;
-import static org.jclouds.googlecomputeengine.features.OperationApiExpectTest.GET_OPERATION_REQUEST;
-import static org.jclouds.googlecomputeengine.features.OperationApiExpectTest.GET_OPERATION_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_RESPONSE;
import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_REQ;
import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_SHORT_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ZoneOperationApiExpectTest.GET_ZONE_OPERATION_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ZoneOperationApiExpectTest.GET_ZONE_OPERATION_RESPONSE;
import static org.jclouds.util.Strings2.toStringAndClose;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.features.InstanceApiExpectTest;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineServiceExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
/**
* @author David Alves
@@ -64,20 +79,11 @@ import static org.testng.Assert.assertNotNull;
@Test(groups = "unit")
public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngineServiceExpectTest {
- public static final HttpRequest LIST_GOOGLE_IMAGES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/google/images")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_GOOGLE_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/image_list_single_page.json")).build();
private HttpRequest INSERT_NETWORK_REQUEST = HttpRequest
.builder()
.method("POST")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/global/networks")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"IPv4Range\":\"10.0.0.0/8\"}",
@@ -87,11 +93,11 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
private HttpRequest INSERT_FIREWALL_REQUEST = HttpRequest
.builder()
.method("POST")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/global/firewalls")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"network\":\"https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/jclouds-test\"," +
+ ".com/compute/v1beta15/projects/myproject/global/networks/jclouds-test\"," +
"\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," +
"\"ports\":[\"22\"]}," +
"{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}",
@@ -104,7 +110,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
" \"id\": \"13024414170909937976\",\n" +
" \"creationTimestamp\": \"2012-10-24T20:13:19.967\",\n" +
" \"selfLink\": \"https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/jclouds-test\",\n" +
+ ".com/compute/v1beta15/projects/myproject/global/networks/jclouds-test\",\n" +
" \"name\": \"jclouds-test\",\n" +
" \"description\": \"test network\",\n" +
" \"IPv4Range\": \"10.0.0.0/8\",\n" +
@@ -114,6 +120,17 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
private HttpResponse SUCESSFULL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/operation.json")).build();
+ private HttpRequest SET_TAGS_REQUEST = HttpRequest.builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"items\":[\"aTag\"],\"fingerprint\":\"abcd\"}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ private HttpResponse SET_TAGS_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
private HttpResponse getInstanceResponseForInstanceAndNetworkAndStatus(String instanceName, String networkName,
String status) throws
@@ -149,19 +166,17 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
return HttpRequest
.builder()
.method("POST")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/instances")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/zones/us-central1-a/instances")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "\"," +
"\"machineType\":\"https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1\"," +
- "\"zone\":\"https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/zones/us-central1-a\"," +
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\"," +
"\"image\":\"https://www.googleapis" +
- ".com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106\"," +
- "\"tags\":[],\"serviceAccounts\":[]," +
+ ".com/compute/v1beta15/projects/google/global/images/gcel-12-04-v20121106\"," +
+ "\"serviceAccounts\":[]," +
"\"networkInterfaces\":[{\"network\":\"https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/" + networkName + "\"," +
+ ".com/compute/v1beta15/projects/myproject/global/networks/" + networkName + "\"," +
"\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," +
"\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," +
"\"value\":\"jclouds:" +
@@ -174,7 +189,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/instances/" + instanceName)
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/instances/" + instanceName)
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
}
@@ -211,15 +226,29 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
ImmutableMap<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.
<HttpRequest, HttpResponse>builder()
.put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE)
+ .put(GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE)
.put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE)
.put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
.put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE)
.put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
+ .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
.build();
ComputeService client = requestsSendResponses(requestResponseMap);
Template template = client.templateBuilder().build();
- Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build();
+ Hardware defaultSize = client.templateBuilder().build().getHardware();
+
+ Hardware smallest = client.templateBuilder().smallest().build().getHardware();
+ assertEquals(defaultSize, smallest);
+
+ Hardware fastest = client.templateBuilder().fastest().build().getHardware();
+ assertNotNull(fastest);
+
+ assertEquals(client.listHardwareProfiles().size(), 5);
+
+ Template toMatch = client.templateBuilder()
+ .imageId(template.getImage().getId())
+ .build();
assertEquals(toMatch.getImage(), template.getImage());
}
@@ -229,26 +258,27 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
HttpRequest deleteNodeRequest = HttpRequest.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/instances/test-delete-networks")
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/instances/test-delete-networks")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpRequest deleteFirewallRequest = HttpRequest.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test-delete")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls/jclouds-test-delete")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpRequest deleteNetworkReqquest = HttpRequest.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/jclouds-test-delete")
+ ".com/compute/v1beta15/projects/myproject/global/networks/jclouds-test-delete")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
List<HttpRequest> orderedRequests = ImmutableList.<HttpRequest>builder()
.add(requestForScopes(COMPUTE_READONLY_SCOPE))
+ .add(GET_PROJECT_REQUEST)
.add(getInstanceRequestForInstance("test-delete-networks"))
.add(LIST_PROJECT_IMAGES_REQUEST)
.add(LIST_GOOGLE_IMAGES_REQUEST)
@@ -256,56 +286,41 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
.add(LIST_MACHINE_TYPES_REQUEST)
.add(requestForScopes(COMPUTE_SCOPE))
.add(deleteNodeRequest)
- .add(GET_OPERATION_REQUEST)
+ .add(GET_ZONE_OPERATION_REQUEST)
.add(getInstanceRequestForInstance("test-delete-networks"))
- .add(LIST_PROJECT_IMAGES_REQUEST)
- .add(LIST_GOOGLE_IMAGES_REQUEST)
- .add(LIST_ZONES_REQ)
- .add(LIST_MACHINE_TYPES_REQUEST)
.add(LIST_INSTANCES_REQUEST)
- .add(LIST_PROJECT_IMAGES_REQUEST)
- .add(LIST_GOOGLE_IMAGES_REQUEST)
- .add(LIST_ZONES_REQ)
- .add(LIST_MACHINE_TYPES_REQUEST)
.add(deleteFirewallRequest)
- .add(GET_OPERATION_REQUEST)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
.add(deleteNetworkReqquest)
- .add(GET_OPERATION_REQUEST)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
.build();
List<HttpResponse> orderedResponses = ImmutableList.<HttpResponse>builder()
.add(TOKEN_RESPONSE)
+ .add(GET_PROJECT_RESPONSE)
.add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
.Status.RUNNING.name()))
.add(LIST_PROJECT_IMAGES_RESPONSE)
.add(LIST_GOOGLE_IMAGES_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
+ .add(LIST_ZONES_SHORT_RESPONSE)
.add(LIST_MACHINE_TYPES_RESPONSE)
.add(TOKEN_RESPONSE)
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
.add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
.Status.TERMINATED.name()))
- .add(LIST_PROJECT_IMAGES_RESPONSE)
- .add(LIST_GOOGLE_IMAGES_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
- .add(LIST_MACHINE_TYPES_RESPONSE)
.add(getListInstancesResponseForSingleInstanceAndNetworkAndStatus("test-delete-networks",
"test-network", Instance
.Status.TERMINATED.name()))
- .add(LIST_PROJECT_IMAGES_RESPONSE)
- .add(LIST_GOOGLE_IMAGES_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
- .add(LIST_MACHINE_TYPES_RESPONSE)
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
.build();
ComputeService client = orderedRequestsSendResponses(orderedRequests, orderedResponses);
- client.destroyNode("test-delete-networks");
+ client.destroyNode("us-central1-a/test-delete-networks");
}
@@ -314,11 +329,14 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
ImmutableMap<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.
<HttpRequest, HttpResponse>builder()
.put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE)
+ .put(GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE)
.put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE)
.put(LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE)
+ .put(LIST_CENTRAL1B_INSTANCES_REQUEST, LIST_CENTRAL1B_INSTANCES_RESPONSE)
.put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
.put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE)
.put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
+ .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
.build();
ComputeService apiWhenServersExist = requestsSendResponses(requestResponseMap);
@@ -331,7 +349,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
assertNotNull(apiWhenServersExist.listNodes());
assertEquals(apiWhenServersExist.listNodes().size(), 1);
- assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), "test-0");
+ assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), "us-central1-a/test-0");
assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "test-0");
}
@@ -347,65 +365,65 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
List<HttpRequest> orderedRequests = ImmutableList.<HttpRequest>builder()
.add(requestForScopes(COMPUTE_READONLY_SCOPE))
+ .add(GET_PROJECT_REQUEST)
.add(LIST_ZONES_REQ)
.add(LIST_PROJECT_IMAGES_REQUEST)
.add(LIST_GOOGLE_IMAGES_REQUEST)
+ .add(LIST_ZONES_REQ)
.add(LIST_MACHINE_TYPES_REQUEST)
.add(GET_NETWORK_REQUEST)
.add(requestForScopes(COMPUTE_SCOPE))
.add(INSERT_NETWORK_REQUEST)
- .add(GET_OPERATION_REQUEST)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
.add(GET_NETWORK_REQUEST)
.add(GET_FIREWALL_REQUEST)
.add(INSERT_FIREWALL_REQUEST)
- .add(GET_OPERATION_REQUEST)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
.add(LIST_INSTANCES_REQUEST)
.add(LIST_PROJECT_IMAGES_REQUEST)
.add(LIST_GOOGLE_IMAGES_REQUEST)
- .add(LIST_ZONES_REQ)
.add(LIST_MACHINE_TYPES_REQUEST)
.add(createInstanceRequestForInstance("test-1", "jclouds-test", openSshKey))
- .add(GET_OPERATION_REQUEST)
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(getInstanceRequestForInstance("test-1"))
+ .add(SET_TAGS_REQUEST)
+ .add(GET_ZONE_OPERATION_REQUEST)
.add(getInstanceRequestForInstance("test-1"))
- .add(LIST_PROJECT_IMAGES_REQUEST)
- .add(LIST_GOOGLE_IMAGES_REQUEST)
- .add(LIST_ZONES_REQ)
- .add(LIST_MACHINE_TYPES_REQUEST)
.build();
List<HttpResponse> orderedResponses = ImmutableList.<HttpResponse>builder()
.add(TOKEN_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
+ .add(GET_PROJECT_RESPONSE)
+ .add(LIST_ZONES_SHORT_RESPONSE)
.add(LIST_PROJECT_IMAGES_RESPONSE)
.add(LIST_GOOGLE_IMAGES_RESPONSE)
+ .add(LIST_ZONES_SHORT_RESPONSE)
.add(LIST_MACHINE_TYPES_RESPONSE)
.add(HttpResponse.builder().statusCode(404).build())
.add(TOKEN_RESPONSE)
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
.add(GET_NETWORK_RESPONSE)
.add(HttpResponse.builder().statusCode(404).build())
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
.add(LIST_INSTANCES_RESPONSE)
.add(LIST_PROJECT_IMAGES_RESPONSE)
.add(LIST_GOOGLE_IMAGES_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
.add(LIST_MACHINE_TYPES_RESPONSE)
.add(SUCESSFULL_OPERATION_RESPONSE)
- .add(GET_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(getInstanceResponse)
+ .add(SET_TAGS_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
.add(getInstanceResponse)
- .add(LIST_PROJECT_IMAGES_RESPONSE)
- .add(LIST_GOOGLE_IMAGES_RESPONSE)
- .add(LIST_ZONES_RESPONSE)
- .add(LIST_MACHINE_TYPES_RESPONSE)
.build();
ComputeService computeService = orderedRequestsSendResponses(orderedRequests, orderedResponses);
GoogleComputeEngineTemplateOptions options = computeService.templateOptions().as(GoogleComputeEngineTemplateOptions.class);
-
+ options.tags(ImmutableSet.of("aTag"));
getOnlyElement(computeService.createNodesInGroup("test", 1, options));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
index 2b76322..fbcd355 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
@@ -58,7 +58,7 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
@Test(enabled = true, dependsOnMethods = "testReboot")
public void testSuspendResume() throws Exception {
}
-
+
@Test(enabled = true, dependsOnMethods = "testSuspendResume")
public void testListNodesByIds() throws Exception {
super.testGetNodesWithDetails();
@@ -76,7 +76,7 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
super.testListNodes();
}
- @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "testListNodesByIds" })
+ @Test(enabled = true, dependsOnMethods = {"testListNodes", "testGetNodesWithDetails", "testListNodesByIds"})
@Override
public void testDestroyNodes() {
super.testDestroyNodes();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
index f8301a2..1d1104f 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
@@ -16,14 +16,14 @@
*/
package org.jclouds.googlecomputeengine.compute.functions;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.googlecomputeengine.domain.Image;
-import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
import java.net.URI;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.testng.annotations.Test;
/**
* @author David Alves
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
index be998b6..40de63e 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
@@ -16,10 +16,14 @@
*/
package org.jclouds.googlecomputeengine.compute.functions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
import org.easymock.EasyMock;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.ComputeMetadata;
@@ -28,13 +32,10 @@ import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.googlecomputeengine.compute.predicates.AllNodesInGroupTerminated;
import org.testng.annotations.Test;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
/**
* @author David Alves
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
index 6429275..484bb84 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
@@ -16,6 +16,14 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
@@ -24,15 +32,6 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
-import javax.ws.rs.core.MediaType;
-import java.net.URI;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
/**
* @author David Alves
*/
@@ -43,7 +42,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpRequest get = HttpRequest
.builder()
.method("GET")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks/testimage1")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -53,7 +52,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
- assertEquals(api.get("testimage1"),
+ assertEquals(api.getInZone("us-central1-a", "testimage1"),
new ParseDiskTest().expected());
}
@@ -61,7 +60,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpRequest get = HttpRequest
.builder()
.method("GET")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks/testimage1")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -70,29 +69,27 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
- assertNull(api.get("testimage1"));
+ assertNull(api.getInZone("us-central1-a", "testimage1"));
}
public void testInsertDiskResponseIs2xx() {
HttpRequest insert = HttpRequest
.builder()
.method("POST")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
.build();
HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
+ .payload(payloadFromResource("/zone_operation.json")).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, insert,
insertDiskResponse).getDiskApiForProject("myproject");
- assertEquals(api.createInZone("testimage1", 1, URI.create("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/zones/us-central1-a"))
- , new ParseOperationTest().expected());
+ assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
}
public void testDeleteDiskResponseIs2xx() {
@@ -100,17 +97,17 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/disks/testimage1")
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks/testimage1")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
+ .payload(payloadFromResource("/zone_operation.json")).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
- assertEquals(api.delete("testimage1"),
+ assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
new ParseOperationTest().expected());
}
@@ -119,7 +116,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/disks/testimage1")
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks/testimage1")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -128,7 +125,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
- assertNull(api.delete("testimage1"));
+ assertNull(api.deleteInZone("us-central1-a", "testimage1"));
}
public void testListDisksResponseIs2xx() {
@@ -136,7 +133,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/disks")
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -146,7 +143,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
- assertEquals(api.listFirstPage().toString(),
+ assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
new ParseDiskListTest().expected().toString());
}
@@ -155,7 +152,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/disks")
+ ".com/compute/v1beta15/projects/myproject/zones/us-central1-a/disks")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -164,6 +161,6 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
index 2b42cd7..5c3d199 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
@@ -19,7 +19,6 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.net.URI;
import java.util.List;
import org.jclouds.collect.PagedIterable;
@@ -38,9 +37,8 @@ import com.google.common.collect.Lists;
public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String DISK_NAME = "disk-api-live-test-disk";
- private static final int TIME_WAIT = 10;
+ private static final int TIME_WAIT = 30;
- private URI zoneUrl;
private int sizeGb = 1;
private DiskApi api() {
@@ -50,15 +48,14 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertDisk() {
Project project = api.getProjectApi().get(userProject.get());
- zoneUrl = getDefaultZoneUrl(project.getName());
- assertOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, zoneUrl), TIME_WAIT);
+ assertZoneOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertDisk")
public void testGetDisk() {
- Disk disk = api().get(DISK_NAME);
+ Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
assertNotNull(disk);
assertDiskEquals(disk);
}
@@ -66,7 +63,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetDisk")
public void testListDisk() {
- PagedIterable<Disk> disks = api().list(new ListOptions.Builder()
+ PagedIterable<Disk> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
.filter("name eq " + DISK_NAME));
List<Disk> disksAsList = Lists.newArrayList(disks.concat());
@@ -80,13 +77,13 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListDisk")
public void testDeleteDisk() {
- assertOperationDoneSucessfully(api().delete(DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
}
private void assertDiskEquals(Disk result) {
assertEquals(result.getName(), DISK_NAME);
assertEquals(result.getSizeGb(), sizeGb);
- assertEquals(result.getZone(), zoneUrl);
+ assertEquals(result.getZone(), getDefaultZoneUrl(userProject.get()));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
index 5dc6fdf..6345c51 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
@@ -16,24 +16,6 @@
*/
package org.jclouds.googlecomputeengine.features;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.io.Payload;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Set;
-
import static com.google.common.base.Joiner.on;
import static com.google.common.collect.Iterables.transform;
import static java.lang.String.format;
@@ -46,6 +28,26 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertNull;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.io.Payload;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
/**
* @author David Alves
*/
@@ -56,7 +58,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls/jclouds-test")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -106,7 +108,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls/jclouds-test")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -123,7 +125,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
HttpRequest request = HttpRequest
.builder()
.method("POST")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/global/firewalls")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(firewallPayloadFirewallOfName(
@@ -142,7 +144,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/default"),
+ ".com/compute/v1beta15/projects/myproject/global/networks/default"),
new FirewallOptions()
.addAllowedRule(Firewall.Rule.builder()
.IPProtocol(IPProtocol.TCP)
@@ -158,7 +160,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
HttpRequest update = HttpRequest
.builder()
.method("PUT")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/myfw")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/global/firewalls/myfw")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(firewallPayloadFirewallOfName(
@@ -181,7 +183,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
new FirewallOptions()
.name("myfw")
.network(URI.create("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/default"))
+ ".com/compute/v1beta15/projects/myproject/global/networks/default"))
.addAllowedRule(Firewall.Rule.builder()
.IPProtocol(IPProtocol.TCP)
.addPort(22)
@@ -195,7 +197,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
HttpRequest update = HttpRequest
.builder()
.method("PATCH")
- .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/myfw")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/myproject/global/firewalls/myfw")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN)
.payload(firewallPayloadFirewallOfName(
@@ -218,7 +220,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
new FirewallOptions()
.name("myfw")
.network(URI.create("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/networks/default"))
+ ".com/compute/v1beta15/projects/myproject/global/networks/default"))
.addAllowedRule(Firewall.Rule.builder()
.IPProtocol(IPProtocol.TCP)
.addPort(22)
@@ -233,7 +235,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls/default-allow-internal")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls/default-allow-internal")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -252,7 +254,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls/default-allow-internal")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls/default-allow-internal")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -269,7 +271,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -288,7 +290,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/firewalls")
+ ".com/compute/v1beta15/projects/myproject/global/firewalls")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
index 72c903f..8c550b7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
@@ -16,8 +16,13 @@
*/
package org.jclouds.googlecomputeengine.features;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.jclouds.googlecomputeengine.domain.Firewall.Rule.IPProtocol;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Firewall;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
@@ -25,12 +30,8 @@ import org.jclouds.googlecomputeengine.options.FirewallOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import java.util.List;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.googlecomputeengine.domain.Firewall.Rule.IPProtocol;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
/**
* @author David Alves
@@ -50,7 +51,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void testInsertFirewall() {
// need to create the network first
- assertOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
(FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
FirewallOptions firewall = new FirewallOptions()
@@ -62,7 +63,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.addSourceTag("tag1")
.addTargetTag("tag2");
- assertOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(),
+ assertGlobalOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(),
FIREWALL_NETWORK_NAME), firewall), TIME_WAIT);
}
@@ -72,7 +73,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
FirewallOptions firewall = new FirewallOptions()
.name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(),FIREWALL_NETWORK_NAME))
+ .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
.addSourceRange("10.0.0.0/8")
.addSourceTag("tag1")
.addTargetTag("tag2")
@@ -83,7 +84,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.build()));
- assertOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
}
@@ -92,7 +93,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
FirewallOptions firewall = new FirewallOptions()
.name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(),FIREWALL_NETWORK_NAME))
+ .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
.allowedRules(ImmutableSet.of(
Firewall.Rule.builder()
.IPProtocol(IPProtocol.TCP)
@@ -106,7 +107,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.addSourceTag("tag1")
.addTargetTag("tag2");
- assertOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
}
@@ -149,8 +150,8 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListFirewall")
public void testDeleteFirewall() {
- assertOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
- assertOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
+ assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
(FIREWALL_NETWORK_NAME), TIME_WAIT);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
new file mode 100644
index 0000000..412dc32
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.parse.ParseOperationListTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+/**
+ * @author David Alves
+ */
+@Test(groups = "unit")
+public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
+ ".com/compute/v1beta15/projects/myproject/global/operations";
+
+ public static final HttpRequest GET_GLOBAL_OPERATION_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_GLOBAL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/global_operation.json")).build();
+
+ public void testGetOperationResponseIs2xx() throws Exception {
+
+ GlobalOperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testGetOperationResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertNull(globalOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ }
+
+ public void testDeleteOperationResponseIs2xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testDeleteOperationResponseIs4xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testLisOperationWithNoOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation_list.json")).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(globalOperationApi.listFirstPage().toString(),
+ new ParseOperationListTest().expected().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX +
+ "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" +
+ "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" +
+ "filter=" +
+ "status%20eq%20done&" +
+ "maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation_list.json")).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ new ParseOperationListTest().expected().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertTrue(globalOperationApi.list().concat().isEmpty());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
new file mode 100644
index 0000000..42adbe6
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.jclouds.googlecomputeengine.features.ProjectApiLiveTest.addItemToMetadata;
+import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.deleteItemFromMetadata;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author David Alves
+ */
+public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String METADATA_ITEM_KEY = "operationLiveTestTestProp";
+ private static final String METADATA_ITEM_VALUE = "operationLiveTestTestValue";
+ private Operation addOperation;
+ private Operation deleteOperation;
+
+ private GlobalOperationApi api() {
+ return api.getGlobalOperationApiForProject(userProject.get());
+ }
+
+
+ @Test(groups = "live")
+ public void testCreateOperations() {
+ //create some operations by adding and deleting metadata items
+ // this will make sure there is stuff to listFirstPage
+ addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(),
+ userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20);
+ deleteOperation = assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(api
+ .getProjectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
+
+ assertNotNull(addOperation);
+ assertNotNull(deleteOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testGetOperation() {
+ Operation operation = api().get(addOperation.getName());
+ assertNotNull(operation);
+ assertOperationEquals(operation, this.addOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testListOperationsWithFiltersAndPagination() {
+ PagedIterable<Operation> operations = api().list(new ListOptions.Builder()
+ .filter("operationType eq setMetadata")
+ .maxResults(1));
+
+ // make sure that in spite of having only one result per page we get at least two results
+ final AtomicInteger counter = new AtomicInteger();
+ operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
+
+ @Override
+ public boolean apply(IterableWithMarker<Operation> input) {
+ counter.addAndGet(Iterables.size(input));
+ return counter.get() == 2;
+ }
+ });
+ }
+
+ private void assertOperationEquals(Operation result, Operation expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
index fe7e41f..d8baecf 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
@@ -16,6 +16,12 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseImageListTest;
import org.jclouds.googlecomputeengine.parse.ParseImageTest;
@@ -24,12 +30,6 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
/**
* @author David Alves
*/
@@ -40,19 +40,30 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/images")
+ ".com/compute/v1beta15/projects/myproject/global/images")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
public static final HttpResponse LIST_PROJECT_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
.payload(staticPayloadFromResource("/image_list.json")).build();
+ public static final HttpRequest LIST_GOOGLE_IMAGES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1beta15/projects/google/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_GOOGLE_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/image_list_single_page.json")).build();
+
+
public void testGetImageResponseIs2xx() throws Exception {
HttpRequest get = HttpRequest
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/google/images/centos-6-2-v20120326")
+ ".com/compute/v1beta15/projects/google/global/images/centos-6-2-v20120326")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -71,7 +82,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("GET")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/google/images/centos-6-2-v20120326")
+ ".com/compute/v1beta15/projects/google/global/images/centos-6-2-v20120326")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -88,7 +99,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/images/centos-6-2-v20120326")
+ ".com/compute/v1beta15/projects/myproject/global/images/centos-6-2-v20120326")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
@@ -107,7 +118,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.builder()
.method("DELETE")
.endpoint("https://www.googleapis" +
- ".com/compute/v1beta13/projects/myproject/images/centos-6-2-v20120326")
+ ".com/compute/v1beta15/projects/myproject/global/images/centos-6-2-v20120326")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/1b30e222/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
index f26b8bb..6b07463 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
@@ -16,8 +16,14 @@
*/
package org.jclouds.googlecomputeengine.features;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.List;
+
import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Image;
@@ -25,13 +31,8 @@ import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTe
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import java.util.Iterator;
-import java.util.List;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
/**
* TODO figure out how to test insert and delete as this requires an image .tar.gz to be present in GCS