3131import com .google .cloud .bigtable .admin .v2 .models .CreateBackupRequest ;
3232import com .google .cloud .bigtable .admin .v2 .models .CreateInstanceRequest ;
3333import com .google .cloud .bigtable .admin .v2 .models .CreateTableRequest ;
34+ import com .google .cloud .bigtable .admin .v2 .models .Instance ;
3435import com .google .cloud .bigtable .admin .v2 .models .Instance .Type ;
3536import com .google .cloud .bigtable .admin .v2 .models .RestoreTableRequest ;
3637import com .google .cloud .bigtable .admin .v2 .models .RestoredTableResult ;
@@ -78,6 +79,7 @@ public class BigtableBackupIT {
7879
7980 private static String targetCluster ;
8081 private static String targetClusterHot ;
82+ private static Instance testInstance ;
8183 private static Table testTable ;
8284 private static Table testTableHot ;
8385
@@ -98,9 +100,12 @@ public static void setUpClass() throws InterruptedException, IOException {
98100 String newInstanceId = PrefixGenerator .newPrefix ("backupIT" );
99101 targetClusterHot = newInstanceId + "-c1" ;
100102
101- instanceAdmin .createInstance (
102- CreateInstanceRequest .of (newInstanceId )
103- .addCluster (targetClusterHot , testEnvRule .env ().getPrimaryZone (), 1 , StorageType .SSD ));
103+ testInstance =
104+ instanceAdmin .createInstance (
105+ CreateInstanceRequest .of (newInstanceId )
106+ .setDisplayName ("BigtableBackupIT" )
107+ .addCluster (
108+ targetClusterHot , testEnvRule .env ().getPrimaryZone (), 1 , StorageType .SSD ));
104109
105110 tableAdminHot =
106111 BigtableTableAdminClient .create (
@@ -122,6 +127,13 @@ public static void tearDownClass() {
122127 // Ignore.
123128 }
124129 }
130+ if (testInstance != null ) {
131+ try {
132+ instanceAdmin .deleteInstance (testInstance .getId ());
133+ } catch (Exception e ) {
134+ // Ignore.
135+ }
136+ }
125137 }
126138
127139 private static void deleteBackupIgnoreErrors (
0 commit comments