@@ -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,9 +99,12 @@ public static void setUpClass() throws InterruptedException, IOException {
9899 String newInstanceId = PrefixGenerator .newPrefix ("backupIT" );
99100 targetClusterHot = newInstanceId + "-c1" ;
100101
101- instanceAdmin .createInstance (
102- CreateInstanceRequest .of (newInstanceId )
103- .addCluster (targetClusterHot , testEnvRule .env ().getPrimaryZone (), 1 , StorageType .SSD ));
102+ testInstance =
103+ instanceAdmin .createInstance (
104+ CreateInstanceRequest .of (newInstanceId )
105+ .setDisplayName ("BigtableBackupIT" )
106+ .addCluster (
107+ targetClusterHot , testEnvRule .env ().getPrimaryZone (), 1 , StorageType .SSD ));
104108
105109 tableAdminHot =
106110 BigtableTableAdminClient .create (
@@ -122,6 +126,13 @@ public static void tearDownClass() {
122126 // Ignore.
123127 }
124128 }
129+ if (testInstance != null ) {
130+ try {
131+ instanceAdmin .deleteInstance (testInstance .getId ());
132+ } catch (Exception e ) {
133+ LOGGER .log (Level .WARNING , "Failed to clean up instance " , e );
134+ }
135+ }
125136 }
126137
127138 private static void deleteBackupIgnoreErrors (
0 commit comments