test suite reviews and discussions
 help / color / mirror / Atom feed
* [PATCH v1] framework/virt_*: fix pylama errors
@ 2021-11-24 13:47 Juraj Linkeš
  2021-12-07 15:04 ` [PATCH v2] framework/pktgen_*: " Juraj Linkeš
  2021-12-08  9:32 ` [PATCH v2] framework/virt_*: " Juraj Linkeš
  0 siblings, 2 replies; 5+ messages in thread
From: Juraj Linkeš @ 2021-11-24 13:47 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
framework/virt_base.py:271: [E] E1101 Instance of 'VirtBase' has no 'add_vm_login' member [pylint]
framework/virt_base.py:274: [E] E1101 Instance of 'VirtBase' has no '_attach_vm' member [pylint]
framework/virt_base.py:319: [E] E1101 Instance of 'VirtBase' has no '_quick_start_vm' member [pylint]
framework/virt_base.py:413: [E] E1111 Assigning result of a function call, where the function has no return [pylint]
framework/virt_base.py:416: [E] E1101 Instance of 'VirtBase' has no 'get_vm_login' member [pylint]
framework/virt_base.py:88: [E] E1111 Assigning result of a function call, where the function has no return [pylint]
framework/virt_dut.py:73: [E] E1003 Bad first argument 'Dut' given to super() [pylint]
framework/virt_resource.py:242: [E] E1101 Instance of 'VirtResource' has no '__port_isused' member [pylint]
framework/virt_resource.py:246: [E] E0602 Undefined variable 'core' [pylint]
framework/virt_resource.py:247: [E] E0602 Undefined variable 'core' [pylint]
framework/virt_scene.py:350: [E] E1101 Instance of 'VirtScene' has no 'tester' member [pylint]
framework/virt_scene.py:393: [E] E1101 Instance of 'VirtScene' has no 'vm_dut' member [pylint]
framework/virt_scene.py:397: [E] E1101 Instance of 'VirtScene' has no 'tester' member [pylint]
framework/virt_scene.py:458: [E] E1123 Unexpected keyword argument 'auto_portmap' in method call [pylint]
framework/virt_scene.py:510: [E] E0102 class already defined line 38 [pylint]
framework/virt_scene.py:517: [E] E1101 Instance of 'QEMUKvm' has no 'params' member [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 framework/dut.py           | 11 +++++++----
 framework/project_dpdk.py  |  5 +++--
 framework/virt_base.py     | 28 ++++++++++++++++++++++++++--
 framework/virt_dut.py      |  2 +-
 framework/virt_resource.py |  7 +++++--
 framework/virt_scene.py    | 13 +++++++------
 6 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index dc3fc874..f4355f40 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -62,10 +62,13 @@ class Dut(Crb):
     CORE_LIST_CACHE_KEY = 'dut_core_list'
     PCI_DEV_CACHE_KEY = 'dut_pci_dev_info'
 
-    def __init__(self, crb, serializer, dut_id):
-        self.NAME = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
-        super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=True, dut_id=dut_id)
-
+    def __init__(self, crb, serializer,
+                 name=None, alt_session=True, dut_id=0):
+        if not name:
+            name = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
+            self.NAME = name
+        super(Dut, self).__init__(crb, serializer, name,
+                                  alt_session=alt_session, dut_id=dut_id)
         self.host_init_flag = False
         self.number_of_cores = 0
         self.tester = None
diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
index 9927bcc1..75613a1d 100644
--- a/framework/project_dpdk.py
+++ b/framework/project_dpdk.py
@@ -60,8 +60,9 @@ class DPDKdut(Dut):
     build, memory and kernel module.
     """
 
-    def __init__(self, crb, serializer, dut_id):
-        super(DPDKdut, self).__init__(crb, serializer, dut_id)
+    def __init__(self, crb, serializer, name=None, alt_session=True, dut_id=0):
+        super(DPDKdut, self).__init__(crb, serializer, name, alt_session,
+                                      dut_id)
         self.testpmd = None
 
     def set_target(self, target, bind_dev=True):
diff --git a/framework/virt_base.py b/framework/virt_base.py
index 148a4d18..ef117062 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -104,7 +104,7 @@ class VirtBase(object):
         """
         Get the virtual type, such as KVM, XEN or LIBVIRT.
         """
-        NotImplemented
+        raise NotImplementedError
 
     def has_virtual_ability(self):
         """
@@ -118,6 +118,30 @@ class VirtBase(object):
         """
         NotImplemented
 
+    def get_vm_login(self):
+        """
+        Get VM credentials.
+        """
+        raise NotImplementedError
+
+    def add_vm_login(self):
+        """
+        Add VM credentials.
+        """
+        raise NotImplementedError
+
+    def _attach_vm(self):
+        """
+        Attach VM.
+        """
+        raise NotImplementedError
+
+    def _quick_start_vm(self):
+        """
+        Quick start VM.
+        """
+        raise NotImplementedError
+
     def load_global_config(self):
         """
         Load global configure in the path DTS_ROOT_PATH/conf.
@@ -230,7 +254,7 @@ class VirtBase(object):
         """
         Get the VM IP.
         """
-        NotImplemented
+        raise NotImplementedError
 
     def get_pci_mappings(self):
         """
diff --git a/framework/virt_dut.py b/framework/virt_dut.py
index bde65667..de892879 100644
--- a/framework/virt_dut.py
+++ b/framework/virt_dut.py
@@ -70,7 +70,7 @@ class VirtDut(DPDKdut):
         self.vm_ip = crb['IP']
         self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
         # do not create addition alt_session
-        super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=False, dut_id=self.dut_id)
+        super(VirtDut, self).__init__(crb, serializer, self.NAME, alt_session=False, dut_id=self.dut_id)
         # load port config from suite cfg
         self.suite = suite
 
diff --git a/framework/virt_resource.py b/framework/virt_resource.py
index 8a19f1b2..3163372d 100644
--- a/framework/virt_resource.py
+++ b/framework/virt_resource.py
@@ -70,6 +70,9 @@ class VirtResource(object):
         # save allocated cores and related vm
         self.allocated_info = {}
 
+    def __port_isused(self, pci):
+        return pci in self.used_ports
+
     def __port_used(self, pci):
         index = self.ports.index(pci)
         self.used_ports[index] = pci
@@ -243,8 +246,8 @@ class VirtResource(object):
                     print("Port %s has been used!!!" % pci)
                 else:
                     if self.__port_on_socket(pci, socket) is True:
-                        self.__port_used(core)
-                        ports.append(core)
+                        self.__port_used(pci)
+                        ports.append(pci)
 
         if vm not in self.allocated_info:
             self.allocated_info[vm] = {}
diff --git a/framework/virt_scene.py b/framework/virt_scene.py
index cc36a09b..d82012b1 100644
--- a/framework/virt_scene.py
+++ b/framework/virt_scene.py
@@ -347,7 +347,7 @@ class VirtScene(object):
             elif cmd['type'] == 'host':
                 crb = self.host_dut
             elif cmd['type'] == 'tester':
-                crb = self.tester
+                crb = self.tester_dut
             else:
                 crb = self.host_dut
 
@@ -390,11 +390,11 @@ class VirtScene(object):
     def run_post_cmds(self):
         for cmd in self.post_cmds:
             if cmd['type'] == 'vm':
-                crb = self.vm_dut
+                crb = None
             elif cmd['type'] == 'host':
                 crb = self.host_dut
             elif cmd['type'] == 'tester':
-                crb = self.tester
+                crb = self.tester_dut
             else:
                 crb = self.host_dut
 
@@ -456,7 +456,6 @@ class VirtScene(object):
                 topo = self.get_cputopo(scene_params)
                 try:
                     vm_dut = vm.start(load_config=False, set_target=False,
-                                      auto_portmap=self.auto_portmap,
                                       cpu_topo=topo)
                     if vm_dut is None:
                         raise Exception("Set up VM ENV failed!")
@@ -507,16 +506,18 @@ class VirtScene(object):
 
 if __name__ == "__main__":
 
-    class QEMUKvm():
+    class QEMUKvmTmp():
 
         def __init__(self, dut, vm_name, suite_name):
             print(vm_name)
             print(suite_name)
 
         def start(self):
-            print(self.params)
+            print(self.__dict__)
             return True
 
+    QEMUKvm = QEMUKvmTmp
+
     class simple_dev(object):
 
         def __init__(self, pci):
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] framework/pktgen_*: fix pylama errors
  2021-11-24 13:47 [PATCH v1] framework/virt_*: fix pylama errors Juraj Linkeš
@ 2021-12-07 15:04 ` Juraj Linkeš
  2021-12-07 15:18   ` [PATCH v3] " Juraj Linkeš
  2021-12-08  9:32 ` [PATCH v2] framework/virt_*: " Juraj Linkeš
  1 sibling, 1 reply; 5+ messages in thread
From: Juraj Linkeš @ 2021-12-07 15:04 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
framework/pktgen_base.py:108: [E] E1101 Instance of 'PacketGenerator' has no '_get_gen_port' member [pylint]
framework/pktgen_base.py:148: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:173: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:279: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:479: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:528: [E] E0602 Undefined variable 'last_no_lost_mult' [pylint]
framework/pktgen_base.py:558: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:573: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:607: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:673: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:677: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:69: [E] E1101 Instance of 'PacketGenerator' has no '_prepare_generator' member; maybe 'prepare_generator'? [pylint]
framework/pktgen_base.py:77: [E] E1101 Instance of 'PacketGenerator' has no '_get_port_pci' member [pylint]
framework/pktgen_ixia.py:1085: [E] E1306 Not enough arguments for format string [pylint]
framework/pktgen_trex.py:194: [E] E0602 Undefined variable 'Ether' [pylint]
framework/pktgen_trex.py:195: [E] E0602 Undefined variable 'IP' [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 framework/pktgen_base.py | 15 ++++++++++++++-
 framework/pktgen_ixia.py |  2 +-
 framework/pktgen_trex.py |  5 ++++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py
index 023652cc..16eae93f 100644
--- a/framework/pktgen_base.py
+++ b/framework/pktgen_base.py
@@ -64,10 +64,17 @@ class PacketGenerator(object):
         self.tester = tester
         self.__streams = []
         self._ports_map = []
+        self.pktgen_type = None
+
+    def _prepare_generator(self):
+        raise NotImplementedError
 
     def prepare_generator(self):
         self._prepare_generator()
 
+    def _get_port_pci(self, port_id):
+        raise NotImplementedError
+
     def _convert_pktgen_port(self, port_id):
         '''
         :param port_id:
@@ -94,6 +101,9 @@ class PacketGenerator(object):
 
         return port
 
+    def _get_gen_port(self, tester_pci):
+        raise NotImplementedError
+
     def _convert_tester_port(self, port_id):
         '''
         :param port_id:
@@ -143,6 +153,9 @@ class PacketGenerator(object):
     def get_streams(self):
         return self.__streams
 
+    def _clear_streams(self):
+        raise NotImplementedError
+
     def clear_streams(self):
         ''' clear streams '''
         self._clear_streams()
@@ -525,7 +538,7 @@ class PacketGenerator(object):
                 break
             pps = (traffic_pps_max - traffic_pps_min)/2 + traffic_pps_min
 
-        self.logger.info("zero loss pps is %f" % last_no_lost_mult)
+        self.logger.info("zero loss pps is %f" % pps)
         # use last result as return data to keep the same with dts/etgen format
         # In fact, multiple link peer have multiple loss rate value,
         # here only pick one
diff --git a/framework/pktgen_ixia.py b/framework/pktgen_ixia.py
index 06667047..9a8c9d2e 100644
--- a/framework/pktgen_ixia.py
+++ b/framework/pktgen_ixia.py
@@ -1082,7 +1082,7 @@ class Ixia(SSHConnection):
         Tells IXIA to prepare the internal buffers were the frames were captured.
         """
         ixia_port = self.get_ixia_port(port_number)
-        command = 'capture get {0} {1} {2}'.format(ixia_port)
+        command = 'capture get {0}'.format(ixia_port)
         self.send_expect(command, '% ', 30)
 
     def stat_get_rate_stat_all_stats(self, port_number):
diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index 2ad05fe6..2f537a0b 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -35,6 +35,9 @@ import sys
 import time
 from pprint import pformat
 
+from scapy.layers.inet import IP
+from scapy.layers.l2 import Ether
+
 from .pktgen_base import (
     PKTGEN,
     PKTGEN_TREX,
@@ -414,6 +417,7 @@ class TrexPacketGenerator(PacketGenerator):
     https://trex-tgn.cisco.com/trex/doc/trex_manual.html
     """
     def __init__(self, tester):
+        super(TrexPacketGenerator, self).__init__(tester)
         self.pktgen_type = PKTGEN_TREX
         self.trex_app = "t-rex-64"
         self._conn = None
@@ -432,7 +436,6 @@ class TrexPacketGenerator(PacketGenerator):
         self.ip_keys = ['start', 'end','action', 'mask', 'step']
         self.vlan_keys = ['start', 'end', 'action', 'step', 'count']
 
-        super(TrexPacketGenerator, self).__init__(tester)
 
         # check trex binary file
         trex_bin = os.sep.join([self.conf.get('trex_root_path'), self.trex_app])
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3] framework/pktgen_*: fix pylama errors
  2021-12-07 15:04 ` [PATCH v2] framework/pktgen_*: " Juraj Linkeš
@ 2021-12-07 15:18   ` Juraj Linkeš
  2022-01-14  8:09     ` Tu, Lijuan
  0 siblings, 1 reply; 5+ messages in thread
From: Juraj Linkeš @ 2021-12-07 15:18 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
framework/pktgen_base.py:108: [E] E1101 Instance of 'PacketGenerator' has no '_get_gen_port' member [pylint]
framework/pktgen_base.py:148: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:173: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:279: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:479: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:528: [E] E0602 Undefined variable 'last_no_lost_mult' [pylint]
framework/pktgen_base.py:558: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:573: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:607: [E] E1101 Instance of 'PacketGenerator' has no '_clear_streams' member; maybe 'clear_streams'? [pylint]
framework/pktgen_base.py:673: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:677: [E] E1101 Instance of 'PacketGenerator' has no 'pktgen_type' member [pylint]
framework/pktgen_base.py:69: [E] E1101 Instance of 'PacketGenerator' has no '_prepare_generator' member; maybe 'prepare_generator'? [pylint]
framework/pktgen_base.py:77: [E] E1101 Instance of 'PacketGenerator' has no '_get_port_pci' member [pylint]
framework/pktgen_ixia.py:1085: [E] E1306 Not enough arguments for format string [pylint]
framework/pktgen_trex.py:194: [E] E0602 Undefined variable 'Ether' [pylint]
framework/pktgen_trex.py:195: [E] E0602 Undefined variable 'IP' [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 framework/pktgen_base.py         | 15 ++++++++++++++-
 framework/pktgen_ixia.py         |  4 ++--
 framework/pktgen_ixia_network.py |  2 +-
 framework/pktgen_trex.py         |  5 ++++-
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py
index 023652cc..16eae93f 100644
--- a/framework/pktgen_base.py
+++ b/framework/pktgen_base.py
@@ -64,10 +64,17 @@ class PacketGenerator(object):
         self.tester = tester
         self.__streams = []
         self._ports_map = []
+        self.pktgen_type = None
+
+    def _prepare_generator(self):
+        raise NotImplementedError
 
     def prepare_generator(self):
         self._prepare_generator()
 
+    def _get_port_pci(self, port_id):
+        raise NotImplementedError
+
     def _convert_pktgen_port(self, port_id):
         '''
         :param port_id:
@@ -94,6 +101,9 @@ class PacketGenerator(object):
 
         return port
 
+    def _get_gen_port(self, tester_pci):
+        raise NotImplementedError
+
     def _convert_tester_port(self, port_id):
         '''
         :param port_id:
@@ -143,6 +153,9 @@ class PacketGenerator(object):
     def get_streams(self):
         return self.__streams
 
+    def _clear_streams(self):
+        raise NotImplementedError
+
     def clear_streams(self):
         ''' clear streams '''
         self._clear_streams()
@@ -525,7 +538,7 @@ class PacketGenerator(object):
                 break
             pps = (traffic_pps_max - traffic_pps_min)/2 + traffic_pps_min
 
-        self.logger.info("zero loss pps is %f" % last_no_lost_mult)
+        self.logger.info("zero loss pps is %f" % pps)
         # use last result as return data to keep the same with dts/etgen format
         # In fact, multiple link peer have multiple loss rate value,
         # here only pick one
diff --git a/framework/pktgen_ixia.py b/framework/pktgen_ixia.py
index 06667047..03dac3de 100644
--- a/framework/pktgen_ixia.py
+++ b/framework/pktgen_ixia.py
@@ -1082,7 +1082,7 @@ class Ixia(SSHConnection):
         Tells IXIA to prepare the internal buffers were the frames were captured.
         """
         ixia_port = self.get_ixia_port(port_number)
-        command = 'capture get {0} {1} {2}'.format(ixia_port)
+        command = 'capture get {0}'.format(ixia_port)
         self.send_expect(command, '% ', 30)
 
     def stat_get_rate_stat_all_stats(self, port_number):
@@ -1369,6 +1369,7 @@ class IxiaPacketGenerator(PacketGenerator):
     Ixia packet generator
     """
     def __init__(self, tester):
+        super(IxiaPacketGenerator, self).__init__(tester)
         # ixia management
         self.pktgen_type = PKTGEN_IXIA
         self._conn = None
@@ -1388,7 +1389,6 @@ class IxiaPacketGenerator(PacketGenerator):
         self.ip_keys = ['start', 'end','action', 'step', 'mask',]
         self.vlan_keys = ['start', 'end', 'action', 'step', 'count',]
 
-        super(IxiaPacketGenerator, self).__init__(tester)
         self.tester = tester
 
     def get_ports(self):
diff --git a/framework/pktgen_ixia_network.py b/framework/pktgen_ixia_network.py
index f3a232d2..3a58abe5 100644
--- a/framework/pktgen_ixia_network.py
+++ b/framework/pktgen_ixia_network.py
@@ -41,6 +41,7 @@ class IxNetworkPacketGenerator(PacketGenerator):
     ixNetwork packet generator
     """
     def __init__(self, tester):
+        super(IxNetworkPacketGenerator, self).__init__(tester)
         self.pktgen_type = PKTGEN_IXIA_NETWORK
         self._conn = None
         # ixNetwork configuration information of dts
@@ -51,7 +52,6 @@ class IxNetworkPacketGenerator(PacketGenerator):
         self._ports = []
         self._rx_ports = []
 
-        super(IxNetworkPacketGenerator, self).__init__(tester)
 
     def get_ports(self):
         ''' used for ixNetwork packet generator '''
diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index 2ad05fe6..2f537a0b 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -35,6 +35,9 @@ import sys
 import time
 from pprint import pformat
 
+from scapy.layers.inet import IP
+from scapy.layers.l2 import Ether
+
 from .pktgen_base import (
     PKTGEN,
     PKTGEN_TREX,
@@ -414,6 +417,7 @@ class TrexPacketGenerator(PacketGenerator):
     https://trex-tgn.cisco.com/trex/doc/trex_manual.html
     """
     def __init__(self, tester):
+        super(TrexPacketGenerator, self).__init__(tester)
         self.pktgen_type = PKTGEN_TREX
         self.trex_app = "t-rex-64"
         self._conn = None
@@ -432,7 +436,6 @@ class TrexPacketGenerator(PacketGenerator):
         self.ip_keys = ['start', 'end','action', 'mask', 'step']
         self.vlan_keys = ['start', 'end', 'action', 'step', 'count']
 
-        super(TrexPacketGenerator, self).__init__(tester)
 
         # check trex binary file
         trex_bin = os.sep.join([self.conf.get('trex_root_path'), self.trex_app])
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] framework/virt_*: fix pylama errors
  2021-11-24 13:47 [PATCH v1] framework/virt_*: fix pylama errors Juraj Linkeš
  2021-12-07 15:04 ` [PATCH v2] framework/pktgen_*: " Juraj Linkeš
@ 2021-12-08  9:32 ` Juraj Linkeš
  1 sibling, 0 replies; 5+ messages in thread
From: Juraj Linkeš @ 2021-12-08  9:32 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
framework/virt_base.py:271: [E] E1101 Instance of 'VirtBase' has no 'add_vm_login' member [pylint]
framework/virt_base.py:274: [E] E1101 Instance of 'VirtBase' has no '_attach_vm' member [pylint]
framework/virt_base.py:319: [E] E1101 Instance of 'VirtBase' has no '_quick_start_vm' member [pylint]
framework/virt_base.py:413: [E] E1111 Assigning result of a function call, where the function has no return [pylint]
framework/virt_base.py:416: [E] E1101 Instance of 'VirtBase' has no 'get_vm_login' member [pylint]
framework/virt_base.py:88: [E] E1111 Assigning result of a function call, where the function has no return [pylint]
framework/virt_dut.py:73: [E] E1003 Bad first argument 'Dut' given to super() [pylint]
- unify the init function of VirtDut's parents
framework/virt_resource.py:242: [E] E1101 Instance of 'VirtResource' has no '__port_isused' member [pylint]
framework/virt_resource.py:246: [E] E0602 Undefined variable 'core' [pylint]
framework/virt_resource.py:247: [E] E0602 Undefined variable 'core' [pylint]
framework/virt_scene.py:350: [E] E1101 Instance of 'VirtScene' has no 'tester' member [pylint]
framework/virt_scene.py:393: [E] E1101 Instance of 'VirtScene' has no 'vm_dut' member [pylint]
framework/virt_scene.py:397: [E] E1101 Instance of 'VirtScene' has no 'tester' member [pylint]
framework/virt_scene.py:458: [E] E1123 Unexpected keyword argument 'auto_portmap' in method call [pylint]
framework/virt_scene.py:510: [E] E0102 class already defined line 38 [pylint]
framework/virt_scene.py:517: [E] E1101 Instance of 'QEMUKvm' has no 'params' member [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 framework/crb.py           |  2 +-
 framework/dut.py           |  9 +++++----
 framework/project_dpdk.py  |  5 +++--
 framework/tester.py        |  2 +-
 framework/virt_base.py     | 28 ++++++++++++++++++++++++++--
 framework/virt_dut.py      | 10 +++++-----
 framework/virt_resource.py |  7 +++++--
 framework/virt_scene.py    | 13 +++++++------
 8 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index c9909add..4ba7d033 100755
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -51,7 +51,7 @@ class Crb(object):
     CPU/PCI/NIC on the board and setup running environment for DPDK.
     """
 
-    def __init__(self, crb, serializer, name, alt_session=True, dut_id=0):
+    def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
         self.dut_id = dut_id
         self.crb = crb
         self.read_cache = False
diff --git a/framework/dut.py b/framework/dut.py
index dc3fc874..784a8375 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -62,10 +62,11 @@ class Dut(Crb):
     CORE_LIST_CACHE_KEY = 'dut_core_list'
     PCI_DEV_CACHE_KEY = 'dut_pci_dev_info'
 
-    def __init__(self, crb, serializer, dut_id):
-        self.NAME = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
-        super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=True, dut_id=dut_id)
-
+    def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
+        if not name:
+            name = 'dut' + LOG_NAME_SEP + '%s' % crb['My IP']
+            self.NAME = name
+        super(Dut, self).__init__(crb, serializer, dut_id, name, alt_session)
         self.host_init_flag = False
         self.number_of_cores = 0
         self.tester = None
diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
index 9927bcc1..37fbc4e6 100644
--- a/framework/project_dpdk.py
+++ b/framework/project_dpdk.py
@@ -60,8 +60,9 @@ class DPDKdut(Dut):
     build, memory and kernel module.
     """
 
-    def __init__(self, crb, serializer, dut_id):
-        super(DPDKdut, self).__init__(crb, serializer, dut_id)
+    def __init__(self, crb, serializer, dut_id=0, name=None, alt_session=True):
+        super(DPDKdut, self).__init__(crb, serializer, dut_id, name,
+                                      alt_session)
         self.testpmd = None
 
     def set_target(self, target, bind_dev=True):
diff --git a/framework/tester.py b/framework/tester.py
index 9dba4e4d..80e531ee 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -80,7 +80,7 @@ class Tester(Crb):
     def __init__(self, crb, serializer):
         self.NAME = 'tester'
         self.scapy_session = None
-        super(Tester, self).__init__(crb, serializer, self.NAME)
+        super(Tester, self).__init__(crb, serializer, name=self.NAME)
         # check the python version of tester
         check_crb_python_version(self)
 
diff --git a/framework/virt_base.py b/framework/virt_base.py
index 148a4d18..ef117062 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -104,7 +104,7 @@ class VirtBase(object):
         """
         Get the virtual type, such as KVM, XEN or LIBVIRT.
         """
-        NotImplemented
+        raise NotImplementedError
 
     def has_virtual_ability(self):
         """
@@ -118,6 +118,30 @@ class VirtBase(object):
         """
         NotImplemented
 
+    def get_vm_login(self):
+        """
+        Get VM credentials.
+        """
+        raise NotImplementedError
+
+    def add_vm_login(self):
+        """
+        Add VM credentials.
+        """
+        raise NotImplementedError
+
+    def _attach_vm(self):
+        """
+        Attach VM.
+        """
+        raise NotImplementedError
+
+    def _quick_start_vm(self):
+        """
+        Quick start VM.
+        """
+        raise NotImplementedError
+
     def load_global_config(self):
         """
         Load global configure in the path DTS_ROOT_PATH/conf.
@@ -230,7 +254,7 @@ class VirtBase(object):
         """
         Get the VM IP.
         """
-        NotImplemented
+        raise NotImplementedError
 
     def get_pci_mappings(self):
         """
diff --git a/framework/virt_dut.py b/framework/virt_dut.py
index bde65667..1afd90a9 100644
--- a/framework/virt_dut.py
+++ b/framework/virt_dut.py
@@ -61,16 +61,16 @@ class VirtDut(DPDKdut):
     """
 
     def __init__(self, hyper, crb, serializer, virttype, vm_name, suite, cpu_topo, dut_id):
+        self.vm_ip = crb['IP']
+        self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
+        # do not create addition alt_session
+        super(VirtDut, self).__init__(crb, serializer, dut_id,
+                                      self.NAME, alt_session=False)
         self.vm_name = vm_name
         self.hyper = hyper
         self.cpu_topo = cpu_topo
-        self.dut_id = dut_id
         self.migration_vm = False
 
-        self.vm_ip = crb['IP']
-        self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
-        # do not create addition alt_session
-        super(Dut, self).__init__(crb, serializer, self.NAME, alt_session=False, dut_id=self.dut_id)
         # load port config from suite cfg
         self.suite = suite
 
diff --git a/framework/virt_resource.py b/framework/virt_resource.py
index 8a19f1b2..3163372d 100644
--- a/framework/virt_resource.py
+++ b/framework/virt_resource.py
@@ -70,6 +70,9 @@ class VirtResource(object):
         # save allocated cores and related vm
         self.allocated_info = {}
 
+    def __port_isused(self, pci):
+        return pci in self.used_ports
+
     def __port_used(self, pci):
         index = self.ports.index(pci)
         self.used_ports[index] = pci
@@ -243,8 +246,8 @@ class VirtResource(object):
                     print("Port %s has been used!!!" % pci)
                 else:
                     if self.__port_on_socket(pci, socket) is True:
-                        self.__port_used(core)
-                        ports.append(core)
+                        self.__port_used(pci)
+                        ports.append(pci)
 
         if vm not in self.allocated_info:
             self.allocated_info[vm] = {}
diff --git a/framework/virt_scene.py b/framework/virt_scene.py
index cc36a09b..d82012b1 100644
--- a/framework/virt_scene.py
+++ b/framework/virt_scene.py
@@ -347,7 +347,7 @@ class VirtScene(object):
             elif cmd['type'] == 'host':
                 crb = self.host_dut
             elif cmd['type'] == 'tester':
-                crb = self.tester
+                crb = self.tester_dut
             else:
                 crb = self.host_dut
 
@@ -390,11 +390,11 @@ class VirtScene(object):
     def run_post_cmds(self):
         for cmd in self.post_cmds:
             if cmd['type'] == 'vm':
-                crb = self.vm_dut
+                crb = None
             elif cmd['type'] == 'host':
                 crb = self.host_dut
             elif cmd['type'] == 'tester':
-                crb = self.tester
+                crb = self.tester_dut
             else:
                 crb = self.host_dut
 
@@ -456,7 +456,6 @@ class VirtScene(object):
                 topo = self.get_cputopo(scene_params)
                 try:
                     vm_dut = vm.start(load_config=False, set_target=False,
-                                      auto_portmap=self.auto_portmap,
                                       cpu_topo=topo)
                     if vm_dut is None:
                         raise Exception("Set up VM ENV failed!")
@@ -507,16 +506,18 @@ class VirtScene(object):
 
 if __name__ == "__main__":
 
-    class QEMUKvm():
+    class QEMUKvmTmp():
 
         def __init__(self, dut, vm_name, suite_name):
             print(vm_name)
             print(suite_name)
 
         def start(self):
-            print(self.params)
+            print(self.__dict__)
             return True
 
+    QEMUKvm = QEMUKvmTmp
+
     class simple_dev(object):
 
         def __init__(self, pci):
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v3] framework/pktgen_*: fix pylama errors
  2021-12-07 15:18   ` [PATCH v3] " Juraj Linkeš
@ 2022-01-14  8:09     ` Tu, Lijuan
  0 siblings, 0 replies; 5+ messages in thread
From: Tu, Lijuan @ 2022-01-14  8:09 UTC (permalink / raw)
  To: Juraj Linkeš, ohilyard; +Cc: dts

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: 2021年12月7日 23:18
> To: Tu, Lijuan <lijuan.tu@intel.com>; ohilyard@iol.unh.edu
> Cc: dts@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v3] framework/pktgen_*: fix pylama errors
> 
> Pylama found the following errors:
> framework/pktgen_base.py:108: [E] E1101 Instance of 'PacketGenerator' has no
> '_get_gen_port' member [pylint]
> framework/pktgen_base.py:148: [E] E1101 Instance of 'PacketGenerator' has no
> '_clear_streams' member; maybe 'clear_streams'? [pylint]
> framework/pktgen_base.py:173: [E] E1101 Instance of 'PacketGenerator' has no
> 'pktgen_type' member [pylint]
> framework/pktgen_base.py:279: [E] E1101 Instance of 'PacketGenerator' has no
> 'pktgen_type' member [pylint]
> framework/pktgen_base.py:479: [E] E1101 Instance of 'PacketGenerator' has no
> '_clear_streams' member; maybe 'clear_streams'? [pylint]
> framework/pktgen_base.py:528: [E] E0602 Undefined variable
> 'last_no_lost_mult' [pylint]
> framework/pktgen_base.py:558: [E] E1101 Instance of 'PacketGenerator' has no
> 'pktgen_type' member [pylint]
> framework/pktgen_base.py:573: [E] E1101 Instance of 'PacketGenerator' has no
> '_clear_streams' member; maybe 'clear_streams'? [pylint]
> framework/pktgen_base.py:607: [E] E1101 Instance of 'PacketGenerator' has no
> '_clear_streams' member; maybe 'clear_streams'? [pylint]
> framework/pktgen_base.py:673: [E] E1101 Instance of 'PacketGenerator' has no
> 'pktgen_type' member [pylint]
> framework/pktgen_base.py:677: [E] E1101 Instance of 'PacketGenerator' has no
> 'pktgen_type' member [pylint]
> framework/pktgen_base.py:69: [E] E1101 Instance of 'PacketGenerator' has no
> '_prepare_generator' member; maybe 'prepare_generator'? [pylint]
> framework/pktgen_base.py:77: [E] E1101 Instance of 'PacketGenerator' has no
> '_get_port_pci' member [pylint]
> framework/pktgen_ixia.py:1085: [E] E1306 Not enough arguments for format
> string [pylint]
> framework/pktgen_trex.py:194: [E] E0602 Undefined variable 'Ether' [pylint]
> framework/pktgen_trex.py:195: [E] E0602 Undefined variable 'IP' [pylint]
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

Applied

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-14  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 13:47 [PATCH v1] framework/virt_*: fix pylama errors Juraj Linkeš
2021-12-07 15:04 ` [PATCH v2] framework/pktgen_*: " Juraj Linkeš
2021-12-07 15:18   ` [PATCH v3] " Juraj Linkeš
2022-01-14  8:09     ` Tu, Lijuan
2021-12-08  9:32 ` [PATCH v2] framework/virt_*: " Juraj Linkeš

test suite reviews and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ https://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git