Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigquery: wait for copy to finish #1456

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.Assert.fail;

import com.google.cloud.Page;
import com.google.cloud.WaitForOption;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQuery.DatasetField;
import com.google.cloud.bigquery.BigQuery.DatasetOption;
Expand Down Expand Up @@ -899,7 +900,7 @@ public void testListJobsWithSelectedFields() {
}

@Test
public void testCreateAndGetJob() {
public void testCreateAndGetJob() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_source_table";
String destinationTableName = "test_create_and_get_job_destination_table";
TableId sourceTable = TableId.of(DATASET, sourceTableName);
Expand Down Expand Up @@ -930,11 +931,18 @@ public void testCreateAndGetJob() {
assertEquals(createdJob.getSelfLink(), remoteJob.getSelfLink());
assertEquals(createdJob.getUserEmail(), remoteJob.getUserEmail());
assertTrue(createdTable.delete());

Job completedJob =
remoteJob.waitFor(
WaitForOption.checkEvery(1, TimeUnit.SECONDS),
WaitForOption.timeout(1, TimeUnit.MINUTES));
assertNotNull(completedJob);
assertNull(completedJob.getStatus().getError());
assertTrue(bigquery.delete(DATASET, destinationTableName));
}

@Test
public void testCreateAndGetJobWithSelectedFields() {
public void testCreateAndGetJobWithSelectedFields() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_with_selected_fields_source_table";
String destinationTableName = "test_create_and_get_job_with_selected_fields_destination_table";
TableId sourceTable = TableId.of(DATASET, sourceTableName);
Expand Down Expand Up @@ -972,6 +980,13 @@ public void testCreateAndGetJobWithSelectedFields() {
assertNull(remoteJob.getSelfLink());
assertNull(remoteJob.getUserEmail());
assertTrue(createdTable.delete());

Job completedJob =
remoteJob.waitFor(
WaitForOption.checkEvery(1, TimeUnit.SECONDS),
WaitForOption.timeout(1, TimeUnit.MINUTES));
assertNotNull(completedJob);
assertNull(completedJob.getStatus().getError());
assertTrue(bigquery.delete(DATASET, destinationTableName));
}

Expand Down