Skip to content

Commit f5108c2

Browse files
Fixed test
1 parent 52cb9b9 commit f5108c2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compute/cloud-client/src/test/java/compute/Util.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import compute.deleteprotection.SetDeleteProtection;
3838
import compute.disks.DeleteDisk;
3939
import compute.disks.DeleteSnapshot;
40+
import compute.disks.RegionalDelete;
4041
import compute.reservation.DeleteReservation;
4142
import java.io.IOException;
4243
import java.nio.charset.StandardCharsets;
@@ -231,6 +232,23 @@ && isCreatedBeforeThresholdTime(snapshot.getCreationTimestamp())) {
231232
}
232233
}
233234

235+
236+
// Delete regional disks which starts with the given prefixToDelete and
237+
// has creation timestamp >24 hours.
238+
public static void cleanUpExistingRegionalDisks(
239+
String prefixToDelete, String projectId, String region)
240+
throws IOException, ExecutionException, InterruptedException, TimeoutException {
241+
try (RegionDisksClient disksClient = RegionDisksClient.create()) {
242+
for (Disk disk : disksClient.list(projectId, region).iterateAll()) {
243+
if (disk.getName().contains(prefixToDelete)
244+
&& disk.getRegion().equals(region)
245+
&& isCreatedBeforeThresholdTime(disk.getCreationTimestamp())) {
246+
RegionalDelete.deleteRegionalDisk(projectId, region, disk.getName());
247+
}
248+
}
249+
}
250+
}
251+
234252
// Delete storagePools which starts with the given prefixToDelete and
235253
// has creation timestamp >24 hours.
236254
public static void cleanUpExistingStoragePool(

compute/cloud-client/src/test/java/compute/disks/DisksIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public static void cleanUp()
177177
DeleteDisk.deleteDisk(PROJECT_ID, ZONE, EMPTY_DISK_NAME);
178178
DeleteDisk.deleteDisk(PROJECT_ID, ZONE, ZONAL_BLANK_DISK);
179179
RegionalDelete.deleteRegionalDisk(PROJECT_ID, REGION, REGIONAL_BLANK_DISK);
180+
RegionalDelete.deleteRegionalDisk(PROJECT_ID, "us-central1", SECONDARY_REGIONAL_DISK);
180181

181182
stdOut.close();
182183
System.setOut(out);
@@ -316,6 +317,5 @@ public void testCreateDiskSecondaryRegional()
316317
REGION, "us-central1", DISK_SIZE, diskType);
317318

318319
assertThat(status).isEqualTo(Operation.Status.DONE);
319-
320320
}
321321
}

0 commit comments

Comments
 (0)