-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly set the host option for the VNC websocket channel
Without setting the host option Cockpit connects to the main Cockpit's machine VNC port instead of the currently open host VNC port. This is a workaround for a bug in cockpit-ws which should set the host option automatically for us depending on what iframe makes the connection. Resolves: RHEL-3959
- Loading branch information
Showing
3 changed files
with
104 additions
and
5 deletions.
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
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,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) 2021 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 <http://www.gnu.org/licenses/>. | ||
|
||
import testlib | ||
from machineslib import VirtualMachinesCase | ||
|
||
|
||
class TestMultiMachineVNC(VirtualMachinesCase): | ||
""" | ||
Test for showing the wrong VNC console when adding another host via the add | ||
host feature the raw stream channel does not set the host option so would | ||
connect to the console of machine you connect to instead of the newly added | ||
host. | ||
https://issues.redhat.com/browse/RHEL-3959 | ||
""" | ||
|
||
provision = { # noqa: RUF012 | ||
"machine1": {"address": "10.111.113.1/20", "memory_mb": 660}, | ||
"machine2": {"address": "10.111.113.2/20", "memory_mb": 660}, | ||
} | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.machine1 = self.machines['machine1'] | ||
self.machine2 = self.machines['machine2'] | ||
|
||
self.setup_ssh_auth() | ||
|
||
def testBasic(self): | ||
b = self.browser | ||
m = self.machine | ||
m2 = self.machine2 | ||
m2_host = "10.111.113.2" | ||
|
||
m.execute(f"ssh-keyscan {m2_host} > /etc/ssh/ssh_known_hosts") | ||
self.startLibvirt(m2) | ||
|
||
# Start a VM with a VNC on machine1 | ||
name = "subVmTest1" | ||
self.createVm(name, graphics="vnc", ptyconsole=True) | ||
|
||
self.login_and_go("/machines") | ||
self.waitPageInit() | ||
|
||
self.waitVmRow(name) | ||
self.goToVmPage(name) | ||
b.wait_in_text(f"#vm-{name}-system-state", "Running") | ||
|
||
self.add_machine(m2_host, known_host=True, password=None) | ||
|
||
b.switch_to_top() | ||
b.click("#hosts-sel button") | ||
|
||
b.click(f"a[href='/@{m2_host}']") | ||
|
||
b.wait_js_cond(f'window.location.pathname == "/@{m2_host}/system"') | ||
b.enter_page("/system", host=m2_host) | ||
b.become_superuser() | ||
|
||
b.go(f"/@{m2_host}/machines") | ||
b.enter_page("/machines", host=m2_host) | ||
|
||
self.createVm(name, graphics="vnc", ptyconsole=True, machine=m2) | ||
self.waitVmRow("subVmTest1") | ||
b.wait_in_text("#vm-subVmTest1-system-state", "Running") | ||
self.goToVmPage("subVmTest1") | ||
|
||
# Wait till we have a VNC connection | ||
b.wait_visible(".pf-v5-c-console__vnc canvas") | ||
|
||
# Both machines should have the equal amount of VNC connections | ||
m1_open_connections = m.execute("ss -tupn | grep 127.0.0.1:5900 | grep qemu").splitlines() | ||
m2_open_connections = m2.execute("ss -tupn | grep 127.0.0.1:5900 | grep qemu").splitlines() | ||
self.assertTrue(len(m1_open_connections) == 1) | ||
self.assertTrue(len(m2_open_connections) == 1) | ||
|
||
|
||
if __name__ == '__main__': | ||
testlib.test_main() |
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