Code cleanup to remove duplicate parts of the code.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
recipes/regression_tests/phase1/3_vlans.py | 31 ++++----------------
.../regression_tests/phase1/3_vlans_over_bond.py | 31 ++++----------------
recipes/regression_tests/phase1/bonding_test.py | 18 ++----------
recipes/regression_tests/phase1/simple_ping.py | 10 +++----
.../phase1/virtual_bridge_2_vlans_over_bond.py | 26 ++---------------
.../phase1/virtual_bridge_vlan_in_guest.py | 19 ++----------
.../phase1/virtual_bridge_vlan_in_host.py | 19 ++----------
.../regression_tests/phase2/3_vlans_over_team.py | 30 ++++---------------
recipes/regression_tests/phase2/team_test.py | 34 +++-------------------
...l_ovs_bridge_2_vlans_over_active_backup_bond.py | 26 ++---------------
.../phase2/virtual_ovs_bridge_vlan_in_guest.py | 19 ++----------
.../phase2/virtual_ovs_bridge_vlan_in_host.py | 19 ++----------
12 files changed, 42 insertions(+), 240 deletions(-)
diff --git a/recipes/regression_tests/phase1/3_vlans.py
b/recipes/regression_tests/phase1/3_vlans.py
index 8aa6a2b..3ead92f 100644
--- a/recipes/regression_tests/phase1/3_vlans.py
+++ b/recipes/regression_tests/phase1/3_vlans.py
@@ -106,7 +106,7 @@ for vlan1 in vlans:
offload, state))
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
# Ping test
m1.run(ping_mod)
@@ -116,29 +116,12 @@ for vlan1 in vlans:
m2.run(netperf_cli_tcp, timeout=70)
m2.run(netperf_cli_udp, timeout=70)
srv_proc.intr()
- elif ipv == 'ipv6':
- # Ping test
- m1.run(ping_mod6)
- # Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp6, timeout=70)
- m2.run(netperf_cli_udp6, timeout=70)
- srv_proc.intr()
- else:
- # Ping tests
- m1.run(ping_mod)
+ if ipv in [ 'ipv6', 'both' ]:
+ # Ping test
m1.run(ping_mod6)
# Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp, timeout=70)
- m2.run(netperf_cli_udp, timeout=70)
- srv_proc.intr()
-
- # Netperf test (both TCP and UDP)
srv_proc = m1.run(netperf_srv6, bg=True)
ctl.wait(2)
m2.run(netperf_cli_tcp6, timeout=70)
@@ -155,11 +138,9 @@ for vlan1 in vlans:
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
# Ping test
m1.run(ping_mod, expect="fail")
- elif ipv == 'ipv6':
- m1.run(ping_mod6, expect="fail")
- else:
- m1.run(ping_mod, expect="fail")
+
+ if ipv in [ 'ipv6', 'both' ]:
m1.run(ping_mod6, expect="fail")
diff --git a/recipes/regression_tests/phase1/3_vlans_over_bond.py
b/recipes/regression_tests/phase1/3_vlans_over_bond.py
index 4cc0f41..f793ed6 100644
--- a/recipes/regression_tests/phase1/3_vlans_over_bond.py
+++ b/recipes/regression_tests/phase1/3_vlans_over_bond.py
@@ -108,7 +108,7 @@ for vlan1 in vlans:
offload, state))
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
# Ping test
m1.run(ping_mod)
@@ -118,29 +118,12 @@ for vlan1 in vlans:
m2.run(netperf_cli_tcp, timeout=70)
m2.run(netperf_cli_udp, timeout=70)
srv_proc.intr()
- elif ipv == 'ipv6':
- # Ping test
- m1.run(ping_mod6)
- # Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp6, timeout=70)
- m2.run(netperf_cli_udp6, timeout=70)
- srv_proc.intr()
- else:
- # Ping tests
- m1.run(ping_mod)
+ if ipv in [ 'ipv6', 'both' ]:
+ # Ping test
m1.run(ping_mod6)
# Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp, timeout=70)
- m2.run(netperf_cli_udp, timeout=70)
- srv_proc.intr()
-
- # Netperf test (both TCP and UDP)
srv_proc = m1.run(netperf_srv6, bg=True)
ctl.wait(2)
m2.run(netperf_cli_tcp6, timeout=70)
@@ -159,11 +142,9 @@ for vlan1 in vlans:
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
# Ping test
m1.run(ping_mod, expect="fail")
- elif ipv == 'ipv6':
- m1.run(ping_mod6, expect="fail")
- else:
- m1.run(ping_mod, expect="fail")
+
+ if ipv in [ 'ipv6', 'both' ]:
m1.run(ping_mod6, expect="fail")
diff --git a/recipes/regression_tests/phase1/bonding_test.py
b/recipes/regression_tests/phase1/bonding_test.py
index 885c541..d0a18f4 100644
--- a/recipes/regression_tests/phase1/bonding_test.py
+++ b/recipes/regression_tests/phase1/bonding_test.py
@@ -95,28 +95,16 @@ for offload in offloads:
state))
m2.run("ethtool -K %s %s %s" % (m2.get_devname("test_if"),
offload,
state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
m1.run(ping_mod)
server_proc = m1.run(netperf_srv, bg=True)
ctl.wait(2)
m2.run(netperf_cli_tcp, timeout=70)
m2.run(netperf_cli_udp, timeout=70)
server_proc.intr()
- elif ipv == 'ipv6':
- m1.run(ping_mod6)
- server_proc = m1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp6, timeout=70)
- m2.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
- else:
- m1.run(ping_mod)
+
+ if ipv in [ 'ipv6', 'both' ]:
m1.run(ping_mod6)
- server_proc = m1.run(netperf_srv, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp, timeout=70)
- m2.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
server_proc = m1.run(netperf_srv6, bg=True)
ctl.wait(2)
m2.run(netperf_cli_tcp6, timeout=70)
diff --git a/recipes/regression_tests/phase1/simple_ping.py
b/recipes/regression_tests/phase1/simple_ping.py
index d2bcdb6..dc961d7 100644
--- a/recipes/regression_tests/phase1/simple_ping.py
+++ b/recipes/regression_tests/phase1/simple_ping.py
@@ -24,12 +24,10 @@ ping_mod6 = ctl.get_module("Icmp6Ping",
ctl.wait(15)
-if ctl.get_alias('ipv') == 'ipv6':
- hostA.run(ping_mod6)
+ipv = ctl.get_alias('ipv')
-elif ctl.get_alias('ipv') == 'ipv4':
- hostA.run(ping_mod)
+if ipv in [ 'ipv6', 'both' ]:
+ hostA.run(ping_mod6)
-else:
+if ipv in [ 'ipv4', 'both' ]:
hostA.run(ping_mod)
- hostA.run(ping_mod6)
diff --git a/recipes/regression_tests/phase1/virtual_bridge_2_vlans_over_bond.py
b/recipes/regression_tests/phase1/virtual_bridge_2_vlans_over_bond.py
index 907b3d5..141f4f0 100644
--- a/recipes/regression_tests/phase1/virtual_bridge_2_vlans_over_bond.py
+++ b/recipes/regression_tests/phase1/virtual_bridge_2_vlans_over_bond.py
@@ -164,7 +164,7 @@ for offload in offloads:
offload, state))
g4.run("ethtool -K %s %s %s" % (g4.get_devname("guestnic"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
g4.run(ping_mod2)
g1.run(ping_mod_bad, expect="fail")
@@ -175,30 +175,8 @@ for offload in offloads:
g3.run(netperf_cli_tcp, timeout=70)
g3.run(netperf_cli_udp, timeout=70)
server_proc.intr()
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- g4.run(ping_mod62)
- g1.run(ping_mod6_bad, expect="fail")
- g3.run(ping_mod6_bad2, expect="fail")
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- g3.run(netperf_cli_tcp6, timeout=70)
- g3.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
- else:
- # IPv4
- g1.run(ping_mod)
- g4.run(ping_mod2)
- g1.run(ping_mod_bad, expect="fail")
- g3.run(ping_mod_bad2, expect="fail")
-
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- g3.run(netperf_cli_tcp, timeout=70)
- g3.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
- # IPv6
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
g4.run(ping_mod62)
g1.run(ping_mod6_bad, expect="fail")
diff --git a/recipes/regression_tests/phase1/virtual_bridge_vlan_in_guest.py
b/recipes/regression_tests/phase1/virtual_bridge_vlan_in_guest.py
index 6f93c14..1a2f911 100644
--- a/recipes/regression_tests/phase1/virtual_bridge_vlan_in_guest.py
+++ b/recipes/regression_tests/phase1/virtual_bridge_vlan_in_guest.py
@@ -102,7 +102,7 @@ for offload in offloads:
h2.run("ethtool -K %s %s %s" % (h2.get_devname("nic"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
server_proc = g1.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -110,25 +110,12 @@ for offload in offloads:
h2.run(netperf_cli_udp, timeout=70)
server_proc.intr()
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp6, timeout=70)
- h2.run(netperf_cli_udp6, timeout=70)
-
- server_proc.intr()
- else:
- g1.run(ping_mod)
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp, timeout=70)
- h2.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
server_proc = g1.run(netperf_srv6, bg=True)
ctl.wait(2)
h2.run(netperf_cli_tcp6, timeout=70)
h2.run(netperf_cli_udp6, timeout=70)
+
server_proc.intr()
diff --git a/recipes/regression_tests/phase1/virtual_bridge_vlan_in_host.py
b/recipes/regression_tests/phase1/virtual_bridge_vlan_in_host.py
index 0525ea5..0188686 100644
--- a/recipes/regression_tests/phase1/virtual_bridge_vlan_in_host.py
+++ b/recipes/regression_tests/phase1/virtual_bridge_vlan_in_host.py
@@ -101,23 +101,7 @@ for offload in offloads:
offload, state))
h2.run("ethtool -K %s %s %s" % (h2.get_devname("nic"),
offload, state))
- if ipv == 'ipv4':
- g1.run(ping_mod)
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp, timeout=70)
- h2.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
-
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp6, timeout=70)
- h2.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
-
- else:
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
server_proc = g1.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -125,6 +109,7 @@ for offload in offloads:
h2.run(netperf_cli_udp, timeout=70)
server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
server_proc = g1.run(netperf_srv6, bg=True)
ctl.wait(2)
diff --git a/recipes/regression_tests/phase2/3_vlans_over_team.py
b/recipes/regression_tests/phase2/3_vlans_over_team.py
index dab21ac..96d1be2 100644
--- a/recipes/regression_tests/phase2/3_vlans_over_team.py
+++ b/recipes/regression_tests/phase2/3_vlans_over_team.py
@@ -110,7 +110,7 @@ for vlan1 in vlans:
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
# Ping test
m1.run(ping_mod)
@@ -120,25 +120,8 @@ for vlan1 in vlans:
m2.run(netperf_cli_tcp, timeout=70)
m2.run(netperf_cli_udp, timeout=70)
srv_proc.intr()
- elif ipv == 'ipv6':
- m1.run(ping_mod6)
-
- # Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp6, timeout=70)
- m2.run(netperf_cli_udp6, timeout=70)
- srv_proc.intr()
- else:
- m1.run(ping_mod)
-
- # Netperf test (both TCP and UDP)
- srv_proc = m1.run(netperf_srv, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp, timeout=70)
- m2.run(netperf_cli_udp, timeout=70)
- srv_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
m1.run(ping_mod6)
# Netperf test (both TCP and UDP)
@@ -162,11 +145,8 @@ for vlan1 in vlans:
m2.run("ethtool -K %s %s %s" %
(m2.get_devname("eth1"),
offload, state))
# Ping test
- if ipv == 'ipv4':
- m1.run(ping_mod, expect="fail")
- elif ipv == 'ipv6':
- m1.run(ping_mod6, expect="fail")
- else:
+ if ipv in [ 'ipv4', 'both' ]:
m1.run(ping_mod, expect="fail")
- m1.run(ping_mod6, expect="fail")
+ if ipv in [ 'ipv6', 'both' ]:
+ m1.run(ping_mod6, expect="fail")
diff --git a/recipes/regression_tests/phase2/team_test.py
b/recipes/regression_tests/phase2/team_test.py
index 4c87613..776589a 100644
--- a/recipes/regression_tests/phase2/team_test.py
+++ b/recipes/regression_tests/phase2/team_test.py
@@ -94,21 +94,7 @@ for offload in offloads:
state))
m2.run("ethtool -K %s %s %s" % (m2.get_devname("test_if"),
offload,
state))
- if ipv == "ipv4":
- m1.run(ping_mod)
- server_proc = m1.run(netperf_srv, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp, timeout=70)
- m2.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
- elif ipv == "ipv6":
- m1.run(ping_mod6)
- server_proc = m1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m2.run(netperf_cli_tcp6, timeout=70)
- m2.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
- else:
+ if ipv in [ 'ipv4', 'both' ]:
m1.run(ping_mod)
server_proc = m1.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -116,6 +102,7 @@ for offload in offloads:
m2.run(netperf_cli_udp, timeout=70)
server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
m1.run(ping_mod6)
server_proc = m1.run(netperf_srv6, bg=True)
ctl.wait(2)
@@ -197,21 +184,7 @@ for offload in offloads:
state))
m2.run("ethtool -K %s %s %s" % (m2.get_devname("test_if"),
offload,
state))
- if ipv == 'ipv4':
- m2.run(ping_mod)
- server_proc = m2.run(netperf_srv, bg=True)
- ctl.wait(2)
- m1.run(netperf_cli_tcp, timeout=70)
- m1.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
- elif ipv == 'ipv6':
- m2.run(ping_mod6)
- server_proc = m2.run(netperf_srv6, bg=True)
- ctl.wait(2)
- m1.run(netperf_cli_tcp6, timeout=70)
- m1.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
- else:
+ if ipv in [ 'ipv4', 'both' ]:
m2.run(ping_mod)
server_proc = m2.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -219,6 +192,7 @@ for offload in offloads:
m1.run(netperf_cli_udp, timeout=70)
server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
m2.run(ping_mod6)
server_proc = m2.run(netperf_srv6, bg=True)
ctl.wait(2)
diff --git
a/recipes/regression_tests/phase2/virtual_ovs_bridge_2_vlans_over_active_backup_bond.py
b/recipes/regression_tests/phase2/virtual_ovs_bridge_2_vlans_over_active_backup_bond.py
index f09ef36..8daa471 100644
---
a/recipes/regression_tests/phase2/virtual_ovs_bridge_2_vlans_over_active_backup_bond.py
+++
b/recipes/regression_tests/phase2/virtual_ovs_bridge_2_vlans_over_active_backup_bond.py
@@ -166,7 +166,7 @@ for offload in offloads:
offload, state))
g4.run("ethtool -K %s %s %s" % (g4.get_devname("guestnic"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
g4.run(ping_mod2)
g1.run(ping_mod_bad, expect="fail")
@@ -177,30 +177,8 @@ for offload in offloads:
g3.run(netperf_cli_tcp, timeout=70)
g3.run(netperf_cli_udp, timeout=70)
server_proc.intr()
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- g4.run(ping_mod62)
- g1.run(ping_mod6_bad, expect="fail")
- g3.run(ping_mod6_bad2, expect="fail")
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- g3.run(netperf_cli_tcp6, timeout=70)
- g3.run(netperf_cli_udp6, timeout=70)
- server_proc.intr()
- else:
- # IPv4
- g1.run(ping_mod)
- g4.run(ping_mod2)
- g1.run(ping_mod_bad, expect="fail")
- g3.run(ping_mod_bad2, expect="fail")
-
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- g3.run(netperf_cli_tcp, timeout=70)
- g3.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
- # IPv6
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
g4.run(ping_mod62)
g1.run(ping_mod6_bad, expect="fail")
diff --git a/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_guest.py
b/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_guest.py
index 2417c8a..662e888 100644
--- a/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_guest.py
+++ b/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_guest.py
@@ -101,7 +101,7 @@ for offload in offloads:
offload, state))
h2.run("ethtool -K %s %s %s" % (h2.get_devname("nic"),
offload, state))
- if ipv == 'ipv4':
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
server_proc = g1.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -109,25 +109,12 @@ for offload in offloads:
h2.run(netperf_cli_udp, timeout=70)
server_proc.intr()
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp6, timeout=70)
- h2.run(netperf_cli_udp6, timeout=70)
-
- server_proc.intr()
- else:
- g1.run(ping_mod)
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp, timeout=70)
- h2.run(netperf_cli_udp, timeout=70)
- server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
server_proc = g1.run(netperf_srv6, bg=True)
ctl.wait(2)
h2.run(netperf_cli_tcp6, timeout=70)
h2.run(netperf_cli_udp6, timeout=70)
+
server_proc.intr()
diff --git a/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_host.py
b/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_host.py
index cee4c49..15122c4 100644
--- a/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_host.py
+++ b/recipes/regression_tests/phase2/virtual_ovs_bridge_vlan_in_host.py
@@ -100,23 +100,7 @@ for offload in offloads:
offload, state))
h2.run("ethtool -K %s %s %s" % (h2.get_devname("nic"),
offload, state))
- if ipv == 'ipv4':
- g1.run(ping_mod)
- server_proc = g1.run(netperf_srv, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp, timeout=65)
- h2.run(netperf_cli_udp, timeout=65)
- server_proc.intr()
-
- elif ipv == 'ipv6':
- g1.run(ping_mod6)
- server_proc = g1.run(netperf_srv6, bg=True)
- ctl.wait(2)
- h2.run(netperf_cli_tcp6, timeout=65)
- h2.run(netperf_cli_udp6, timeout=65)
- server_proc.intr()
-
- else:
+ if ipv in [ 'ipv4', 'both' ]:
g1.run(ping_mod)
server_proc = g1.run(netperf_srv, bg=True)
ctl.wait(2)
@@ -124,6 +108,7 @@ for offload in offloads:
h2.run(netperf_cli_udp, timeout=65)
server_proc.intr()
+ if ipv in [ 'ipv6', 'both' ]:
g1.run(ping_mod6)
server_proc = g1.run(netperf_srv6, bg=True)
ctl.wait(2)
--
1.9.3