From: yufengx.mo@intel.com
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 5/6] pmd_bonded_8023ad: framework work flow
Date: Wed, 6 Jun 2018 13:38:32 +0800 [thread overview]
Message-ID: <1528263513-26500-6-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1528263513-26500-1-git-send-email-yufengx.mo@intel.com>
From: yufengmx <yufengx.mo@intel.com>
add dts work flow support for switch equipment.
Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
framework/dts.py | 20 +++++++++++++++++++-
framework/dut.py | 14 +++++++++++---
framework/exception.py | 10 ++++++++++
framework/logger.py | 24 +++++++++++++++++++++++-
framework/project_dpdk.py | 6 +++++-
framework/settings.py | 7 ++++++-
framework/ssh_connection.py | 9 ++++++---
framework/ssh_pexpect.py | 36 ++++++++++++++++++++++++++++++++++--
8 files changed, 114 insertions(+), 12 deletions(-)
diff --git a/framework/dts.py b/framework/dts.py
index 0b2240c..06e2441 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -249,6 +249,14 @@ def dts_log_testsuite(duts, tester, suite_obj, log_handler, test_classname):
except Exception as ex:
pass
+ # check if dts use switch equipment
+ try:
+ if tester.it_uses_switch():
+ switch_scenes = getattr(tester, 'switch_scenes')
+ for name, obj in switch_scenes.iteritems():
+ obj.logger.config_suite(test_classname, obj.name)
+ except Exception as ex:
+ pass
def dts_log_execution(duts, tester, log_handler):
"""
@@ -266,6 +274,15 @@ def dts_log_execution(duts, tester, log_handler):
tester.ixia_packet_gen.logger.config_execution('ixia')
except Exception as ex:
pass
+
+ # check if dts use switch equipment
+ try:
+ if tester.it_uses_switch():
+ switch_scenes = getattr(tester, 'switch_scenes')
+ for name, obj in switch_scenes.iteritems():
+ obj.logger.config_execution(obj.name)
+ except Exception as ex:
+ pass
def dts_crbs_init(crbInsts, skip_setup, read_cache, project, base_dir, serializer, virttype):
@@ -296,6 +313,7 @@ def dts_crbs_init(crbInsts, skip_setup, read_cache, project, base_dir, serialize
show_speedup_options_messages(read_cache, skip_setup)
tester.set_speedup_options(read_cache, skip_setup)
tester.init_ext_gen()
+ tester.init_switch()
nic = settings.load_global_setting(settings.HOST_NIC_SETTING)
for dutobj in duts:
diff --git a/framework/dut.py b/framework/dut.py
index 18f0b39..e230450 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -980,13 +980,21 @@ class Dut(Crb):
def disable_tester_ipv6(self):
for tester_port in self.ports_map:
- if self.tester.ports_info[tester_port]['type'] != 'ixia':
+ if self.tester.ports_info[tester_port]['type'] == 'ixia':
+ continue
+ elif self.tester.ports_info[tester_port]['type'] == 'switch':
+ continue
+ else:
port = self.tester.ports_info[tester_port]['port']
port.disable_ipv6()
def enable_tester_ipv6(self):
for tester_port in range(len(self.tester.ports_info)):
- if self.tester.ports_info[tester_port]['type'] != 'ixia':
+ if self.tester.ports_info[tester_port]['type'] == 'ixia':
+ continue
+ elif self.tester.ports_info[tester_port]['type'] == 'switch':
+ continue
+ else:
port = self.tester.ports_info[tester_port]['port']
port.enable_ipv6()
diff --git a/framework/exception.py b/framework/exception.py
index 654e420..027568a 100644
--- a/framework/exception.py
+++ b/framework/exception.py
@@ -143,3 +143,13 @@ class VirtVmOperationException(Exception):
class VirtHostPrepareException(Exception):
pass
+
+class SwitchException(Exception):
+ """
+ switch exception
+ """
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return "Switch exception: " + self.msg
diff --git a/framework/logger.py b/framework/logger.py
index 8d0e5e8..cd16ac1 100644
--- a/framework/logger.py
+++ b/framework/logger.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -64,6 +64,9 @@ logging.DTS_IXIA_OUTPUT = logging.DEBUG + 5
logging.DTS_VIRTDUT_CMD = logging.INFO + 6
logging.DTS_VIRTDUT_OUTPUT = logging.DEBUG + 6
+logging.DTS_SWITCH_CMD = logging.INFO + 7
+logging.DTS_SWITCH_OUTPUT = logging.DEBUG + 7
+
logging.addLevelName(logging.DTS_DUT_CMD, 'DTS_DUT_CMD')
logging.addLevelName(logging.DTS_DUT_OUTPUT, 'DTS_DUT_OUTPUT')
logging.addLevelName(logging.DTS_DUT_RESULT, 'DTS_DUT_RESULT')
@@ -75,6 +78,9 @@ logging.addLevelName(logging.DTS_TESTER_RESULT, 'DTS_TESTER_RESULT')
logging.addLevelName(logging.DTS_IXIA_CMD, 'DTS_IXIA_CMD')
logging.addLevelName(logging.DTS_IXIA_OUTPUT, 'DTS_IXIA_OUTPUT')
+logging.addLevelName(logging.DTS_SWITCH_CMD, 'DTS_SWITCH_CMD')
+logging.addLevelName(logging.DTS_SWITCH_OUTPUT, 'DTS_SWITCH_OUTPUT')
+
logging.addLevelName(logging.DTS_VIRTDUT_CMD, 'VIRTDUT_CMD')
logging.addLevelName(logging.DTS_VIRTDUT_OUTPUT, 'VIRTDUT_OUTPUT')
@@ -143,6 +149,12 @@ class BaseLoggerAdapter(logging.LoggerAdapter):
def dts_ixia_output(self, msg, *args, **kwargs):
self.log(logging.DTS_IXIA_OUTPUT, msg, *args, **kwargs)
+ def dts_switch_cmd(self, msg, *args, **kwargs):
+ self.log(logging.DTS_SWITCH_CMD, msg, *args, **kwargs)
+
+ def dts_switch_output(self, msg, *args, **kwargs):
+ self.log(logging.DTS_SWITCH_OUTPUT, msg, *args, **kwargs)
+
def dts_virtdut_cmd(self, msg, *args, **kwargs):
self.log(logging.DTS_VIRTDUT_CMD, msg, *args, **kwargs)
@@ -167,6 +179,8 @@ class ColorHandler(logging.StreamHandler):
logging.SUITE_TESTER_CMD: '', # SYSTEM
logging.DTS_IXIA_CMD: '', # SYSTEM
logging.DTS_IXIA_OUTPUT: '', # SYSTEM
+ logging.DTS_SWITCH_CMD: '', # SYSTEM
+ logging.DTS_SWITCH_OUTPUT: '', # SYSTEM
logging.DTS_VIRTDUT_CMD: '', # SYSTEM
logging.DTS_VIRTDUT_OUTPUT: '', # SYSTEM
logging.WARN: '\033[01;33m', # BOLD YELLOW
@@ -310,6 +324,11 @@ class DTSLOG(BaseLoggerAdapter):
elif crb.startswith('ixia'):
self.info_lvl = logging.DTS_IXIA_CMD
self.debug_lvl = logging.DTS_IXIA_OUTPUT
+ elif crb.startswith('switch'):
+ self.info_lvl = logging.DTS_SWITCH_CMD
+ self.debug_lvl = logging.DTS_SWITCH_OUTPUT
+
+ set_salt(crb, 'switch')
elif crb.startswith('virtdut'):
self.info_lvl = logging.DTS_VIRTDUT_CMD
self.debug_lvl = logging.DTS_VIRTDUT_OUTPUT
@@ -342,6 +361,9 @@ class DTSLOG(BaseLoggerAdapter):
elif crb == 'ixia':
self.info_lvl = logging.DTS_IXIA_CMD
self.debug_lvl = logging.DTS_IXIA_OUTPUT
+ elif crb == 'switch':
+ self.info_lvl = logging.DTS_SWITCH_CMD
+ self.debug_lvl = logging.DTS_SWITCH_OUTPUT
elif crb == 'virtdut':
self.info_lvl = logging.DTS_VIRTDUT_CMD
self.debug_lvl = logging.DTS_VIRTDUT_OUTPUT
diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
index f87fd13..315d673 100644
--- a/framework/project_dpdk.py
+++ b/framework/project_dpdk.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@ from dut import Dut
from tester import Tester
from logger import getLogger
from settings import IXIA, DRIVERS
+from settings import SWITCH
class DPDKdut(Dut):
@@ -493,6 +494,9 @@ class DPDKtester(Tester):
assert ("No such file or directory" not in out), "Can not find /root/igb_uio.ko for performance"
self.setup_memory()
+ if SWITCH in self.crb and self.crb[SWITCH] is not None:
+ self.logger.info("Use switch")
+
self.stage = "post-init"
def setup_memory(self, hugepages=-1):
diff --git a/framework/settings.py b/framework/settings.py
index 07c3ac6..d1b26d9 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -194,6 +194,11 @@ Global macro for dts.
IXIA = "ixia"
"""
+Global macro for dts.
+"""
+SWITCH = "switch"
+
+"""
The log name seperater.
"""
LOG_NAME_SEP = '.'
diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 622ed50..a849a2b 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -44,8 +44,11 @@ class SSHConnection(object):
Implement send_expect/copy function upper SSHPexpet module.
"""
- def __init__(self, host, session_name, username, password='', dut_id=0):
- self.session = SSHPexpect(host, username, password, dut_id)
+ def __init__(self, host, session_name, username, password='', dut_id=0,
+ node_type=None):
+ node_type = node_type or "normal"
+ self.session = SSHPexpect(host, username, password, dut_id,
+ node_type=node_type)
self.name = session_name
connection = {}
connection[self.name] = self.session
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 3c988b7..d266519 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -14,7 +14,7 @@ Aslo support transfer files to tester or DUT.
class SSHPexpect(object):
- def __init__(self, host, username, password, dut_id):
+ def __init__(self, host, username, password, dut_id, node_type="normal"):
self.magic_prompt = "MAGIC PROMPT"
self.logger = None
@@ -22,7 +22,39 @@ class SSHPexpect(object):
self.username = username
self.password = password
- self._connect_host(dut_id=dut_id)
+ if node_type == "switch":
+ self.login_switch()
+ else:
+ self._connect_host(dut_id=dut_id)
+
+ def login_switch(self):
+ try:
+ self.session = pxssh.pxssh()
+ if ':' in self.host:
+ self.ip = self.host.split(':')[0]
+ self.port = int(self.host.split(':')[1])
+ self.session.login(self.ip,
+ self.username,
+ self.password,
+ #original_prompt='[$#>]',
+ auto_prompt_reset=False,
+ port=self.port,
+ login_timeout=60)
+ else:
+ self.session.login(self.host,
+ self.username,
+ self.password,
+ #original_prompt=r'[$#>]',
+ auto_prompt_reset=False,
+ login_timeout=60)
+ except Exception, e:
+ print RED(e)
+ if getattr(self, 'port', None):
+ suggestion = "\nSuggession: Check if the fireware on [ %s ] " % \
+ self.ip + "is stoped\n"
+ print GREEN(suggestion)
+
+ raise SSHConnectionException(self.host)
@parallel_lock(num=8)
def _connect_host(self, dut_id=0):
--
1.9.3
next prev parent reply other threads:[~2018-06-06 5:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 5:38 [dts] [PATCH V1 0/6] pmd_bonded_8023ad: upload test plan yufengx.mo
2018-06-06 5:38 ` [dts] [PATCH V1 1/6] " yufengx.mo
2018-07-06 1:30 ` Liu, Yong
2018-06-06 5:38 ` [dts] [PATCH V1 2/6] pmd_bonded_8023ad: upload automation script yufengx.mo
2019-01-21 7:19 ` Chen, Zhaoyan
2018-06-06 5:38 ` [dts] [PATCH V1 3/6] pmd_bonded_8023ad: add switch module in dts/framework yufengx.mo
2018-06-06 5:38 ` [dts] [PATCH V1 4/6] pmd_bonded_8023ad: dts configuration files yufengx.mo
2018-06-06 5:38 ` yufengx.mo [this message]
2018-06-06 5:38 ` [dts] [PATCH V1 6/6] pmd_bonded_8023ad: framework etgen/ixia yufengx.mo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528263513-26500-6-git-send-email-yufengx.mo@intel.com \
--to=yufengx.mo@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).