|
12 | 12 |
|
13 | 13 | """ |
14 | 14 |
|
| 15 | +from airgun.exceptions import NoSuchElementException |
15 | 16 | from fauxfactory import gen_string |
16 | 17 | from nailgun import client |
17 | 18 | from nailgun.entity_mixins import TaskFailedError |
18 | 19 | import pytest |
19 | 20 |
|
20 | 21 | from robottelo.config import get_credentials, settings |
| 22 | +from robottelo.constants import ANY_CONTEXT |
21 | 23 | from robottelo.hosts import get_sat_version |
22 | 24 |
|
23 | 25 | CAPSULE_TARGET_VERSION = f'6.{get_sat_version().minor}.z' |
@@ -136,3 +138,67 @@ def test_positive_use_alternate_directory( |
136 | 138 | task = target_sat.cli.Task.list_tasks({'search': command})[0] |
137 | 139 | search = target_sat.cli.Task.list_tasks({'search': f'id={task["id"]}'}) |
138 | 140 | assert search[0]['action'] == task['action'] |
| 141 | + |
| 142 | + |
| 143 | +class TestCockpit: |
| 144 | + """Tests for cockpit plugin""" |
| 145 | + |
| 146 | + pytestmark = pytest.mark.destructive |
| 147 | + |
| 148 | + @pytest.mark.upgrade |
| 149 | + @pytest.mark.rhel_ver_match(r'^\d+$') |
| 150 | + @pytest.mark.no_containers |
| 151 | + def test_positive_cockpit(self, cockpit_host, class_cockpit_sat, class_org): |
| 152 | + """Install cockpit plugin and test whether webconsole button and cockpit integration works. |
| 153 | + also verify if cockpit service is restarted after the service restart. |
| 154 | +
|
| 155 | + :id: 5a9be063-cdc4-43ce-91b9-7608fbebf8bb |
| 156 | +
|
| 157 | + :expectedresults: Cockpit page is loaded and displays sat host info |
| 158 | +
|
| 159 | + :BZ: 1876220 |
| 160 | +
|
| 161 | + :steps: |
| 162 | + 1. kill the cockpit service. |
| 163 | + 2. go to web console and verify if getting 503 error. |
| 164 | + 3. check if service "cockpit.service" exists using service list. |
| 165 | + 4. restart the satellite services. |
| 166 | + 5. check cockpit page is loaded and displays sat host info. |
| 167 | +
|
| 168 | + :expectedresults: |
| 169 | + 1. cockpit service is restarted after the services restart. |
| 170 | + 2. cockpit page is loaded and displays sat host info |
| 171 | +
|
| 172 | + :Verifies: SAT-27411 |
| 173 | +
|
| 174 | + :customerscenario: true |
| 175 | +
|
| 176 | + :parametrized: yes |
| 177 | + """ |
| 178 | + with class_cockpit_sat.ui_session() as session: |
| 179 | + session.organization.select(org_name=class_org.name) |
| 180 | + session.location.select(loc_name=ANY_CONTEXT['location']) |
| 181 | + kill_process = class_cockpit_sat.execute('pkill -f cockpit-ws') |
| 182 | + assert kill_process.status == 0 |
| 183 | + # Verify if getting 503 error |
| 184 | + with pytest.raises(NoSuchElementException): |
| 185 | + session.host.get_webconsole_content(entity_name=cockpit_host.hostname) |
| 186 | + title = session.browser.title |
| 187 | + assert "503 Service Unavailable" in title |
| 188 | + |
| 189 | + service_list = class_cockpit_sat.cli.Service.list() |
| 190 | + assert service_list.status == 0 |
| 191 | + assert "foreman-cockpit.service" in service_list.stdout |
| 192 | + |
| 193 | + service_restart = class_cockpit_sat.cli.Service.restart() |
| 194 | + assert service_restart.status == 0 |
| 195 | + session.browser.switch_to_window(session.browser.window_handles[0]) |
| 196 | + session.browser.close_window(session.browser.window_handles[-1]) |
| 197 | + hostname_inside_cockpit = session.host.get_webconsole_content( |
| 198 | + entity_name=cockpit_host.hostname, |
| 199 | + rhel_version=cockpit_host.os_version.major, |
| 200 | + ) |
| 201 | + assert cockpit_host.hostname in hostname_inside_cockpit, ( |
| 202 | + f'cockpit page shows hostname {hostname_inside_cockpit} ' |
| 203 | + f'instead of {cockpit_host.hostname}' |
| 204 | + ) |
0 commit comments