Skip to content

Commit 7264113

Browse files
Fixed tests
1 parent 9f12638 commit 7264113

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

compute/cloud-client/src/main/java/compute/reservation/ConsumeSpecificSharedReservation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static void createInstance(String projectId, String zone, String instance
174174

175175
if (response.hasError()) {
176176
System.out.println("Instance creation failed ! ! " + response);
177-
}
177+
}
178178
System.out.println("Operation Status: " + response.getStatus());
179179
}
180180
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public static void setUp()
6464
throws IOException, ExecutionException, InterruptedException, TimeoutException {
6565
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
6666
requireEnvVar("GOOGLE_CLOUD_PROJECT");
67-
6867
RESERVATION_NAME = "test-reservation-" + javaVersion + "-"
6968
+ UUID.randomUUID().toString().substring(0, 8);
7069

@@ -75,7 +74,7 @@ public static void setUp()
7574
@AfterAll
7675
public static void cleanup()
7776
throws IOException, ExecutionException, InterruptedException, TimeoutException {
78-
// Delete the reservation created for testing.
77+
// Delete all reservations created for testing.
7978
DeleteReservation.deleteReservation(PROJECT_ID, ZONE, RESERVATION_NAME);
8079

8180
// Test that reservations are deleted
@@ -104,6 +103,7 @@ public void secondGetReservationTest()
104103
throws IOException {
105104
Reservation reservation = GetReservation.getReservation(
106105
PROJECT_ID, RESERVATION_NAME, ZONE);
106+
107107
assertNotNull(reservation);
108108
assertThat(reservation.getName()).isEqualTo(RESERVATION_NAME);
109109
}
@@ -112,6 +112,7 @@ public void secondGetReservationTest()
112112
public void thirdListReservationTest() throws IOException {
113113
List<Reservation> reservations =
114114
ListReservations.listReservations(PROJECT_ID, ZONE);
115+
115116
assertThat(reservations).isNotNull();
116117
Assert.assertTrue(reservations.get(0).getName().contains("test-"));
117118
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public static void setUp()
8686
"test-reservation-global-" + javaVersion, PROJECT_ID, ZONE);
8787
Util.cleanUpExistingReservations("test-reservation-regional-" + javaVersion, PROJECT_ID, ZONE);
8888

89+
// Initialize the client once for all tests
90+
reservationsClient = ReservationsClient.create();
91+
8992
RESERVATION_NAME_GLOBAL = "test-reservation-global-" + javaVersion + "-"
9093
+ UUID.randomUUID().toString().substring(0, 8);
9194
RESERVATION_NAME_REGIONAL = "test-reservation-regional-" + javaVersion + "-"
@@ -105,9 +108,6 @@ public static void setUp()
105108
PROJECT_ID, REGION, REGIONAL_INSTANCE_TEMPLATE_NAME);
106109
assertThat(stdOut.toString()).contains("Instance Template Operation Status: DONE");
107110

108-
// Initialize the client once for all tests
109-
reservationsClient = ReservationsClient.create();
110-
111111
stdOut.close();
112112
System.setOut(out);
113113
}
@@ -144,6 +144,9 @@ public static void cleanup()
144144
NotFoundException.class,
145145
() -> GetReservation.getReservation(PROJECT_ID, RESERVATION_NAME_REGIONAL, ZONE));
146146

147+
// Close the client after all tests
148+
reservationsClient.close();
149+
147150
stdOut.close();
148151
System.setOut(out);
149152
}
@@ -154,7 +157,6 @@ public void testCreateReservationWithGlobalInstanceTemplate()
154157
CreateReservationForInstanceTemplate.createReservationForInstanceTemplate(
155158
PROJECT_ID, RESERVATION_NAME_GLOBAL,
156159
GLOBAL_INSTANCE_TEMPLATE_URI, NUMBER_OF_VMS, ZONE);
157-
158160
Reservation reservation = reservationsClient.get(PROJECT_ID, ZONE, RESERVATION_NAME_GLOBAL);
159161

160162
Assert.assertTrue(reservation.getSpecificReservation()

0 commit comments

Comments
 (0)