Skip to content

Commit

Permalink
Update flaky integration tests (#1359)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 authored Jan 31, 2024
1 parent 959b9ae commit d4d55e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
2 changes: 1 addition & 1 deletion test/integration/test_ibm_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_retrieve_jobs_order(self):
job = self.sim_backend.run(self.bell)
job.wait_for_final_state()
newest_jobs = self.service.jobs(
limit=10,
limit=20,
pending=False,
descending=True,
created_after=self.last_month,
Expand Down
32 changes: 0 additions & 32 deletions test/integration/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ..unit.mock.proxy_server import MockProxyServer, use_proxies
from ..ibm_test_case import IBMIntegrationJobTestCase
from ..decorators import run_integration_test
from ..utils import cancel_job_safe, wait_for_status


class TestIntegrationResults(IBMIntegrationJobTestCase):
Expand Down Expand Up @@ -199,37 +198,6 @@ def result_callback(job_id, result):
self.assertEqual(iterations - 1, final_it)
self.assertIsNotNone(job._ws_client._server_close_code)

@run_integration_test
def test_callback_cancel_job(self, service):
"""Test canceling a running job while streaming results."""

def result_callback(job_id, result):
# pylint: disable=unused-argument
nonlocal final_it
if "iteration" in result:
final_it = result["iteration"]

final_it = 0
iterations = 5
sub_tests = [JobStatus.QUEUED, JobStatus.RUNNING]

for status in sub_tests:
with self.subTest(status=status):
if status == JobStatus.QUEUED:
_ = self._run_program(service)

job = self._run_program(
service=service,
interim_results="foo",
callback=result_callback,
)
wait_for_status(job, status)
if not cancel_job_safe(job, self.log):
return
time.sleep(3) # Wait for cleanup
self.assertIsNotNone(job._ws_client._server_close_code)
self.assertLess(final_it, iterations)

@skip("skip until qiskit-ibm-runtime #933 is fixed")
@run_integration_test
def test_websocket_proxy(self, service):
Expand Down
4 changes: 3 additions & 1 deletion test/integration/test_retrieve_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def test_jobs_filter_by_date(self, service):
job = self._run_program(service)
job.wait_for_final_state()
time_after_job = datetime.now(timezone.utc)
rjobs = service.jobs(created_before=time_after_job, created_after=current_time)
rjobs = service.jobs(
created_before=time_after_job, created_after=current_time, pending=False, limit=20
)
self.assertTrue(job.job_id() in [j.job_id() for j in rjobs])
for job in rjobs:
self.assertTrue(job.creation_date <= time_after_job)
Expand Down

0 comments on commit d4d55e5

Please sign in to comment.