Skip to content

Commit 9096e70

Browse files
authored
tests(bigtable): fix mv tests zone (#2609)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Rollback plan is reviewed and LGTMed - [ ] All new data plane features have a completed end to end testing plan Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent bd45d78 commit 9096e70

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.cloud.bigtable.admin.v2.models.CreateInstanceRequest;
2828
import com.google.cloud.bigtable.admin.v2.models.CreateMaterializedViewRequest;
2929
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
30-
import com.google.cloud.bigtable.admin.v2.models.Instance;
3130
import com.google.cloud.bigtable.admin.v2.models.MaterializedView;
3231
import com.google.cloud.bigtable.admin.v2.models.StorageType;
3332
import com.google.cloud.bigtable.admin.v2.models.Table;
@@ -39,7 +38,7 @@
3938
import java.io.IOException;
4039
import java.util.List;
4140
import java.util.logging.Logger;
42-
import org.junit.AfterClass;
41+
import org.junit.After;
4342
import org.junit.Before;
4443
import org.junit.BeforeClass;
4544
import org.junit.ClassRule;
@@ -55,10 +54,10 @@ public class BigtableMaterializedViewIT {
5554
private static final Logger LOGGER = Logger.getLogger(BigtableMaterializedViewIT.class.getName());
5655
private static final int[] BACKOFF_DURATION = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
5756

58-
private static BigtableInstanceAdminClient client;
59-
private static BigtableTableAdminClient tableAdminClient;
60-
private static Table testTable;
61-
private static String instanceId = "";
57+
private BigtableInstanceAdminClient client;
58+
private BigtableTableAdminClient tableAdminClient;
59+
private Table testTable;
60+
private String instanceId = "";
6261

6362
// TODO: Update this test once emulator supports InstanceAdmin operation
6463
// https://github.com/googleapis/google-cloud-go/issues/1069
@@ -68,33 +67,30 @@ public static void validatePlatform() throws IOException {
6867
.withMessage("BigtableInstanceAdminClient doesn't support on Emulator")
6968
.that(testEnvRule.env())
7069
.isNotInstanceOf(EmulatorEnv.class);
71-
72-
createInstance();
7370
}
7471

75-
public static void createInstance() throws IOException {
72+
@Before
73+
public void setUp() throws InterruptedException, IOException {
7674
client = testEnvRule.env().getInstanceAdminClient();
7775

78-
Instance instance =
79-
client.createInstance(
80-
CreateInstanceRequest.of(new PrefixGenerator().newPrefix())
81-
.addCluster("my-cluster", "us-east1-c", 3, StorageType.SSD));
82-
instanceId = instance.getId();
76+
instanceId = new PrefixGenerator().newPrefix();
77+
client.createInstance(
78+
CreateInstanceRequest.of(instanceId)
79+
.setDisplayName("BigtableMaterializedViewIT")
80+
.addCluster(
81+
instanceId + "-c1", testEnvRule.env().getPrimaryZone(), 1, StorageType.SSD));
8382
tableAdminClient = testEnvRule.env().getTableAdminClientForInstance(instanceId);
83+
84+
testTable = createTestTable(tableAdminClient);
8485
}
8586

86-
@AfterClass
87-
public static void deleteInstance() {
87+
@After
88+
public void deleteInstance() {
8889
if (!instanceId.isEmpty()) {
8990
client.deleteInstance(instanceId);
9091
}
9192
}
9293

93-
@Before
94-
public void setUp() throws InterruptedException {
95-
testTable = createTestTable(tableAdminClient);
96-
}
97-
9894
@Test
9995
public void createMaterializedViewAndGetMaterializedViewTest() {
10096
String materializedViewId = prefixGenerator.newPrefix();
@@ -209,8 +205,7 @@ private String getQuery() {
209205
+ "` GROUP BY _key";
210206
}
211207

212-
private static Table createTestTable(BigtableTableAdminClient tableAdmin)
213-
throws InterruptedException {
208+
private Table createTestTable(BigtableTableAdminClient tableAdmin) throws InterruptedException {
214209
String tableId = PrefixGenerator.newPrefix("BigtableMaterializedViewIT#createTestTable");
215210
Table testTable = tableAdmin.createTable(CreateTableRequest.of(tableId).addFamily("cf1"));
216211

0 commit comments

Comments
 (0)