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

Add Q-CTRL integration tests #1173

Merged
merged 25 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
096480b
add initial qctrl test file
kt474 Oct 25, 2023
949a372
add test & decorator
kt474 Oct 25, 2023
81d0d49
add tests from Mirko
kt474 Oct 25, 2023
cf5d284
Merge branch 'main' into qctrl-integration-tests
kt474 Nov 13, 2023
8a71575
Merge branch 'main' into qctrl-integration-tests
kt474 Nov 18, 2023
f34cd3a
Added assertness for preciseness of results
merav-aharoni Nov 23, 2023
79c1ff1
Merge branch 'main' into qctrl-integration-tests
kt474 Nov 28, 2023
2a20d47
Merge pull request #1 from merav-aharoni/qctrl_assertions
kt474 Nov 28, 2023
6420996
remove print statements
kt474 Nov 28, 2023
09161e9
move into e2e folder
kt474 Nov 28, 2023
730145a
Merge branch 'main' into qctrl-integration-tests
kt474 Nov 28, 2023
77dd09b
Merge branch 'main' into qctrl-integration-tests
kt474 Dec 12, 2023
bb62fbe
setup ci
kt474 Dec 12, 2023
6a1256b
Update q-ctrl-tests.yml
kt474 Dec 12, 2023
c46e25e
add account test
kt474 Dec 12, 2023
21a9735
Merge branch 'qctrl-integration-tests' of https://github.com/kt474/qi…
kt474 Dec 12, 2023
c87a0f8
add more account tests
kt474 Dec 12, 2023
b5c85ba
Update test/qctrl/test_qctrl.py
kt474 Dec 14, 2023
0d2a0a9
address comments
kt474 Dec 14, 2023
827280b
Merge branch 'qctrl-integration-tests' of https://github.com/kt474/qi…
kt474 Dec 14, 2023
6a45d78
Merge branch 'Qiskit:main' into qctrl-integration-tests
kt474 Dec 14, 2023
68577a1
Merge branch 'main' into qctrl-integration-tests
kt474 Dec 20, 2023
292e4fe
update date to 2023
kt474 Dec 20, 2023
79c676c
Update test/qctrl/test_qctrl.py
kt474 Dec 20, 2023
4b81f9a
Update test/qctrl/test_qctrl.py
kt474 Dec 20, 2023
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
53 changes: 53 additions & 0 deletions .github/workflows/q-ctrl-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
kt474 marked this conversation as resolved.
Show resolved Hide resolved
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

name: Q-CTRL Tests
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
integration-tests:
name: Run integration tests - ${{ matrix.environment }}
runs-on: ${{ matrix.os }}
strategy:
# avoid cancellation of in-progress jobs if any matrix job fails
fail-fast: false
matrix:
python-version: [ 3.9 ]
os: [ "ubuntu-latest" ]
environment: [ "ibm-cloud-staging" ]
environment: ${{ matrix.environment }}
env:
QISKIT_IBM_TOKEN: ${{ secrets.QISKIT_IBM_TOKEN_QCTRL }}
QISKIT_IBM_URL: ${{ secrets.QISKIT_IBM_URL }}
QISKIT_IBM_INSTANCE: ${{ secrets.QISKIT_IBM_INSTANCE_QCTRL }}
CHANNEL_STRATEGY: q-ctrl
LOG_LEVEL: DEBUG
STREAM_LOG: True
QISKIT_IN_PARALLEL: True
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -c constraints.txt -r requirements-dev.txt
- name: Run q-ctrl tests
run: python -m unittest test/qctrl/test_qctrl.py
10 changes: 7 additions & 3 deletions test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ def _wrapper(self, *args, **kwargs):


def _get_integration_test_config():
token, url, instance = (
token, url, instance, channel_strategy = (
os.getenv("QISKIT_IBM_TOKEN"),
os.getenv("QISKIT_IBM_URL"),
os.getenv("QISKIT_IBM_INSTANCE"),
os.getenv("CHANNEL_STRATEGY"),
)
channel: Any = "ibm_quantum" if url.find("quantum-computing.ibm.com") >= 0 else "ibm_cloud"
return channel, token, url, instance
return channel, token, url, instance, channel_strategy


def run_integration_test(func):
Expand Down Expand Up @@ -115,7 +116,7 @@ def _wrapper(self, *args, **kwargs):
["ibm_cloud", "ibm_quantum"] if supported_channel is None else supported_channel
)

channel, token, url, instance = _get_integration_test_config()
channel, token, url, instance, channel_strategy = _get_integration_test_config()
if not all([channel, token, url]):
raise Exception("Configuration Issue") # pylint: disable=broad-exception-raised

Expand All @@ -131,13 +132,15 @@ def _wrapper(self, *args, **kwargs):
channel=channel,
token=token,
url=url,
channel_strategy=channel_strategy,
)
dependencies = IntegrationTestDependencies(
channel=channel,
token=token,
url=url,
instance=instance,
service=service,
channel_strategy=channel_strategy,
)
kwargs["dependencies"] = dependencies
func(self, *args, **kwargs)
Expand All @@ -156,6 +159,7 @@ class IntegrationTestDependencies:
token: str
channel: str
url: str
channel_strategy: str


def integration_test_setup_with_backend(
Expand Down
23 changes: 23 additions & 0 deletions test/integration/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
get_resource_controller_api_url,
get_iam_api_url,
)
from qiskit_ibm_runtime.exceptions import IBMNotAuthorizedError
from ..ibm_test_case import IBMIntegrationTestCase
from ..decorators import IntegrationTestDependencies

Expand Down Expand Up @@ -51,6 +52,28 @@ def _skip_on_ibm_quantum(self):
if self.dependencies.channel == "ibm_quantum":
self.skipTest("Not supported on ibm_quantum")

def test_channel_strategy(self):
"""Test passing in a channel strategy."""
self._skip_on_ibm_quantum()
# test when channel strategy not supported by instance
with self.assertRaises(IBMNotAuthorizedError):
QiskitRuntimeService(
channel="ibm_cloud",
url=self.dependencies.url,
token=self.dependencies.token,
instance=self.dependencies.instance,
channel_strategy="q-ctrl",
)
# test passing in default
service = QiskitRuntimeService(
channel="ibm_cloud",
url=self.dependencies.url,
token=self.dependencies.token,
instance=self.dependencies.instance,
channel_strategy="default",
)
self.assertTrue(service)

def test_resolve_crn_for_valid_service_instance_name(self):
"""Verify if CRN is transparently resolved based for an existing service instance name."""
self._skip_on_ibm_quantum()
Expand Down
Loading
Loading