Skip to content

Commit 4f207be

Browse files
Cleaned unused code
1 parent 54ba77f commit 4f207be

File tree

1 file changed

+1
-48
lines changed

1 file changed

+1
-48
lines changed

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

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@
2121
import static org.junit.jupiter.api.Assertions.assertNotNull;
2222

2323
import com.google.api.gax.rpc.NotFoundException;
24-
import com.google.cloud.compute.v1.Instance;
25-
import com.google.cloud.compute.v1.InstancesClient;
2624
import com.google.cloud.compute.v1.Reservation;
27-
import com.google.cloud.compute.v1.ReservationsClient;
28-
import compute.CreateInstance;
29-
import compute.DeleteInstance;
3025
import compute.Util;
3126
import java.io.ByteArrayOutputStream;
3227
import java.io.IOException;
@@ -54,11 +49,7 @@ public class CrudOperationsReservationIT {
5449

5550
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
5651
private static final String ZONE = "us-east4-c";
57-
private static ReservationsClient reservationsClient;
58-
private static InstancesClient instancesClient;
5952
private static String RESERVATION_NAME;
60-
private static String RESERVATION_NAME_FROM_VM;
61-
private static String INSTANCE_FOR_RESERVATION;
6253
private static final int NUMBER_OF_VMS = 3;
6354
static String javaVersion = System.getProperty("java.version").substring(0, 2);
6455

@@ -73,43 +64,24 @@ public static void setUp()
7364
throws IOException, ExecutionException, InterruptedException, TimeoutException {
7465
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
7566
requireEnvVar("GOOGLE_CLOUD_PROJECT");
76-
reservationsClient = ReservationsClient.create();
77-
instancesClient = InstancesClient.create();
7867

7968
RESERVATION_NAME = "test-reservation-" + javaVersion + "-"
8069
+ UUID.randomUUID().toString().substring(0, 8);
81-
RESERVATION_NAME_FROM_VM = "test-reservation-from-vm-" + javaVersion + "-"
82-
+ UUID.randomUUID().toString().substring(0, 8);
83-
INSTANCE_FOR_RESERVATION = "test-instance-for-reserv-" + javaVersion + "-"
84-
+ UUID.randomUUID().toString().substring(0, 8);
8570

8671
// Cleanup existing stale resources.
87-
Util.cleanUpExistingInstances("test-instance-for-reserv-" + javaVersion, PROJECT_ID, ZONE);
8872
Util.cleanUpExistingReservations("test-reservation-" + javaVersion, PROJECT_ID, ZONE);
89-
Util.cleanUpExistingReservations("test-reservation-from-vm-" + javaVersion, PROJECT_ID, ZONE);
90-
91-
CreateInstance.createInstance(PROJECT_ID, ZONE, INSTANCE_FOR_RESERVATION);
92-
9373
}
9474

9575
@AfterAll
9676
public static void cleanup()
9777
throws IOException, ExecutionException, InterruptedException, TimeoutException {
9878
// Delete resources created for testing.
99-
DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_FOR_RESERVATION);
10079
DeleteReservation.deleteReservation(PROJECT_ID, ZONE, RESERVATION_NAME);
101-
DeleteReservation.deleteReservation(PROJECT_ID, ZONE, RESERVATION_NAME_FROM_VM);
10280

103-
// Test that reservations are deleted
81+
// Test that reservation is deleted
10482
Assertions.assertThrows(
10583
NotFoundException.class,
10684
() -> 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();
11385
}
11486

11587
@Test
@@ -144,24 +116,5 @@ public void thirdListReservationTest() throws IOException {
144116

145117
assertThat(reservations).isNotNull();
146118
Assert.assertTrue(reservations.get(0).getName().contains("test-"));
147-
Assert.assertTrue(reservations.get(1).getName().contains("test-"));
148-
}
149-
150-
@Test
151-
public void testCreateComputeReservationFromVm()
152-
throws IOException, ExecutionException, InterruptedException, TimeoutException {
153-
CreateReservationFromVm.createComputeReservationFromVm(
154-
PROJECT_ID, ZONE, RESERVATION_NAME_FROM_VM, INSTANCE_FOR_RESERVATION);
155-
156-
Instance instance = instancesClient.get(PROJECT_ID, ZONE, INSTANCE_FOR_RESERVATION);
157-
Reservation reservation =
158-
reservationsClient.get(PROJECT_ID, ZONE, RESERVATION_NAME_FROM_VM);
159-
160-
Assert.assertNotNull(reservation);
161-
assertThat(reservation.getName()).isEqualTo(RESERVATION_NAME_FROM_VM);
162-
Assert.assertEquals(instance.getMinCpuPlatform(),
163-
reservation.getSpecificReservation().getInstanceProperties().getMinCpuPlatform());
164-
Assert.assertEquals(instance.getGuestAcceleratorsList(),
165-
reservation.getSpecificReservation().getInstanceProperties().getGuestAcceleratorsList());
166119
}
167120
}

0 commit comments

Comments
 (0)