2020import static com .google .common .truth .Truth .assertWithMessage ;
2121import static org .junit .jupiter .api .Assertions .assertNotNull ;
2222
23- // import com.google.api.gax.rpc.NotFoundException;
23+ import com .google .api .gax .rpc .NotFoundException ;
2424import com .google .cloud .compute .v1 .Instance ;
2525import com .google .cloud .compute .v1 .InstancesClient ;
2626import com .google .cloud .compute .v1 .Reservation ;
2727import com .google .cloud .compute .v1 .ReservationsClient ;
28- // import compute.CreateInstance;
29- // import compute.DeleteInstance;
28+ import compute .CreateInstance ;
29+ import compute .DeleteInstance ;
3030import compute .Util ;
3131import java .io .ByteArrayOutputStream ;
3232import java .io .IOException ;
3939import org .junit .Assert ;
4040import org .junit .FixMethodOrder ;
4141import org .junit .jupiter .api .AfterAll ;
42- // import org.junit.jupiter.api.Assertions;
42+ import org .junit .jupiter .api .Assertions ;
4343import org .junit .jupiter .api .BeforeAll ;
44- import org .junit .jupiter .api .Disabled ;
4544import org .junit .jupiter .api .Test ;
4645import org .junit .jupiter .api .Timeout ;
4746import org .junit .runner .RunWith ;
5453public class CrudOperationsReservationIT {
5554
5655 private static final String PROJECT_ID = System .getenv ("GOOGLE_CLOUD_PROJECT" );
57- private static final String ZONE = "us-west1 -a" ;
56+ private static final String ZONE = "us-central1 -a" ;
5857 private static ReservationsClient reservationsClient ;
5958 private static InstancesClient instancesClient ;
6059 private static String RESERVATION_NAME ;
@@ -87,37 +86,32 @@ public static void setUp()
8786 // Cleanup existing stale resources.
8887 Util .cleanUpExistingInstances ("test-instance-for-reserv-" + javaVersion , PROJECT_ID , ZONE );
8988 Util .cleanUpExistingReservations ("test-reservation-" + javaVersion , PROJECT_ID , ZONE );
90- Util .cleanUpExistingReservations ("test-reservation-" + javaVersion , PROJECT_ID , "us-central1-a" );
91- Util .cleanUpExistingReservations ("test-reservation-" + javaVersion , PROJECT_ID , "asia-south1-a" );
9289 Util .cleanUpExistingReservations ("test-reservation-from-vm-" + javaVersion , PROJECT_ID , ZONE );
93- Util .cleanUpExistingReservations ("test-reservation-from-vm-" + javaVersion , PROJECT_ID , "us-central1-a" );
94- Util .cleanUpExistingReservations ("test-reservation-from-vm-" + javaVersion , PROJECT_ID , "asia-south1-a" );
9590
96- // CreateInstance.createInstance(PROJECT_ID, ZONE, INSTANCE_FOR_RESERVATION);
91+ CreateInstance .createInstance (PROJECT_ID , ZONE , INSTANCE_FOR_RESERVATION );
9792
9893 }
9994
10095 @ AfterAll
10196 public static void cleanup ()
10297 throws IOException , ExecutionException , InterruptedException , TimeoutException {
10398 // Delete resources created for testing.
104- // DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_FOR_RESERVATION);
105- // DeleteReservation.deleteReservation(PROJECT_ID, ZONE, RESERVATION_NAME);
106- // DeleteReservation.deleteReservation(PROJECT_ID, ZONE, RESERVATION_NAME_FROM_VM);
99+ DeleteInstance .deleteInstance (PROJECT_ID , ZONE , INSTANCE_FOR_RESERVATION );
100+ DeleteReservation .deleteReservation (PROJECT_ID , ZONE , RESERVATION_NAME );
101+ DeleteReservation .deleteReservation (PROJECT_ID , ZONE , RESERVATION_NAME_FROM_VM );
107102
108103 // Test that reservations are deleted
109- // Assertions.assertThrows(
110- // NotFoundException.class,
111- // () -> GetReservation.getReservation(PROJECT_ID, RESERVATION_NAME, ZONE));
112- // Assertions.assertThrows(
113- // NotFoundException.class,
114- // () -> GetReservation.getReservation(PROJECT_ID, RESERVATION_NAME_FROM_VM, ZONE));
115-
116- // reservationsClient.close();
117- // instancesClient.close();
104+ Assertions .assertThrows (
105+ NotFoundException .class ,
106+ () -> GetReservation .getReservation (PROJECT_ID , RESERVATION_NAME , ZONE ));
107+ Assertions .assertThrows (
108+ NotFoundException .class ,
109+ () -> GetReservation .getReservation (PROJECT_ID , RESERVATION_NAME_FROM_VM , ZONE ));
110+
111+ reservationsClient .close ();
112+ instancesClient .close ();
118113 }
119114
120- @ Disabled
121115 @ Test
122116 public void firstCreateReservationTest ()
123117 throws IOException , ExecutionException , InterruptedException , TimeoutException {
@@ -133,7 +127,6 @@ public void firstCreateReservationTest()
133127 System .setOut (out );
134128 }
135129
136- @ Disabled
137130 @ Test
138131 public void secondGetReservationTest ()
139132 throws IOException {
@@ -144,7 +137,6 @@ public void secondGetReservationTest()
144137 assertThat (reservation .getName ()).isEqualTo (RESERVATION_NAME );
145138 }
146139
147- @ Disabled
148140 @ Test
149141 public void thirdListReservationTest () throws IOException {
150142 List <Reservation > reservations =
@@ -155,7 +147,6 @@ public void thirdListReservationTest() throws IOException {
155147 Assert .assertTrue (reservations .get (1 ).getName ().contains ("test-" ));
156148 }
157149
158- @ Disabled
159150 @ Test
160151 public void testCreateComputeReservationFromVm ()
161152 throws IOException , ExecutionException , InterruptedException , TimeoutException {
0 commit comments