You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/07 17:08:03 UTC
[3/5] jclouds-labs-google git commit: Consolidate operation state
management.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/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
deleted file mode 100644
index 5205589..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
+++ /dev/null
@@ -1,64 +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.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Iterator;
-
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.testng.SkipException;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "GlobalOperationApiLiveTest")
-public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private Operation operation;
-
- private GlobalOperationApi api() {
- return api.getGlobalOperationApi(userProject.get());
- }
-
- public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().list(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 && operations.hasNext(); ) {
- ListPage<Operation> result = operations.next();
- if (result.isEmpty()) {
- operation = result.get(0);
- count++;
- }
- }
- if (count < 2) {
- throw new SkipException("Not enough global operations");
- }
- assertEquals(count, 2);
- }
-
- @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
- public void testGetOperation() {
- Operation result = api().get(operation.name());
- assertNotNull(result);
- assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/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 9b70697..4123ad1 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,8 +32,6 @@ 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 TIME_WAIT = 60;
-
private static final int OFFSET = 2;
private HttpHealthCheckCreationOptions options;
@@ -51,7 +49,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
.healthyThreshold(30)
.unhealthyThreshold(15)
.description("A First Health Check!");
- assertGlobalOperationDoneSucessfully(api().insert(HTTP_HEALTH_CHECK_NAME, options), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().insert(HTTP_HEALTH_CHECK_NAME, options));
}
@Test(groups = "live", dependsOnMethods = "testInsertHttpHealthCheck")
@@ -79,7 +77,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
.port(options.port() + OFFSET)
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
.timeoutSec(options.timeoutSec() + OFFSET);
- assertGlobalOperationDoneSucessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
// Check changes happened and others unchanged.
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
@@ -98,7 +96,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
HttpHealthCheckCreationOptions newOptions = new HttpHealthCheckCreationOptions()
.checkIntervalSec(options.checkIntervalSec() - OFFSET)
.timeoutSec(options.timeoutSec() - OFFSET);
- assertGlobalOperationDoneSucessfully(api().update(HTTP_HEALTH_CHECK_NAME, newOptions), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().update(HTTP_HEALTH_CHECK_NAME, newOptions));
// Check changes happened.
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
@@ -114,6 +112,6 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live", dependsOnMethods = {"testListHttpHealthCheck", "testUpdateHttpHealthCheck"})
public void testDeleteHttpHealthCheck() {
- assertGlobalOperationDoneSucessfully(api().delete(HTTP_HEALTH_CHECK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().delete(HTTP_HEALTH_CHECK_NAME));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/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 2fc56a1..17bc13f 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
@@ -33,7 +33,6 @@ import org.testng.annotations.Test;
public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public static final String DISK_NAME = "image-api-live-test-disk";
- public static final int TIME_WAIT = 300;
public static final int sizeGb = 10;
public static final String IMAGE_NAME = "image-api-live-test-image";
@@ -77,14 +76,14 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertDisk() {
- assertZoneOperationDoneSuccessfully(diskApi().create(DISK_NAME, sizeGb), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().create(DISK_NAME, sizeGb));
Disk disk = diskApi().get(DISK_NAME);
diskURI = disk.selfLink();
}
@Test(groups = "live", dependsOnMethods = "testInsertDisk")
public void testCreateImageFromPD(){
- assertGlobalOperationDoneSucessfully(imageApi().createFromDisk(IMAGE_NAME, diskURI.toString()), TIME_WAIT);
+ assertOperationDoneSuccessfully(imageApi().createFromDisk(IMAGE_NAME, diskURI.toString()));
}
@Test(groups = "live", dependsOnMethods = "testCreateImageFromPD")
@@ -95,8 +94,8 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetCreatedImage")
public void testCleanup(){
- assertGlobalOperationDoneSucessfully(imageApi().delete(IMAGE_NAME), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(imageApi().delete(IMAGE_NAME));
+ assertOperationDoneSuccessfully(diskApi().delete(DISK_NAME));
}
private void assertImageEquals(Image result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
index 84a8a2d..a7ec619 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
@@ -19,6 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
@@ -52,7 +53,7 @@ import com.google.inject.Module;
public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String INSTANCE_NETWORK_NAME = "instance-api-live-test-network";
- private static final String INSTANCE_NAME = "instance-api-live-test-instance";
+ private static final String INSTANCE_NAME = "test-1";
private static final String BOOT_DISK_NAME = INSTANCE_NAME + "-boot-disk";
private static final String DISK_NAME = "instance-live-test-disk";
private static final String IPV4_RANGE = "10.0.0.0/8";
@@ -61,9 +62,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final List<String> TAGS = ImmutableList.of("instance-live-test-tag1", "instance-live-test-tag2");
private static final String ATTACH_DISK_NAME = "instance-api-live-test-attach-disk";
private static final String ATTACH_DISK_DEVICE_NAME = "attach-disk-1";
-
private static final int DEFAULT_DISK_SIZE_GB = 10;
- private static final int TIME_WAIT = 600;
private InstanceTemplate instance;
@@ -108,20 +107,17 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void testInsertInstance() {
// need to insert the network first
- assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
- (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+ assertOperationDoneSuccessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
+ (INSTANCE_NETWORK_NAME, IPV4_RANGE));
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instance.image());
- assertZoneOperationDoneSuccessfully(diskApi().create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions),
- TIME_WAIT);
-
- assertZoneOperationDoneSuccessfully(diskApi().create("instance-live-test-disk", DEFAULT_DISK_SIZE_GB), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(api().create(INSTANCE_NAME, instance), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions));
+ assertOperationDoneSuccessfully(diskApi().create("instance-live-test-disk", DEFAULT_DISK_SIZE_GB));
+ assertOperationDoneSuccessfully(api().create(INSTANCE_NAME, instance));
}
@Test(groups = "live", dependsOnMethods = "testInsertInstance")
public void testGetInstance() {
-
Instance instance = api().get(INSTANCE_NAME);
assertNotNull(instance);
assertInstanceEquals(instance, this.instance);
@@ -130,9 +126,8 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListInstance")
public void testSetMetadataForInstance() {
Instance originalInstance = api().get(INSTANCE_NAME);
- assertZoneOperationDoneSuccessfully(api().setMetadata(INSTANCE_NAME,
- ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE), originalInstance.metadata().fingerprint()),
- TIME_WAIT);
+ assertOperationDoneSuccessfully(api().setMetadata(INSTANCE_NAME,
+ ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE), originalInstance.metadata().fingerprint()));
Instance modifiedInstance = api().get(INSTANCE_NAME);
@@ -145,8 +140,8 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListInstance")
public void testSetTagsForInstance() {
Instance originalInstance = api().get(INSTANCE_NAME);
- assertZoneOperationDoneSuccessfully(
- api().setTags(INSTANCE_NAME, TAGS, originalInstance.tags().fingerprint()), TIME_WAIT);
+ assertOperationDoneSuccessfully(
+ api().setTags(INSTANCE_NAME, TAGS, originalInstance.tags().fingerprint()));
Instance modifiedInstance = api().get(INSTANCE_NAME);
@@ -156,13 +151,13 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testSetMetadataForInstance")
public void testAttachDiskToInstance() {
- assertZoneOperationDoneSuccessfully(diskApi().create(ATTACH_DISK_NAME, 1), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().create(ATTACH_DISK_NAME, 1));
Instance originalInstance = api().get(INSTANCE_NAME);
- assertZoneOperationDoneSuccessfully(api().attachDisk(INSTANCE_NAME,
+ assertOperationDoneSuccessfully(api().attachDisk(INSTANCE_NAME,
new AttachDiskOptions().type(DiskType.PERSISTENT)
.source(getDiskUrl(userProject.get(), ATTACH_DISK_NAME)).mode(DiskMode.READ_ONLY)
- .deviceName(ATTACH_DISK_DEVICE_NAME)), TIME_WAIT);
+ .deviceName(ATTACH_DISK_DEVICE_NAME)));
Instance modifiedInstance = api().get(INSTANCE_NAME);
@@ -180,13 +175,13 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testAttachDiskToInstance")
public void testDetachDiskFromInstance() {
Instance originalInstance = api().get(INSTANCE_NAME);
- assertZoneOperationDoneSuccessfully(api().detachDisk(INSTANCE_NAME, ATTACH_DISK_DEVICE_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().detachDisk(INSTANCE_NAME, ATTACH_DISK_DEVICE_NAME));
Instance modifiedInstance = api().get(INSTANCE_NAME);
assertTrue(modifiedInstance.disks().size() < originalInstance.disks().size());
- assertZoneOperationDoneSuccessfully(diskApi().delete(ATTACH_DISK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().delete(ATTACH_DISK_NAME));
}
@Test(groups = "live", dependsOnMethods = "testInsertInstance")
@@ -204,16 +199,16 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testDetachDiskFromInstance")
public void testResetInstance() {
- assertZoneOperationDoneSuccessfully(api().reset(INSTANCE_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().reset(INSTANCE_NAME));
}
@Test(groups = "live", dependsOnMethods = "testResetInstance")
public void testDeleteInstance() {
- assertZoneOperationDoneSuccessfully(api().delete(INSTANCE_NAME), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(diskApi().delete(BOOT_DISK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().delete(INSTANCE_NAME));
+ assertOperationDoneSuccessfully(diskApi().delete(DISK_NAME));
+ assertNull(diskApi().get(BOOT_DISK_NAME)); // auto-delete!
Operation deleteNetwork = api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME);
- assertGlobalOperationDoneSucessfully(deleteNetwork, TIME_WAIT);
+ assertOperationDoneSuccessfully(deleteNetwork);
}
private void assertInstanceEquals(Instance result, InstanceTemplate expected) {
@@ -224,10 +219,9 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@AfterClass(groups = { "integration", "live" })
protected void tearDownContext() {
try {
- waitZoneOperationDone(api().delete(INSTANCE_NAME), TIME_WAIT);
- waitZoneOperationDone(diskApi().delete(DISK_NAME), TIME_WAIT);
- waitZoneOperationDone(diskApi().delete(BOOT_DISK_NAME), TIME_WAIT);
- waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME), TIME_WAIT);
+ waitOperationDone(api().delete(INSTANCE_NAME));
+ waitOperationDone(diskApi().delete(DISK_NAME));
+ waitOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME));
} catch (Exception e) {
// we don't really care about any exception here, so just delete away.
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
index 080b63c..e814462 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
@@ -33,7 +33,6 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String NETWORK_NAME = "network-api-live-test-network";
private static final String IPV4_RANGE = "10.0.0.0/8";
- private static final int TIME_WAIT = 10;
private NetworkApi api() {
return api.getNetworkApi(userProject.get());
@@ -41,7 +40,7 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertNetwork() {
- assertGlobalOperationDoneSucessfully(api().createInIPv4Range(NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().createInIPv4Range(NETWORK_NAME, IPV4_RANGE));
}
@Test(groups = "live", dependsOnMethods = "testInsertNetwork")
@@ -64,7 +63,7 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListNetwork")
public void testDeleteNetwork() {
- assertGlobalOperationDoneSucessfully(api().delete(NETWORK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().delete(NETWORK_NAME));
}
private void assertNetworkEquals(Network result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiExpectTest.java
new file mode 100644
index 0000000..36edf75
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiExpectTest.java
@@ -0,0 +1,294 @@
+/*
+ * 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.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationListTest;
+import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest;
+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 = "OperationApiExpectTest")
+public class OperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private static final String OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/global/operations";
+ private static final String REGION_OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/regions/us-central1/operations";
+ private static final String ZONE_OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/zones/us-central1-a/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 get() throws Exception {
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getOperationApi("myproject");
+
+ assertEquals(api.get(GET_GLOBAL_OPERATION_REQUEST.getEndpoint()),
+ new ParseGlobalOperationTest().expected());
+ }
+
+ public void getResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getOperationApi("myproject");
+
+ assertNull(api.get(GET_GLOBAL_OPERATION_REQUEST.getEndpoint()));
+ }
+
+ public void delete() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getOperationApi("myproject");
+
+ api.delete(delete.getEndpoint());
+ }
+
+ public void deleteResponseIs4xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getOperationApi("myproject");
+
+ api.delete(delete.getEndpoint());
+ }
+
+ public void list() {
+ 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();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.list().next().toString(),
+ new ParseGlobalOperationListTest().expected().toString());
+ }
+
+ public void listResponseIs4xx() {
+ 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();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertFalse(api.list().hasNext());
+ }
+
+ public void listWithOptions() {
+ 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();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.listPage("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ filter("status eq done").maxResults(3)).toString(),
+ new ParseGlobalOperationListTest().expected().toString());
+ }
+
+ private ListPage<Operation> regionList() {
+ return ListPage.create( //
+ ImmutableList.of(new ParseRegionOperationTest().expected()), // items
+ null // nextPageToken
+ );
+ }
+
+ public void listInRegion() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(REGION_OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_operation_list.json")).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.listInRegion("us-central1").next().toString(), regionList().toString());
+ }
+
+ public void listInRegionResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(REGION_OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertFalse(api.listInRegion("us-central1").hasNext());
+ }
+
+ public void listPageInRegion() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(REGION_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("/region_operation_list.json")).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.listPageInRegion("us-central1",
+ "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ filter("status eq done").maxResults(3)).toString(), regionList().toString());
+ }
+
+
+ private ListPage<Operation> zoneList() {
+ return ListPage.create( //
+ ImmutableList.of(new ParseZoneOperationTest().expected()), // items
+ null // nextPageToken
+ );
+ }
+
+ public void listInZone() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(ZONE_OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation_list.json")).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.listInZone("us-central1-a").next().toString(), zoneList().toString());
+ }
+
+ public void listInZoneResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(ZONE_OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertFalse(api.listInZone("us-central1-a").hasNext());
+ }
+
+ public void listPageInZone() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(ZONE_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("/zone_operation_list.json")).build();
+
+ OperationApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getOperationApi("myproject");
+
+ assertEquals(api.listPageInZone("us-central1-a",
+ "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ filter("status eq done").maxResults(3)).toString(), zoneList().toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiLiveTest.java
new file mode 100644
index 0000000..9b8e6da
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/OperationApiLiveTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.options.ListOptions.Builder.maxResults;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", testName = "GlobalOperationApiLiveTest")
+public class OperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private Operation operation;
+
+ private OperationApi api() {
+ return api.getOperationApi(userProject.get());
+ }
+
+ public void listWithOptions() {
+ Iterator<ListPage<Operation>> operations = api().list(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 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ operation = result.get(0);
+ count++;
+ }
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough global operations");
+ }
+ assertEquals(count, 2);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "listWithOptions")
+ public void testGetOperation() {
+ Operation result = api().get(operation.selfLink());
+ assertNotNull(result);
+ assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
+ }
+
+ public void listInRegionWithOptions() {
+ Iterator<ListPage<Operation>> operations = api().listInRegion(DEFAULT_REGION_NAME, 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 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ count++;
+ }
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough region operations");
+ }
+ assertEquals(count, 2);
+ }
+
+ public void listInZoneWithOptions() {
+ Iterator<ListPage<Operation>> operations = api().listInZone(DEFAULT_ZONE_NAME, 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 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ count++;
+ }
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough zone operations");
+ }
+ assertEquals(count, 2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
index 45c180d..984d185 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
@@ -33,8 +33,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
-/**
- */
public class ProjectApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String METADATA_ITEM_KEY = "projectLiveTestTestProp";
@@ -66,8 +64,8 @@ public class ProjectApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void addItemToMetadata() {
this.initialMetadataSize = project.commonInstanceMetadata().items().size();
this.initialFingerprint = this.project.commonInstanceMetadata().fingerprint();
- assertGlobalOperationDoneSucessfully(addItemToMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY,
- METADATA_ITEM_VALUE), 20);
+ assertOperationDoneSuccessfully(addItemToMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY,
+ METADATA_ITEM_VALUE));
this.project = projectApi().get(userProject.get());
assertNotNull(project);
assertTrue(this.project.commonInstanceMetadata().items().containsKey(METADATA_ITEM_KEY),
@@ -79,7 +77,7 @@ public class ProjectApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "addItemToMetadata")
public void testDeleteItemFromMetadata() {
- assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
+ assertOperationDoneSuccessfully(deleteItemFromMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY));
this.project = projectApi().get(userProject.get());
assertNotNull(project);
assertFalse(project.commonInstanceMetadata().items().containsKey(METADATA_ITEM_KEY));
@@ -115,8 +113,6 @@ public class ProjectApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
metadataBuilder.putAll(Maps.filterKeys(project.commonInstanceMetadata().items(), not(equalTo(key))));
return projectApi.setCommonInstanceMetadata(projectName, metadataBuilder.build(),
- project.commonInstanceMetadata().fingerprint());
+ project.commonInstanceMetadata().fingerprint());
}
-
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
deleted file mode 100644
index ce7fdc8..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
+++ /dev/null
@@ -1,168 +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.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
-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 = "RegionOperationApiExpectTest")
-public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- private static final String OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/regions/us-central1/operations";
-
- private static final String DELETE_OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/regions/us-central1/operations";
-
- public static final HttpRequest GET_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_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/region_operation.json")).build();
-
- private ListPage<Operation> expectedList() {
- return ListPage.create( //
- ImmutableList.of(new ParseRegionOperationTest().expected()), // items
- null // nextPageToken
- );
- }
-
- public void testGetOperationResponseIs2xx() throws Exception {
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE)
- .getRegionOperationApi("myproject", "us-central1");
-
- assertEquals(regionOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
- new ParseRegionOperationTest().expected());
- }
-
- public void testGetOperationResponseIs4xx() throws Exception {
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- assertNull(regionOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
- }
-
- public void testDeleteOperationResponseIs2xx() throws Exception {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- regionOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
- }
-
- public void testDeleteOperationResponseIs4xx() throws Exception {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- regionOperationApi.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("/region_operation_list.json")).build();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- assertEquals(regionOperationApi.list().next().toString(), expectedList().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("/region_operation_list.json")).build();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- assertEquals(regionOperationApi.listPage("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
- "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz", filter("status eq done").maxResults(3)).toString(),
- expectedList().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();
-
- RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
-
- assertFalse(regionOperationApi.list().hasNext());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
deleted file mode 100644
index f15fbf5..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
+++ /dev/null
@@ -1,64 +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.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Iterator;
-
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.testng.SkipException;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "RegionOperationApiLiveTest")
-public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private Operation operation;
-
- private RegionOperationApi api() {
- return api.getRegionOperationApi(userProject.get(), DEFAULT_REGION_NAME);
- }
-
- public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().list(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 && operations.hasNext(); ) {
- ListPage<Operation> result = operations.next();
- if (result.isEmpty()) {
- operation = result.get(0);
- count++;
- }
- }
- if (count < 2) {
- throw new SkipException("Not enough operations in " + DEFAULT_REGION_NAME);
- }
- assertEquals(count, 2);
- }
-
- @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
- public void testGetOperation() {
- Operation result = api().get(operation.name());
- assertNotNull(result);
- assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
index 2cbaf64..c2631f2 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
@@ -36,7 +36,6 @@ public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String IPV4_RANGE = "10.0.0.0/8";
private static final String ROUTE_NAME = "route-api-live-test-route";
private static final String ROUTE_NETWORK_NAME = "route-api-live-test-network";
- public static final int TIME_WAIT = 30;
private RouteApi api() {
return api.getRouteApi(userProject.get());
@@ -44,17 +43,16 @@ public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertRoute() {
- assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
- (ROUTE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api().createInNetwork(ROUTE_NAME,
+ assertOperationDoneSuccessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
+ (ROUTE_NETWORK_NAME, IPV4_RANGE));
+ assertOperationDoneSuccessfully(api().createInNetwork(ROUTE_NAME,
getNetworkUrl(userProject.get(), ROUTE_NETWORK_NAME),
new RouteOptions().addTag("footag")
.addTag("bartag")
.description("RouteApi Live Test")
.destRange(DEST_RANGE)
.priority(1000)
- .nextHopGateway(getGatewayUrl(userProject.get(), DEFAULT_GATEWAY_NAME))),
- TIME_WAIT);
+ .nextHopGateway(getGatewayUrl(userProject.get(), DEFAULT_GATEWAY_NAME))));
}
@Test(groups = "live", dependsOnMethods = "testInsertRoute")
@@ -80,9 +78,8 @@ public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListRoute")
public void testDeleteRoute() {
- assertGlobalOperationDoneSucessfully(api().delete(ROUTE_NAME), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get())
- .delete(ROUTE_NETWORK_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().delete(ROUTE_NAME));
+ assertOperationDoneSuccessfully(api.getNetworkApi(userProject.get()).delete(ROUTE_NETWORK_NAME));
}
private void assertRouteEquals(Route result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
index 8d478b6..61a2191 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
@@ -16,7 +16,6 @@
*/
package org.jclouds.googlecomputeengine.features;
-import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
@@ -45,10 +44,10 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testCreateSnapshot() {
- assertZoneOperationDoneSuccessfully(diskApi().create(DISK_NAME, 1), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().create(DISK_NAME, 1));
disk = diskApi().get(DISK_NAME);
- assertZoneOperationDoneSuccessfully(diskApi().createSnapshot(DISK_NAME, SNAPSHOT_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().createSnapshot(DISK_NAME, SNAPSHOT_NAME));
}
@Test(groups = "live", dependsOnMethods = "testCreateSnapshot")
@@ -72,8 +71,8 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListSnapshot")
public void testDeleteDisk() {
- assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api().delete(SNAPSHOT_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(diskApi().delete(DISK_NAME));
+ assertOperationDoneSuccessfully(api().delete(SNAPSHOT_NAME));
}
private void assertSnapshotEquals(Snapshot result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/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
index 26c016a..147e114 100644
--- 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
@@ -65,8 +65,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getTargetPoolApi("myproject", "us-central1");
- assertEquals(api.get("test"),
- new ParseTargetPoolTest().expected());
+ assertEquals(api.get("test"), new ParseTargetPoolTest().expected());
}
public void testGetTargetPoolResponseIs4xx() throws Exception {
@@ -229,8 +228,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, addHealthCheck, operationResponse).getTargetPoolApi("myproject", "us-central1");
- assertEquals(api.addHealthCheck("test", HEALTH_CHECKS),
- new ParseRegionOperationTest().expected());
+ assertEquals(api.addHealthCheck("test", HEALTH_CHECKS), new ParseRegionOperationTest().expected());
}
@Test(expectedExceptions = ResourceNotFoundException.class)
@@ -253,8 +251,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, removeHealthCheck, operationResponse).getTargetPoolApi("myproject", "us-central1");
- assertEquals(api.removeHealthCheck("test", HEALTH_CHECKS),
- new ParseRegionOperationTest().expected());
+ assertEquals(api.removeHealthCheck("test", HEALTH_CHECKS), new ParseRegionOperationTest().expected());
}
@Test(expectedExceptions = ResourceNotFoundException.class)
@@ -283,8 +280,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, SetBackup, operationResponse).getTargetPoolApi("myproject", "us-central1");
- assertEquals(api.setBackup("testpool", TARGET_POOL),
- new ParseRegionOperationTest().expected());
+ assertEquals(api.setBackup("testpool", TARGET_POOL), new ParseRegionOperationTest().expected());
}
public void testSetBackupWithFailoverRatioResponseIs2xx(){
@@ -304,8 +300,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TOKEN_RESPONSE, SetBackup, operationResponse).getTargetPoolApi("myproject", "us-central1");
Float failoverRatio = Float.valueOf("0.5");
- assertEquals(api.setBackup("testpool", failoverRatio, TARGET_POOL),
- new ParseRegionOperationTest().expected());
+ assertEquals(api.setBackup("testpool", failoverRatio, TARGET_POOL), new ParseRegionOperationTest().expected());
}
@Test(expectedExceptions = ResourceNotFoundException.class)
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/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 753b81a..37fcacf 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
@@ -48,7 +48,6 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String BACKUP_TARGETPOOL_NAME = "targetpool-api-live-test-backup";
private static final String TARGETPOOL_NAME = "targetpool-api-live-test-primary";
private static final String THIRD_TARGETPOOL_NAME = "targetpool-apo-live-test-third";
- private static final int TIME_WAIT = 30;
private static final String DESCRIPTION = "A New TargetPool!";
private static final String DESCRIPTION_BACKUP = "A backup target pool!";
@@ -59,7 +58,6 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String HEALTHCHECK_NAME = "target-pool-test-health-check";
private static final int DEFAULT_DISK_SIZE_GB = 10;
- private static final int TIME_WAIT_LONG = 600;
private List<URI> instances;
private List<URI> httpHealthChecks;
@@ -98,17 +96,16 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
// Insert a network.
- assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
- (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT_LONG);
+ assertOperationDoneSuccessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
+ (INSTANCE_NETWORK_NAME, IPV4_RANGE));
// Create a disk.
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instanceTemplate.image());
- assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME)
- .create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions), TIME_WAIT_LONG);
+ assertOperationDoneSuccessfully(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME)
+ .create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions));
// Create an instance.
- assertZoneOperationDoneSuccessfully(instanceApi.create(INSTANCE_NAME, instanceTemplate),
- TIME_WAIT_LONG);
+ assertOperationDoneSuccessfully(instanceApi.create(INSTANCE_NAME, instanceTemplate));
Instance instance = instanceApi.get(INSTANCE_NAME);
instances = new ArrayList<URI>();
instances.add(instance.selfLink());
@@ -118,7 +115,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.checkIntervalSec(30)
.timeoutSec(20)
.description("A test HealthCheck for adding to targetPools");
- assertGlobalOperationDoneSucessfully(httpHealthCheckApi.insert(HEALTHCHECK_NAME, options), TIME_WAIT);
+ assertOperationDoneSuccessfully(httpHealthCheckApi.insert(HEALTHCHECK_NAME, options));
HttpHealthCheck healthCheck = httpHealthCheckApi.get(HEALTHCHECK_NAME);
httpHealthChecks = new ArrayList<URI>();
httpHealthChecks.add(healthCheck.selfLink());
@@ -129,7 +126,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
.description(DESCRIPTION_BACKUP)
.sessionAffinity(SessionAffinityValue.CLIENT_IP);
- assertRegionOperationDoneSucessfully(api().create(BACKUP_TARGETPOOL_NAME, targetPoolCreationOptions), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().create(BACKUP_TARGETPOOL_NAME, targetPoolCreationOptions));
}
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
@@ -142,7 +139,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
.backupPool(targetPool.selfLink())
.failoverRatio((float) 0.5);
- assertRegionOperationDoneSucessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions));
TargetPool targetPool2 = api().get(TARGETPOOL_NAME);
assertNotNull(targetPool2);
assertEquals(targetPool2.name(), TARGETPOOL_NAME);
@@ -163,7 +160,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool", "testCreateInstanceAndHealthCheck"})
public void testAddInstanceTargetPool() {
- assertRegionOperationDoneSucessfully(api().addInstance(BACKUP_TARGETPOOL_NAME, instances), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().addInstance(BACKUP_TARGETPOOL_NAME, instances));
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
assertNotNull(targetPool);
assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME);
@@ -172,7 +169,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testAddInstanceTargetPool")
public void testRemoveInstanceTargetPool() {
- assertRegionOperationDoneSucessfully(api().removeInstance(BACKUP_TARGETPOOL_NAME, instances), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().removeInstance(BACKUP_TARGETPOOL_NAME, instances));
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
@@ -183,7 +180,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2", "testCreateInstanceAndHealthCheck"})
public void testAddHealthCheckTargetPool() {
- assertRegionOperationDoneSucessfully(api().addHealthCheck(TARGETPOOL_NAME, httpHealthChecks), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().addHealthCheck(TARGETPOOL_NAME, httpHealthChecks));
TargetPool targetPool = api().get(TARGETPOOL_NAME);
assertNotNull(targetPool);
assertEquals(targetPool.name(), TARGETPOOL_NAME);
@@ -192,7 +189,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testAddHealthCheckTargetPool")
public void testRemoveHealthCheckTargetPool() {
- assertRegionOperationDoneSucessfully(api().removeHealthCheck(TARGETPOOL_NAME, httpHealthChecks), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().removeHealthCheck(TARGETPOOL_NAME, httpHealthChecks));
TargetPool targetPool = api().get(TARGETPOOL_NAME);
@@ -210,7 +207,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"})
public void testListBackupTargetPool() {
TargetPoolCreationOptions options = new TargetPoolCreationOptions().description("A targetPool for testing setBackup.");
- assertRegionOperationDoneSucessfully(api().create(THIRD_TARGETPOOL_NAME, options), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().create(THIRD_TARGETPOOL_NAME, options));
TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME);
assertNotNull(targetPool);
assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME);
@@ -219,7 +216,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
URI selfLink = api().get(TARGETPOOL_NAME).selfLink();
Float failoverRatio = Float.valueOf((float) 0.5);
- assertRegionOperationDoneSucessfully(api().setBackup(THIRD_TARGETPOOL_NAME, failoverRatio, selfLink), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().setBackup(THIRD_TARGETPOOL_NAME, failoverRatio, selfLink));
TargetPool targetPoolUpdated = api().get(THIRD_TARGETPOOL_NAME);
assertNotNull(targetPoolUpdated);
@@ -234,9 +231,9 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
"testListBackupTargetPool"}, alwaysRun = true)
public void testDeleteTargetPool() {
// Note: This ordering matters due one being the backup of the other ect.
- assertRegionOperationDoneSucessfully(api().delete(THIRD_TARGETPOOL_NAME), TIME_WAIT);
- assertRegionOperationDoneSucessfully(api().delete(TARGETPOOL_NAME), TIME_WAIT);
- assertRegionOperationDoneSucessfully(api().delete(BACKUP_TARGETPOOL_NAME), TIME_WAIT);
+ assertOperationDoneSuccessfully(api().delete(THIRD_TARGETPOOL_NAME));
+ assertOperationDoneSuccessfully(api().delete(TARGETPOOL_NAME));
+ assertOperationDoneSuccessfully(api().delete(BACKUP_TARGETPOOL_NAME));
}
@AfterClass(groups = { "integration", "live" })
@@ -245,10 +242,10 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
HttpHealthCheckApi httpHealthCheckApi = api.getHttpHealthCheckApi(userProject.get());
try {
- waitZoneOperationDone(instanceApi.delete(INSTANCE_NAME), TIME_WAIT_LONG);
- waitZoneOperationDone(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME).delete(BOOT_DISK_NAME), TIME_WAIT);
- waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME), TIME_WAIT_LONG);
- waitGlobalOperationDone(httpHealthCheckApi.delete(HEALTHCHECK_NAME), TIME_WAIT);
+ waitOperationDone(instanceApi.delete(INSTANCE_NAME));
+ waitOperationDone(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME).delete(BOOT_DISK_NAME));
+ waitOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME));
+ waitOperationDone(httpHealthCheckApi.delete(HEALTHCHECK_NAME));
} catch (Exception e) {
// we don't really care about any exception here, so just delete away.
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
deleted file mode 100644
index 4a3136a..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
+++ /dev/null
@@ -1,170 +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.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest;
-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 = "ZoneOperationApiExpectTest")
-public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- private static final String OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/zones/us-central1-a/operations";
-
- public static final HttpRequest GET_ZONE_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_ZONE_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/zone_operation.json")).build();
-
- public void testGetOperationResponseIs2xx() throws Exception {
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, GET_ZONE_OPERATION_RESPONSE)
- .getZoneOperationApi("myproject", "us-central1-a");
-
- assertEquals(zoneOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
- new ParseZoneOperationTest().expected());
- }
-
- public void testGetOperationResponseIs4xx() throws Exception {
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, operationResponse)
- .getZoneOperationApi("myproject", "us-central1-a");
-
- assertNull(zoneOperationApi.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("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, delete,
- operationResponse).getZoneOperationApi("myproject", "us-central1-a");
-
- zoneOperationApi.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("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
-
- zoneOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
- }
-
- private static ListPage<Operation> expectedList() {
- return ListPage.create( //
- ImmutableList.of(new ParseZoneOperationTest().expected()), // items
- null // nextPageToken
- );
- }
-
- public void testListOperationWithNoOptionsResponseIs2xx() {
- 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("/zone_operation_list.json")).build();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
-
- assertEquals(zoneOperationApi.list().next().toString(),
- expectedList().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("/zone_operation_list.json")).build();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
-
- assertEquals(zoneOperationApi.listPage(
- "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
- "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
- filter("status eq done").maxResults(3)).toString(),
- expectedList().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();
-
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
-
- assertFalse(zoneOperationApi.list().hasNext());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/8895953d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
deleted file mode 100644
index 0d9422f..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
+++ /dev/null
@@ -1,64 +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.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Iterator;
-
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.testng.SkipException;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "ZoneOperationApiLiveTest")
-public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private Operation operation;
-
- private ZoneOperationApi api() {
- return api.getZoneOperationApi(userProject.get(), DEFAULT_ZONE_NAME);
- }
-
- public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().list(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 && operations.hasNext(); ) {
- ListPage<Operation> result = operations.next();
- if (result.isEmpty()) {
- operation = result.get(0);
- count++;
- }
- }
- if (count < 2) {
- throw new SkipException("Not enough operations in " + DEFAULT_ZONE_NAME);
- }
- assertEquals(count, 2);
- }
-
- @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
- public void testGetOperation() {
- Operation result = api().get(operation.name());
- assertNotNull(result);
- assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
- }
-}