Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions web/pgadmin/tools/backup/tests/test_backup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ def create_backup_job(tester, url, params, assert_equal):

def run_backup_job(tester, job_id, expected_params, assert_in, assert_not_in,
assert_equal):
cnt = 0
the_process = None
while True:
if cnt >= 5:
break
# Wait up to 30s for the background pg_dump to actually finish.
# The completion signal is `exit_code` becoming non-None — NOT the
# mere presence of `execution_time`, which is set while the process
# is still running.
for _ in range(60):
# Check the process list
response1 = tester.get('/misc/bgprocess/?_={0}'.format(
secrets.choice(range(1, 9999999))))
Expand All @@ -39,13 +40,12 @@ def run_backup_job(tester, job_id, expected_params, assert_in, assert_not_in,
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception:
except StopIteration:
the_process = None

if the_process and 'execution_time' in the_process:
if the_process and the_process.get('exit_code') is not None:
break
time.sleep(0.5)
cnt += 1

assert_equal('execution_time' in the_process, True)
assert_equal('stime' in the_process, True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ def create_import_export_job(tester, url, params, assert_equal):

def run_import_export_job(tester, job_id, expected_params, assert_in,
assert_not_in, assert_equal):
cnt = 0
the_process = None
while True:
if cnt >= 5:
break
# Wait up to 30s for the background psql/COPY job to actually finish.
# The completion signal is `exit_code` becoming non-None — NOT the
# mere presence of `execution_time`, which is set while the process
# is still running.
for _ in range(60):
# Check the process list
response1 = tester.get('/misc/bgprocess/?_={0}'.format(
secrets.choice(range(1, 9999999))))
Expand All @@ -52,13 +53,12 @@ def run_import_export_job(tester, job_id, expected_params, assert_in,
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception:
except StopIteration:
the_process = None

if the_process and 'execution_time' in the_process:
if the_process and the_process.get('exit_code') is not None:
break
time.sleep(0.5)
cnt += 1

assert_equal('execution_time' in the_process, True)
assert_equal('stime' in the_process, True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def runTest(self):
response_data = json.loads(response.data.decode('utf-8'))
job_id = response_data['data']['job_id']

cnt = 0
the_process = None
while True:
if cnt >= 10:
break
# Wait up to 30s for the background maintenance command to
# actually finish. The completion signal is `exit_code` becoming
# non-None — NOT the mere presence of `execution_time`, which is
# set while the process is still running.
for _ in range(60):
# Check the process list
response1 = self.tester.get('/misc/bgprocess/?_={0}'.format(
secrets.choice(range(1, 9999999))))
Expand All @@ -87,13 +88,12 @@ def runTest(self):
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception:
except StopIteration:
the_process = None

if the_process and 'execution_time' in the_process:
if the_process and the_process.get('exit_code') is not None:
break
time.sleep(0.5)
cnt += 1

self.assertTrue('execution_time' in the_process)
self.assertTrue('stime' in the_process)
Expand Down
14 changes: 7 additions & 7 deletions web/pgadmin/tools/restore/tests/test_create_restore_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ def runTest(self):
response_data = json.loads(response.data.decode('utf-8'))
job_id = response_data['data']['job_id']

cnt = 0
the_process = None
while True:
if cnt >= 5:
break
# Wait up to 30s for the background pg_restore to actually
# finish. The completion signal is `exit_code` becoming non-None
# — NOT the mere presence of `execution_time`, which is set
# while the process is still running.
for _ in range(60):
# Check the process list
response1 = self.tester.get('/misc/bgprocess/?_={0}'.format(
secrets.choice(range(1, 9999999))))
Expand All @@ -179,13 +180,12 @@ def runTest(self):
try:
the_process = next(
p for p in process_list if p['id'] == job_id)
except Exception:
except StopIteration:
the_process = None

if the_process and 'execution_time' in the_process:
if the_process and the_process.get('exit_code') is not None:
break
time.sleep(0.5)
cnt += 1

self.assertTrue('execution_time' in the_process)
self.assertTrue('stime' in the_process)
Expand Down
Loading