Skip to content

Commit

Permalink
test: fix flaky test (#726)
Browse files Browse the repository at this point in the history
* test: fix flaky test

* test: fix flaky test
  • Loading branch information
Praful Makani committed Sep 8, 2020
1 parent fb6d543 commit 136d6fb
Showing 1 changed file with 10 additions and 13 deletions.
Expand Up @@ -860,7 +860,7 @@ public void testListTablesWithRangePartitioning() {

@Test
public void testListPartitions() throws InterruptedException {
String tableName = "test_table_partitions";
String tableName = "test_table_partitions_" + UUID.randomUUID().toString().substring(0, 8);
Date date = Date.fromJavaUtilDate(new java.util.Date());
String partitionDate = date.toString().replaceAll("-", "");
TableId tableId = TableId.of(DATASET, tableName + "$" + partitionDate);
Expand All @@ -873,18 +873,15 @@ public void testListPartitions() throws InterruptedException {
Job job = bigquery.create(JobInfo.of(QueryJobConfiguration.newBuilder(query).build()));
job.waitFor();
assertTrue(job.isDone());
try {
Map<String, Object> row = new HashMap<String, Object>();
row.put("StringField", "StringValue");
InsertAllRequest request = InsertAllRequest.newBuilder(tableId).addRow(row).build();
InsertAllResponse response = bigquery.insertAll(request);
assertFalse(response.hasErrors());
assertEquals(0, response.getInsertErrors().size());
List<String> partitions = bigquery.listPartitions(TableId.of(DATASET, tableName));
assertEquals(1, partitions.size());
} finally {
bigquery.delete(tableId);
}
Map<String, Object> row = new HashMap<>();
row.put("StringField", "StringValue");
InsertAllRequest request = InsertAllRequest.newBuilder(tableId).addRow(row).build();
InsertAllResponse response = bigquery.insertAll(request);
assertFalse(response.hasErrors());
assertEquals(0, response.getInsertErrors().size());
List<String> partitions = bigquery.listPartitions(TableId.of(DATASET, tableName));
assertEquals(1, partitions.size());
bigquery.delete(tableId);
}

@Test
Expand Down

0 comments on commit 136d6fb

Please sign in to comment.