Skip to content

Commit

Permalink
Minor integration test updates (Qiskit#1996)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 authored Oct 25, 2024
1 parent 9522760 commit e9b56a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
2 changes: 2 additions & 0 deletions test/integration/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def test_backend_target_history(self):
def test_backend_target_refresh(self):
"""Test refreshing the backend target."""
backend = self.backend
if backend.simulator:
raise SkipTest("Simulator target is the same.")
with self.subTest(backend=backend.name):
old_target = backend.target
old_configuration = backend.configuration()
Expand Down
53 changes: 0 additions & 53 deletions test/integration/test_ibm_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

"""IBMJob Test."""
import copy
import time
from datetime import datetime, timedelta
from unittest import SkipTest

from dateutil import tz
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.compiler import transpile
from qiskit.providers.jobstatus import JobStatus
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
Expand All @@ -44,57 +42,6 @@ def setUp(self):
self.sim_job = sampler.run([self.isa_circuit])
self.last_month = datetime.now() - timedelta(days=30)

def test_run_multiple_simulator(self):
"""Test running multiple jobs in a simulator."""
num_qubits = 16
quantum_register = QuantumRegister(num_qubits, "qr")
classical_register = ClassicalRegister(num_qubits, "cr")
quantum_circuit = QuantumCircuit(quantum_register, classical_register)
for i in range(num_qubits - 1):
quantum_circuit.cx(quantum_register[i], quantum_register[i + 1])
quantum_circuit.measure(quantum_register, classical_register)
num_jobs = 4
sampler = Sampler(mode=self.sim_backend)
job_array = [
sampler.run([transpile(quantum_circuit, backend=self.sim_backend)] * 20, shots=2048)
for _ in range(num_jobs)
]
timeout = 30
start_time = time.time()
while True:
check = sum(job.status() == "RUNNING" for job in job_array)
if check >= 2:
self.log.info("found %d simultaneous jobs", check)
break
if all((job.status() == "DONE" for job in job_array)):
# done too soon? don't generate error
self.log.warning("all jobs completed before simultaneous jobs could be detected")
break
for job in job_array:
self.log.info(
"%s %s %s %s",
job.status(),
job.status() == "RUNNING",
check,
job.job_id(),
)
self.log.info("- %s", str(time.time() - start_time))
if time.time() - start_time > timeout and self.sim_backend.status().pending_jobs <= 4:
raise TimeoutError(
"Failed to see multiple running jobs after " "{0} seconds.".format(timeout)
)
time.sleep(0.2)

result_array = [job.result() for job in job_array]
self.log.info("got back all job results")
# Ensure all jobs have finished.
self.assertTrue(all((job.status() == "DONE" for job in job_array)))
self.assertTrue(all((result.metadata for result in result_array)))

# Ensure job ids are unique.
job_ids = [job.job_id() for job in job_array]
self.assertEqual(sorted(job_ids), sorted(list(set(job_ids))))

def test_cancel(self):
"""Test job cancellation."""
if self.dependencies.channel == "ibm_cloud":
Expand Down

0 comments on commit e9b56a6

Please sign in to comment.