Skip to content

Commit

Permalink
Merge pull request SatelliteQE#2691 from anarang/rhai
Browse files Browse the repository at this point in the history
Adding test to verify if 'Unregister system' works correctly for RHAI.
  • Loading branch information
elyezer committed Aug 20, 2015
2 parents 9ef1223 + 2e2d634 commit 75b8a9b
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 49 deletions.
12 changes: 11 additions & 1 deletion robottelo/ui/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1987,5 +1987,15 @@ def __iter__(self):
("//div[@class='system-summary']/p")),
"insights.org_selection_msg": (
By.ID, "content"),

"insights.unregister_system": (
By.XPATH, (
"//table/tbody/tr/td[5]/a")),
"insights.unregister_button": (
By.XPATH, (
"//div[@class='sweet-alert showSweetAlert visible']//"
"button[@class='confirm']")),
"insights.no_systems_element": (
By.XPATH, (
"//div[@class='text-center']//h4")
),
})
77 changes: 39 additions & 38 deletions robottelo/ui/rhai.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,49 @@ def view_registered_systems(self):
return result

def register_client_to_rhai(self, activation_key, org):
with VirtualMachine(distro='rhel67') as vm:
# Download and Install ketello-ca rpm
vm.install_katello_cert()
vm.register_contenthost(activation_key, org)
self.vm = VirtualMachine(distro='rhel67')
self.vm.create()
# Download and Install ketello-ca rpm
self.vm.install_katello_cert()
self.vm.register_contenthost(activation_key, org)

# Red Hat Access Insights requires RHEL 6/7 repo and it not
# possible to sync the repo during the tests,
# adding a file in /etc/yum.repos.d/rhel6/7.repo
# Red Hat Access Insights requires RHEL 6/7 repo and it not
# possible to sync the repo during the tests,
# adding a file in /etc/yum.repos.d/rhel6/7.repo

rhel6_repo = conf.properties['insights.rhel6_repo']
rhel6_repo = conf.properties['insights.rhel6_repo']

repo_file = (
'[rhel6-rpms]\n'
'name=RHEL6\n'
'baseurl={0}\n'
'enabled=1\n'
.format(rhel6_repo)
)
repo_file = (
'[rhel6-rpms]\n'
'name=RHEL6\n'
'baseurl={0}\n'
'enabled=1\n'
.format(rhel6_repo)
)

vm.run(
'echo "{0}" >> /etc/yum.repos.d/rhel6.repo'
.format(repo_file)
)
self.vm.run(
'echo "{0}" >> /etc/yum.repos.d/rhel6.repo'
.format(repo_file)
)

# Install redhat-access-insights package
package_name = 'redhat-access-insights'
result = vm.run('yum install -y {0}'.format(package_name))
if result.return_code != 0:
raise AccessInsightsError(
'Unable to install redhat-access-insights rpm'
)
# Install redhat-access-insights package
package_name = 'redhat-access-insights'
result = self.vm.run('yum install -y {0}'.format(package_name))
if result.return_code != 0:
raise AccessInsightsError(
'Unable to install redhat-access-insights rpm'
)

# Verify if package is installed by query it
result = vm.run('rpm -q {0}'.format(package_name))
if result.return_code != 0:
raise AccessInsightsError(
'Unable to install redhat-access-insights rpm'
)
# Verify if package is installed by query it
result = self.vm.run('rpm -q {0}'.format(package_name))
if result.return_code != 0:
raise AccessInsightsError(
'Unable to install redhat-access-insights rpm'
)

# Register client with Red Hat Access Insights
result = vm.run('redhat-access-insights --register')
if result.return_code != 0:
raise AccessInsightsError(
'Unable to register client to Access Insights through '
'Satellite')
# Register client with Red Hat Access Insights
result = self.vm.run('redhat-access-insights --register')
if result.return_code != 0:
raise AccessInsightsError(
'Unable to register client to Access Insights through '
'Satellite')
62 changes: 52 additions & 10 deletions tests/foreman/rhai/test_rhai.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ def test_client_registration_to_rhai(self):
"""
# Register a VM to Access Insights Service
self.rhai.register_client_to_rhai(
self.ak_name,
self.org_label,
)
try:
self.rhai.register_client_to_rhai(
self.ak_name,
self.org_label,
)

with Session(self.browser) as session:
# view clients registered to Red Hat Access Insights
session.nav.go_to_select_org(self.org_name)
Navigator(self.browser).go_to_insights_systems()
result = self.rhai.view_registered_systems()
self.assertIn("1", result, 'Registered clients are not listed')
with Session(self.browser) as session:
# view clients registered to Red Hat Access Insights
session.nav.go_to_select_org(self.org_name)
Navigator(self.browser).go_to_insights_systems()
result = self.rhai.view_registered_systems()
self.assertIn("1", result, 'Registered clients are not listed')

finally:
self.rhai.vm.destroy()

def test_org_selection_for_rhai(self):
"""@Test: Verify that user attempting to access RHAI is directed to
Expand All @@ -101,3 +105,41 @@ def test_org_selection_for_rhai(self):
result = session.nav.wait_until_element(
locators['insights.org_selection_msg']).text
self.assertIn("Organization Selection Required", result)

def test_unregister_system_from_rhai(self):
"""@Test: Verify that 'Unregister' a system from RHAI works correctly
@Feature: If a machine if unregistered from the RHAI web interface,
then the client should be able to use the service.
@Assert: Once the machine is unregistered from the RHAI web interface
then the unregistered client machine should return a 1 on running the
service 'redhat-access-insights'
"""
# Register a VM to Access Insights Service
try:
self.rhai.register_client_to_rhai(
self.ak_name,
self.org_label,
)
with Session(self.browser) as session:
session.nav.go_to_select_org(self.org_name)
Navigator(self.browser).go_to_insights_systems()
# Click on the unregister icon 'X' in the table against the
# registered system listed.
session.nav.click(
locators['insights.unregister_system']
)
# Confirm selection for clicking on 'Yes' to unregister the
# system
session.nav.click(
locators['insights.unregister_button']
)
result = self.rhai.vm.run('redhat-access-insights')
self.assertEqual(result.return_code, 1,
"System has not been unregistered")

finally:
# Destroy the VM
self.rhai.vm.destroy()

0 comments on commit 75b8a9b

Please sign in to comment.