test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 0/6] DTS enhancement and clean up
@ 2015-01-13 13:42 Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

This patch set mostly try to do some enhancement of DTS,
also include some bug fix, code rework and clean up.

Michael Qiu (6):
  framework/tester: Fix NoneType Error of port_map
  framework/crbs: Info clean up of crbs
  framework: Add login password support
  framework/ssh: Add verify ability for command execution
  framework: Fix ifname not found error
  framework/crb: rework restore_interfaces()

 framework/crb.py            | 54 +++++++++++++++++++++++++++------------------
 framework/crbs.py           | 10 +++++----
 framework/dut.py            | 22 ++++++++++++++++--
 framework/etgen.py          |  7 +++++-
 framework/ssh_connection.py |  8 +++----
 framework/ssh_pexpect.py    | 36 ++++++++++++++++++++----------
 framework/tester.py         | 17 ++++++++++----
 7 files changed, 106 insertions(+), 48 deletions(-)

-- 
1.9.3

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

* [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-14  1:15   ` Liu, Yong
  2015-01-25  1:07   ` Liu, Yong
  2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

File "./framework/tester.py", line 110, in tester_prerequisites
    assert len(self.ports_map) > 0
TypeError: object of type 'NoneType' has no len()

Currently ports_map is initialized with empty list,
but it could be overridden by 'None' value.

This patch solves this issue

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/tester.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/framework/tester.py b/framework/tester.py
index 2c023dd..d69503a 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -125,7 +125,8 @@ class Tester(Crb):
         self.restore_interfaces()
         self.scan_ports()
         self.map_available_ports()
-        assert len(self.ports_map) > 0
+        if self.ports_map == 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):
         """
-- 
1.9.3

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

* [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-25  1:07   ` Liu, Yong
  2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

It is not a good idea to add exactly IP and other details of
one machine inside a company.

Make it more clean and more general.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/crbs.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/framework/crbs.py b/framework/crbs.py
index 98821ea..77446c3 100644
--- a/framework/crbs.py
+++ b/framework/crbs.py
@@ -3,12 +3,13 @@ Static configuration data for any CRBs that can be used.
 """
 from settings import IXIA
 
+# Todo: modify this script to a config file, like crbs.cfg
 crbs = [
-    {'IP': '10.239.128.117',
+    {'IP': '',
      'name': 'CrownPassCRB1',
-     'user': 'root',
-     'pass': 'tester',
-     'tester IP': '10.239.128.116',
+     'user': '',
+     'pass': '',
+     'tester IP': '',
      IXIA: None,
      'memory channels': 4,
      'bypass core0': True},
-- 
1.9.3

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

* [dts] [PATCH 3/6] framework: Add login password support
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-14  1:18   ` Liu, Yong
  2015-01-25  1:07   ` Liu, Yong
  2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

DTS login dut and tester machine via ssh service while
public and private keys are needed.

That means it can't use the user:password to login, which
should not always be a good idea.

Add login with password for another choice.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/crbs.py           |  1 +
 framework/dut.py            | 12 ++++++++++--
 framework/etgen.py          |  7 ++++++-
 framework/ssh_connection.py |  4 ++--
 framework/ssh_pexpect.py    | 23 ++++++++++++-----------
 framework/tester.py         | 12 ++++++++++--
 6 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/framework/crbs.py b/framework/crbs.py
index 77446c3..6aa5435 100644
--- a/framework/crbs.py
+++ b/framework/crbs.py
@@ -10,6 +10,7 @@ crbs = [
      'user': '',
      'pass': '',
      'tester IP': '',
+     'tester pass': '',
      IXIA: None,
      'memory channels': 4,
      'bypass core0': True},
diff --git a/framework/dut.py b/framework/dut.py
index 4def144..d7099ef 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -59,9 +59,11 @@ class Dut(Crb):
         super(Dut, self).__init__(crb, serializer)
         self.NAME = 'dut'
         self.logger = getLogger(self.NAME)
-        self.session = SSHConnection(self.get_ip_address(), self.NAME)
+        self.session = SSHConnection(self.get_ip_address(), self.NAME,
+                                     self.get_password())
         self.session.init_log(self.logger)
-        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
+        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME,
+                                         self.get_password())
         self.alt_session.init_log(self.logger)
         self.number_of_cores = 0
         self.tester = None
@@ -120,6 +122,12 @@ class Dut(Crb):
         """
         return self.crb['IP']
 
+    def get_password(self):
+        """
+        Get DUT's login password.
+        """
+        return self.crb['pass']
+
     def dut_prerequisites(self):
         """
         Prerequest function should be called before execute any test case.
diff --git a/framework/etgen.py b/framework/etgen.py
index fe7100c..2f2e975 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -137,7 +137,9 @@ class IxiaPacketGenerator(SSHConnection):
         self.tester = tester
         self.NAME = 'ixia'
         self.logger = getLogger(self.NAME)
-        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(), self.NAME)
+        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
+                                                  self.NAME,
+                                                  self.get_password())
         super(IxiaPacketGenerator, self).init_log(self.logger)
 
         self.tcl_cmds = []
@@ -170,6 +172,9 @@ class IxiaPacketGenerator(SSHConnection):
     def get_ip_address(self):
         return self.tester.get_ip_address()
 
+    def get_password(self):
+        return self.tester.get_password()
+
     def add_tcl_cmd(self, cmd):
         """
         Add one tcl command into command list.
diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index be1fb76..4306162 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -40,8 +40,8 @@ class SSHConnection(object):
     Implement send_expect/copy function upper SSHPexpet module.
     """
 
-    def __init__(self, host, session_name):
-        self.session = SSHPexpect(host, USERNAME)
+    def __init__(self, host, session_name, password = ''):
+        self.session = SSHPexpect(host, USERNAME, password)
         self.name = session_name
 
     def init_log(self, logger):
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 8fb441b..9c353e7 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -12,12 +12,14 @@ Aslo support transfer files to tester or DUT.
 
 class SSHPexpect(object):
 
-    def __init__(self, host, username):
+    def __init__(self, host, username, password):
         try:
             self.session = pxssh.pxssh()
             self.username = username
             self.host = host
-            self.session.login(self.host, self.username)
+            self.password = password
+            self.session.login(self.host, self.username,
+                               self.password, original_prompt='[$#>]')
             self.send_expect('stty -echo', '# ', timeout=2)
         except Exception:
             raise SSHConnectionException(host)
@@ -69,21 +71,20 @@ class SSHPexpect(object):
         Copies a file from a remote place into local.
         """
         command = 'scp {0}@{1}:{2} .'.format(self.username, self.host, filename)
-        self._spawn_scp(command, password)
+        if password == '':
+            self._spawn_scp(command, self.password)
+        else:
+            self._spawn_scp(command, password)
 
     def copy_file_to(self, filename, password=''):
         """
         Sends a local file to a remote place.
         """
         command = 'scp {0} {1}@{2}:'.format(filename, self.username, self.host)
-        self._spawn_scp(command, password)
-
-    def copy_file_from(self, filename, password=''):
-        """
-        copy a remote file to a local place.
-        """
-        command = 'scp {1}@{2}:{0} .'.format(filename, self.username, self.host)
-        self._spawn_scp(command, password)
+        if password == '':
+            self._spawn_scp(command, self.password)
+        else:
+            self._spawn_scp(command, password)
 
     def _spawn_scp(self, scp_cmd, password):
         """
diff --git a/framework/tester.py b/framework/tester.py
index d69503a..0ebe29a 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -61,9 +61,11 @@ class Tester(Crb):
         self.NAME = 'tester'
 
         self.logger = getLogger(self.NAME)
-        self.session = SSHConnection(self.get_ip_address(), self.NAME)
+        self.session = SSHConnection(self.get_ip_address(),
+                                     self.NAME, self.get_password())
         self.session.init_log(self.logger)
-        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
+        self.alt_session = SSHConnection(self.get_ip_address(),
+                                         self.NAME, self.get_password())
         self.alt_session.init_log(self.logger)
 
         self.ports_map = []
@@ -88,6 +90,12 @@ class Tester(Crb):
         """
         return self.crb['tester IP']
 
+    def get_password(self):
+        """
+        Get tester login password of tester CRB.
+        """
+        return self.crb['tester pass']
+
     def has_external_traffic_generator(self):
         """
         Check whether performance test will base on IXIA equipment.
-- 
1.9.3

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

* [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
                   ` (2 preceding siblings ...)
  2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-14  1:24   ` Liu, Yong
  2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
  2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
  5 siblings, 2 replies; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

ssh command exection never try to verify the failure or success,

It should be very dangerous when execute command both in dut and
tester machine without check the status, maybe unexpected error
happens.

This patch add this ability to verify the status.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/ssh_connection.py |  4 ++--
 framework/ssh_pexpect.py    | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 4306162..1ff79b9 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -49,9 +49,9 @@ class SSHConnection(object):
         self.logger.config_execution(self.name)
         self.session.init_log(logger, self.name)
 
-    def send_expect(self, cmds, expected, timeout=15):
+    def send_expect(self, cmds, expected, timeout=15, verify=False):
         self.logger.info(cmds)
-        out = self.session.send_expect(cmds, expected, timeout)
+        out = self.session.send_expect(cmds, expected, timeout, verify=False)
         self.logger.debug(out)
         return out
 
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 9c353e7..2fad899 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -29,12 +29,23 @@ class SSHPexpect(object):
         self.logger.config_execution(name)
         self.logger.info("ssh %s@%s" % (self.username, self.host))
 
-    def send_expect(self, command, expected, timeout=15):
+    def send_expect_base(self, command, expected, timeout=15):
         self.session.PROMPT = expected
         self.__sendline(command)
         self.__prompt(command, timeout)
         return self.get_output_before()
 
+    def send_expect(self, command, expected, timeout=15, verify=False):
+        ret = self.send_expect_base(command, expected, timeout)
+        if verify:
+            ret_status = self.send_expect_base("echo $?", expected)
+            if not int(ret_status):
+                return ret
+            else:
+                return -1
+        else:
+            return ret
+
     def __prompt(self, command, timeout):
         if not self.session.prompt(timeout):
             raise TimeoutException(command, self.get_output_all())
-- 
1.9.3

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

* [dts] [PATCH 5/6] framework: Fix ifname not found error
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
                   ` (3 preceding siblings ...)
  2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-14  1:35   ` Liu, Yong
  2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
  5 siblings, 1 reply; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

Currently, DTS try to get ifname by the file name below the dir:
	/sys/bus/pci/devices/xxxx:xx:xx.x/net

But if the device driver has been unbind or not loaded successful,
kernel will not create that entry, so the ifname will not exist.

This will cause DTS failure.

Check that entry to avoid this issue.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/crb.py    | 21 +++++++++++++++------
 framework/dut.py    | 10 ++++++++++
 framework/tester.py |  2 +-
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index aca62c1..ee005c4 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -55,7 +55,8 @@ class Crb(object):
         self.serializer = serializer
         self.ports_info = None
 
-    def send_expect(self, cmds, expected, timeout=TIMEOUT, alt_session=False):
+    def send_expect(self, cmds, expected, timeout=TIMEOUT,
+                    alt_session=False, verify = False):
         """
         Send commands to crb and return string before expected string. If
         there's no expected string found before timeout, TimeoutException will
@@ -63,9 +64,10 @@ class Crb(object):
         """
 
         if alt_session:
-            return self.alt_session.session.send_expect(cmds, expected, timeout)
+            return self.alt_session.session.send_expect(cmds, expected,
+                                                        timeout, verify)
 
-        return self.session.send_expect(cmds, expected, timeout)
+        return self.session.send_expect(cmds, expected, timeout, verify)
 
     def set_test_types(self, func_tests, perf_tests):
         """
@@ -166,7 +168,9 @@ class Crb(object):
 
                 addr_array = pci_bus.split(':')
                 itf = self.get_interface_name(addr_array[0], addr_array[1])
-                self.send_expect("ifconfig %s up" % itf, "# ")
+                # In case the device driver has already been unbind
+                if itf:
+                    self.send_expect("ifconfig %s up" % itf, "# ")
 
         except Exception as e:
             self.logger.error("   !!! Restore ITF: " + e.message)
@@ -226,8 +230,13 @@ class Crb(object):
         """
         Get interface name of specified pci device on linux.
         """
-        command = 'ls /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
-        return self.send_expect(command, '# ')
+        ifname_path = '/sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
+        # In case the device driver has already been unbind
+        ret = self.send_expect("ls %s"% ifname_path, '# ', verify=True)
+        if ret == -1:
+            return None
+        else:
+            return ret
 
     def get_interface_name_freebsd(self, bus_id, devfun_id):
         """
diff --git a/framework/dut.py b/framework/dut.py
index d7099ef..96b8bd6 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -424,6 +424,11 @@ class Dut(Crb):
             if pci_id == '8086:10fb':
                 self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
             intf = self.get_interface_name(bus_id, devfun_id)
+            # Skip undrived pci Eth device
+            if not intf:
+                self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id,
+                                                          skipped))
+                continue
 
             out = self.send_expect("ip link show %s" % intf, "# ")
             if "DOWN" in out:
@@ -478,6 +483,11 @@ class Dut(Crb):
                 continue
 
             intf = self.get_interface_name(pci_bus)
+            # Skip undrived pci devices
+            if not intf:
+                self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id,
+                                                      skipped))
+                continue
 
             macaddr = self.get_mac_addr(intf)
             ipv6 = self.get_ipv6_addr(intf)
diff --git a/framework/tester.py b/framework/tester.py
index 0ebe29a..40f9344 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -213,7 +213,7 @@ class Tester(Crb):
 
             intf = self.get_interface_name(bus_id, devfun_id)
 
-            if "No such file" in intf:
+            if not intf:
                 self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id,
                                                              "unknow_interface"))
                 continue
-- 
1.9.3

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

* [dts] [PATCH 6/6] framework/crb: rework restore_interfaces()
  2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
                   ` (4 preceding siblings ...)
  2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
@ 2015-01-13 13:42 ` Michael Qiu
  2015-01-14  1:35   ` Liu, Yong
  5 siblings, 1 reply; 17+ messages in thread
From: Michael Qiu @ 2015-01-13 13:42 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

Currently restore_interfaces() is very ugly, and hard to add new
device's support.

Just make it more flexible to support other new device.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/crb.py | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index ee005c4..a08db46 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -139,30 +139,33 @@ class Crb(object):
         """
         Restore Linux interfaces.
         """
+        # ToDo: put to cfg file later
+        driver_list = ["igb", "ixgbe", "e1000e", "e1000", "virtio_net", "i40e"]
         if dts.drivername == "vfio-pci":
             self.send_expect("rmmod vfio_iommu_type1", "# ", 10)
             self.send_expect("rmmod vfio_pci", "# ", 10)
             self.send_expect("rmmod vfio", "# ", 10)
         else:
             self.send_expect("rmmod igb_uio", "# ", 10)
-        self.send_expect("modprobe igb", "# ", 20)
-        self.send_expect("modprobe ixgbe", "# ", 20)
-        self.send_expect("modprobe e1000e", "# ", 20)
-        self.send_expect("modprobe e1000", "# ", 20)
-        self.send_expect("modprobe virtio_net", "# ", 20)
+	for driver in driver_list:
+            # Need remove check after i40e driver in upstream linux kernel
+            if driver != "i40e":
+                self.send_expect("modprobe %s"%driver, "# ", 20)
+            else:
+                self.send_expect("insmod /root/i40e.ko", "# ", 30)
 
         try:
             for (pci_bus, pci_id) in self.pci_devices_info:
-                if pci_id in ('8086:10fb', '8086:151c', '8086:1528', '8086:1512', '8086:154a'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
-                elif pci_id in ('8086:10e8', '8086:150e', '8086:1521', '8086:10c9', '8086:1526', '8086:1533'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/igb/bind" % pci_bus, "# ")
-                elif pci_id in('8086:10d3', '8086:10b9'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000e/bind" % pci_bus, "# ")
-                elif pci_id in ('8086:100f', '8086:100e'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000/bind" % pci_bus, "# ")
-                elif pci_id in ('1af4:1000'):
-                    self.send_expect("echo 0000%s > /sys/bus/pci/drivers/virtio-pci/bind" % pci_bus, "# ")
+                full_bus = "0000:%s"% pci_bus
+                driver_path = "/sys/bus/pci/devices/%s/driver"%full_bus
+                # Get the abs path of the driver
+                driver_path =  self.send_expect("cd %s && pwd -P" %
+                                                driver_path, "# ",
+                                                verify = True)
+                if driver_path != -1 and \
+                   driver_path.split('/')[-1] in driver_list:
+                        self.send_expect("echo %s > %s/bind" %
+                                         (full_bus, driver_path), "# ")
                 else:
                     continue
 
-- 
1.9.3

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

* Re: [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map
  2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
@ 2015-01-14  1:15   ` Liu, Yong
  2015-01-25  1:07   ` Liu, Yong
  1 sibling, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-14  1:15 UTC (permalink / raw)
  To: Qiu, Michael, dts

Thanks Michael. This patch is fine here.  My confused is that  in function map_available_ports, DTS will call map_available_ports_uncached  to initialize ports_map when ports_map is none. 
Can you give more detail about how ports_map is None, maybe there's other potential issues.

    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))

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 1/6] framework/tester: Fix NoneType Error of port_map
> 
> File "./framework/tester.py", line 110, in tester_prerequisites
>     assert len(self.ports_map) > 0
> TypeError: object of type 'NoneType' has no len()
> 
> Currently ports_map is initialized with empty list,
> but it could be overridden by 'None' value.
> 
> This patch solves this issue
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/tester.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/framework/tester.py b/framework/tester.py
> index 2c023dd..d69503a 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -125,7 +125,8 @@ class Tester(Crb):
>          self.restore_interfaces()
>          self.scan_ports()
>          self.map_available_ports()
> -        assert len(self.ports_map) > 0
> +        if self.ports_map == 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):
>          """
> --
> 1.9.3

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

* Re: [dts] [PATCH 3/6] framework: Add login password support
  2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
@ 2015-01-14  1:18   ` Liu, Yong
  2015-01-25  1:07   ` Liu, Yong
  1 sibling, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-14  1:18 UTC (permalink / raw)
  To: Qiu, Michael, dts

That's  good idea. DTS should support both with password and without password.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 3/6] framework: Add login password support
> 
> DTS login dut and tester machine via ssh service while
> public and private keys are needed.
> 
> That means it can't use the user:password to login, which
> should not always be a good idea.
> 
> Add login with password for another choice.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/crbs.py           |  1 +
>  framework/dut.py            | 12 ++++++++++--
>  framework/etgen.py          |  7 ++++++-
>  framework/ssh_connection.py |  4 ++--
>  framework/ssh_pexpect.py    | 23 ++++++++++++-----------
>  framework/tester.py         | 12 ++++++++++--
>  6 files changed, 41 insertions(+), 18 deletions(-)
> 
> diff --git a/framework/crbs.py b/framework/crbs.py
> index 77446c3..6aa5435 100644
> --- a/framework/crbs.py
> +++ b/framework/crbs.py
> @@ -10,6 +10,7 @@ crbs = [
>       'user': '',
>       'pass': '',
>       'tester IP': '',
> +     'tester pass': '',
>       IXIA: None,
>       'memory channels': 4,
>       'bypass core0': True},
> diff --git a/framework/dut.py b/framework/dut.py
> index 4def144..d7099ef 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -59,9 +59,11 @@ class Dut(Crb):
>          super(Dut, self).__init__(crb, serializer)
>          self.NAME = 'dut'
>          self.logger = getLogger(self.NAME)
> -        self.session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.session = SSHConnection(self.get_ip_address(), self.NAME,
> +                                     self.get_password())
>          self.session.init_log(self.logger)
> -        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME,
> +                                         self.get_password())
>          self.alt_session.init_log(self.logger)
>          self.number_of_cores = 0
>          self.tester = None
> @@ -120,6 +122,12 @@ class Dut(Crb):
>          """
>          return self.crb['IP']
> 
> +    def get_password(self):
> +        """
> +        Get DUT's login password.
> +        """
> +        return self.crb['pass']
> +
>      def dut_prerequisites(self):
>          """
>          Prerequest function should be called before execute any test case.
> diff --git a/framework/etgen.py b/framework/etgen.py
> index fe7100c..2f2e975 100644
> --- a/framework/etgen.py
> +++ b/framework/etgen.py
> @@ -137,7 +137,9 @@ class IxiaPacketGenerator(SSHConnection):
>          self.tester = tester
>          self.NAME = 'ixia'
>          self.logger = getLogger(self.NAME)
> -        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> self.NAME)
> +        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> +                                                  self.NAME,
> +                                                  self.get_password())
>          super(IxiaPacketGenerator, self).init_log(self.logger)
> 
>          self.tcl_cmds = []
> @@ -170,6 +172,9 @@ class IxiaPacketGenerator(SSHConnection):
>      def get_ip_address(self):
>          return self.tester.get_ip_address()
> 
> +    def get_password(self):
> +        return self.tester.get_password()
> +
>      def add_tcl_cmd(self, cmd):
>          """
>          Add one tcl command into command list.
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index be1fb76..4306162 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -40,8 +40,8 @@ class SSHConnection(object):
>      Implement send_expect/copy function upper SSHPexpet module.
>      """
> 
> -    def __init__(self, host, session_name):
> -        self.session = SSHPexpect(host, USERNAME)
> +    def __init__(self, host, session_name, password = ''):
> +        self.session = SSHPexpect(host, USERNAME, password)
>          self.name = session_name
> 
>      def init_log(self, logger):
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 8fb441b..9c353e7 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -12,12 +12,14 @@ Aslo support transfer files to tester or DUT.
> 
>  class SSHPexpect(object):
> 
> -    def __init__(self, host, username):
> +    def __init__(self, host, username, password):
>          try:
>              self.session = pxssh.pxssh()
>              self.username = username
>              self.host = host
> -            self.session.login(self.host, self.username)
> +            self.password = password
> +            self.session.login(self.host, self.username,
> +                               self.password, original_prompt='[$#>]')
>              self.send_expect('stty -echo', '# ', timeout=2)
>          except Exception:
>              raise SSHConnectionException(host)
> @@ -69,21 +71,20 @@ class SSHPexpect(object):
>          Copies a file from a remote place into local.
>          """
>          command = 'scp {0}@{1}:{2} .'.format(self.username, self.host, filename)
> -        self._spawn_scp(command, password)
> +        if password == '':
> +            self._spawn_scp(command, self.password)
> +        else:
> +            self._spawn_scp(command, password)
> 
>      def copy_file_to(self, filename, password=''):
>          """
>          Sends a local file to a remote place.
>          """
>          command = 'scp {0} {1}@{2}:'.format(filename, self.username, self.host)
> -        self._spawn_scp(command, password)
> -
> -    def copy_file_from(self, filename, password=''):
> -        """
> -        copy a remote file to a local place.
> -        """
> -        command = 'scp {1}@{2}:{0} .'.format(filename, self.username, self.host)
> -        self._spawn_scp(command, password)
> +        if password == '':
> +            self._spawn_scp(command, self.password)
> +        else:
> +            self._spawn_scp(command, password)
> 
>      def _spawn_scp(self, scp_cmd, password):
>          """
> diff --git a/framework/tester.py b/framework/tester.py
> index d69503a..0ebe29a 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -61,9 +61,11 @@ class Tester(Crb):
>          self.NAME = 'tester'
> 
>          self.logger = getLogger(self.NAME)
> -        self.session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.session = SSHConnection(self.get_ip_address(),
> +                                     self.NAME, self.get_password())
>          self.session.init_log(self.logger)
> -        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.alt_session = SSHConnection(self.get_ip_address(),
> +                                         self.NAME, self.get_password())
>          self.alt_session.init_log(self.logger)
> 
>          self.ports_map = []
> @@ -88,6 +90,12 @@ class Tester(Crb):
>          """
>          return self.crb['tester IP']
> 
> +    def get_password(self):
> +        """
> +        Get tester login password of tester CRB.
> +        """
> +        return self.crb['tester pass']
> +
>      def has_external_traffic_generator(self):
>          """
>          Check whether performance test will base on IXIA equipment.
> --
> 1.9.3

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

* Re: [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution
  2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
@ 2015-01-14  1:24   ` Liu, Yong
  2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
  1 sibling, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-14  1:24 UTC (permalink / raw)
  To: Qiu, Michael, dts

Thanks for this idea. DTS can check return status as it default behavior. And when command return error, the output is still valuable.
My suggestion is that function send_expect should return both output message and command executed return value.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 4/6] framework/ssh: Add verify ability for command
> execution
> 
> ssh command exection never try to verify the failure or success,
> 
> It should be very dangerous when execute command both in dut and
> tester machine without check the status, maybe unexpected error
> happens.
> 
> This patch add this ability to verify the status.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/ssh_connection.py |  4 ++--
>  framework/ssh_pexpect.py    | 13 ++++++++++++-
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index 4306162..1ff79b9 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -49,9 +49,9 @@ class SSHConnection(object):
>          self.logger.config_execution(self.name)
>          self.session.init_log(logger, self.name)
> 
> -    def send_expect(self, cmds, expected, timeout=15):
> +    def send_expect(self, cmds, expected, timeout=15, verify=False):
>          self.logger.info(cmds)
> -        out = self.session.send_expect(cmds, expected, timeout)
> +        out = self.session.send_expect(cmds, expected, timeout, verify=False)
>          self.logger.debug(out)
>          return out
> 
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 9c353e7..2fad899 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -29,12 +29,23 @@ class SSHPexpect(object):
>          self.logger.config_execution(name)
>          self.logger.info("ssh %s@%s" % (self.username, self.host))
> 
> -    def send_expect(self, command, expected, timeout=15):
> +    def send_expect_base(self, command, expected, timeout=15):
>          self.session.PROMPT = expected
>          self.__sendline(command)
>          self.__prompt(command, timeout)
>          return self.get_output_before()
> 
> +    def send_expect(self, command, expected, timeout=15, verify=False):
> +        ret = self.send_expect_base(command, expected, timeout)
> +        if verify:
> +            ret_status = self.send_expect_base("echo $?", expected)
> +            if not int(ret_status):
> +                return ret
> +            else:
> +                return -1
> +        else:
> +            return ret
> +
>      def __prompt(self, command, timeout):
>          if not self.session.prompt(timeout):
>              raise TimeoutException(command, self.get_output_all())
> --
> 1.9.3

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

* Re: [dts] [PATCH 5/6] framework: Fix ifname not found error
  2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
@ 2015-01-14  1:35   ` Liu, Yong
  0 siblings, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-14  1:35 UTC (permalink / raw)
  To: Qiu, Michael, dts

DTS need handle those devices without network interface. Those NICs which kernel not supported should also can be tested in DTS.
I think we need modify original logic. Let's pending this patch until fixed issue first.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 5/6] framework: Fix ifname not found error
> 
> Currently, DTS try to get ifname by the file name below the dir:
> 	/sys/bus/pci/devices/xxxx:xx:xx.x/net
> 
> But if the device driver has been unbind or not loaded successful,
> kernel will not create that entry, so the ifname will not exist.
> 
> This will cause DTS failure.
> 
> Check that entry to avoid this issue.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/crb.py    | 21 +++++++++++++++------
>  framework/dut.py    | 10 ++++++++++
>  framework/tester.py |  2 +-
>  3 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/framework/crb.py b/framework/crb.py
> index aca62c1..ee005c4 100644
> --- a/framework/crb.py
> +++ b/framework/crb.py
> @@ -55,7 +55,8 @@ class Crb(object):
>          self.serializer = serializer
>          self.ports_info = None
> 
> -    def send_expect(self, cmds, expected, timeout=TIMEOUT,
> alt_session=False):
> +    def send_expect(self, cmds, expected, timeout=TIMEOUT,
> +                    alt_session=False, verify = False):
>          """
>          Send commands to crb and return string before expected string. If
>          there's no expected string found before timeout, TimeoutException will
> @@ -63,9 +64,10 @@ class Crb(object):
>          """
> 
>          if alt_session:
> -            return self.alt_session.session.send_expect(cmds, expected, timeout)
> +            return self.alt_session.session.send_expect(cmds, expected,
> +                                                        timeout, verify)
> 
> -        return self.session.send_expect(cmds, expected, timeout)
> +        return self.session.send_expect(cmds, expected, timeout, verify)
> 
>      def set_test_types(self, func_tests, perf_tests):
>          """
> @@ -166,7 +168,9 @@ class Crb(object):
> 
>                  addr_array = pci_bus.split(':')
>                  itf = self.get_interface_name(addr_array[0], addr_array[1])
> -                self.send_expect("ifconfig %s up" % itf, "# ")
> +                # In case the device driver has already been unbind
> +                if itf:
> +                    self.send_expect("ifconfig %s up" % itf, "# ")
> 
>          except Exception as e:
>              self.logger.error("   !!! Restore ITF: " + e.message)
> @@ -226,8 +230,13 @@ class Crb(object):
>          """
>          Get interface name of specified pci device on linux.
>          """
> -        command = 'ls /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id,
> devfun_id)
> -        return self.send_expect(command, '# ')
> +        ifname_path = '/sys/bus/pci/devices/0000:%s:%s/net' % (bus_id,
> devfun_id)
> +        # In case the device driver has already been unbind
> +        ret = self.send_expect("ls %s"% ifname_path, '# ', verify=True)
> +        if ret == -1:
> +            return None
> +        else:
> +            return ret
> 
>      def get_interface_name_freebsd(self, bus_id, devfun_id):
>          """
> diff --git a/framework/dut.py b/framework/dut.py
> index d7099ef..96b8bd6 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -424,6 +424,11 @@ class Dut(Crb):
>              if pci_id == '8086:10fb':
>                  self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" %
> pci_bus, "# ")
>              intf = self.get_interface_name(bus_id, devfun_id)
> +            # Skip undrived pci Eth device
> +            if not intf:
> +                self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id,
> +                                                          skipped))
> +                continue
> 
>              out = self.send_expect("ip link show %s" % intf, "# ")
>              if "DOWN" in out:
> @@ -478,6 +483,11 @@ class Dut(Crb):
>                  continue
> 
>              intf = self.get_interface_name(pci_bus)
> +            # Skip undrived pci devices
> +            if not intf:
> +                self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id,
> +                                                      skipped))
> +                continue
> 
>              macaddr = self.get_mac_addr(intf)
>              ipv6 = self.get_ipv6_addr(intf)
> diff --git a/framework/tester.py b/framework/tester.py
> index 0ebe29a..40f9344 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -213,7 +213,7 @@ class Tester(Crb):
> 
>              intf = self.get_interface_name(bus_id, devfun_id)
> 
> -            if "No such file" in intf:
> +            if not intf:
>                  self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id,
>                                                               "unknow_interface"))
>                  continue
> --
> 1.9.3

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

* Re: [dts] [PATCH 6/6] framework/crb: rework restore_interfaces()
  2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
@ 2015-01-14  1:35   ` Liu, Yong
  0 siblings, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-14  1:35 UTC (permalink / raw)
  To: Qiu, Michael, dts

That's great, will merged into main branch.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 6/6] framework/crb: rework restore_interfaces()
> 
> Currently restore_interfaces() is very ugly, and hard to add new
> device's support.
> 
> Just make it more flexible to support other new device.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/crb.py | 33 ++++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/framework/crb.py b/framework/crb.py
> index ee005c4..a08db46 100644
> --- a/framework/crb.py
> +++ b/framework/crb.py
> @@ -139,30 +139,33 @@ class Crb(object):
>          """
>          Restore Linux interfaces.
>          """
> +        # ToDo: put to cfg file later
> +        driver_list = ["igb", "ixgbe", "e1000e", "e1000", "virtio_net", "i40e"]
>          if dts.drivername == "vfio-pci":
>              self.send_expect("rmmod vfio_iommu_type1", "# ", 10)
>              self.send_expect("rmmod vfio_pci", "# ", 10)
>              self.send_expect("rmmod vfio", "# ", 10)
>          else:
>              self.send_expect("rmmod igb_uio", "# ", 10)
> -        self.send_expect("modprobe igb", "# ", 20)
> -        self.send_expect("modprobe ixgbe", "# ", 20)
> -        self.send_expect("modprobe e1000e", "# ", 20)
> -        self.send_expect("modprobe e1000", "# ", 20)
> -        self.send_expect("modprobe virtio_net", "# ", 20)
> +	for driver in driver_list:
> +            # Need remove check after i40e driver in upstream linux kernel
> +            if driver != "i40e":
> +                self.send_expect("modprobe %s"%driver, "# ", 20)
> +            else:
> +                self.send_expect("insmod /root/i40e.ko", "# ", 30)
> 
>          try:
>              for (pci_bus, pci_id) in self.pci_devices_info:
> -                if pci_id in ('8086:10fb', '8086:151c', '8086:1528', '8086:1512',
> '8086:154a'):
> -                    self.send_expect("echo 0000:%s >
> /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
> -                elif pci_id in ('8086:10e8', '8086:150e', '8086:1521', '8086:10c9',
> '8086:1526', '8086:1533'):
> -                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/igb/bind" %
> pci_bus, "# ")
> -                elif pci_id in('8086:10d3', '8086:10b9'):
> -                    self.send_expect("echo 0000:%s >
> /sys/bus/pci/drivers/e1000e/bind" % pci_bus, "# ")
> -                elif pci_id in ('8086:100f', '8086:100e'):
> -                    self.send_expect("echo 0000:%s >
> /sys/bus/pci/drivers/e1000/bind" % pci_bus, "# ")
> -                elif pci_id in ('1af4:1000'):
> -                    self.send_expect("echo 0000%s > /sys/bus/pci/drivers/virtio-
> pci/bind" % pci_bus, "# ")
> +                full_bus = "0000:%s"% pci_bus
> +                driver_path = "/sys/bus/pci/devices/%s/driver"%full_bus
> +                # Get the abs path of the driver
> +                driver_path =  self.send_expect("cd %s && pwd -P" %
> +                                                driver_path, "# ",
> +                                                verify = True)
> +                if driver_path != -1 and \
> +                   driver_path.split('/')[-1] in driver_list:
> +                        self.send_expect("echo %s > %s/bind" %
> +                                         (full_bus, driver_path), "# ")
>                  else:
>                      continue
> 
> --
> 1.9.3

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

* Re: [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map
  2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
  2015-01-14  1:15   ` Liu, Yong
@ 2015-01-25  1:07   ` Liu, Yong
  1 sibling, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-25  1:07 UTC (permalink / raw)
  To: Qiu, Michael, dts

Applied. Thanks.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 1/6] framework/tester: Fix NoneType Error of port_map
> 
> File "./framework/tester.py", line 110, in tester_prerequisites
>     assert len(self.ports_map) > 0
> TypeError: object of type 'NoneType' has no len()
> 
> Currently ports_map is initialized with empty list,
> but it could be overridden by 'None' value.
> 
> This patch solves this issue
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/tester.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/framework/tester.py b/framework/tester.py
> index 2c023dd..d69503a 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -125,7 +125,8 @@ class Tester(Crb):
>          self.restore_interfaces()
>          self.scan_ports()
>          self.map_available_ports()
> -        assert len(self.ports_map) > 0
> +        if self.ports_map == 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):
>          """
> --
> 1.9.3

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

* Re: [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs
  2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
@ 2015-01-25  1:07   ` Liu, Yong
  0 siblings, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-25  1:07 UTC (permalink / raw)
  To: Qiu, Michael, dts

Applied. Thanks.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 2/6] framework/crbs: Info clean up of crbs
> 
> It is not a good idea to add exactly IP and other details of
> one machine inside a company.
> 
> Make it more clean and more general.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/crbs.py | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/framework/crbs.py b/framework/crbs.py
> index 98821ea..77446c3 100644
> --- a/framework/crbs.py
> +++ b/framework/crbs.py
> @@ -3,12 +3,13 @@ Static configuration data for any CRBs that can be used.
>  """
>  from settings import IXIA
> 
> +# Todo: modify this script to a config file, like crbs.cfg
>  crbs = [
> -    {'IP': '10.239.128.117',
> +    {'IP': '',
>       'name': 'CrownPassCRB1',
> -     'user': 'root',
> -     'pass': 'tester',
> -     'tester IP': '10.239.128.116',
> +     'user': '',
> +     'pass': '',
> +     'tester IP': '',
>       IXIA: None,
>       'memory channels': 4,
>       'bypass core0': True},
> --
> 1.9.3

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

* Re: [dts] [PATCH 3/6] framework: Add login password support
  2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
  2015-01-14  1:18   ` Liu, Yong
@ 2015-01-25  1:07   ` Liu, Yong
  1 sibling, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-01-25  1:07 UTC (permalink / raw)
  To: Qiu, Michael, dts

Applied. Thanks.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 3/6] framework: Add login password support
> 
> DTS login dut and tester machine via ssh service while
> public and private keys are needed.
> 
> That means it can't use the user:password to login, which
> should not always be a good idea.
> 
> Add login with password for another choice.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  framework/crbs.py           |  1 +
>  framework/dut.py            | 12 ++++++++++--
>  framework/etgen.py          |  7 ++++++-
>  framework/ssh_connection.py |  4 ++--
>  framework/ssh_pexpect.py    | 23 ++++++++++++-----------
>  framework/tester.py         | 12 ++++++++++--
>  6 files changed, 41 insertions(+), 18 deletions(-)
> 
> diff --git a/framework/crbs.py b/framework/crbs.py
> index 77446c3..6aa5435 100644
> --- a/framework/crbs.py
> +++ b/framework/crbs.py
> @@ -10,6 +10,7 @@ crbs = [
>       'user': '',
>       'pass': '',
>       'tester IP': '',
> +     'tester pass': '',
>       IXIA: None,
>       'memory channels': 4,
>       'bypass core0': True},
> diff --git a/framework/dut.py b/framework/dut.py
> index 4def144..d7099ef 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -59,9 +59,11 @@ class Dut(Crb):
>          super(Dut, self).__init__(crb, serializer)
>          self.NAME = 'dut'
>          self.logger = getLogger(self.NAME)
> -        self.session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.session = SSHConnection(self.get_ip_address(), self.NAME,
> +                                     self.get_password())
>          self.session.init_log(self.logger)
> -        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME,
> +                                         self.get_password())
>          self.alt_session.init_log(self.logger)
>          self.number_of_cores = 0
>          self.tester = None
> @@ -120,6 +122,12 @@ class Dut(Crb):
>          """
>          return self.crb['IP']
> 
> +    def get_password(self):
> +        """
> +        Get DUT's login password.
> +        """
> +        return self.crb['pass']
> +
>      def dut_prerequisites(self):
>          """
>          Prerequest function should be called before execute any test case.
> diff --git a/framework/etgen.py b/framework/etgen.py
> index fe7100c..2f2e975 100644
> --- a/framework/etgen.py
> +++ b/framework/etgen.py
> @@ -137,7 +137,9 @@ class IxiaPacketGenerator(SSHConnection):
>          self.tester = tester
>          self.NAME = 'ixia'
>          self.logger = getLogger(self.NAME)
> -        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> self.NAME)
> +        super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> +                                                  self.NAME,
> +                                                  self.get_password())
>          super(IxiaPacketGenerator, self).init_log(self.logger)
> 
>          self.tcl_cmds = []
> @@ -170,6 +172,9 @@ class IxiaPacketGenerator(SSHConnection):
>      def get_ip_address(self):
>          return self.tester.get_ip_address()
> 
> +    def get_password(self):
> +        return self.tester.get_password()
> +
>      def add_tcl_cmd(self, cmd):
>          """
>          Add one tcl command into command list.
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index be1fb76..4306162 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -40,8 +40,8 @@ class SSHConnection(object):
>      Implement send_expect/copy function upper SSHPexpet module.
>      """
> 
> -    def __init__(self, host, session_name):
> -        self.session = SSHPexpect(host, USERNAME)
> +    def __init__(self, host, session_name, password = ''):
> +        self.session = SSHPexpect(host, USERNAME, password)
>          self.name = session_name
> 
>      def init_log(self, logger):
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 8fb441b..9c353e7 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -12,12 +12,14 @@ Aslo support transfer files to tester or DUT.
> 
>  class SSHPexpect(object):
> 
> -    def __init__(self, host, username):
> +    def __init__(self, host, username, password):
>          try:
>              self.session = pxssh.pxssh()
>              self.username = username
>              self.host = host
> -            self.session.login(self.host, self.username)
> +            self.password = password
> +            self.session.login(self.host, self.username,
> +                               self.password, original_prompt='[$#>]')
>              self.send_expect('stty -echo', '# ', timeout=2)
>          except Exception:
>              raise SSHConnectionException(host)
> @@ -69,21 +71,20 @@ class SSHPexpect(object):
>          Copies a file from a remote place into local.
>          """
>          command = 'scp {0}@{1}:{2} .'.format(self.username, self.host,
> filename)
> -        self._spawn_scp(command, password)
> +        if password == '':
> +            self._spawn_scp(command, self.password)
> +        else:
> +            self._spawn_scp(command, password)
> 
>      def copy_file_to(self, filename, password=''):
>          """
>          Sends a local file to a remote place.
>          """
>          command = 'scp {0} {1}@{2}:'.format(filename, self.username,
> self.host)
> -        self._spawn_scp(command, password)
> -
> -    def copy_file_from(self, filename, password=''):
> -        """
> -        copy a remote file to a local place.
> -        """
> -        command = 'scp {1}@{2}:{0} .'.format(filename, self.username,
> self.host)
> -        self._spawn_scp(command, password)
> +        if password == '':
> +            self._spawn_scp(command, self.password)
> +        else:
> +            self._spawn_scp(command, password)
> 
>      def _spawn_scp(self, scp_cmd, password):
>          """
> diff --git a/framework/tester.py b/framework/tester.py
> index d69503a..0ebe29a 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -61,9 +61,11 @@ class Tester(Crb):
>          self.NAME = 'tester'
> 
>          self.logger = getLogger(self.NAME)
> -        self.session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.session = SSHConnection(self.get_ip_address(),
> +                                     self.NAME, self.get_password())
>          self.session.init_log(self.logger)
> -        self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> +        self.alt_session = SSHConnection(self.get_ip_address(),
> +                                         self.NAME, self.get_password())
>          self.alt_session.init_log(self.logger)
> 
>          self.ports_map = []
> @@ -88,6 +90,12 @@ class Tester(Crb):
>          """
>          return self.crb['tester IP']
> 
> +    def get_password(self):
> +        """
> +        Get tester login password of tester CRB.
> +        """
> +        return self.crb['tester pass']
> +
>      def has_external_traffic_generator(self):
>          """
>          Check whether performance test will base on IXIA equipment.
> --
> 1.9.3

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

* [dts] [PATCH v2] framework/ssh: Add verify ability for command execution
  2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
  2015-01-14  1:24   ` Liu, Yong
@ 2015-01-27  5:22   ` Michael Qiu
  2015-02-15  5:05     ` Liu, Yong
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Qiu @ 2015-01-27  5:22 UTC (permalink / raw)
  To: dts

ssh command exection never try to verify the failure or success,

It should be very dangerous when execute command both in dut and
tester machine without check the status, maybe unexpected error
happens.

This patch add this ability to verify the status.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
v2 --> v1
	add error log when return error code for that
	can be track in log.

 framework/ssh_connection.py |  4 ++--
 framework/ssh_pexpect.py    | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 4306162..d0b5e07 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -49,9 +49,9 @@ class SSHConnection(object):
         self.logger.config_execution(self.name)
         self.session.init_log(logger, self.name)
 
-    def send_expect(self, cmds, expected, timeout=15):
+    def send_expect(self, cmds, expected, timeout=15, verify=False):
         self.logger.info(cmds)
-        out = self.session.send_expect(cmds, expected, timeout)
+        out = self.session.send_expect(cmds, expected, timeout, verify=False)
         self.logger.debug(out)
         return out
 
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 9c353e7..b7d3475 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -29,12 +29,24 @@ class SSHPexpect(object):
         self.logger.config_execution(name)
         self.logger.info("ssh %s@%s" % (self.username, self.host))
 
-    def send_expect(self, command, expected, timeout=15):
+    def send_expect_base(self, command, expected, timeout=15):
         self.session.PROMPT = expected
         self.__sendline(command)
         self.__prompt(command, timeout)
         return self.get_output_before()
 
+    def send_expect(self, command, expected, timeout=15, verify=False):
+        ret = self.send_expect_base(command, expected, timeout)
+        if verify:
+            ret_status = self.send_expect_base("echo $?", expected)
+            if not int(ret_status):
+                return ret
+            else:
+		self.logger.error("Command: %s failure!" % command)
+                return -1
+        else:
+            return ret
+
     def __prompt(self, command, timeout):
         if not self.session.prompt(timeout):
             raise TimeoutException(command, self.get_output_all())
-- 
1.9.3

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

* Re: [dts] [PATCH v2] framework/ssh: Add verify ability for command execution
  2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
@ 2015-02-15  5:05     ` Liu, Yong
  0 siblings, 0 replies; 17+ messages in thread
From: Liu, Yong @ 2015-02-15  5:05 UTC (permalink / raw)
  To: Qiu, Michael, dts

Applied, thx.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Michael Qiu
> Sent: Tuesday, January 27, 2015 1:23 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] framework/ssh: Add verify ability for command
> execution
> 
> ssh command exection never try to verify the failure or success,
> 
> It should be very dangerous when execute command both in dut and
> tester machine without check the status, maybe unexpected error
> happens.
> 
> This patch add this ability to verify the status.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
> v2 --> v1
> 	add error log when return error code for that
> 	can be track in log.
> 
>  framework/ssh_connection.py |  4 ++--
>  framework/ssh_pexpect.py    | 14 +++++++++++++-
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index 4306162..d0b5e07 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -49,9 +49,9 @@ class SSHConnection(object):
>          self.logger.config_execution(self.name)
>          self.session.init_log(logger, self.name)
> 
> -    def send_expect(self, cmds, expected, timeout=15):
> +    def send_expect(self, cmds, expected, timeout=15, verify=False):
>          self.logger.info(cmds)
> -        out = self.session.send_expect(cmds, expected, timeout)
> +        out = self.session.send_expect(cmds, expected, timeout,
> verify=False)
>          self.logger.debug(out)
>          return out
> 
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 9c353e7..b7d3475 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -29,12 +29,24 @@ class SSHPexpect(object):
>          self.logger.config_execution(name)
>          self.logger.info("ssh %s@%s" % (self.username, self.host))
> 
> -    def send_expect(self, command, expected, timeout=15):
> +    def send_expect_base(self, command, expected, timeout=15):
>          self.session.PROMPT = expected
>          self.__sendline(command)
>          self.__prompt(command, timeout)
>          return self.get_output_before()
> 
> +    def send_expect(self, command, expected, timeout=15, verify=False):
> +        ret = self.send_expect_base(command, expected, timeout)
> +        if verify:
> +            ret_status = self.send_expect_base("echo $?", expected)
> +            if not int(ret_status):
> +                return ret
> +            else:
> +		self.logger.error("Command: %s failure!" % command)
> +                return -1
> +        else:
> +            return ret
> +
>      def __prompt(self, command, timeout):
>          if not self.session.prompt(timeout):
>              raise TimeoutException(command, self.get_output_all())
> --
> 1.9.3

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

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

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
2015-01-14  1:15   ` Liu, Yong
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
2015-01-14  1:18   ` Liu, Yong
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
2015-01-14  1:24   ` Liu, Yong
2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
2015-02-15  5:05     ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
2015-01-14  1:35   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
2015-01-14  1:35   ` Liu, Yong

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).