Skip to content

Commit aa351b4

Browse files
authored
test: Fix SchemaBundle BTQL integration test (#2705)
1 parent 1bfb763 commit aa351b4

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@
5353
@RunWith(JUnit4.class)
5454
public class ExecuteQueryIT {
5555

56-
public static String SCHEMA_BUNDLE_ID = "my_bundle";
57-
5856
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule();
5957
private static BigtableDataClient dataClient;
6058
private static String tableId;
59+
private static String schemaBundleId;
6160
private static String cf;
6261
private static String uniquePrefix;
6362

@@ -78,6 +77,7 @@ public static void setUpAll() throws IOException {
7877
dataClient = testEnvRule.env().getDataClient();
7978
cf = testEnvRule.env().getFamilyId();
8079
uniquePrefix = UUID.randomUUID() + "-execute-query-it-";
80+
schemaBundleId = UUID.randomUUID() + "-bundle";
8181

8282
dataClient.mutateRow(
8383
RowMutation.create(TableId.of(tableId), uniquePrefix + "a")
@@ -161,7 +161,7 @@ public void withHistoryQuery() {
161161

162162
@SuppressWarnings("DoubleBraceInitialization")
163163
@Test
164-
public void allTypes() {
164+
public void allTypes() throws Exception {
165165
createTestSchemaBundle();
166166
Album album = Album.newBuilder().setTitle("Lover").build();
167167
PreparedStatement preparedStatement =
@@ -172,11 +172,11 @@ public void allTypes() {
172172
+ " STRUCT(1 as a, \"foo\" as b) AS structCol, [1,2,3] AS arrCol, "
173173
+ cf
174174
+ " as mapCol, "
175-
+ " CAST(b'\022\005Lover' AS "
176-
+ SCHEMA_BUNDLE_ID
177-
+ ".com.google.cloud.bigtable.data.v2.test.Album) as protoCol, CAST('JAZZ' AS "
178-
+ SCHEMA_BUNDLE_ID
179-
+ ".com.google.cloud.bigtable.data.v2.test.Genre) as enumCol FROM `"
175+
+ " CAST(b'\022\005Lover' AS `"
176+
+ schemaBundleId
177+
+ ".com.google.cloud.bigtable.data.v2.test.Album`) as protoCol, CAST('JAZZ' AS `"
178+
+ schemaBundleId
179+
+ ".com.google.cloud.bigtable.data.v2.test.Genre`) as enumCol FROM `"
180180
+ tableId
181181
+ "` WHERE _key='"
182182
+ uniquePrefix
@@ -400,18 +400,23 @@ public void testNullColumns() {
400400
}
401401

402402
private static void deleteTestSchemaBundle() {
403-
testEnvRule.env().getTableAdminClient().deleteSchemaBundle(tableId, SCHEMA_BUNDLE_ID);
403+
testEnvRule.env().getTableAdminClient().deleteSchemaBundle(tableId, schemaBundleId);
404404
}
405405

406-
private static void createTestSchemaBundle() {
406+
private static void createTestSchemaBundle() throws Exception {
407407
FileDescriptorSet fileDescriptorSet =
408408
FileDescriptorSet.newBuilder()
409409
.addFile(Singer.getDescriptor().getFile().toProto())
410410
.addFile(Album.getDescriptor().getFile().toProto())
411411
.build();
412412
CreateSchemaBundleRequest request =
413-
CreateSchemaBundleRequest.of(tableId, SCHEMA_BUNDLE_ID)
413+
CreateSchemaBundleRequest.of(tableId, schemaBundleId)
414414
.setProtoSchema(fileDescriptorSet.toByteString());
415415
testEnvRule.env().getTableAdminClient().createSchemaBundle(request);
416+
417+
// For some reason the ExecuteQuery data path sometimes cannot resolve a newly-created schema
418+
// bundle immediately after its creation. Adding a manual sleep to avoid test flakiness until
419+
// the underlying issue is resolved.
420+
Thread.sleep(5000);
416421
}
417422
}

0 commit comments

Comments
 (0)