File: check-shell-multi-os

package info (click to toggle)
cockpit 355-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 311,568 kB
  • sloc: javascript: 774,787; python: 40,655; ansic: 35,157; cpp: 11,141; sh: 3,512; makefile: 580; xml: 261
file content (96 lines) | stat: -rwxr-xr-x 3,594 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv)

# This file is part of Cockpit.
#
# Copyright (C) 2013 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see <https://www.gnu.org/licenses/>.

import testlib


@testlib.skipBeiboot("host switching disabled in beiboot mode")
class TestRHEL8(testlib.MachineCase):
    provision = {
        "0": {"address": "10.111.113.1/20", "memory_mb": 768},
        "stock": {"address": "10.111.113.5/20", "image": "rhel-8-10", "memory_mb": 512}
    }

    def logout_pf5(self, b):
        b.switch_to_top()
        b.wait_visible("#toggle-menu")
        if (b.attr("#toggle-menu", "aria-expanded") != "true"):
            b.click("#toggle-menu")
        b.mouse('#logout', "click", scrollVisible=False)
        b.wait_visible('#login')

    def test(self):
        dev_m = self.machine
        dev_b = self.browser

        stock_m = self.machines['stock']
        stock_m.execute("hostnamectl set-hostname stock")
        self.enable_multihost(dev_m)

        # Wait for connectivity between the two
        stock_m.execute("ping -q -w5 -c5 10.111.113.1")
        dev_m.execute("ping -q -w5 -c5 10.111.113.5")

        self.allow_hostkey_messages()

        dev_m.start_cockpit()

        # dev → stock: direct login
        dev_b.open("/=10.111.113.5")
        dev_b.try_login()
        dev_b.wait_in_text("#hostkey-message-1", "10.111.113.5")
        dev_b.click('#login-button')
        dev_b.wait_in_text("#hosts-sel", "admin@stock")
        dev_b.enter_page("/system")
        dev_b.wait_in_text(".ct-overview-header-hostname", "stock")
        dev_b.wait_in_text(".ct-overview-header-hostname", "running Red Hat Enterprise Linux 8")
        # Logout (needs PF5 selectors so we can't use logout())
        self.logout_pf5(dev_b)

        # dev → stock: via shell Add host
        dev_b.login_and_go()
        dev_b.add_machine("10.111.113.5")
        dev_b.wait_in_text(".ct-overview-header-hostname", "stock")
        dev_b.wait_in_text(".ct-overview-header-hostname", "running Red Hat Enterprise Linux 8")
        self.logout_pf5(dev_b)

        dev_m.stop_cockpit()
        dev_b.kill()

        # stock → dev: direct login
        stock_m.start_cockpit()
        stock_b = self.new_browser(stock_m)
        stock_b.open("/=10.111.113.1")
        stock_b.try_login()
        stock_b.wait_in_text("#hostkey-message-1", "10.111.113.1")
        stock_b.click('#login-button')
        dev_hostname = dev_m.execute("hostname").strip()
        stock_b.wait_in_text("#hosts-sel", f"admin@{dev_hostname}")
        stock_b.enter_page("/system")
        stock_b.wait_in_text(".ct-overview-header-hostname", dev_hostname)
        self.logout_pf5(stock_b)

        # stock → dev: via shell Add host
        stock_b.login_and_go()
        stock_b.add_machine("10.111.113.1", expect_warning=False)
        stock_b.wait_in_text(".ct-overview-header-hostname", dev_hostname)


if __name__ == '__main__':
    testlib.test_main()