Skip to content

Commit 73513df

Browse files
Fixed claenup method for Hyperdisk
1 parent 67f3a58 commit 73513df

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ public static void cleanUpExistingSnapshots(String prefixToDelete, String projec
223223
throws IOException, ExecutionException, InterruptedException, TimeoutException {
224224
try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
225225
for (Snapshot snapshot : snapshotsClient.list(projectId).iterateAll()) {
226-
if (isCreatedBeforeThresholdTime(snapshot.getCreationTimestamp())) {
226+
if (containPrefixToDelete(snapshot, prefixToDelete)
227+
&& isCreatedBeforeThresholdTime(snapshot.getCreationTimestamp())) {
227228
DeleteSnapshot.deleteSnapshot(projectId, snapshot.getName());
228229
}
229230
}
@@ -237,7 +238,8 @@ public static void cleanUpExistingStoragePool(
237238
throws IOException, ExecutionException, InterruptedException, TimeoutException {
238239
try (StoragePoolsClient storagePoolsClient = StoragePoolsClient.create()) {
239240
for (StoragePool storagePool : storagePoolsClient.list(projectId, zone).iterateAll()) {
240-
if (isCreatedBeforeThresholdTime(storagePool.getCreationTimestamp())) {
241+
if (containPrefixToDelete(storagePool, prefixToDelete)
242+
&& isCreatedBeforeThresholdTime(storagePool.getCreationTimestamp())) {
241243
deleteStoragePool(projectId, zone, storagePool.getName());
242244
}
243245
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public static void setUp()
6464
STORAGE_POOL_NAME = "test-storage-pool-enc-" + UUID.randomUUID();
6565

6666
Util.cleanUpExistingDisks("test-hyperdisk-enc-", PROJECT_ID, ZONE);
67-
Util.cleanUpExistingStoragePool("test-storage-pool-enc-", PROJECT_ID, ZONE);
67+
Util.cleanUpExistingStoragePool("test-storage-pool-", PROJECT_ID, ZONE);
68+
Util.cleanUpExistingStoragePool("test-storage-pool-", PROJECT_ID, "us-central1-a");
69+
Util.cleanUpExistingStoragePool("test-storage-pool-", PROJECT_ID, "asia-south1-a");
70+
6871
}
6972

7073
@AfterAll

0 commit comments

Comments
 (0)