Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 64847d1

Browse files
authoredMay 28, 2020
docs(samples): Fix flaky test (#397)
We found that UpdateTableExpirationIT is flaky since during table creation the table is not created.
1 parent 117b49e commit 64847d1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static junit.framework.TestCase.assertNotNull;
2121

22+
import com.google.cloud.bigquery.Field;
23+
import com.google.cloud.bigquery.Schema;
24+
import com.google.cloud.bigquery.StandardSQLTypeName;
2225
import java.io.ByteArrayOutputStream;
2326
import java.io.PrintStream;
27+
import java.util.UUID;
2428
import java.util.concurrent.TimeUnit;
2529
import org.junit.After;
2630
import org.junit.Before;
@@ -58,8 +62,13 @@ public void tearDown() {
5862

5963
@Test
6064
public void updateTableExpiration() {
61-
String tableName = "update_expiration_table";
62-
CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, null);
65+
String suffix = UUID.randomUUID().toString().replace('-', '_');
66+
String tableName = "update_expiration_table_" + suffix;
67+
Schema schema =
68+
Schema.of(
69+
Field.of("stringField", StandardSQLTypeName.STRING),
70+
Field.of("booleanField", StandardSQLTypeName.BOOL));
71+
CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, schema);
6372
Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
6473
UpdateTableExpiration.updateTableExpiration(BIGQUERY_DATASET_NAME, tableName, newExpiration);
6574
assertThat(bout.toString()).contains("Table expiration updated successfully");

0 commit comments

Comments
 (0)
Failed to load comments.