Skip to content
Permalink
Browse files
docs(samples): Fix flaky test (#397)
We found that UpdateTableExpirationIT is flaky since during table creation the table is not created.
  • Loading branch information
irvifa committed May 28, 2020
1 parent 117b49e commit 64847d1e5137e811e7f462fc058908fa9fcc55fb
Showing with 11 additions and 2 deletions.
  1. +11 −2 samples/snippets/src/test/java/com/example/bigquery/UpdateTableExpirationIT.java
@@ -19,8 +19,12 @@
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertNotNull;

import com.google.cloud.bigquery.Field;
import com.google.cloud.bigquery.Schema;
import com.google.cloud.bigquery.StandardSQLTypeName;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
@@ -58,8 +62,13 @@ public void tearDown() {

@Test
public void updateTableExpiration() {
String tableName = "update_expiration_table";
CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, null);
String suffix = UUID.randomUUID().toString().replace('-', '_');
String tableName = "update_expiration_table_" + suffix;
Schema schema =
Schema.of(
Field.of("stringField", StandardSQLTypeName.STRING),
Field.of("booleanField", StandardSQLTypeName.BOOL));
CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, schema);
Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
UpdateTableExpiration.updateTableExpiration(BIGQUERY_DATASET_NAME, tableName, newExpiration);
assertThat(bout.toString()).contains("Table expiration updated successfully");

0 comments on commit 64847d1

Please sign in to comment.