Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 9a6787c

Browse files
committed
test: clean up instance in test
Change-Id: Ib3a73e2cc24f7e27fd346eb80b7ec5175e3c11a4
1 parent b6cb64a commit 9a6787c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableBackupIT.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class BigtableBackupIT {
8080
private static String targetClusterHot;
8181
private static Table testTable;
8282
private static Table testTableHot;
83+
private static Instance testInstance;
8384

8485
@BeforeClass
8586
public static void setUpClass() throws InterruptedException, IOException {
@@ -98,8 +99,9 @@ public static void setUpClass() throws InterruptedException, IOException {
9899
String newInstanceId = PrefixGenerator.newPrefix("backupIT");
99100
targetClusterHot = newInstanceId + "-c1";
100101

101-
instanceAdmin.createInstance(
102+
testInstance = instanceAdmin.createInstance(
102103
CreateInstanceRequest.of(newInstanceId)
104+
.setDisplayName("BigtableBackupIT")
103105
.addCluster(targetClusterHot, testEnvRule.env().getPrimaryZone(), 1, StorageType.SSD));
104106

105107
tableAdminHot =
@@ -122,6 +124,13 @@ public static void tearDownClass() {
122124
// Ignore.
123125
}
124126
}
127+
if (testInstance != null) {
128+
try {
129+
instanceAdmin.deleteInstance(testInstance.getId());
130+
} catch (Exception e) {
131+
LOGGER.log(Level.WARNING, "Failed to clean up instance ", e);
132+
}
133+
}
125134
}
126135

127136
private static void deleteBackupIgnoreErrors(

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableCmekIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public static void validatePlatform() throws IOException {
115115
LOGGER.info("Creating cluster in zone: " + zones.get(0));
116116
instanceAdmin.createInstance(
117117
CreateInstanceRequest.of(instanceId)
118+
.setDisplayName("BigtableCmekIT")
118119
.addCmekCluster(clusterId1, zones.get(0), 1, StorageType.SSD, kmsKeyName));
119120
// Create a table. Key is inherited from the cluster configuration
120121
tableAdmin.createTable(CreateTableRequest.of(TEST_TABLE_ID).addFamily("cf"));

0 commit comments

Comments
 (0)