From: Ondrej Lichtner <olichtne(a)redhat.com>
Updating the SimplePerfRecipe class to use an EnrtConfiguration object
created by the base class and tracking a new attribute
(test_wide_devices) that is relevant to the SimplePerfRecipe class with
the configured devices.
Adding an implementation of the generate_test_wide_description method
that uses this new attribute to add a description of what was
configured.
This also implements the test_wide_configuration method in a way that
enables collaborative inheritance to work properly so that we can extend
the recipe functionality by simply adding a parent class that adds some
generic test wide configuration.
This way the EnrtConfiguration object is created by the BaseEnrtRecipe
class and only extended by the individual test_wide_configuration
methods.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Recipes/ENRT/SimplePerfRecipe.py | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/lnst/Recipes/ENRT/SimplePerfRecipe.py
b/lnst/Recipes/ENRT/SimplePerfRecipe.py
index 42491e3..afdc2b3 100644
--- a/lnst/Recipes/ENRT/SimplePerfRecipe.py
+++ b/lnst/Recipes/ENRT/SimplePerfRecipe.py
@@ -4,7 +4,7 @@
from lnst.Controller import HostReq, DeviceReq, RecipeParam
-from lnst.Recipes.ENRT.BaseEnrtRecipe import BaseEnrtRecipe, EnrtConfiguration
+from lnst.Recipes.ENRT.BaseEnrtRecipe import BaseEnrtRecipe
class SimplePerfRecipe(BaseEnrtRecipe):
host1 = HostReq()
@@ -22,9 +22,8 @@ class SimplePerfRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
-
- configuration = EnrtConfiguration()
- configuration.params = self.params
+ configuration = super().test_wide_configuration()
+ configuration.test_wide_devices = []
if "mtu" in self.params:
host1.eth0.mtu = self.params.mtu
@@ -33,10 +32,12 @@ def test_wide_configuration(self):
host1.eth0.ip_add(ipaddress("192.168.101.1/24"))
host1.eth0.ip_add(ipaddress("fc00::1/64"))
host1.eth0.up()
+ configuration.test_wide_devices.append(host1.eth0)
host2.eth0.ip_add(ipaddress("192.168.101.2/24"))
host2.eth0.ip_add(ipaddress("fc00::2/64"))
host2.eth0.up()
+ configuration.test_wide_devices.append(host2.eth0)
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
@@ -51,8 +52,20 @@ def test_wide_configuration(self):
return configuration
+ def generate_test_wide_description(self, config):
+ parent = super().generate_test_wide_description(config)
+ parent += [
+ "Configured {}.{}.ips = {}".format(
+ dev.host.hostid, dev.name, dev.ips
+ )
+ for dev in config.test_wide_devices
+ ]
+ return parent
+
def test_wide_deconfiguration(self, config):
- host1, host2 = self.matched.host1, self.matched.host2
+ del config.test_wide_devices
+
+ super().test_wide_deconfiguration(config)
def generate_ping_endpoints(self, config):
return [(self.matched.host1.eth0, self.matched.host2.eth0)]
--
2.22.0