Skip to content

Commit

Permalink
docs(samples): Fix flaky test (#397)
Browse files Browse the repository at this point in the history
We found that UpdateTableExpirationIT is flaky since during table creation the table is not created.
  • Loading branch information
irvifa authored May 28, 2020
1 parent 117b49e commit 64847d1
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 64847d1

Please sign in to comment.