3535import java .util .concurrent .TimeUnit ;
3636import java .util .concurrent .TimeoutException ;
3737import org .junit .Assert ;
38+ import org .junit .FixMethodOrder ;
3839import org .junit .jupiter .api .AfterAll ;
3940import org .junit .jupiter .api .Assertions ;
4041import org .junit .jupiter .api .BeforeAll ;
4142import org .junit .jupiter .api .Test ;
4243import org .junit .jupiter .api .Timeout ;
4344import org .junit .runner .RunWith ;
4445import 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 )
4851public 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