Skip to content

Commit 9a4ab90

Browse files
Cleanup reservations
1 parent f4663a5 commit 9a4ab90

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

compute/cloud-client/src/test/java/compute/reservation/ReservationIT.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static com.google.common.truth.Truth.assertWithMessage;
21-
import static compute.Util.isCreatedBeforeThresholdTime;
2221

2322
import com.google.api.gax.rpc.NotFoundException;
2423
import com.google.cloud.compute.v1.Reservation;
@@ -83,10 +82,9 @@ public static void setUp()
8382
Util.cleanUpExistingInstanceTemplates("test-global-inst-temp-" + javaVersion, PROJECT_ID);
8483
Util.cleanUpExistingRegionalInstanceTemplates(
8584
"test-regional-inst-temp-" + javaVersion, PROJECT_ID, ZONE);
86-
cleanUpExistingReservations(PROJECT_ID, ZONE);
8785
//Util.cleanUpExistingReservations(
88-
// "test-reserv-global-" + javaVersion, PROJECT_ID, ZONE);
89-
//Util.cleanUpExistingReservations("test-reserv-regional-" + javaVersion, PROJECT_ID, ZONE);
86+
// "test-reserv-global-" + javaVersion, PROJECT_ID, ZONE);
87+
Util.cleanUpExistingReservations("test-reserv-regional-" + javaVersion, PROJECT_ID, ZONE);
9088

9189
// Initialize the client once for all tests
9290
reservationsClient = ReservationsClient.create();
@@ -179,16 +177,4 @@ public void testCreateReservationWithRegionInstanceTemplate()
179177
Assert.assertTrue(reservation.getZone().contains(ZONE));
180178
Assert.assertEquals(RESERVATION_NAME_REGIONAL, reservation.getName());
181179
}
182-
183-
public static void cleanUpExistingReservations(
184-
String projectId, String zone)
185-
throws IOException, ExecutionException, InterruptedException, TimeoutException {
186-
try (ReservationsClient reservationsClient = ReservationsClient.create()) {
187-
for (Reservation reservation : reservationsClient.list(projectId, zone).iterateAll()) {
188-
if (isCreatedBeforeThresholdTime(reservation.getCreationTimestamp())) {
189-
DeleteReservation.deleteReservation(projectId, zone, reservation.getName());
190-
}
191-
}
192-
}
193-
}
194180
}

0 commit comments

Comments
 (0)