test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] framework: port map owner changed from tester to DUT
@ 2015-02-13  8:28 Yong Liu
  2015-02-15  2:29 ` Xu, HuilongX
  0 siblings, 1 reply; 2+ messages in thread
From: Yong Liu @ 2015-02-13  8:28 UTC (permalink / raw)
  To: dts

Network topology will be scanned automatically and save port map as one 
attribute of DUT crb. Port map saved in DUT crb will be convienient for later 
enhancement. Like create new VM, create VF device and etc.

Signed-off-by: Marvinliu <yong.liu@intel.com>
---
 framework/dts.py    |  2 +-
 framework/dut.py    | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 framework/tester.py | 67 +----------------------------------------------------
 3 files changed, 69 insertions(+), 67 deletions(-)

diff --git a/framework/dts.py b/framework/dts.py
index bddbe33..87fe649 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -303,8 +303,8 @@ def dts_run_prerequisties(pkgName, patch):
     Run dts prerequisties function.
     """
     try:
-        dut.prerequisites(pkgName, patch)
         tester.prerequisites(performance_only)
+        dut.prerequisites(pkgName, patch)
 
         serializer.save_to_file()
     except Exception as ex:
diff --git a/framework/dut.py b/framework/dut.py
index e095d86..b574229 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -51,6 +51,7 @@ class Dut(Crb):
     or CRBBareMetal.
     """
 
+    PORT_MAP_CACHE_KEY = 'dut_port_map'
     PORT_INFO_CACHE_KEY = 'dut_port_info'
     NUMBER_CORES_CACHE_KEY = 'dut_number_cores'
     CORE_LIST_CACHE_KEY = 'dut_core_list'
@@ -72,6 +73,7 @@ class Dut(Crb):
         self.architecture = None
         self.ports_info = None
         self.conf = UserConf()
+        self.ports_map = []
 
     def change_config_option(self, target, parameter, value):
         """
@@ -163,6 +165,11 @@ class Dut(Crb):
         # load port infor from config file
         self.load_portconf()
         self.mount_procfs()
+        # auto detect network topology
+        self.map_available_ports()
+        if self.ports_map is None or len(self.ports_map) == 0:
+            raise ValueError("ports_map should not be empty, please check all links")
+
 
     def restore_interfaces(self):
         """
@@ -574,3 +581,63 @@ class Dut(Crb):
                     if key in port and port_cfg[key] != port[key]:
                         self.logger.warning("CONGGURED %s NOT SAME AS SCANNED!!!" % (key.upper()))
                     port[key] = port_cfg[key]
+
+    def map_available_ports(self):
+        """
+        Load or generate network connection mapping list.
+        """
+        if self.read_cache:
+            self.ports_map = self.serializer.load(self.PORT_MAP_CACHE_KEY)
+
+        if not self.read_cache or self.ports_map is None:
+            self.map_available_ports_uncached()
+            self.serializer.save(self.PORT_MAP_CACHE_KEY, self.ports_map)
+            self.logger.warning("DUT PORT MAP: " + str(self.ports_map))
+
+    def map_available_ports_uncached(self):
+        """
+        Generate network connection mapping list.
+        """
+
+        nrPorts = len(self.ports_info)
+        if nrPorts == 0:
+            return
+
+        self.ports_map = [-1] * nrPorts
+
+        hits = [False] * len(self.tester.ports_info)
+
+        for dutPort in range(nrPorts):
+            peer = self.get_peer_pci(dutPort)
+            dutpci = self.ports_info[dutPort]['pci']
+            if peer is not None:
+                for remotePort in range(len(self.tester.ports_info)):
+                    if self.tester.ports_info[localPort]['pci'] == peer:
+                        hits[remotePort] = True
+                        self.ports_map[dutPort] = remotePort
+                        break
+                if self.ports_map[dutPort] == -1:
+                    self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!")
+                else:
+                    continue  # skip ping6 map
+
+            for remotePort in range(len(self.tester.ports_info)):
+                if hits[remotePort]:
+                    continue
+
+                # skip ping self port
+                remotepci = self.tester.ports_info[remotePort]['pci']
+                if (self.crb['IP'] == self.crb['tester IP']) and (dutpci == remotepci):
+                    continue
+
+                ipv6 = self.get_ipv6_address(dutPort)
+                if ipv6 == "Not connected":
+                    continue
+
+                out = self.tester.send_ping6(remotePort, ipv6, self.get_mac_address(dutPort))
+
+                if ('64 bytes from' in out):
+                    self.logger.info("PORT MAP: [dut %d: tester %d]" % (dutPort, remotePort))
+                    hits[remotePort] = True
+                    self.ports_map[dutPort] = remotePort
+                    break
diff --git a/framework/tester.py b/framework/tester.py
index 68fec69..2834d77 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -50,7 +50,6 @@ class Tester(Crb):
     A config file and pcap file must have previously been copied
     to this machine.
     """
-    PORT_MAP_CACHE_KEY = 'tester_port_map'
     PORT_INFO_CACHE_KEY = 'tester_port_info'
     CORE_LIST_CACHE_KEY = 'tester_core_list'
     NUMBER_CORES_CACHE_KEY = 'tester_number_cores'
@@ -68,7 +67,6 @@ class Tester(Crb):
                                          self.NAME, self.get_password())
         self.alt_session.init_log(self.logger)
 
-        self.ports_map = []
         self.bgProcIsRunning = False
         self.dut = None
         self.inBg = 0
@@ -132,15 +130,12 @@ class Tester(Crb):
         self.pci_devices_information()
         self.restore_interfaces()
         self.scan_ports()
-        self.map_available_ports()
-        if self.ports_map is None or len(self.ports_map) == 0:
-            raise ValueError("ports_map should not be empty, please check all links")
 
     def get_local_port(self, remotePort):
         """
         Return tester local port connect to specified dut port.
         """
-        return self.ports_map[remotePort]
+        return self.dut.ports_map[remotePort]
 
     def get_local_port_type(self, remotePort):
         """
@@ -254,66 +249,6 @@ class Tester(Crb):
         else:
             return self.send_expect("ping6 -w 5 -c 5 -A -I %s %s" % (self.ports_info[localPort]['intf'], ipv6), "# ", 10)
 
-    def map_available_ports(self):
-        """
-        Load or generate network connection mapping list.
-        """
-        if self.read_cache:
-            self.ports_map = self.serializer.load(self.PORT_MAP_CACHE_KEY)
-
-        if not self.read_cache or self.ports_map is None:
-            self.map_available_ports_uncached()
-            self.serializer.save(self.PORT_MAP_CACHE_KEY, self.ports_map)
-            self.logger.warning("DUT PORT MAP: " + str(self.ports_map))
-
-    def map_available_ports_uncached(self):
-        """
-        Generate network connection mapping list.
-        """
-
-        nrPorts = len(self.dut.ports_info)
-        if nrPorts == 0:
-            return
-
-        self.ports_map = [-1] * nrPorts
-
-        hits = [False] * len(self.ports_info)
-
-        for dutPort in range(nrPorts):
-            peer = self.dut.get_peer_pci(dutPort)
-            dutpci = self.dut.ports_info[dutPort]['pci']
-            if peer is not None:
-                for localPort in range(len(self.ports_info)):
-                    if self.ports_info[localPort]['pci'] == peer:
-                        hits[localPort] = True
-                        self.ports_map[dutPort] = localPort
-                        break
-                if self.ports_map[dutPort] == -1:
-                    self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!")
-                else:
-                    continue  # skip ping6 map
-
-            for localPort in range(len(self.ports_info)):
-                if hits[localPort]:
-                    continue
-
-                # skip ping self port
-                localpci = self.ports_info[localPort]['pci']
-                if (self.crb['IP'] == self.crb['tester IP']) and (dutpci == localpci):
-                    continue
-
-                ipv6 = self.dut.get_ipv6_address(dutPort)
-                if ipv6 == "Not connected":
-                    continue
-
-                out = self.send_ping6(localPort, ipv6, self.dut.get_mac_address(dutPort))
-
-                if ('64 bytes from' in out):
-                    self.logger.info("PORT MAP: [local %d: dut %d]" % (localPort, dutPort))
-                    hits[localPort] = True
-                    self.ports_map[dutPort] = localPort
-                    break
-
     def get_port_numa(self, port):
         """
         Return tester local port numa.
-- 
1.9.3

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

end of thread, other threads:[~2015-02-15  2:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-13  8:28 [dts] [PATCH] framework: port map owner changed from tester to DUT Yong Liu
2015-02-15  2:29 ` Xu, HuilongX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).