-
Notifications
You must be signed in to change notification settings - Fork 22
enable smoke test with CRD 3scale client #643
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
Open
mkudlej
wants to merge
2
commits into
3scale-qe:main
Choose a base branch
from
mkudlej:capabilities_client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ | |
import pytest | ||
from dynaconf.vendor.box.exceptions import BoxKeyError | ||
from pytest_metadata.plugin import metadata_key | ||
from threescale_api import client, errors | ||
from threescale_api_crd import client as crd_client | ||
from threescale_api import client as rest_client | ||
from threescale_api import errors | ||
from weakget import weakget | ||
|
||
# to actually initialize all the providers | ||
|
@@ -51,6 +53,13 @@ def term_handler(): | |
signal.signal(signal.SIGTERM, orig) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def api_client_type(pytestconfig): | ||
"""Do tests use REST API client(False) or CR Capabilities client(True)?""" | ||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rename this fixture to something like |
||
|
||
return pytestconfig.getoption("capabilities") | ||
|
||
|
||
def pytest_addoption(parser): | ||
"""Add option to include disruptive tests in testrun""" | ||
|
||
|
@@ -78,6 +87,9 @@ def pytest_addoption(parser): | |
help="Skip tests incompatible with persistence " "plugin (default: False)", | ||
) | ||
parser.addoption("--images", action="store_true", default=False, help="Run also image check tests (default: False)") | ||
parser.addoption( | ||
"--capabilities", action="store_true", default=False, help="Run tests with CR api client (default: False)" | ||
) | ||
|
||
|
||
# there are many branches as there are many options to influence test selection | ||
|
@@ -125,6 +137,10 @@ def pytest_runtest_setup(item): | |
else: | ||
if Capability.APICAST not in CapabilityRegistry(): | ||
pytest.skip(f"Skipping test because current gateway doesn't have implicit capability {Capability.APICAST}") | ||
if "/cr_capabilities/" in item.nodeid and not item.config.getoption("--capabilities"): | ||
pytest.skip("Excluding CR Capabilities tests") | ||
if "nocrcap" in marks and item.config.getoption("--capabilities"): | ||
pytest.skip("Excluding tests incompatible with CR capabilities") | ||
|
||
|
||
@pytest.hookimpl(hookwrapper=True) | ||
|
@@ -374,9 +390,8 @@ def testconfig(): | |
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def threescale(testconfig, request): | ||
def threescale(testconfig, request, api_client_type): | ||
"Threescale client" | ||
|
||
if weakget(testconfig)["fixtures"]["threescale"]["private_tenant"] % False: | ||
custom_tenant = request.getfixturevalue("custom_tenant") | ||
password = secrets.token_urlsafe(16) | ||
|
@@ -399,7 +414,16 @@ def threescale(testconfig, request): | |
|
||
return admin | ||
|
||
return client.ThreeScaleClient( | ||
if api_client_type: | ||
return crd_client.ThreeScaleClientCRD( | ||
testconfig["threescale"]["admin"]["url"], | ||
testconfig["threescale"]["admin"]["token"], | ||
ssl_verify=testconfig["ssl_verify"], | ||
ocp_namespace=testconfig["openshift"]["projects"]["threescale"]["name"], | ||
wait=0, | ||
) | ||
|
||
return rest_client.ThreeScaleClient( | ||
testconfig["threescale"]["admin"]["url"], | ||
testconfig["threescale"]["admin"]["token"], | ||
ssl_verify=testconfig["ssl_verify"], | ||
|
@@ -408,10 +432,18 @@ def threescale(testconfig, request): | |
|
||
|
||
@pytest.fixture(scope="session") | ||
def master_threescale(testconfig): | ||
def master_threescale(testconfig, api_client_type): | ||
"""Threescale client using master url and token""" | ||
|
||
return client.ThreeScaleClient( | ||
if api_client_type: | ||
return crd_client.ThreeScaleClientCRD( | ||
testconfig["threescale"]["master"]["url"], | ||
testconfig["threescale"]["master"]["token"], | ||
ssl_verify=testconfig["ssl_verify"], | ||
ocp_namespace=testconfig["openshift"]["projects"]["threescale"]["name"], | ||
) | ||
|
||
return rest_client.ThreeScaleClient( | ||
testconfig["threescale"]["master"]["url"], | ||
testconfig["threescale"]["master"]["token"], | ||
ssl_verify=testconfig["ssl_verify"], | ||
|
@@ -841,6 +873,8 @@ def _custom_service( | |
params["description"] = blame_desc(request, params.get("description")) | ||
|
||
svc = threescale_client.services.create(params=params) | ||
if len(svc.mapping_rules.list()) == 0: | ||
svc.mapping_rules.create(rawobj.Mapping(svc.metrics.list()[0], pattern="/")) | ||
|
||
self._autoclean = autoclean | ||
if not testconfig["skip_cleanup"]: | ||
|
@@ -851,7 +885,6 @@ def finalizer(): | |
hook(svc) | ||
except Exception: # pylint: disable=broad-except | ||
pass | ||
|
||
svc.delete() | ||
|
||
with self._lock: | ||
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.