Skip to content

Commit 9263d70

Browse files
Fixed test
1 parent 59cbd57 commit 9263d70

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@
3131
import java.util.concurrent.TimeUnit;
3232
import java.util.concurrent.TimeoutException;
3333
import org.junit.Assert;
34-
import org.junit.FixMethodOrder;
3534
import org.junit.jupiter.api.AfterAll;
3635
import org.junit.jupiter.api.Assertions;
3736
import org.junit.jupiter.api.BeforeAll;
3837
import org.junit.jupiter.api.Test;
3938
import org.junit.jupiter.api.Timeout;
4039
import org.junit.runner.RunWith;
4140
import org.junit.runners.JUnit4;
42-
import org.junit.runners.MethodSorters;
4341

4442
@RunWith(JUnit4.class)
4543
@Timeout(value = 25, unit = TimeUnit.MINUTES)
46-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4744
public class CrudOperationReservationIT {
4845

4946
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
@@ -91,7 +88,7 @@ public static void cleanup()
9188
}
9289

9390
@Test
94-
public void firstGetReservationTest()
91+
public void testGetReservation()
9592
throws IOException {
9693
Reservation reservation = GetReservation.getReservation(
9794
PROJECT_ID, RESERVATION_NAME, ZONE);
@@ -101,23 +98,11 @@ public void firstGetReservationTest()
10198
}
10299

103100
@Test
104-
public void secondListReservationTest() throws IOException {
101+
public void testListReservation() throws IOException {
105102
List<Reservation> reservations =
106103
ListReservations.listReservations(PROJECT_ID, ZONE);
107104

108105
assertThat(reservations).isNotNull();
109106
Assert.assertTrue(reservations.get(0).getName().contains("test-"));
110107
}
111-
112-
@Test
113-
public void thirdUpdateVmsForReservationTest()
114-
throws IOException, ExecutionException, InterruptedException, TimeoutException {
115-
TimeUnit.MINUTES.sleep(3);
116-
int newNumberOfVms = 5;
117-
UpdateVmsForReservation.updateVmsForReservation(
118-
PROJECT_ID, ZONE, RESERVATION_NAME, newNumberOfVms);
119-
Reservation reservation = reservationsClient.get(PROJECT_ID, ZONE, RESERVATION_NAME);
120-
121-
Assert.assertEquals(newNumberOfVms, reservation.getSpecificReservation().getCount());
122-
}
123108
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@
3535
import java.util.concurrent.TimeUnit;
3636
import java.util.concurrent.TimeoutException;
3737
import org.junit.Assert;
38+
import org.junit.FixMethodOrder;
3839
import org.junit.jupiter.api.AfterAll;
3940
import org.junit.jupiter.api.Assertions;
4041
import org.junit.jupiter.api.BeforeAll;
4142
import org.junit.jupiter.api.Test;
4243
import org.junit.jupiter.api.Timeout;
4344
import org.junit.runner.RunWith;
4445
import org.junit.runners.JUnit4;
46+
import org.junit.runners.MethodSorters;
4547

4648
@RunWith(JUnit4.class)
4749
@Timeout(value = 25, unit = TimeUnit.MINUTES)
50+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4851
public class ReservationIT {
4952

5053
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
@@ -145,7 +148,7 @@ public static void cleanup()
145148
}
146149

147150
@Test
148-
public void testCreateReservationWithGlobalInstanceTemplate()
151+
public void firstCreateReservationWithGlobalInstanceTemplateTest()
149152
throws IOException, ExecutionException, InterruptedException, TimeoutException {
150153
CreateReservationForInstanceTemplate.createReservationForInstanceTemplate(
151154
PROJECT_ID, RESERVATION_NAME_GLOBAL,
@@ -158,7 +161,7 @@ public void testCreateReservationWithGlobalInstanceTemplate()
158161
}
159162

160163
@Test
161-
public void testCreateReservationWithRegionInstanceTemplate()
164+
public void firstCreateReservationWithRegionInstanceTemplateTest()
162165
throws IOException, ExecutionException, InterruptedException, TimeoutException {
163166
CreateReservationForInstanceTemplate.createReservationForInstanceTemplate(
164167
PROJECT_ID, RESERVATION_NAME_REGIONAL, REGIONAL_INSTANCE_TEMPLATE_URI,
@@ -170,4 +173,15 @@ public void testCreateReservationWithRegionInstanceTemplate()
170173
Assert.assertTrue(reservation.getZone().contains(ZONE));
171174
Assert.assertEquals(RESERVATION_NAME_REGIONAL, reservation.getName());
172175
}
176+
177+
@Test
178+
public void secondUpdateVmsForReservationTest()
179+
throws IOException, ExecutionException, InterruptedException, TimeoutException {
180+
int newNumberOfVms = 5;
181+
UpdateVmsForReservation.updateVmsForReservation(
182+
PROJECT_ID, ZONE, RESERVATION_NAME_REGIONAL, newNumberOfVms);
183+
Reservation reservation = reservationsClient.get(PROJECT_ID, ZONE, RESERVATION_NAME_REGIONAL);
184+
185+
Assert.assertEquals(newNumberOfVms, reservation.getSpecificReservation().getCount());
186+
}
173187
}

0 commit comments

Comments
 (0)