| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2013 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import json |
| 9 |
|
| 10 |
import netlib |
| 11 |
import testlib |
| 12 |
|
| 13 |
|
| 14 |
@testlib.skipOstree("NetworkManager-team not installed") |
| 15 |
@testlib.skipImage("TODO: networkmanager fails on Arch Linux", "arch") |
| 16 |
@testlib.skipImage("team not supported", "centos-10*", "rhel-10*") |
| 17 |
@testlib.nondestructive |
| 18 |
class TestTeam(netlib.NetworkCase): |
| 19 |
def testBasic(self): |
| 20 |
b = self.browser |
| 21 |
|
| 22 |
self.login_and_go("/network") |
| 23 |
b.wait_visible("#networking") |
| 24 |
|
| 25 |
b.wait_visible("button:contains('Add team')") |
| 26 |
|
| 27 |
iface1 = "cockpit1" |
| 28 |
self.add_veth(iface1, dhcp_cidr="10.111.113.1/24", dhcp_range=['10.111.113.2', '10.111.113.254']) |
| 29 |
self.nm_activate_eth(iface1) |
| 30 |
iface2 = "cockpit2" |
| 31 |
self.add_veth(iface2, dhcp_cidr="10.111.114.1/24", dhcp_range=['10.111.114.2', '10.111.114.254']) |
| 32 |
self.nm_activate_eth(iface2) |
| 33 |
self.wait_for_iface(iface1) |
| 34 |
self.wait_for_iface(iface2) |
| 35 |
|
| 36 |
# team them |
| 37 |
b.click("button:contains('Add team')") |
| 38 |
b.wait_visible("#network-team-settings-dialog") |
| 39 |
|
| 40 |
# wait until dialog initialized |
| 41 |
b.wait_visible("#network-team-settings-dialog button[aria-label=Close]") |
| 42 |
b.wait_in_text("#network-team-settings-body", "cockpit2") |
| 43 |
b.assert_pixels("#network-team-settings-dialog", "networking-team-settings-dialog") |
| 44 |
|
| 45 |
b.set_input_text("#network-team-settings-interface-name-input", "tteam") |
| 46 |
b.set_checked(f"input[data-iface='{iface1}']", val=True) |
| 47 |
b.set_checked(f"input[data-iface='{iface2}']", val=True) |
| 48 |
b.click("#network-team-settings-dialog button:contains('Add')") |
| 49 |
b.wait_not_present("#network-team-settings-dialog") |
| 50 |
self.toggle_onoff("label[for='interface-switch']") |
| 51 |
|
| 52 |
b.wait_text("#network-interface-name", "tteam") |
| 53 |
b.wait(lambda: 'nmcli con show | grep tteam') |
| 54 |
|
| 55 |
# Check that the members are displayed |
| 56 |
b.wait_visible(f"#network-interface-members tr[data-interface='{iface1}']") |
| 57 |
b.wait_visible(f"#network-interface-members tr[data-interface='{iface2}']") |
| 58 |
|
| 59 |
# Deactivate the team and make sure it is still there after a |
| 60 |
# reload. |
| 61 |
self.wait_onoff("label[for='interface-switch']", val=True) |
| 62 |
self.toggle_onoff("label[for='interface-switch']") |
| 63 |
self.wait_for_iface_setting('Status', 'Inactive') |
| 64 |
b.reload() |
| 65 |
b.enter_page("/network") |
| 66 |
b.wait_text("#network-interface-name", "tteam") |
| 67 |
b.wait_text("#network-interface-hw", "Team") |
| 68 |
b.wait_visible(f"#network-interface-members tr[data-interface='{iface1}']") |
| 69 |
b.wait_visible(f"#network-interface-members tr[data-interface='{iface2}']") |
| 70 |
|
| 71 |
# Delete the team |
| 72 |
b.click("#network-interface button:contains('Delete')") |
| 73 |
b.wait_visible("#networking") |
| 74 |
b.wait_not_present("#networking-interfaces tr[data-interface='tteam']") |
| 75 |
|
| 76 |
# Check that the former members are displayed and both On |
| 77 |
self.wait_for_iface(iface1) |
| 78 |
self.wait_for_iface(iface2) |
| 79 |
|
| 80 |
def testActive(self): |
| 81 |
b = self.browser |
| 82 |
m = self.machine |
| 83 |
|
| 84 |
self.login_and_go("/network") |
| 85 |
b.wait_visible("#networking") |
| 86 |
|
| 87 |
iface = "cockpit1" |
| 88 |
self.add_veth(iface, dhcp_cidr="10.111.112.2/20") |
| 89 |
self.nm_activate_eth(iface) |
| 90 |
self.wait_for_iface(iface) |
| 91 |
|
| 92 |
# Put an active interface into a team. We can't select/copy the MAC, so we can't expect to |
| 93 |
# get the same IP as the active interface, but it should get a valid DHCP IP. |
| 94 |
|
| 95 |
b.click("button:contains('Add team')") |
| 96 |
b.wait_visible("#network-team-settings-dialog") |
| 97 |
b.set_input_text("#network-team-settings-interface-name-input", "tteam") |
| 98 |
b.set_checked(f"input[data-iface='{iface}']", val=True) |
| 99 |
b.click("#network-team-settings-dialog button:contains('Add')") |
| 100 |
b.wait_not_present("#network-team-settings-dialog") |
| 101 |
self.toggle_onoff("label[for='interface-switch']") |
| 102 |
|
| 103 |
b.wait_text("#network-interface-name", "tteam") |
| 104 |
b.wait(lambda: 'nmcli con show | grep tteam') |
| 105 |
|
| 106 |
# Check that it has the interface and the right IP address |
| 107 |
b.wait_visible(f"#network-interface-members tr[data-interface='{iface}']") |
| 108 |
b.wait_in_text("#network-interface .pf-v6-c-card:contains('tteam')", "10.111") |
| 109 |
|
| 110 |
# Check team port |
| 111 |
b.click("#network-interface-members button:contains('cockpit1')") |
| 112 |
b.click("#networking-edit-teamport") |
| 113 |
b.wait_visible("#network-team-port-settings-dialog") |
| 114 |
b.set_input_text("#network-team-port-settings-activebackup-prio-input", "10") |
| 115 |
b.set_checked("#network-team-port-settings-activebackup-sticky-input", val=True) |
| 116 |
b.click("#network-team-port-settings-save") |
| 117 |
b.wait_not_present("#network-team-port-settings-dialog") |
| 118 |
|
| 119 |
b.wait_attr("#network-interface", "data-test-wait", "false") |
| 120 |
|
| 121 |
# Confirm that team port settings are applied |
| 122 |
dump_config_cmd = "teamdctl tteam port config dump cockpit1 || true" |
| 123 |
b.wait(lambda: "sticky" in m.execute(dump_config_cmd)) |
| 124 |
cockpit1_config = m.execute(dump_config_cmd) |
| 125 |
team_port_config = json.loads(cockpit1_config) |
| 126 |
self.assertEqual(team_port_config.get("prio"), "10") |
| 127 |
self.assertTrue(team_port_config.get("sticky")) |
| 128 |
|
| 129 |
|
| 130 |
if __name__ == '__main__': |
| 131 |
testlib.test_main() |