forked from RedHatInsights/rhc
-
Notifications
You must be signed in to change notification settings - Fork 1
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
adding tmt #1
Open
Lorquas
wants to merge
42
commits into
main
Choose a base branch
from
packit
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
adding tmt #1
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
7bf58a6
adding tmt
Lorquas 344e354
removing manual trigger
Lorquas b19967c
using internal tf
Lorquas e890043
using internal tf
Lorquas c06d597
build: split spec file generation in own target
ptoscano ea7c132
build: split tarball generation in own target
ptoscano a17348a
build: drop unused replacement for spec file generation
ptoscano bfdd094
packit: try to do git builds
ptoscano 7ac4b11
simple tmt test for version
ptoscano 4a77dd6
initial integration test sample
ptoscano b1216e0
try to pick insights-client
ptoscano 08cf6b6
Added an ansible playbook to deploy rhc tests
jstavel 11e4842
removed ansible stuff - it is not required for simple workflow
jstavel 3828c73
added test for disconnect
jstavel fcc149b
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel c6c8402
Added an ansible playbook to deploy rhc tests
jstavel 0ad2a81
removed ansible stuff - it is not required for simple workflow
jstavel ff018fb
feat: all basic tests for rhc
jstavel 1b3212e
feat: a test for inventory record
jstavel 77686ea
feat: a test for tags in inventory
jstavel b4c8056
fix: Update testing matrix
jirihnidek 4a1bf0f
build(deps): bump golang.org/x/sys
dependabot[bot] ac39596
fix: Fix issues of bash auto-complete script
jirihnidek 2519b37
fix: insights connection status
ahitacat 9db5d63
PEP8
Lorquas bf8e72b
adding pre-commit
Lorquas ae27bd1
fix: test.sh will use requirements.txt to install the whole python te…
jstavel 2c9dc9a
fix: fixtures are returned by yield statement
jstavel 1fd2f77
feat: fixture settings for Dynaconf to be available the pytest way
jstavel a13976f
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel d5aea8d
Merge branch 'RedHatInsights:packit' into packit
Archana-PandeyM 8f09d3d
removed mqtt related fixture
jstavel e41f305
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel 61b5fbf
fix: pre-commit issues fixed
jstavel fb01318
feat: rhc connecting using activation key
jstavel 248ec0b
feat: rhc tests use fixture registered_system, not_registered_system …
jstavel 2d132ef
feat: e2e tests uses registered_system and not_registered_system already
jstavel 6c95c20
fix: removed unused dependencies
jstavel 95579c8
feat: env pytest mark to specify a required dynaconf environment
jstavel 0845ab3
fixed stdout verification
jstavel c80c118
added settings fixture, fixed a problem with stdout verification
jstavel 02fc923
updated to use pytest-client-tools rather than conftest.py
jstavel 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 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest-subtests |
This file contains 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import logging | ||
from packaging import version | ||
from functools import partial | ||
|
||
""" | ||
# rhc --version | ||
rhc version 0.2.4 | ||
""" | ||
def test_version(rhc, subtests): | ||
with subtests.test("RHC version"): | ||
proc = rhc.run("--version") | ||
|
@@ -11,24 +16,109 @@ def test_version(rhc, subtests): | |
rhc_version = version.parse(version_string.split()[2]) | ||
assert isinstance(rhc_version, version.Version) is True | ||
|
||
""" | ||
# rhc connect | ||
... it will connect a system to Red Hat services | ||
... it will prompt for username and password | ||
... it will inform a user about connection progress | ||
|
||
def test_rhc_register(external_candlepin, test_config, rhc, subtests): | ||
|
||
# rhc disconnect | ||
... it will disconnect from all Red Hat services | ||
... it will inform a user how it goes | ||
""" | ||
def test_rhc_connect_disconnect(external_candlepin, test_config, rhc, subtests): | ||
assert not rhc.is_registered | ||
candlepin_config = partial(test_config.get,"candlepin") | ||
with subtests.test(msg="RHC connect"): | ||
proc= rhc.connect( | ||
username=test_config.get("candlepin", "username"), | ||
password=test_config.get("candlepin", "password"), | ||
proc = rhc.connect( | ||
username=candlepin_config("username"), | ||
password=candlepin_config("password"), | ||
) | ||
logging.info(f'result is {proc.stdout}') | ||
assert "Successfully connected to Red Hat!" in proc.stdout.decode() | ||
assert rhc.is_registered | ||
|
||
with subtests.test(msg="RHC disconnect"): | ||
rhc.disconnect() | ||
proc = rhc.disconnect() | ||
proc_stdout = proc.stdout.decode() | ||
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. you assign |
||
logging.info(f'result of disconnect task: {proc.stdout}') | ||
assert not rhc.is_registered | ||
assert "Disconnected from Red Hat Subsription Management",\ | ||
"The application should inform a system is disconnected from Red Hat Subscription Management" | ||
jstavel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert "Disconnected from Red Hat Insights",\ | ||
"The application should inform a system is disconnected from Red Hat Insights" | ||
|
||
""" | ||
The application handles a case when a user provides wrong credentials. | ||
""" | ||
def test_rhc_connect_with_wrong_credentials(any_candlepin, test_config, rhc, subtests): | ||
assert not rhc.is_registered | ||
candlepin_config = partial(test_config.get,"candlepin") | ||
with subtests.test(msg="Wrong password"): | ||
proc = rhc.connect( | ||
username=candlepin_config("username"), | ||
password="WRONG-PASSWORD", | ||
) | ||
logging.info(f'result is {proc.stdout}') | ||
proc_stdout = proc.stdout.decode() | ||
proc_stderr = proc.stderr.decode() | ||
assert "error: Invalid username or password" in proc_stdout,\ | ||
"The application informs about wrong credentials" | ||
assert "To create a login, please visit https://www.redhat.com/wapps/ugc/register.html" in proc_stdout,\ | ||
"The application offers a way to fix it" | ||
assert "Traceback" not in proc_stdout + proc_stderr,\ | ||
"No traceback appears in an application response" | ||
|
||
with subtests.test(msg="Wrong username"): | ||
proc = rhc.connect( | ||
username="WRONG-USERNAME", | ||
password=candlepin_config("username"), | ||
) | ||
logging.info(f'result is {proc.stdout}') | ||
proc_stdout = proc.stdout.decode() | ||
proc_stderr = proc.stderr.decode() | ||
assert "error: Invalid username or password" in proc_stdout,\ | ||
"The application informs about wrong credentials" | ||
assert "To create a login, please visit https://www.redhat.com/wapps/ugc/register.html" in proc_stdout,\ | ||
"The application offers a way to fix it" | ||
assert "Traceback" not in proc_stdout + proc_stderr,\ | ||
"No traceback appears in an application response" | ||
|
||
|
||
""" | ||
The application handles a case when a system is already connected to Red Hat services. | ||
""" | ||
def test_rhc_connect_when_connected(any_candlepin, test_config, rhc, subtests): | ||
assert not rhc.is_registered | ||
candlepin_config = partial(test_config.get,"candlepin") | ||
proc_01 = rhc.connect( | ||
jstavel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
username=candlepin_config("username"), | ||
password=candlepin_config("password"), | ||
) | ||
proc_02 = rhc.connect( | ||
username=candlepin_config("username"), | ||
password=candlepin_config("password"), | ||
) | ||
logging.info(f'result of the second connect: {proc_02.stdout}') | ||
proc_02_stdout = proc_02.stdout.decode() | ||
assert "This might take a few seconds." in proc_02_stdout,\ | ||
"Application should inform about an activation progress" | ||
assert "This system is already connected to Red Hat Subscription Management" in proc_02_stdout,\ | ||
"Application should inform about connecting to Red Hat Subscription Management" | ||
assert "Enabled console.redhat.com services" in proc_02_stdout, \ | ||
"Application should inform about console.redhat.com service" | ||
|
||
|
||
""" | ||
The applications provides a status of connection to Red Hat services. | ||
""" | ||
def test_rhc_status(rhc): | ||
assert not rhc.is_registered | ||
proc = rhc.run("status") | ||
logging.info(f'rhc status is: {proc.stdout}') | ||
decoded_stdout = proc.stdout.decode() | ||
assert "Not connected to Red Hat Subscription Management" in decoded_stdout,\ | ||
"Application should inform about status of connection to Red Hat Subscription Management" | ||
assert "Not connected to Red Hat Insights" in decoded_stdout, \ | ||
"Application should inform about status of connection to Red Hat Insights" |
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sh | ||
import logging | ||
|
||
def show_rhcd_service_status(): | ||
sh.systemctl("status rhcd".split()) | ||
|
||
def rhcd_service_is_active(): | ||
try: | ||
stdout = sh.systemctl("is-active rhcd".split()).strip() | ||
return stdout == "active" | ||
except sh.ErrorReturnCode_3: | ||
return False |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test for activation-key?