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

adding tmt #1

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7bf58a6
adding tmt
Lorquas Sep 13, 2023
344e354
removing manual trigger
Lorquas Sep 19, 2023
b19967c
using internal tf
Lorquas Sep 20, 2023
e890043
using internal tf
Lorquas Sep 20, 2023
c06d597
build: split spec file generation in own target
ptoscano Sep 21, 2023
ea7c132
build: split tarball generation in own target
ptoscano Sep 21, 2023
a17348a
build: drop unused replacement for spec file generation
ptoscano Sep 22, 2023
bfdd094
packit: try to do git builds
ptoscano Sep 21, 2023
7ac4b11
simple tmt test for version
ptoscano Sep 21, 2023
4a77dd6
initial integration test sample
ptoscano Sep 22, 2023
b1216e0
try to pick insights-client
ptoscano Sep 25, 2023
08cf6b6
Added an ansible playbook to deploy rhc tests
jstavel Oct 6, 2023
11e4842
removed ansible stuff - it is not required for simple workflow
jstavel Oct 9, 2023
3828c73
added test for disconnect
jstavel Oct 17, 2023
fcc149b
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel Oct 17, 2023
c6c8402
Added an ansible playbook to deploy rhc tests
jstavel Oct 6, 2023
0ad2a81
removed ansible stuff - it is not required for simple workflow
jstavel Oct 9, 2023
ff018fb
feat: all basic tests for rhc
jstavel Oct 26, 2023
1b3212e
feat: a test for inventory record
jstavel Oct 27, 2023
77686ea
feat: a test for tags in inventory
jstavel Oct 31, 2023
b4c8056
fix: Update testing matrix
jirihnidek Aug 22, 2023
4a1bf0f
build(deps): bump golang.org/x/sys
dependabot[bot] Aug 22, 2023
ac39596
fix: Fix issues of bash auto-complete script
jirihnidek Oct 2, 2023
2519b37
fix: insights connection status
ahitacat Oct 17, 2023
9db5d63
PEP8
Lorquas Nov 3, 2023
bf8e72b
adding pre-commit
Lorquas Nov 7, 2023
ae27bd1
fix: test.sh will use requirements.txt to install the whole python te…
jstavel Nov 15, 2023
2c9dc9a
fix: fixtures are returned by yield statement
jstavel Nov 15, 2023
1fd2f77
feat: fixture settings for Dynaconf to be available the pytest way
jstavel Nov 15, 2023
a13976f
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel Nov 15, 2023
d5aea8d
Merge branch 'RedHatInsights:packit' into packit
Archana-PandeyM Nov 21, 2023
8f09d3d
removed mqtt related fixture
jstavel Nov 21, 2023
e41f305
Merge branch 'packit' of github.com:Lorquas/rhc into packit
jstavel Nov 21, 2023
61b5fbf
fix: pre-commit issues fixed
jstavel Nov 22, 2023
fb01318
feat: rhc connecting using activation key
jstavel Nov 23, 2023
248ec0b
feat: rhc tests use fixture registered_system, not_registered_system …
jstavel Nov 24, 2023
2d132ef
feat: e2e tests uses registered_system and not_registered_system already
jstavel Nov 24, 2023
6c95c20
fix: removed unused dependencies
jstavel Nov 24, 2023
95579c8
feat: env pytest mark to specify a required dynaconf environment
jstavel Nov 27, 2023
0845ab3
fixed stdout verification
jstavel Jan 8, 2024
c80c118
added settings fixture, fixed a problem with stdout verification
jstavel Jan 8, 2024
02fc923
updated to use pytest-client-tools rather than conftest.py
jstavel Jan 10, 2024
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
1 change: 1 addition & 0 deletions integration-tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-subtests
100 changes: 95 additions & 5 deletions integration-tests/test_rhc.py
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")
Expand All @@ -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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for activation-key?

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()
Copy link
Owner Author

@Lorquas Lorquas Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you assign proc_stdout but never use it?

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"
12 changes: 12 additions & 0 deletions integration-tests/utils.py
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