Skip to content

Commit 7a86cd3

Browse files
Fixed tests
1 parent 4d8e4ed commit 7a86cd3

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@
4444
import org.junit.runners.JUnit4;
4545

4646
@RunWith(JUnit4.class)
47-
@Timeout(value = 25, unit = TimeUnit.MINUTES)
47+
@Timeout(value = 6, unit = TimeUnit.MINUTES)
4848
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
4949
public class CrudOperationsReservationIT {
5050

5151
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
52-
private static final String ZONE = "us-east4-c";
53-
private static String RESERVATION_NAME;
54-
private static final int NUMBER_OF_VMS = 3;
52+
private static final String ZONE = "us-central1-a";
5553
static String javaVersion = System.getProperty("java.version").substring(0, 2);
54+
private static final String RESERVATION_NAME = "test-reservation-" + javaVersion + "-"
55+
+ UUID.randomUUID().toString().substring(0, 8);
56+
private static final int NUMBER_OF_VMS = 3;
5657

5758
// Check if the required environment variables are set.
5859
public static void requireEnvVar(String envVarName) {
@@ -65,8 +66,6 @@ public static void setUp()
6566
throws IOException, ExecutionException, InterruptedException, TimeoutException {
6667
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
6768
requireEnvVar("GOOGLE_CLOUD_PROJECT");
68-
RESERVATION_NAME = "test-reservation-" + javaVersion + "-"
69-
+ UUID.randomUUID().toString().substring(0, 8);
7069

7170
// Cleanup existing stale resources.
7271
Util.cleanUpExistingReservations("test-reservation-" + javaVersion, PROJECT_ID, ZONE);

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,28 @@
4747
import org.junit.runners.JUnit4;
4848

4949
@RunWith(JUnit4.class)
50-
@Timeout(value = 25, unit = TimeUnit.MINUTES)
51-
@TestMethodOrder(MethodOrderer. OrderAnnotation. class)
50+
@Timeout(value = 6, unit = TimeUnit.MINUTES)
51+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
5252
public class ReservationIT {
5353

5454
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
5555
private static final String ZONE = "us-west1-a";
5656
private static final String REGION = ZONE.substring(0, ZONE.lastIndexOf('-'));
57-
private static ReservationsClient reservationsClient;
58-
private static String RESERVATION_NAME_GLOBAL;
59-
private static String RESERVATION_NAME_REGIONAL;
60-
private static String GLOBAL_INSTANCE_TEMPLATE_URI;
61-
private static String REGIONAL_INSTANCE_TEMPLATE_URI;
6257
static String javaVersion = System.getProperty("java.version").substring(0, 2);
58+
private static ReservationsClient reservationsClient;
59+
private static final String RESERVATION_NAME_GLOBAL = "test-reservation-global-" + javaVersion
60+
+ "-" + UUID.randomUUID().toString().substring(0, 8);
61+
private static final String RESERVATION_NAME_REGIONAL = "test-reservation-regional-" + javaVersion
62+
+ "-" + UUID.randomUUID().toString().substring(0, 8);
6363
private static final String GLOBAL_INSTANCE_TEMPLATE_NAME =
6464
"test-global-inst-temp-" + javaVersion + "-" + UUID.randomUUID().toString().substring(0, 8);
6565
private static final String REGIONAL_INSTANCE_TEMPLATE_NAME =
66-
"test-regional-inst-temp-" + javaVersion + "-"
67-
+ UUID.randomUUID().toString().substring(0, 8);
66+
"test-regional-inst-temp-" + javaVersion + "-" + UUID.randomUUID().toString().substring(0, 8);
67+
private static final String GLOBAL_INSTANCE_TEMPLATE_URI =
68+
String.format("projects/%s/global/instanceTemplates/%s", PROJECT_ID, GLOBAL_INSTANCE_TEMPLATE_NAME);
69+
private static final String REGIONAL_INSTANCE_TEMPLATE_URI =
70+
String.format("projects/%s/regions/%s/instanceTemplates/%s",
71+
PROJECT_ID, REGION, REGIONAL_INSTANCE_TEMPLATE_NAME);
6872
private static final int NUMBER_OF_VMS = 3;
6973

7074
// Check if the required environment variables are set.
@@ -93,16 +97,6 @@ public static void setUp()
9397
// Initialize the client once for all tests
9498
reservationsClient = ReservationsClient.create();
9599

96-
RESERVATION_NAME_GLOBAL = "test-reservation-global-" + javaVersion + "-"
97-
+ UUID.randomUUID().toString().substring(0, 8);
98-
RESERVATION_NAME_REGIONAL = "test-reservation-regional-" + javaVersion + "-"
99-
+ UUID.randomUUID().toString().substring(0, 8);
100-
GLOBAL_INSTANCE_TEMPLATE_URI = String.format("projects/%s/global/instanceTemplates/%s",
101-
PROJECT_ID, GLOBAL_INSTANCE_TEMPLATE_NAME);
102-
REGIONAL_INSTANCE_TEMPLATE_URI =
103-
String.format("projects/%s/regions/%s/instanceTemplates/%s",
104-
PROJECT_ID, REGION, REGIONAL_INSTANCE_TEMPLATE_NAME);
105-
106100
// Create instance template with GLOBAL location.
107101
CreateInstanceTemplate.createInstanceTemplate(PROJECT_ID, GLOBAL_INSTANCE_TEMPLATE_NAME);
108102
assertThat(stdOut.toString())

0 commit comments

Comments
 (0)