1818
1919import static com .google .common .truth .Truth .assertThat ;
2020import static com .google .common .truth .Truth .assertWithMessage ;
21- import static compute .Util .isCreatedBeforeThresholdTime ;
2221
2322import com .google .api .gax .rpc .NotFoundException ;
2423import 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