Skip to content

Commit

Permalink
Wait for load jobs to complete in system tests. (googleapis#3782)
Browse files Browse the repository at this point in the history
  • Loading branch information
tswast authored and landrito committed Aug 22, 2017
1 parent 2251178 commit 066f540
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bigquery/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from test_utils.system import unique_resource_id


JOB_TIMEOUT = 120 # 2 minutes
WHERE = os.path.abspath(os.path.dirname(__file__))


Expand Down Expand Up @@ -381,8 +382,7 @@ def test_load_table_from_local_file_then_dump_table(self):
)

# Retry until done.
retry = RetryInstanceState(_job_done, max_tries=8)
retry(job.reload)()
job.result(timeout=JOB_TIMEOUT)

self.assertEqual(job.output_rows, len(ROWS))

Expand Down Expand Up @@ -419,8 +419,7 @@ def test_load_table_from_local_avro_file_then_dump_table(self):
)

# Retry until done.
retry = RetryInstanceState(_job_done, max_tries=8)
retry(job.reload)()
job.result(timeout=JOB_TIMEOUT)

self.assertEqual(job.output_rows, len(ROWS))

Expand Down Expand Up @@ -770,8 +769,7 @@ def _load_table_for_dml(self, rows, dataset_name, table_name):
)

# Retry until done.
retry = RetryInstanceState(_job_done, max_tries=8)
retry(job.reload)()
job.result(timeout=JOB_TIMEOUT)
self._fetch_single_page(table)

def test_sync_query_w_dml(self):
Expand Down Expand Up @@ -799,7 +797,9 @@ def test_dbapi_w_dml(self):
WHERE greeting = 'Hello World'
"""

Config.CURSOR.execute(query_template.format(dataset_name, table_name))
Config.CURSOR.execute(
query_template.format(dataset_name, table_name),
job_id='test_dbapi_w_dml_{}'.format(unique_resource_id()))
self.assertEqual(Config.CURSOR.rowcount, 1)
self.assertIsNone(Config.CURSOR.fetchone())

Expand Down Expand Up @@ -1086,7 +1086,7 @@ def test_async_query_future(self):
str(uuid.uuid4()), 'SELECT 1')
query_job.use_legacy_sql = False

iterator = query_job.result().fetch_data()
iterator = query_job.result(timeout=JOB_TIMEOUT).fetch_data()
rows = list(iterator)
self.assertEqual(rows, [(1,)])

Expand Down

0 comments on commit 066f540

Please sign in to comment.