test(bigtable): Enable tests (#2582) · googleapis/java-bigtable@4285a7e · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 4285a7e

Browse files
authored
test(bigtable): Enable tests (#2582)
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: - [x] 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 - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Rollback plan is reviewed and LGTMed - [x] 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 d9ba32b commit 4285a7e

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,76 @@
2424
import com.google.api.gax.rpc.NotFoundException;
2525
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient;
2626
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
27+
import com.google.cloud.bigtable.admin.v2.models.CreateInstanceRequest;
2728
import com.google.cloud.bigtable.admin.v2.models.CreateMaterializedViewRequest;
2829
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
30+
import com.google.cloud.bigtable.admin.v2.models.Instance;
2931
import com.google.cloud.bigtable.admin.v2.models.MaterializedView;
32+
import com.google.cloud.bigtable.admin.v2.models.StorageType;
3033
import com.google.cloud.bigtable.admin.v2.models.Table;
3134
import com.google.cloud.bigtable.admin.v2.models.UpdateMaterializedViewRequest;
3235
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv;
3336
import com.google.cloud.bigtable.test_helpers.env.PrefixGenerator;
3437
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule;
3538
import io.grpc.StatusRuntimeException;
39+
import java.io.IOException;
3640
import java.util.List;
3741
import java.util.logging.Logger;
42+
import org.junit.AfterClass;
3843
import org.junit.Before;
3944
import org.junit.BeforeClass;
4045
import org.junit.ClassRule;
41-
import org.junit.Ignore;
4246
import org.junit.Rule;
4347
import org.junit.Test;
4448
import org.junit.runner.RunWith;
4549
import org.junit.runners.JUnit4;
4650

4751
@RunWith(JUnit4.class)
48-
@Ignore("Not fully working yet in production")
4952
public class BigtableMaterializedViewIT {
5053
@ClassRule public static final TestEnvRule testEnvRule = new TestEnvRule();
5154
@Rule public final PrefixGenerator prefixGenerator = new PrefixGenerator();
5255
private static final Logger LOGGER = Logger.getLogger(BigtableMaterializedViewIT.class.getName());
5356
private static final int[] BACKOFF_DURATION = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
5457

5558
private static BigtableInstanceAdminClient client;
59+
private static BigtableTableAdminClient tableAdminClient;
5660
private static Table testTable;
57-
58-
private String instanceId = testEnvRule.env().getInstanceId();
61+
private static String instanceId = "";
5962

6063
// TODO: Update this test once emulator supports InstanceAdmin operation
6164
// https://github.com/googleapis/google-cloud-go/issues/1069
6265
@BeforeClass
63-
public static void validatePlatform() {
66+
public static void validatePlatform() throws IOException {
6467
assume()
6568
.withMessage("BigtableInstanceAdminClient doesn't support on Emulator")
6669
.that(testEnvRule.env())
6770
.isNotInstanceOf(EmulatorEnv.class);
71+
72+
createInstance();
73+
}
74+
75+
public static void createInstance() throws IOException {
76+
client = testEnvRule.env().getInstanceAdminClient();
77+
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();
83+
tableAdminClient =
84+
BigtableTableAdminClient.create(testEnvRule.env().getProjectId(), instanceId);
85+
}
86+
87+
@AfterClass
88+
public static void deleteInstance() {
89+
if (!instanceId.isEmpty()) {
90+
client.deleteInstance(instanceId);
91+
}
6892
}
6993

7094
@Before
7195
public void setUp() throws InterruptedException {
72-
client = testEnvRule.env().getInstanceAdminClient();
73-
testTable = createTestTable(testEnvRule.env().getTableAdminClient());
96+
testTable = createTestTable(tableAdminClient);
7497
}
7598

7699
@Test

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.