summaryrefslogtreecommitdiffstats
path: root/testsuites/vstf/vstf_scripts/vstf/controller
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/controller')
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/api_server.py75
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/database/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/database/dbinterface.py388
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/database/tables.py13
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/env_build/cfg_intent_parse.py5
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_build.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_collect.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/fabricant.py34
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py9
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py155
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py70
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py88
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py50
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py8
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py8
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py11
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/cpu_settings.py24
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/device_settings.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/flows_settings.py44
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/forwarding_settings.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/html_settings.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/mail_settings.py29
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/perf_settings.py21
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/settings.py79
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/template_settings.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/tester_settings.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/settings/tool_settings.py23
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/spirent/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/spirent/appliance.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py168
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/result_analysis.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/flow_producer.py11
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/model.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/perf_provider.py52
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/performance.py54
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/raw_data.py14
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/configuration.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/model.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_cfg_intent_parse.py3
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_collect.py36
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_driver_function.py17
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_env_build.py27
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_perf.py14
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_ssh.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/vstfadm.py115
58 files changed, 1273 insertions, 489 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/api_server.py b/testsuites/vstf/vstf_scripts/vstf/controller/api_server.py
index a37bf4c1..02bf486c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/api_server.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/api_server.py
@@ -45,10 +45,11 @@ cmd = CommandLine()
class OpsChains(object):
+
def __init__(self, monitor, port):
"""The ops chains will setup the proxy to rabbitmq
and setup a thread to watch the queues of rabbitmq
-
+
"""
LOG.info("VSTF Manager start to listen to %s", monitor)
if not os.path.exists(cst.VSTFCPATH):
@@ -63,7 +64,8 @@ class OpsChains(object):
if not target:
respond = "the target is empty, not support now."
else:
- respond = self.chanl.call(self.chanl.make_msg("list_nic_devices"), target)
+ respond = self.chanl.call(
+ self.chanl.make_msg("list_nic_devices"), target)
return respond
def src_install(self, host, config_file):
@@ -118,8 +120,8 @@ class OpsChains(object):
return Fabricant(host, self.chanl).affctl_list()
def _create_task(self, scenario):
- taskid = self.dbconn.create_task(str(uuid.uuid4()), time.strftime(cst.TIME_FORMAT),
- desc=scenario + "Test")
+ taskid = self.dbconn.create_task(str(uuid.uuid4()), time.strftime(
+ cst.TIME_FORMAT), desc=scenario + "Test")
LOG.info("new Task id:%s" % taskid)
if -1 == taskid:
raise Exception("DB create task failed.")
@@ -142,7 +144,8 @@ class OpsChains(object):
LOG.info(nic_info)
- os_info, cpu_info, mem_info, hw_info = self.collection.collect_host_info(host["agent"])
+ os_info, cpu_info, mem_info, hw_info = self.collection.collect_host_info(host[
+ "agent"])
LOG.info(os_info)
LOG.info(cpu_info)
LOG.info(mem_info)
@@ -165,11 +168,11 @@ class OpsChains(object):
forward_settings = ForwardingSettings()
head_d = {
"ip": head,
- "namespace":forward_settings.settings["head"]["namespace"]
+ "namespace": forward_settings.settings["head"]["namespace"]
}
tail_d = {
"ip": tail,
- "namespace":forward_settings.settings["tail"]["namespace"]
+ "namespace": forward_settings.settings["tail"]["namespace"]
}
LOG.info(head_d)
LOG.info(tail_d)
@@ -184,10 +187,19 @@ class OpsChains(object):
info_str = "do report over"
return info_str
- def run_perf_cmd(self, case, rpath='./', affctl=False, build_on=False, save_on=False, report_on=False,
- mail_on=False):
+ def run_perf_cmd(
+ self,
+ case,
+ rpath='./',
+ affctl=False,
+ build_on=False,
+ save_on=False,
+ report_on=False,
+ mail_on=False):
LOG.info(case)
- LOG.info("build_on:%s report_on:%s mail_on:%s" % (build_on, report_on, mail_on))
+ LOG.info(
+ "build_on:%s report_on:%s mail_on:%s" %
+ (build_on, report_on, mail_on))
casetag = case['case']
tool = case['tool']
protocol = case['protocol']
@@ -216,7 +228,10 @@ class OpsChains(object):
tool_settings = ToolSettings()
tester_settings = TesterSettings()
flow_producer = FlowsProducer(self.chanl, flows_settings)
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
perf = pf.Performance(self.chanl, provider)
flow_producer.create(scenario, casetag)
@@ -225,20 +240,29 @@ class OpsChains(object):
LOG.info(result)
if save_on:
taskid = self._create_task(scenario)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, ttype, switch, provider, tool)
+ testid = self.dbconn.add_test_2task(
+ taskid, casetag, protocol, ttype, switch, provider, tool)
LOG.info(testid)
self.dbconn.add_data_2test(testid, result)
if report_on:
self.report(rpath, not mail_on, taskid)
return result
- def run_perf_file(self, rpath='./', affctl=False, report_on=True, mail_on=True):
+ def run_perf_file(
+ self,
+ rpath='./',
+ affctl=False,
+ report_on=True,
+ mail_on=True):
perf_settings = PerfSettings()
flows_settings = FlowsSettings()
tool_settings = ToolSettings()
tester_settings = TesterSettings()
flow_producer = FlowsProducer(self.chanl, flows_settings)
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
perf = pf.Performance(self.chanl, provider)
tests = perf_settings.settings
@@ -274,7 +298,8 @@ class OpsChains(object):
result = perf.run(tool, protocol, ttype, sizes, affctl)
LOG.info(result)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, ttype, switch, provider, tool)
+ testid = self.dbconn.add_test_2task(
+ taskid, casetag, protocol, ttype, switch, provider, tool)
LOG.info(testid)
self.dbconn.add_data_2test(testid, result)
@@ -293,6 +318,7 @@ class OpsChains(object):
class Manager(daemon.Daemon):
+
def __init__(self):
"""
The manager will create a socket for vstfadm.
@@ -356,13 +382,16 @@ class Manager(daemon.Daemon):
self.daemon_die()
raise e
except Exception as e:
- # here just the function failed no need exit, just return the msg
+ # here just the function failed no need exit, just return
+ # the msg
msg = "Run function failed. [ %s ]" % (e)
response = msg
LOG.error(msg)
try:
response = message.add_context(response, **context)
- LOG.debug("Manager send the response: <%(r)s", {'r': response})
+ LOG.debug(
+ "Manager send the response: <%(r)s", {
+ 'r': response})
message.send(conn.send, message.encode(response))
except Exception as e:
self.daemon_die()
@@ -374,7 +403,8 @@ class Manager(daemon.Daemon):
"""overwrite daemon.Daemon.daemon_die(self)"""
LOG.info("manage catch the signal %s to exit." % signum)
if self.conn:
- # we can not close the conn direct, just tell manager to stop accept
+ # we can not close the conn direct, just tell manager to stop
+ # accept
self.run_flag = False
if self.ops:
@@ -418,8 +448,13 @@ def do_stop(args):
def main():
"""this is for vstfctl"""
- setup_logging(level=logging.INFO, log_file="/var/log/vstf/vstf-manager.log", clevel=logging.INFO)
- parser = VstfParser(prog="vstf-manager", description="vstf manager command line")
+ setup_logging(
+ level=logging.INFO,
+ log_file="/var/log/vstf/vstf-manager.log",
+ clevel=logging.INFO)
+ parser = VstfParser(
+ prog="vstf-manager",
+ description="vstf manager command line")
parser.set_subcommand_parser(target=sys.modules[__name__])
args = parser.parse_args()
args.func(args)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/database/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/database/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/database/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/database/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/database/dbinterface.py b/testsuites/vstf/vstf_scripts/vstf/controller/database/dbinterface.py
index 410e1ee5..a2aad9e8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/database/dbinterface.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/database/dbinterface.py
@@ -33,6 +33,7 @@ def after_cursor_execute(conn, cursor, statement,
class DbManage(object):
+
def __init__(self, db_name=const.DBPATH):
db_exists = os.path.exists(db_name)
try:
@@ -165,9 +166,18 @@ class DbManage(object):
else:
return 0
- def add_test_2task(self, task, case, protocol, typ, switch, provider, tool):
+ def add_test_2task(
+ self,
+ task,
+ case,
+ protocol,
+ typ,
+ switch,
+ provider,
+ tool):
try:
- item = table.TblTestList(task, case, protocol, typ, switch, provider, tool)
+ item = table.TblTestList(
+ task, case, protocol, typ, switch, provider, tool)
self._session.add(item)
self._session.commit()
except Exception:
@@ -236,7 +246,8 @@ class DbManage(object):
ret = self._session.query(table.TblTaskList)
if ret:
for tmp in ret.all():
- result.append([tmp.TaskID, tmp.TaskName, tmp.Date, tmp.EXTInfo])
+ result.append(
+ [tmp.TaskID, tmp.TaskName, tmp.Date, tmp.EXTInfo])
return result
def query_all_task_id(self):
@@ -255,7 +266,9 @@ class DbManage(object):
return query.all()
def query_scenario(self, casetag):
- query = self._session.query(table.TblCaseInfo.ScenarioName).filter(table.TblCaseInfo.CaseTag == casetag)
+ query = self._session.query(
+ table.TblCaseInfo.ScenarioName).filter(
+ table.TblCaseInfo.CaseTag == casetag)
ret = ""
if query and query.first():
ret = query.first()[0]
@@ -282,10 +295,13 @@ class DbManage(object):
# Single TblTestList API
def query_caselist(self, taskid, scenario):
- query = self._session.query(table.TblTestList.CaseTag).filter(and_(
- table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
- table.TblCaseInfo.ScenarioName == scenario,
- table.TblTestList.TaskID == taskid)).group_by(table.TblCaseInfo.CaseTag)
+ query = self._session.query(
+ table.TblTestList.CaseTag).filter(
+ and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.ScenarioName == scenario,
+ table.TblTestList.TaskID == taskid)).group_by(
+ table.TblCaseInfo.CaseTag)
return query.all()
def query_testlist(self, taskid, scenario):
@@ -308,65 +324,85 @@ class DbManage(object):
return query.all()
def query_casetools(self, taskid, casetag):
- query = self._session.query(table.TblTestList.Tools).filter(and_(
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.TaskID == taskid)).group_by(table.TblTestList.Tools)
+ query = self._session.query(
+ table.TblTestList.Tools).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.TaskID == taskid)).group_by(
+ table.TblTestList.Tools)
return query.all()
def query_scenariolist(self, taskid):
- query = self._session.query(table.TblCaseInfo.ScenarioName).filter(and_(
- table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
- table.TblTestList.TaskID == taskid)).group_by(table.TblCaseInfo.ScenarioName)
+ query = self._session.query(
+ table.TblCaseInfo.ScenarioName).filter(
+ and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblTestList.TaskID == taskid)).group_by(
+ table.TblCaseInfo.ScenarioName)
return query.all()
def query_throughput_load(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.OfferedLoad).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.OfferedLoad).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_bandwidth(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.Bandwidth).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_table(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(table.TblThroughput.AvgFrameSize,
- table.TblThroughput.Bandwidth,
- table.TblThroughput.OfferedLoad,
- table.TblThroughput.CPU,
- table.TblThroughput.MppspGhz,
- table.TblThroughput.MinimumLatency,
- table.TblThroughput.MaximumLatency,
- table.TblThroughput.AverageLatency,
- ).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth,
+ table.TblThroughput.OfferedLoad,
+ table.TblThroughput.CPU,
+ table.TblThroughput.MppspGhz,
+ table.TblThroughput.MinimumLatency,
+ table.TblThroughput.MaximumLatency,
+ table.TblThroughput.AverageLatency,
+ ).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_simpletable(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(table.TblThroughput.AvgFrameSize,
- table.TblThroughput.Bandwidth,
- table.TblThroughput.OfferedLoad,
- table.TblThroughput.CPU,
- table.TblThroughput.MppspGhz,
- table.TblThroughput.AverageLatency,
- ).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth,
+ table.TblThroughput.OfferedLoad,
+ table.TblThroughput.CPU,
+ table.TblThroughput.MppspGhz,
+ table.TblThroughput.AverageLatency,
+ ).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_testdata(self, testid, ptype):
@@ -376,79 +412,103 @@ class DbManage(object):
def query_throughput_avg(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.AverageLatency).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.AverageLatency).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_frameloss_bandwidth(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.Bandwidth).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_load(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.OfferedLoad).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.OfferedLoad).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_table(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(table.TblFrameloss.AvgFrameSize,
- table.TblFrameloss.Bandwidth,
- table.TblFrameloss.OfferedLoad,
- table.TblFrameloss.CPU,
- table.TblFrameloss.MppspGhz,
- table.TblFrameloss.MinimumLatency,
- table.TblFrameloss.MaximumLatency,
- table.TblFrameloss.AverageLatency
- ).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth,
+ table.TblFrameloss.OfferedLoad,
+ table.TblFrameloss.CPU,
+ table.TblFrameloss.MppspGhz,
+ table.TblFrameloss.MinimumLatency,
+ table.TblFrameloss.MaximumLatency,
+ table.TblFrameloss.AverageLatency).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_simpletable(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(table.TblFrameloss.AvgFrameSize,
- table.TblFrameloss.Bandwidth,
- table.TblFrameloss.OfferedLoad,
- table.TblFrameloss.CPU,
- table.TblFrameloss.MppspGhz,
- table.TblFrameloss.AverageLatency
- ).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth,
+ table.TblFrameloss.OfferedLoad,
+ table.TblFrameloss.CPU,
+ table.TblFrameloss.MppspGhz,
+ table.TblFrameloss.AverageLatency).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_avg(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.AverageLatency).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.AverageLatency).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_latency_avg(self, taskid, casetag, provider):
ptype = 'latency'
- query = self._session.query(table.TblLatency.AvgFrameSize, table.TblLatency.AverageLatency).filter(and_(
- table.TblTestList.TaskID == taskid,
- table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
- table.TblTestList.TestID == table.TblLatency.TestID))
+ query = self._session.query(
+ table.TblLatency.AvgFrameSize,
+ table.TblLatency.AverageLatency).filter(
+ and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblLatency.TestID))
return query.all()
def query_summary_table(self, taskid, casetag, provider, ptype):
@@ -482,51 +542,71 @@ class DbManage(object):
return []
def query_throughput_provider(self, taskid, casetag, provider):
- query = self._session.query(table.TblThroughput).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider,
- table.TblTestList.TaskID == taskid,
- table.TblTestList.TestID == table.TblThroughput.TestID))
+ query = self._session.query(
+ table.TblThroughput).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_frameloss_provider(self, taskid, casetag, provider):
- query = self._session.query(table.TblFrameloss).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider,
- table.TblTestList.TaskID == taskid,
- table.TblTestList.TestID == table.TblFrameloss.TestID))
+ query = self._session.query(
+ table.TblFrameloss).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_latency_provider(self, taskid, casetag, provider):
- query = self._session.query(table.TblLatency).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider,
- table.TblTestList.TaskID == taskid,
- table.TblTestList.TestID == table.TblLatency.TestID))
+ query = self._session.query(
+ table.TblLatency).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblLatency.TestID))
return query.all()
def query_case_type_count(self, taskid, casetag, ptype):
- query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Type == ptype,
- table.TblTestList.TaskID == taskid))
+ query = self._session.query(
+ table.TblTestList).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_case_provider_count(self, taskid, casetag, provider):
- query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Provider == provider,
- table.TblTestList.TaskID == taskid))
+ query = self._session.query(
+ table.TblTestList).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_case_type_provider_count(self, taskid, casetag, provider, ptype):
- query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
- table.TblTestList.Type == ptype,
- table.TblTestList.Provider == provider,
- table.TblTestList.TaskID == taskid))
+ query = self._session.query(
+ table.TblTestList).filter(
+ and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_exten_info(self, taskid):
- query = self._session.query(table.TblEXTInfo.EXTName,
- table.TblEXTInfo.EXTContent,
- table.TblEXTInfo.Description).filter(table.TblEXTInfo.TaskID == taskid)
+ query = self._session.query(
+ table.TblEXTInfo.EXTName,
+ table.TblEXTInfo.EXTContent,
+ table.TblEXTInfo.Description).filter(
+ table.TblEXTInfo.TaskID == taskid)
return query.all()
@@ -534,12 +614,27 @@ def unit_test():
import time
dbase = DbManage()
- taskid = dbase.create_task("test", str(time.ctime()), "this is a unit test")
- dbase.add_host_2task(taskid, "hosta", "hw82576", "xxx", "x", "82599", "ubuntu")
+ taskid = dbase.create_task("test", str(
+ time.ctime()), "this is a unit test")
+ dbase.add_host_2task(
+ taskid,
+ "hosta",
+ "hw82576",
+ "xxx",
+ "x",
+ "82599",
+ "ubuntu")
dbase.add_extent_2task(taskid, "CETH", "driver", "version 2.0")
dbase.add_extent_2task(taskid, "EVS", "switch", "version 3.0")
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "throughput", "ovs", None, "netperf")
+ testid = dbase.add_test_2task(
+ taskid,
+ "Tn-1",
+ 'udp',
+ "throughput",
+ "ovs",
+ None,
+ "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -557,7 +652,14 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "frameloss", "ovs", None, "netperf")
+ testid = dbase.add_test_2task(
+ taskid,
+ "Tn-1",
+ 'udp',
+ "frameloss",
+ "ovs",
+ None,
+ "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -575,13 +677,35 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "latency", "ovs", None, "netperf")
+ testid = dbase.add_test_2task(
+ taskid,
+ "Tn-1",
+ 'udp',
+ "latency",
+ "ovs",
+ None,
+ "netperf")
data = {
- 64: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0},
- 128: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0},
- 512: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0},
- 1024: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0}
- }
+ 64: {
+ 'MaximumLatency': 0.0,
+ 'AverageLatency': 0.0,
+ 'MinimumLatency': 0.0,
+ 'OfferedLoad': 0.0},
+ 128: {
+ 'MaximumLatency': 0.0,
+ 'AverageLatency': 0.0,
+ 'MinimumLatency': 0.0,
+ 'OfferedLoad': 0.0},
+ 512: {
+ 'MaximumLatency': 0.0,
+ 'AverageLatency': 0.0,
+ 'MinimumLatency': 0.0,
+ 'OfferedLoad': 0.0},
+ 1024: {
+ 'MaximumLatency': 0.0,
+ 'AverageLatency': 0.0,
+ 'MinimumLatency': 0.0,
+ 'OfferedLoad': 0.0}}
dbase.add_data_2test(testid, data)
query = dbase.query_testlist(1, "Tn")
for item in query:
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/database/tables.py b/testsuites/vstf/vstf_scripts/vstf/controller/database/tables.py
index 55b02e5f..92f857a0 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/database/tables.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/database/tables.py
@@ -52,7 +52,7 @@ class TblCaseInfo(Base):
ScenarioName, FigurePath, Direction, Directiontag,
Configure, Description, **kwargs):
"""
- :param CaseID:
+ :param CaseID:
:param CaseTag: ??
:param CaseName: name of case, like tester-vm
:param ScenarioName: name of scenario, like Tn
@@ -135,7 +135,16 @@ class TblTestList(Base):
Provider = Column(String(const.PROVIDER_LEN))
Tools = Column(String(const.TOOLS_LEN))
- def __init__(self, taskid, casetag, protocol, typ, switch, provider, tools, **kwargs):
+ def __init__(
+ self,
+ taskid,
+ casetag,
+ protocol,
+ typ,
+ switch,
+ provider,
+ tools,
+ **kwargs):
"""Table of test"""
self.TaskID = taskid
self.CaseTag = casetag
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/cfg_intent_parse.py b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/cfg_intent_parse.py
index b536e3b8..acc88d91 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/cfg_intent_parse.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/cfg_intent_parse.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class IntentParser(object):
+
def __init__(self, cfg_file):
self.cfg_file = cfg_file
with file(cfg_file) as fp:
@@ -59,7 +60,9 @@ class IntentParser(object):
for tap_cfg in vm_cfg['taps']:
br_type_set.add(tap_cfg["br_type"])
if len(br_type_set) > 1:
- raise Exception("specified more than one type of vswitchfor host:%s" % host_cfg['ip'])
+ raise Exception(
+ "specified more than one type of vswitchfor host:%s" %
+ host_cfg['ip'])
if len(br_type_set) > 0:
br_type = br_type_set.pop()
host_cfg['br_type'] = br_type
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_build.py b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_build.py
index 1d201b77..40e25e9f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_build.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_build.py
@@ -17,6 +17,7 @@ LOG = logging.getLogger(__name__)
class EnvBuildApi(object):
+
def __init__(self, conn, config_file):
LOG.info("welcome to EnvBuilder")
self.conn = conn
@@ -48,6 +49,7 @@ class EnvBuildApi(object):
class TransmitterBuild(object):
+
def __init__(self, conn, config_file):
LOG.info("welcome to TransmitterBuild")
self.conn = conn
@@ -72,7 +74,9 @@ if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
- parser.add_argument('--rpc_server', help='rabbitmq server for deliver messages.')
+ parser.add_argument(
+ '--rpc_server',
+ help='rabbitmq server for deliver messages.')
parser.add_argument('--config', help='config file to parse')
args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_collect.py b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_collect.py
index 6e32a05d..7861ad31 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_collect.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/env_build/env_collect.py
@@ -11,6 +11,7 @@ from vstf.rpc_frame_work import rpc_producer
class EnvCollectApi(object):
+
def __init__(self, rb_mq_server):
"""
When use collect, a connection of rabbitmq is needed.
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/fabricant.py b/testsuites/vstf/vstf_scripts/vstf/controller/fabricant.py
index 3b1c082f..3f6978e4 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/fabricant.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/fabricant.py
@@ -12,6 +12,7 @@ import vstf.common.constants as cst
class Fabricant(object):
+
def __init__(self, target, conn):
self.conn = conn
self.target = target
@@ -21,7 +22,12 @@ class Fabricant(object):
@property
def declare_commands(self):
- driver = {"install_drivers", "clean_drivers", "autoneg_on", "autoneg_off", "autoneg_query"}
+ driver = {
+ "install_drivers",
+ "clean_drivers",
+ "autoneg_on",
+ "autoneg_off",
+ "autoneg_query"}
builder = {"build_env", "clean_env"}
@@ -29,7 +35,10 @@ class Fabricant(object):
perf = {"perf_run", "run_vnstat", "kill_vnstat", "force_clean"}
- device_mgr = {"get_device_detail", "list_nic_devices", "get_device_verbose"}
+ device_mgr = {
+ "get_device_detail",
+ "list_nic_devices",
+ "get_device_verbose"}
netns = {"clean_all_namespace", "config_dev", "recover_dev", "ping"}
@@ -37,11 +46,22 @@ class Fabricant(object):
cmdline = {"execute"}
- spirent = {"send_packet", "stop_flow", "mac_learning", "run_rfc2544suite", "run_rfc2544_throughput",
- "run_rfc2544_frameloss", "run_rfc2544_latency"}
-
- equalizer = {"get_numa_core", "get_nic_numa", "get_nic_interrupt_proc", "get_vm_info", "bind_cpu",
- "catch_thread_info"}
+ spirent = {
+ "send_packet",
+ "stop_flow",
+ "mac_learning",
+ "run_rfc2544suite",
+ "run_rfc2544_throughput",
+ "run_rfc2544_frameloss",
+ "run_rfc2544_latency"}
+
+ equalizer = {
+ "get_numa_core",
+ "get_nic_numa",
+ "get_nic_interrupt_proc",
+ "get_vm_info",
+ "bind_cpu",
+ "catch_thread_info"}
return driver | cpu | builder | perf | device_mgr | netns | cmdline | collect | spirent | equalizer
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py
index 6792ad91..c217f9e5 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py
@@ -21,6 +21,7 @@ PASSWD = None
class Mail(object):
+
def __init__(self, srv=SRV, user=USER, passwd=PASSWD):
self.srv = srv
self.user = USER
@@ -81,7 +82,10 @@ class Mail(object):
def attach_files(self, files):
for _file in files:
part = MIMEApplication(open(_file, "rb").read())
- part.add_header('Content-Disposition', 'attachment', filename=os.path.basename(_file))
+ part.add_header(
+ 'Content-Disposition',
+ 'attachment',
+ filename=os.path.basename(_file))
self._msg.attach(part)
def send(self):
@@ -114,11 +118,11 @@ if __name__ == "__main__":
<head>
<title>vstf</title>
</head>
-
+
<body>
hello vstf
</body>
-
+
</html>
"""
m.attach_text(context, m.HTML)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py
index a4d7bb0a..42f991a8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class SendMail(object):
+
def __init__(self, mail_info):
self._mail_info = mail_info
@@ -32,7 +33,9 @@ class SendMail(object):
if 'attach' in self._mail_info['body']:
send.attach_files(self._mail_info['body']['attach'])
- send.attach_text(self._mail_info['body']['content'], self._mail_info['body']['subtype'])
+ send.attach_text(
+ self._mail_info['body']['content'],
+ self._mail_info['body']['subtype'])
send.attach_title(self._mail_info['body']['subject'])
send.send()
@@ -50,11 +53,11 @@ def unit_test():
<head>
<title>vstf</title>
</head>
-
+
<body>
hello vstf
</body>
-
+
</html>
"""
mail_settings.set_subtype('html')
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py
index 547db686..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py
@@ -6,5 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py
index ea296550..a3285c9e 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class CandyGenerator(object):
+
def __init__(self, task):
self._task = task
@@ -99,7 +100,8 @@ class CandyGenerator(object):
"data": scenario_data.get_latency_bardata(case)
}
table = scenario_data.get_latency_tabledata(case)
- test_section = self.create_test(sectionid, params_info, table, draw)
+ test_section = self.create_test(
+ sectionid, params_info, table, draw)
scenario_chapter[name] = test_section
return scenario_chapter
@@ -125,7 +127,10 @@ class CandyGenerator(object):
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-candy.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-candy.log",
+ clevel=logging.INFO)
dbase = DbManage()
taskid = dbase.get_last_taskid()
@@ -135,4 +140,3 @@ def main():
creator.create("Tn")
if __name__ == '__main__':
main()
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py
index f9fc69d9..ded94ebd 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py
@@ -12,12 +12,14 @@ import vstf.common.constants as cst
class DataProvider(object):
+
def __init__(self, taskid, dbase):
self._dbase = dbase
self._taskid = taskid
class CommonData(DataProvider):
+
def get_taskname(self):
return self._dbase.query_taskname(self._taskid)
@@ -67,6 +69,7 @@ class CommonData(DataProvider):
class ScenarioData(DataProvider):
+
def __init__(self, taskid, dbase, scenario):
print "ScenarioData in"
DataProvider.__init__(self, taskid, dbase)
@@ -96,13 +99,15 @@ class ScenarioData(DataProvider):
return query
def is_provider_start(self, case, provider):
- count = self._dbase.query_case_provider_count(self._taskid, case, provider)
+ count = self._dbase.query_case_provider_count(
+ self._taskid, case, provider)
if count:
return True
return False
def is_type_provider_start(self, case, provider, ptype):
- count = self._dbase.query_case_type_provider_count(self._taskid, case, provider, ptype)
+ count = self._dbase.query_case_type_provider_count(
+ self._taskid, case, provider, ptype)
if count:
return True
return False
@@ -133,7 +138,12 @@ class ScenarioData(DataProvider):
test_type = "frameloss"
return self.get_summary_tabledata(case, provider, test_type)
- def get_summary_tabledata(self, case, provider, test_type, table_type='pdf'):
+ def get_summary_tabledata(
+ self,
+ case,
+ provider,
+ test_type,
+ table_type='pdf'):
table_head = []
table_body = []
type_title = {
@@ -142,41 +152,77 @@ class ScenarioData(DataProvider):
}
tools = self.get_test_tools(case)
if "spirent" in tools:
- table_body = self._dbase.query_summary_table(self._taskid, case, provider, test_type)
+ table_body = self._dbase.query_summary_table(
+ self._taskid, case, provider, test_type)
if 'pdf' == table_type:
- table_head = [
- ["FrameSize (byte)", test_type, "", "", "", "Latency(uSec)", "", ""],
- ["", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)", " Mpps/Ghz ",
- " Min ", " Max ", " Avg "]
- ]
+ table_head = [["FrameSize (byte)",
+ test_type,
+ "",
+ "",
+ "",
+ "Latency(uSec)",
+ "",
+ ""],
+ ["",
+ " Mpps ",
+ " " + type_title[test_type] + " (%) ",
+ "CPU Used (%)",
+ " Mpps/Ghz ",
+ " Min ",
+ " Max ",
+ " Avg "]]
else:
- table_head = [
- ["FrameSize (byte)", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)",
- " Mpps/Ghz ", "MinLatency(uSec)", "MaxLatency(uSec)", "AvgLatency(uSec)"],
- ]
+ table_head = [["FrameSize (byte)",
+ " Mpps ",
+ " " + type_title[test_type] + " (%) ",
+ "CPU Used (%)",
+ " Mpps/Ghz ",
+ "MinLatency(uSec)",
+ "MaxLatency(uSec)",
+ "AvgLatency(uSec)"],
+ ]
else:
- table_body = self._dbase.query_summary_simpletable(self._taskid, case, provider, test_type)
+ table_body = self._dbase.query_summary_simpletable(
+ self._taskid, case, provider, test_type)
if 'pdf' == table_type:
- table_head = [
- ["FrameSize (byte)", test_type, "", "", "", "Latency(uSec)"],
- ["", " Mpps ", " " + type_title[test_type] + " (%)", "CPU Used (%)", " Mpps/Ghz ",
- " Avg "]
- ]
+ table_head = [["FrameSize (byte)",
+ test_type,
+ "",
+ "",
+ "",
+ "Latency(uSec)"],
+ ["",
+ " Mpps ",
+ " " + type_title[test_type] + " (%)",
+ "CPU Used (%)",
+ " Mpps/Ghz ",
+ " Avg "]]
else:
- table_head = [
- ["FrameSize (byte)", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)",
- " Mpps/Ghz ", "AvgLatency(uSec)"],
- ]
+ table_head = [["FrameSize (byte)",
+ " Mpps ",
+ " " + type_title[test_type] + " (%) ",
+ "CPU Used (%)",
+ " Mpps/Ghz ",
+ "AvgLatency(uSec)"],
+ ]
return table_head + table_body
def get_ratedata(self, testid, test_type):
- table_head = [
- ["FrameSize (bytes)", "Bandwidth(Mpps)", "Load (%)", "CPU Usage(%)", "Mpps/Ghz", "AvgLatency(uSec)"],
- ]
+ table_head = [["FrameSize (bytes)",
+ "Bandwidth(Mpps)",
+ "Load (%)",
+ "CPU Usage(%)",
+ "Mpps/Ghz",
+ "AvgLatency(uSec)"],
+ ]
query = self._dbase.query_testdata(testid, test_type)
table_body = []
for item in query:
- table_body.append([item.AvgFrameSize, item.Bandwidth, item.OfferedLoad, item.CPU, item.MppspGhz,
+ table_body.append([item.AvgFrameSize,
+ item.Bandwidth,
+ item.OfferedLoad,
+ item.CPU,
+ item.MppspGhz,
item.AverageLatency])
result = []
if table_body:
@@ -203,20 +249,29 @@ class ScenarioData(DataProvider):
for provider in cst.PROVIDERS:
if self.is_provider_start(case, provider):
if item == 'Percent':
- query = self._dbase.query_load(self._taskid, case, provider, test_type)
+ query = self._dbase.query_load(
+ self._taskid, case, provider, test_type)
elif item == 'Mpps':
- query = self._dbase.query_bandwidth(self._taskid, case, provider, test_type)
+ query = self._dbase.query_bandwidth(
+ self._taskid, case, provider, test_type)
else:
- query = self._dbase.query_avglatency(self._taskid, case, provider, test_type)
+ query = self._dbase.query_avglatency(
+ self._taskid, case, provider, test_type)
query = map(lambda x: list(x), zip(*query))
if query:
- table_head = [[type_dict["FrameSize"]] + map(lambda x: " %4d " % (x), query[0])]
+ table_head = [[type_dict["FrameSize"]] +
+ map(lambda x: " %4d " % (x), query[0])]
if item == "Avg":
- data = map(lambda x: item_dict[item] + "%.1f" % x + item_dict[item], query[1])
+ data = map(
+ lambda x: item_dict[item] + "%.1f" %
+ x + item_dict[item], query[1])
else:
- data = map(lambda x: item_dict[item] + "%.2f" % x + item_dict[item], query[1])
+ data = map(
+ lambda x: item_dict[item] + "%.2f" %
+ x + item_dict[item], query[1])
if item == "Mpps":
- line_table = map(lambda x: "%.2f" % (line_speed * 1000 / (8 * (x + 20))), query[0])
+ line_table = map(lambda x: "%.2f" % (
+ line_speed * 1000 / (8 * (x + 20))), query[0])
table.append([type_dict[provider]] + data)
if table:
if item == "Mpps":
@@ -260,7 +315,8 @@ class ScenarioData(DataProvider):
result = []
if table_data:
ytitle = "Average Latency (uSec)"
- category_names = map(lambda x: "FS:%4d" % int(float(x)) + "LOAD:50", table_data[0][1:])
+ category_names = map(lambda x: "FS:%4d" %
+ int(float(x)) + "LOAD:50", table_data[0][1:])
bar_ = map(lambda x: x[0], table_data[1:])
data = map(lambda x: x[1:], table_data[1:])
result = [ytitle, category_names, bar_, data]
@@ -268,10 +324,12 @@ class ScenarioData(DataProvider):
def get_bardata(self, case, provider, test_type):
if test_type == "latency":
- query = self._dbase.query_avglatency(self._taskid, case, provider, test_type)
+ query = self._dbase.query_avglatency(
+ self._taskid, case, provider, test_type)
item = "Avg"
else:
- query = self._dbase.query_load(self._taskid, case, provider, test_type)
+ query = self._dbase.query_load(
+ self._taskid, case, provider, test_type)
item = "Percent"
title_dict = {
@@ -290,7 +348,9 @@ class ScenarioData(DataProvider):
query = map(lambda x: list(x), zip(*query))
result = []
if query:
- category_names = map(lambda x: "FS:%4d" % x + name_dict[item], query[0])
+ category_names = map(
+ lambda x: "FS:%4d" %
+ x + name_dict[item], query[0])
data = query[1:]
bar_ = [color_dict[item]]
result = [ytitle, category_names, bar_, data]
@@ -298,6 +358,7 @@ class ScenarioData(DataProvider):
class TaskData(object):
+
def __init__(self, taskid, dbase):
self.__common = CommonData(taskid, dbase)
scenario_list = self.__common.get_scenariolist()
@@ -312,6 +373,7 @@ class TaskData(object):
class HistoryData(DataProvider):
+
def get_data(self, task_list, case, provider, ttype, item):
"""
@provider in ["fastlink", "rdp", "l2switch", ""]
@@ -324,17 +386,18 @@ class HistoryData(DataProvider):
sizes = []
for taskid in task_list:
if item == 'ratep':
- query = self._dbase.query_bandwidth(taskid, case, provider, ttype)
+ query = self._dbase.query_bandwidth(
+ taskid, case, provider, ttype)
else:
- query = self._dbase.query_avglatency(taskid, case, provider, ttype)
+ query = self._dbase.query_avglatency(
+ taskid, case, provider, ttype)
if query:
data = {}
for size, value in query:
data[size] = value
sizes.extend(data.keys())
- sizes = {}.fromkeys(sizes).keys()
- sizes.sort()
+ sizes = sorted({}.fromkeys(sizes).keys())
datas.append({taskid: data})
result = []
@@ -367,7 +430,10 @@ class HistoryData(DataProvider):
return task_list
def get_history_info(self, case):
- provider_dict = {"fastlink": "Fast Link ", "l2switch": "L2Switch ", "rdp": "Kernel RDP "}
+ provider_dict = {
+ "fastlink": "Fast Link ",
+ "l2switch": "L2Switch ",
+ "rdp": "Kernel RDP "}
ttype_dict = {
"throughput": "Throughput Testing ",
"frameloss": "Frame Loss Testing ",
@@ -390,7 +456,8 @@ class HistoryData(DataProvider):
item = "ratep"
for provider in cst.PROVIDERS:
- table_data = self.get_data(task_list, case, provider, ttype, item)
+ table_data = self.get_data(
+ task_list, case, provider, ttype, item)
if table_data:
data = {
"title": provider_dict[provider] + items_dict[item],
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py
index 5769da79..02606b4b 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py
@@ -13,6 +13,7 @@ import vstf.common.pyhtml as pyhtm
class HtmlBase(object):
+
def __init__(self, provider):
self._page = pyhtm.PyHtml('Html Text')
self._provider = provider
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py
index 695ea37f..f866f185 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py
@@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__)
class HtmlCreator(HtmlBase):
+
def create_story(self):
self.add_context()
@@ -70,7 +71,10 @@ class HtmlCreator(HtmlBase):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/html-creator.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/html-creator.log",
+ clevel=logging.INFO)
out_file = "vstf_report.html"
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py
index ef8b54df..6622281b 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py
@@ -32,8 +32,16 @@ from vstf.controller.reporters.report.pdf.styles import *
class eImage(Image):
""" an image(digital picture)which contains the function of auto zoom picture """
- def __init__(self, filename, width=None, height=None, kind='direct', mask="auto", lazy=1, hAlign='CENTRE',
- vAlign='BOTTOM'):
+ def __init__(
+ self,
+ filename,
+ width=None,
+ height=None,
+ kind='direct',
+ mask="auto",
+ lazy=1,
+ hAlign='CENTRE',
+ vAlign='BOTTOM'):
Image.__init__(self, filename, None, None, kind, mask, lazy)
print height, width
print self.drawHeight, self.drawWidth
@@ -78,6 +86,7 @@ class eTable(object):
class eCommonTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -89,6 +98,7 @@ class eCommonTable(eTable):
class eConfigTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -113,6 +123,7 @@ class eConfigTable(eTable):
class eSummaryTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -127,6 +138,7 @@ class eSummaryTable(eTable):
class eGitInfoTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -141,6 +153,7 @@ class eGitInfoTable(eTable):
class eScenarioTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -157,6 +170,7 @@ class eScenarioTable(eTable):
class eOptionsTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -181,6 +195,7 @@ class eOptionsTable(eTable):
class eProfileTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -194,6 +209,7 @@ class eProfileTable(eTable):
class eDataTable(eTable):
+
def analysisData(self, data):
result = data
self._style = [
@@ -229,6 +245,7 @@ class eDataTable(eTable):
class eGraphicsTable(eTable):
+
def analysisData(self, data):
self._style = [
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
@@ -238,12 +255,14 @@ class eGraphicsTable(eTable):
class noScaleXValueAxis(XValueAxis):
+
def __init__(self):
XValueAxis.__init__(self)
def makeTickLabels(self):
g = Group()
- if not self.visibleLabels: return g
+ if not self.visibleLabels:
+ return g
f = self._labelTextFormat # perhaps someone already set it
if f is None:
@@ -307,14 +326,17 @@ class noScaleXValueAxis(XValueAxis):
txt = f(t)
else:
raise ValueError('Invalid labelTextFormat %s' % f)
- if post: txt = post % txt
+ if post:
+ txt = post % txt
pos[d] = v
label.setOrigin(*pos)
label.setText(txt)
- # special property to ensure a label doesn't project beyond the bounds of an x-axis
+ # special property to ensure a label doesn't project beyond
+ # the bounds of an x-axis
if self.keepTickLabelsInside:
- if isinstance(self, XValueAxis): # not done yet for y axes
+ if isinstance(
+ self, XValueAxis): # not done yet for y axes
a_x = self._x
if not i: # first one
x0, y0, x1, y1 = label.getBounds()
@@ -324,7 +346,8 @@ class noScaleXValueAxis(XValueAxis):
a_x1 = a_x + self._length
x0, y0, x1, y1 = label.getBounds()
if x1 > a_x1:
- label = label.clone(dx=label.dx - x1 + a_x1)
+ label = label.clone(
+ dx=label.dx - x1 + a_x1)
g.add(label)
return g
@@ -342,8 +365,10 @@ class noScaleXValueAxis(XValueAxis):
The chart first configures the axis, then asks it to
"""
assert self._configured, "Axis cannot scale numbers before it is configured"
- if value is None: value = 0
- # this could be made more efficient by moving the definition of org and sf into the configuration
+ if value is None:
+ value = 0
+ # this could be made more efficient by moving the definition of org and
+ # sf into the configuration
org = (self._x, self._y)[self._dataIndex]
sf = self._length / (len(self._tickValues) + 1)
if self.reverseDirection:
@@ -353,6 +378,7 @@ class noScaleXValueAxis(XValueAxis):
class noScaleLinePlot(LinePlot):
+
def __init__(self):
LinePlot.__init__(self)
self.xValueAxis = noScaleXValueAxis()
@@ -373,7 +399,8 @@ class noScaleLinePlot(LinePlot):
for colNo in range(len_row):
datum = self.data[rowNo][colNo] # x, y value
x = self.x + self.width / (len_row + 1) * (colNo + 1)
- self.xValueAxis.labels[colNo].x = self.x + self.width / (len_row + 1) * (colNo + 1)
+ self.xValueAxis.labels[colNo].x = self.x + \
+ self.width / (len_row + 1) * (colNo + 1)
y = self.yValueAxis.scale(datum[1])
# print self.width, " ", x
line.append((x, y))
@@ -383,6 +410,7 @@ class noScaleLinePlot(LinePlot):
# def _innerDrawLabel(self, rowNo, colNo, x, y):
# return None
class eLinePlot(object):
+
def __init__(self, data, style):
self._lpstyle = style
self._linename = data[0]
@@ -485,9 +513,11 @@ class eLinePlot(object):
for i in range(line_cnts):
styleIndex = i % sytle_cnts
lp.lines[i].strokeColor = self._lpstyle.linestyle[styleIndex][0]
- lp.lines[i].symbol = makeMarker(self._lpstyle.linestyle[styleIndex][1])
+ lp.lines[i].symbol = makeMarker(
+ self._lpstyle.linestyle[styleIndex][1])
lp.lines[i].strokeWidth = self._lpstyle.linestyle[styleIndex][2]
- color_paris.append((self._lpstyle.linestyle[styleIndex][0], self._linename[i]))
+ color_paris.append(
+ (self._lpstyle.linestyle[styleIndex][0], self._linename[i]))
# lp.lineLabels[i].strokeColor = self._lpstyle.linestyle[styleIndex][0]
lp.lineLabelFormat = self._lpstyle.format[0]
@@ -501,8 +531,6 @@ class eLinePlot(object):
lp.yValueAxis.valueMin, lp.yValueAxis.valueMax, lp.yValueAxis.valueSteps = self._yvalue
-
-
# lp.xValueAxis.forceZero = 0
# lp.xValueAxis.avoidBoundFrac = 1
# lp.xValueAxis.tickDown = 3
@@ -540,6 +568,7 @@ class eLinePlot(object):
class eHorizontalLineChart(object):
+
def __init__(self, data, style):
self._lcstyle = style
if len(data) < 1:
@@ -630,9 +659,11 @@ class eHorizontalLineChart(object):
for i in range(line_cnts):
styleIndex = i % sytle_cnts
lc.lines[i].strokeColor = self._lcstyle.linestyle[styleIndex][0]
- lc.lines[i].symbol = makeMarker(self._lcstyle.linestyle[styleIndex][1])
+ lc.lines[i].symbol = makeMarker(
+ self._lcstyle.linestyle[styleIndex][1])
lc.lines[i].strokeWidth = self._lcstyle.linestyle[styleIndex][2]
- color_paris.append((self._lcstyle.linestyle[styleIndex][0], self._linename[i]))
+ color_paris.append(
+ (self._lcstyle.linestyle[styleIndex][0], self._linename[i]))
lc.lineLabels.fontSize = self._lcstyle.labelsfont - 2
@@ -660,6 +691,7 @@ class eHorizontalLineChart(object):
class eBarChartColumn(object):
+
def __init__(self, data, style):
self._bcstyle = style
if len(data) < 4:
@@ -702,7 +734,10 @@ class eBarChartColumn(object):
color_paris = []
for i in range(bar_cnt):
bc.bars[i].fillColor = self._bcstyle.pillarstyle[self._bar[i]][0]
- color_paris.append((self._bcstyle.pillarstyle[self._bar[i]][0], self._bar[i]))
+ color_paris.append(
+ (self._bcstyle.pillarstyle[
+ self._bar[i]][0],
+ self._bar[i]))
bc.fillColor = self._bcstyle.background
bc.barLabels.fontName = 'Helvetica'
@@ -761,6 +796,7 @@ class eBarChartColumn(object):
class eParagraph(object):
+
def __init__(self, data, style):
self._pstyle = style
self._data = self.analysisData(data)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py
index c33974ec..67f988c9 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py
@@ -22,6 +22,7 @@ LOG = logging.getLogger(__name__)
class PdfCreator(object):
+
def __init__(self, provider):
self._provider = provider
self._story = []
@@ -114,7 +115,10 @@ class PdfCreator(object):
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-creator.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/pdf-creator.log",
+ clevel=logging.INFO)
out_file = "vstf_report.pdf"
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py
index 69c65401..7e287814 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py
@@ -13,9 +13,11 @@ from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus import PageBreak
from vstf.controller.reporters.report.pdf.styles import TemplateStyle, ps_head_lv1, ps_head_lv2, ps_head_lv3
import vstf.common.constants as cst
+from functools import reduce
class BaseDocTemplate(SimpleDocTemplate):
+
def __init__(self, filename, **kw):
self.allowSplitting = 0
SimpleDocTemplate.__init__(self, filename, **kw)
@@ -34,6 +36,7 @@ class BaseDocTemplate(SimpleDocTemplate):
class PdfTemplate(object):
+
def __init__(self, title, logo, header, footer, note=[], style="default"):
self._style = TemplateStyle(name=style)
self._title = title
@@ -41,7 +44,8 @@ class PdfTemplate(object):
#self._header = header[0]
self._footer = footer
self._note = note
- info = " Generated on %s " % time.strftime(cst.TIME_FORMAT2, time.localtime())
+ info = " Generated on %s " % time.strftime(
+ cst.TIME_FORMAT2, time.localtime())
self._note += [info]
def myFirstPage(self, canvas, doc):
@@ -54,46 +58,78 @@ class PdfTemplate(object):
sizes = (self._style.page_wight, self._style.page_height)
doc = BaseDocTemplate(output, pagesize=sizes)
# doc.build(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
- doc.multiBuild(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
+ doc.multiBuild(
+ story,
+ onFirstPage=self.myFirstPage,
+ onLaterPages=self.myLaterPages)
class PdfVswitch(PdfTemplate):
+
def myFirstPage(self, canvas, doc):
canvas.saveState()
title_lines = len(self._title)
line_size = [self._style.title_size] * title_lines
line_size.append(0)
- canvas.drawImage(self._logo,
- (self._style.page_wight - self._style.logo_width) / 2.0,
- self._style.page_height / 2.0 + (1 + self._style.title_leading) * reduce(lambda x, y: x + y,
- line_size),
- self._style.logo_width,
- self._style.logo_height
- )
+ canvas.drawImage(
+ self._logo,
+ (self._style.page_wight -
+ self._style.logo_width) /
+ 2.0,
+ self._style.page_height /
+ 2.0 +
+ (
+ 1 +
+ self._style.title_leading) *
+ reduce(
+ lambda x,
+ y: x +
+ y,
+ line_size),
+ self._style.logo_width,
+ self._style.logo_height)
for i in range(title_lines):
canvas.setFont(self._style.title_font, line_size[i])
- canvas.drawCentredString(self._style.page_wight / 2.0,
- self._style.page_height / 2.0 + (1 + self._style.title_leading) * reduce(
- lambda x, y: x + y, line_size[i + 1:]),
- self._title[i]
- )
+ canvas.drawCentredString(
+ self._style.page_wight /
+ 2.0,
+ self._style.page_height /
+ 2.0 +
+ (
+ 1 +
+ self._style.title_leading) *
+ reduce(
+ lambda x,
+ y: x +
+ y,
+ line_size[
+ i +
+ 1:]),
+ self._title[i])
size = self._style.body_size
canvas.setFont(self._style.body_font, size)
note_line = len(self._note)
for i in range(note_line):
print self._note[i]
- canvas.drawCentredString(self._style.page_wight / 2.0,
- self._style.page_height / 5.0 + (1 + self._style.body_leading) * size * (
- note_line - i - 1),
- self._note[i]
- )
+ canvas.drawCentredString(self._style.page_wight /
+ 2.0, self._style.page_height /
+ 5.0 +
+ (1 +
+ self._style.body_leading) *
+ size *
+ (note_line -
+ i -
+ 1), self._note[i])
size = self._style.body_size - 2
canvas.setFont(self._style.body_font, size)
- canvas.drawCentredString(self._style.page_wight / 2.0,
- self._style.page_bottom / 2.0 + (1 + self._style.body_leading) * size,
- self._footer[0])
+ canvas.drawCentredString(self._style.page_wight /
+ 2.0, self._style.page_bottom /
+ 2.0 +
+ (1 +
+ self._style.body_leading) *
+ size, self._footer[0])
canvas.restoreState()
def myLaterPages(self, canvas, doc):
@@ -106,9 +142,7 @@ class PdfVswitch(PdfTemplate):
)
size = self._style.body_size - 2
canvas.setFont(self._style.body_font, size)
- canvas.drawCentredString(self._style.page_wight / 2.0,
- self._style.page_bottom - 24,
- "%s%s Page %2d " % (self._footer[0], " " * 8, doc.page - 1)
- )
+ canvas.drawCentredString(
+ self._style.page_wight / 2.0, self._style.page_bottom - 24, "%s%s Page %2d " %
+ (self._footer[0], " " * 8, doc.page - 1))
canvas.restoreState()
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py
index 940c20fb..f1442fe7 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py
@@ -21,6 +21,7 @@ from element import *
class Story(object):
+
def __init__(self):
self._storylist = []
@@ -30,6 +31,7 @@ class Story(object):
class StoryDecorator(Story):
+
def __init__(self, story, data=None, style=None):
self._story = story
self._data = data
@@ -47,6 +49,7 @@ class StoryDecorator(Story):
class ImageStory(StoryDecorator):
+
def new_story(self):
print "Image Story"
for filename in self._data:
@@ -60,7 +63,12 @@ class ImageStory(StoryDecorator):
image_hAlign = style.image_hAlign
image_vAlign = style.image_vAlign
self._story.storylist.append(
- eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign))
+ eImage(
+ filename,
+ image_width,
+ image_height,
+ hAlign=image_hAlign,
+ vAlign=image_vAlign))
else:
style = is_default
image_height = style.image_height
@@ -69,22 +77,30 @@ class ImageStory(StoryDecorator):
image_vAlign = style.image_vAlign
# self._story.storylist.append(eGraphicsTable([[' ' * 5, eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign)]], ts_left).table)
self._story.storylist.append(
- eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign))
+ eImage(
+ filename,
+ image_width,
+ image_height,
+ hAlign=image_hAlign,
+ vAlign=image_vAlign))
class HeaderStory(StoryDecorator):
+
def new_story(self):
print "header story"
self._story.storylist.append(PageBreak())
class PageBreakStory(StoryDecorator):
+
def new_story(self):
print "PageBreak story"
self._story.storylist.append(PageBreak())
class TableOfContentsStory(StoryDecorator):
+
def new_story(self):
print "TableOfContents story"
self._data = [" ", " ", "Table Of Contents", ""]
@@ -96,35 +112,43 @@ class TableOfContentsStory(StoryDecorator):
class SpaceStory(StoryDecorator):
+
def new_story(self):
style = ps_space
self._story.storylist.append(eParagraph([" ", " "], style).para)
class TableStory(StoryDecorator):
+
def new_story(self):
print "table story"
style = ts_default
if self._style == 1:
self._story.storylist.append(eDataTable(self._data, style).table)
- elif self._style ==2:
+ elif self._style == 2:
style = ts_left
self._story.storylist.append(eCommonTable(self._data, style).table)
elif self._style == 3:
self._story.storylist.append(eConfigTable(self._data, style).table)
elif self._style == 4:
- self._story.storylist.append(eOptionsTable(self._data, style).table)
+ self._story.storylist.append(
+ eOptionsTable(self._data, style).table)
elif self._style == 5:
- self._story.storylist.append(eProfileTable(self._data, style).table)
+ self._story.storylist.append(
+ eProfileTable(self._data, style).table)
elif self._style == 6:
- self._story.storylist.append(eSummaryTable(self._data, style).table)
+ self._story.storylist.append(
+ eSummaryTable(self._data, style).table)
elif self._style == 7:
- self._story.storylist.append(eScenarioTable(self._data, style).table)
+ self._story.storylist.append(
+ eScenarioTable(self._data, style).table)
elif self._style == 8:
- self._story.storylist.append(eGitInfoTable(self._data, style).table)
+ self._story.storylist.append(
+ eGitInfoTable(self._data, style).table)
class LinePlotStory(StoryDecorator):
+
def new_story(self):
print "LinePlot"
style = lps_default
@@ -137,18 +161,21 @@ class LinePlotStory(StoryDecorator):
class LineChartStory(StoryDecorator):
+
def new_story(self):
print "LineChartStory: "
style = lcs_default
if not self._data:
print "data error "
return
- data = eGraphicsTable([[eHorizontalLineChart(self._data, style).draw]]).table
+ data = eGraphicsTable(
+ [[eHorizontalLineChart(self._data, style).draw]]).table
if data:
self._story.storylist.append(data)
class BarChartStory(StoryDecorator):
+
def new_story(self):
print "BarChartStory: "
style = bcs_default
@@ -156,12 +183,14 @@ class BarChartStory(StoryDecorator):
print "data error "
return
- data = eGraphicsTable([[eBarChartColumn(self._data, style).draw]]).table
+ data = eGraphicsTable(
+ [[eBarChartColumn(self._data, style).draw]]).table
if data:
self._story.storylist.append(data)
class ParagraphStory(StoryDecorator):
+
def new_story(self):
print "Paragraph Story"
style = ps_body
@@ -174,6 +203,7 @@ class ParagraphStory(StoryDecorator):
class TitleStory(StoryDecorator):
+
def new_story(self):
print "Paragraph Story"
if self._style - 1 in range(9):
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py
index 74c4c593..2e0863ec 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py
@@ -15,6 +15,7 @@ from vstf.controller.settings.template_settings import TemplateSettings
class HtmlProvider(object):
+
def __init__(self, info, style):
self._info = info
self._style = style
@@ -32,7 +33,10 @@ class HtmlProvider(object):
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/html-provder.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/html-provder.log",
+ clevel=logging.INFO)
html_settings = HtmlSettings()
LOG.info(html_settings.settings)
@@ -42,4 +46,4 @@ def main():
LOG.info(provider.get_context)
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py
index e1cb09ef..f7752016 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py
@@ -15,6 +15,7 @@ from vstf.controller.settings.template_settings import TemplateSettings
class PdfProvider(object):
+
def __init__(self, info):
self._info = info
@@ -37,7 +38,10 @@ class PdfProvider(object):
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/pdf-provider.log",
+ clevel=logging.INFO)
info = TemplateSettings()
provider = PdfProvider(info.settings)
@@ -46,4 +50,4 @@ def main():
LOG.info(provider.get_context)
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py
index 654c9b83..ea0a1ad0 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py
@@ -30,6 +30,7 @@ LOG = logging.getLogger(__name__)
class Report(object):
+
def __init__(self, dbase, rpath):
"""
@@ -47,7 +48,10 @@ class Report(object):
creator = CandyGenerator(task)
attach_list = []
for scenario in scenario_list:
- out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_FORMAT3)))
+ out_file = os.path.join(
+ self._rpath, "vstf_report_%s_%s.pdf" %
+ (scenario, time.strftime(
+ cst.TIME_FORMAT3)))
LOG.info(out_file)
creator.create(scenario)
info = TemplateSettings()
@@ -90,7 +94,10 @@ class Report(object):
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-reporter.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-reporter.log",
+ clevel=logging.INFO)
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('-rpath',
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/cpu_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/cpu_settings.py
index a25af4c1..9589e119 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/cpu_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/cpu_settings.py
@@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__)
class CpuSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/perf/",
filename="sw_perf.cpu-settings",
mode=sets.SETS_SINGLE):
@@ -32,9 +33,22 @@ class CpuSettings(sets.Settings):
for item in body:
item = item.encode()
func_name = "set_%s" % item
- setattr(self, func_name, self._setting_file(func_name, self._mset['affctl'], self._fset['affctl'], item))
+ setattr(
+ self,
+ func_name,
+ self._setting_file(
+ func_name,
+ self._mset['affctl'],
+ self._fset['affctl'],
+ item))
func_name = "mset_%s" % item
- setattr(self, func_name, self._setting_memory(func_name, self._mset['affctl'], item))
+ setattr(
+ self,
+ func_name,
+ self._setting_memory(
+ func_name,
+ self._mset['affctl'],
+ item))
LOG.debug(self.__dict__)
@@ -59,8 +73,10 @@ class CpuSettings(sets.Settings):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-cpu-settings.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-cpu-settings.log",
+ clevel=logging.INFO)
if __name__ == '__main__':
unit_test()
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/device_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/device_settings.py
index 25f2c5bf..5fe3976f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/device_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/device_settings.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class DeviceSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/perf/",
filename="sw_perf.device-settings",
mode=sets.SETS_SINGLE):
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/flows_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/flows_settings.py
index 9cd1a1b7..f28d5b5b 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/flows_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/flows_settings.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class FlowsSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/perf/",
filename="sw_perf.flownodes-settings",
mode=sets.SETS_SINGLE):
@@ -27,16 +28,44 @@ class FlowsSettings(sets.Settings):
for actor in self._check_actors:
actor = actor.encode()
func_name = "add_%s" % actor
- setattr(self, func_name, self._adding_file(func_name, self._mset, self._fset, actor, self._check_add))
+ setattr(
+ self,
+ func_name,
+ self._adding_file(
+ func_name,
+ self._mset,
+ self._fset,
+ actor,
+ self._check_add))
func_name = "madd_%s" % actor
- setattr(self, func_name, self._adding_memory(func_name, self._mset, actor, self._check_add))
+ setattr(
+ self,
+ func_name,
+ self._adding_memory(
+ func_name,
+ self._mset,
+ actor,
+ self._check_add))
for actor in self._nocheck_actors:
actor = actor.encode()
func_name = "add_%s" % actor
- setattr(self, func_name, self._adding_file(func_name, self._mset, self._fset, actor))
+ setattr(
+ self,
+ func_name,
+ self._adding_file(
+ func_name,
+ self._mset,
+ self._fset,
+ actor))
func_name = "madd_%s" % actor
- setattr(self, func_name, self._adding_memory(func_name, self._mset, actor))
+ setattr(
+ self,
+ func_name,
+ self._adding_memory(
+ func_name,
+ self._mset,
+ actor))
LOG.debug(self.__dict__.keys())
@@ -70,7 +99,10 @@ class FlowsSettings(sets.Settings):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-flows-settings.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-flows-settings.log",
+ clevel=logging.INFO)
flows_settings = FlowsSettings()
LOG.info(flows_settings.settings)
@@ -113,7 +145,7 @@ def unit_test():
cpu = {
"agent": "192.168.188.16",
- "affctl":{
+ "affctl": {
"policy": 2
}
}
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/forwarding_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/forwarding_settings.py
index 636ddfda..138337cb 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/forwarding_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/forwarding_settings.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class ForwardingSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/perf/",
filename="sw_perf.forwarding-settings",
mode=sets.SETS_SINGLE):
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/html_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/html_settings.py
index ce87733e..89af7a54 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/html_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/html_settings.py
@@ -15,13 +15,21 @@ LOG = logging.getLogger(__name__)
class HtmlSettings(sets.Settings):
- def __init__(self, path="/etc/vstf/", filename="reporters.html-settings", mode=sets.SETS_DEFAULT):
+
+ def __init__(
+ self,
+ path="/etc/vstf/",
+ filename="reporters.html-settings",
+ mode=sets.SETS_DEFAULT):
super(HtmlSettings, self).__init__(path, filename, mode)
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/html-settings.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/html-settings.log",
+ clevel=logging.DEBUG)
html_settings = HtmlSettings()
style = {
'table': {
@@ -36,13 +44,13 @@ def unit_test():
'border': '1px solid green',
'padding': '8px',
'word-wrap': 'break-all'
- },
+ },
'th':
{
'background-color': '#EAF2D3',
'border': '1px solid green',
'padding': '8px'
- }
+ }
}
html_settings.set_style(style)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/mail_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/mail_settings.py
index db01097f..967aa601 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/mail_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/mail_settings.py
@@ -18,7 +18,12 @@ LOG = logging.getLogger(__name__)
class MailSettings(sets.Settings):
- def __init__(self, path="/etc/vstf", filename="reporters.mail.mail-settings", mode=sets.SETS_DEFAULT):
+
+ def __init__(
+ self,
+ path="/etc/vstf",
+ filename="reporters.mail.mail-settings",
+ mode=sets.SETS_DEFAULT):
super(MailSettings, self).__init__(path, filename, mode)
def _register_func(self):
@@ -30,11 +35,24 @@ class MailSettings(sets.Settings):
for item in body:
item = item.encode()
func_name = "set_%s" % item
- setattr(self, func_name, self._setting_file(func_name, self._mset['body'], self._fset['body'], item))
+ setattr(
+ self,
+ func_name,
+ self._setting_file(
+ func_name,
+ self._mset['body'],
+ self._fset['body'],
+ item))
other = {"attach", "content", "subtype"}
for item in other:
func_name = "mset_%s" % item
- setattr(self, func_name, self._setting_memory(func_name, self._mset['body'], item))
+ setattr(
+ self,
+ func_name,
+ self._setting_memory(
+ func_name,
+ self._mset['body'],
+ item))
LOG.debug(self.__dict__)
@@ -80,7 +98,10 @@ class MailSettings(sets.Settings):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-mail-settings.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-mail-settings.log",
+ clevel=logging.INFO)
mail_settings = MailSettings()
mail_settings.sinput()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/perf_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/perf_settings.py
index 610cb4ae..adc8dee4 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/perf_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/perf_settings.py
@@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__)
class PerfSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/perf/",
filename="sw_perf.batch-settings",
mode=sets.SETS_SINGLE):
@@ -42,14 +43,23 @@ class PerfSettings(sets.Settings):
if not scenario:
LOG.warn("not support the case:%s", value["case"])
return
- self._adding_file("add", self._mset, self._fset, scenario, check=self._check_add)(value)
+ self._adding_file(
+ "add",
+ self._mset,
+ self._fset,
+ scenario,
+ check=self._check_add)(value)
def madd_case(self, case):
scenario = self.dbconn.query_scenario(case)
if not scenario:
LOG.warn("not support the case:%s", case)
return
- self._adding_memory("madd", self._mset, scenario, check=self._check_add)(case)
+ self._adding_memory(
+ "madd",
+ self._mset,
+ scenario,
+ check=self._check_add)(case)
@deco.dcheck('sizes')
@deco.dcheck("type", choices=cst.TTYPES)
@@ -74,7 +84,7 @@ class PerfSettings(sets.Settings):
pprint.pprint(self.settings)
print "+++++++++++++++++++++++++++++++++++"
return True
-
+
@deco.vstf_input('sizes', types=list)
@deco.vstf_input("type", types=str, choices=cst.TTYPES)
@deco.vstf_input("profile", types=str, choices=cst.PROVIDERS)
@@ -98,7 +108,10 @@ def unit_test():
perf_settings.sinput()
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-perf-settings.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-perf-settings.log",
+ clevel=logging.DEBUG)
if __name__ == '__main__':
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/settings.py
index 2c712bb2..a01689d5 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/settings.py
@@ -31,7 +31,8 @@ def dict2object(dic):
module_name = dic.pop('__module__')
module = __import__(module_name)
class_ = getattr(module, class_name)
- args = dict((key.encode('ascii'), value) for key, value in dic.items()) # get args
+ args = dict((key.encode('ascii'), value)
+ for key, value in dic.items()) # get args
inst = class_(**args) # create new instance
else:
inst = dic
@@ -52,6 +53,7 @@ def filter_comments(filename, flags="//"):
class BaseSettings(object):
+
def _load(self, fullname):
data = filter_comments(fullname)
LOG.debug(fullname)
@@ -68,7 +70,11 @@ class BaseSettings(object):
for litem in ldata:
if rdata:
for ritem in rdata:
- if isinstance(litem, dict) or isinstance(litem, list):
+ if isinstance(
+ litem,
+ dict) or isinstance(
+ litem,
+ list):
tmp = self._sub(litem, ritem)
else:
tmp = ritem
@@ -104,15 +110,22 @@ class BaseSettings(object):
if os.path.exists(filename):
os.remove(filename)
with open(filename, 'w') as ofile:
- content = json.dumps(data, sort_keys=True, indent=4, separators=(',', ':'))
+ content = json.dumps(
+ data,
+ sort_keys=True,
+ indent=4,
+ separators=(
+ ',',
+ ':'))
ofile.write(content)
class DefaultSettings(BaseSettings):
+
def __init__(self, path):
self._default = os.path.join(path, 'default')
self._user = os.path.join(path, 'user')
-
+
def load(self, filename):
dfile = os.path.join(self._default, filename)
if os.path.exists(dfile):
@@ -137,6 +150,7 @@ class DefaultSettings(BaseSettings):
class SingleSettings(BaseSettings):
+
def __init__(self, path):
self._path = path
@@ -161,6 +175,7 @@ SETTINGS = [SETS_SINGLE, SETS_DEFAULT]
class Settings(object):
+
def __init__(self, path, filename, mode=SETS_SINGLE):
if mode not in SETTINGS:
raise Exception("error Settings mode : %s" % (mode))
@@ -257,23 +272,65 @@ class Settings(object):
for item in items:
item = item.encode()
func_name = "set_%s" % item
- setattr(self, func_name, self._setting_file(func_name, self._mset, self._fset, item))
+ setattr(
+ self,
+ func_name,
+ self._setting_file(
+ func_name,
+ self._mset,
+ self._fset,
+ item))
func_name = "mset_%s" % item
- setattr(self, func_name, self._setting_memory(func_name, self._mset, item))
+ setattr(
+ self,
+ func_name,
+ self._setting_memory(
+ func_name,
+ self._mset,
+ item))
elif isinstance(self._fset, list):
func_name = "set"
- setattr(self, func_name, self._setting_file(func_name, self._mset, self._fset, None))
+ setattr(
+ self,
+ func_name,
+ self._setting_file(
+ func_name,
+ self._mset,
+ self._fset,
+ None))
func_name = "mset"
- setattr(self, func_name, self._setting_memory(func_name, self._mset, None))
+ setattr(
+ self,
+ func_name,
+ self._setting_memory(
+ func_name,
+ self._mset,
+ None))
func_name = "add"
- setattr(self, func_name, self._adding_file(func_name, self._mset, self._fset, None))
+ setattr(
+ self,
+ func_name,
+ self._adding_file(
+ func_name,
+ self._mset,
+ self._fset,
+ None))
func_name = "madd"
- setattr(self, func_name, self._adding_memory(func_name, self._mset, None))
+ setattr(
+ self,
+ func_name,
+ self._adding_memory(
+ func_name,
+ self._mset,
+ None))
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf-settings.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf-settings.log",
+ clevel=logging.INFO)
path = '/etc/vstf'
setting = DefaultSettings(path)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/template_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/template_settings.py
index b677c539..2e449fef 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/template_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/template_settings.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class TemplateSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/reporter/",
filename="reporters.template-settings",
mode=sets.SETS_SINGLE):
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/tester_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/tester_settings.py
index 554c8042..5d64d29c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/tester_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/tester_settings.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class TesterSettings(sets.Settings):
+
def __init__(self, path="/etc/vstf/env/",
filename="tester.json",
mode=sets.SETS_SINGLE):
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/settings/tool_settings.py b/testsuites/vstf/vstf_scripts/vstf/controller/settings/tool_settings.py
index a84bc59f..aed3306f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/settings/tool_settings.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/settings/tool_settings.py
@@ -18,7 +18,12 @@ LOG = logging.getLogger(__name__)
class ToolSettings(sets.Settings):
- def __init__(self, path="/etc/vstf", filename="sw_perf.tool-settings", mode=sets.SETS_DEFAULT):
+
+ def __init__(
+ self,
+ path="/etc/vstf",
+ filename="sw_perf.tool-settings",
+ mode=sets.SETS_DEFAULT):
super(ToolSettings, self).__init__(path, filename, mode)
def _register_func(self):
@@ -29,8 +34,15 @@ class ToolSettings(sets.Settings):
for item in body:
item = item.encode()
func_name = "set_%s" % (item)
- setattr(self, func_name,
- self._setting_file(func_name, self._mset, self._fset, item, check=self._check_keys))
+ setattr(
+ self,
+ func_name,
+ self._setting_file(
+ func_name,
+ self._mset,
+ self._fset,
+ item,
+ check=self._check_keys))
def _check_keys(self, value):
keys = ['threads', 'wait', 'time']
@@ -70,7 +82,10 @@ class ToolSettings(sets.Settings):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/tool-settings.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/tool-settings.log",
+ clevel=logging.INFO)
tool_settings = ToolSettings()
value = {
"time": 10,
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/appliance.py b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/appliance.py
index d4c5be64..610b27dc 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/appliance.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/appliance.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class spirentSTC(object):
+
def __init__(self):
super(spirentSTC, self).__init__()
self.runmodel = None
@@ -25,7 +26,7 @@ class spirentSTC(object):
:param str conner: the spirent tester, the agent id of spirent vm
:param list measurand: the tested host's agent id
:param str model: the model used of the tested host
-
+
"""
mgr = stevedore.driver.DriverManager(namespace="spirent.model.plugins",
name=model,
@@ -41,7 +42,7 @@ class spirentSTC(object):
def run(config):
- # test option parser
+ # test option parser
if not os.path.exists(config['configfile']):
LOG.error('The config file %s does exist.', config.get("configfile"))
return False
@@ -54,7 +55,7 @@ def run(config):
LOG.error("[ERROR]Check parameter invalid.")
return False
- # check logical parameter in the
+ # check logical parameter in the
flag = runmodel.check_logic_invalid
if not flag:
LOG.error("[ERROR]Check logic parameter with host invalid.")
@@ -86,7 +87,8 @@ def run(config):
LOG.error("[ERROR]Restructure the test data failed.")
perfdata = getResult(result_dict)
columndata = getResultColumn(result_dict)
- column_array, data_array = analysis_instance.analyseResult(suite, columndata, perfdata)
+ column_array, data_array = analysis_instance.analyseResult(
+ suite, columndata, perfdata)
temp = {'columns': column_array, 'data': data_array}
result[suite] = temp
return result
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
index a29794f4..38bfa70e 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
@@ -24,6 +24,7 @@ reverse_dict = {
class BaseModel(object):
+
def __init__(self, config):
self.config = config
@@ -117,6 +118,7 @@ def _tranfer_array_to_range(array):
class TnV(BaseModel):
+
def __init__(self, config):
super(TnV, self).__init__(config)
self.config = config
@@ -178,7 +180,8 @@ class TnV(BaseModel):
info = self.handle.get(option, 'macs')
macs = info.split()
if len(macs) != int(self.config['virtenv']) or macs == []:
- print("[ERROR]The macs number is not equal to vms or containers.")
+ print(
+ "[ERROR]The macs number is not equal to vms or containers.")
return False
for mac in macs:
# check mac valid
@@ -211,12 +214,12 @@ class TnV(BaseModel):
@property
def check_logic_invalid(self):
return self.flow_match() and self.match_virt_env() and \
- self.match_flows_and_nic and self.check_mac_valid() and \
- self.check_vlan_valid()
+ self.match_flows_and_nic and self.check_mac_valid() and \
+ self.check_vlan_valid()
@property
def read_flow_init(self):
- # The
+ # The
temp_flow = {}
src_macs = self._get_range('send', 'macs')
dst_macs = self._get_range('recv', 'macs')
@@ -233,7 +236,7 @@ class TnV(BaseModel):
temp_flow['tester_ip'] = self._get_nic_from_file('common', 'tester_ip')
vlan = src_vlan
avg_flow = int(self.config['flows']) / int(self.config['virtenv'])
- # build the main dictionary
+ # build the main dictionary
for _direct in sorted(fwd[self.config['direct']]):
i = 0
j = 0
@@ -267,9 +270,11 @@ class TnV(BaseModel):
temp_flow['qemu_thread_list'] = _vm_info['qemu_thread']
forward_core = {
- "forward": _vm_info['qemu_thread'][_queue + avg_flow * vm_index],
- "reverse": _vm_info['qemu_thread'][_queue + avg_flow * vm_index + int(self.config['flows'])]
- }
+ "forward": _vm_info['qemu_thread'][
+ _queue + avg_flow * vm_index],
+ "reverse": _vm_info['qemu_thread'][
+ _queue + avg_flow * vm_index + int(
+ self.config['flows'])]}
temp_flow['fwd_thread'] = forward_core[_direct]
temp_flow['fwd_vhost'] = None
@@ -280,7 +285,8 @@ class TnV(BaseModel):
temp_flow['dst_nic'] = dst_nic
# above all
j += 1
- self.init_flows[_direct + '_' + _vm + '_' + str(_queue)] = copy.deepcopy(temp_flow)
+ self.init_flows[_direct + '_' + _vm + '_' +
+ str(_queue)] = copy.deepcopy(temp_flow)
i += 1
src_nic_irq, dst_nic_irq = dst_nic_irq, src_nic_irq
vlan = dst_vlan
@@ -323,30 +329,67 @@ class TnV(BaseModel):
try:
i += 1
thread_info = None
- self.mac_learning(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)],
- self.init_flows[reverse_dict[_direct] + '_' + _vm + '_' + str(_queue)])
- streamblock = self.send_packet(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ self.mac_learning(
+ self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)],
+ self.init_flows[
+ reverse_dict[_direct] +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)])
+ streamblock = self.send_packet(
+ self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
time.sleep(1)
result, thread_info = self.catch_thread_info()
thread_info = eval(thread_info)
- self.stop_flow(streamblock, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ self.stop_flow(
+ streamblock, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)])
time.sleep(1)
if not result:
print("[ERROR]Catch the thread info failed.")
break
except:
- print("[ERROR]send flow failed error or get host thread info failed.")
+ print(
+ "[ERROR]send flow failed error or get host thread info failed.")
# compare the got thread info to
- if check_dict(thread_info, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)]):
- self.set_thread2flow(thread_info, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
- print("[INFO]Flow %s_%s_%s : fwd_vhost %s src_recv_irq %s dst_send_irq %s"
- % (_direct, _vm, _queue, thread_info['fwd_vhost'], thread_info['src_recv_irq'],
- thread_info['dst_send_irq']))
- print("%s" % (self.init_flows[_direct + '_' + _vm + '_' + str(_queue)]))
+ if check_dict(
+ thread_info, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)]):
+ self.set_thread2flow(
+ thread_info, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)])
+ print(
+ "[INFO]Flow %s_%s_%s : fwd_vhost %s src_recv_irq %s dst_send_irq %s" %
+ (_direct,
+ _vm,
+ _queue,
+ thread_info['fwd_vhost'],
+ thread_info['src_recv_irq'],
+ thread_info['dst_send_irq']))
+ print(
+ "%s" %
+ (self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)]))
break
else:
- dst_ip_update(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ dst_ip_update(
+ self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)])
return self.init_flows
def affinity_bind(self, aff_strategy):
@@ -361,7 +404,8 @@ class TnV(BaseModel):
# recognize the thread id
for flowname in sorted(self.init_flows.keys()):
tmp_thread = self.init_flows[flowname]['fwd_thread']
- qemu_other = qemu_other + copy.deepcopy(self.init_flows[flowname]['qemu_thread_list'])
+ qemu_other = qemu_other + \
+ copy.deepcopy(self.init_flows[flowname]['qemu_thread_list'])
qemu_list.append(tmp_thread)
if self.init_flows[flowname]['direct'] == 'forward':
dst_vhost.append(self.init_flows[flowname]['fwd_vhost'])
@@ -386,16 +430,38 @@ class TnV(BaseModel):
handle = ConfigParser.ConfigParser()
handle.read(self.config['strategyfile'])
try:
- qemu_numa = handle.get('strategy' + self.config['strategy'], 'qemu_numa')
- src_vhost_numa = handle.get('strategy' + self.config['strategy'], 'src_vhost_numa')
- dst_vhost_numa = handle.get('strategy' + self.config['strategy'], 'dst_vhost_numa')
- src_irq_numa = handle.get('strategy' + self.config['strategy'], 'src_irq_numa')
- dst_irq_numa = handle.get('strategy' + self.config['strategy'], 'dst_irq_numa')
- loan_numa = handle.get('strategy' + self.config['strategy'], 'loan_numa')
+ qemu_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'qemu_numa')
+ src_vhost_numa = handle.get(
+ 'strategy' + self.config['strategy'],
+ 'src_vhost_numa')
+ dst_vhost_numa = handle.get(
+ 'strategy' + self.config['strategy'],
+ 'dst_vhost_numa')
+ src_irq_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'src_irq_numa')
+ dst_irq_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'dst_irq_numa')
+ loan_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'loan_numa')
except:
print("[ERROR]Parse the strategy file failed or get the options failed.")
- for value in [qemu_numa, src_vhost_numa, dst_vhost_numa, src_irq_numa, dst_irq_numa, loan_numa]:
+ for value in [
+ qemu_numa,
+ src_vhost_numa,
+ dst_vhost_numa,
+ src_irq_numa,
+ dst_irq_numa,
+ loan_numa]:
if value is not None or value == '':
raise ValueError('some option in the strategy file is none.')
# cores mapping thread
@@ -407,26 +473,39 @@ class TnV(BaseModel):
for node in numa_topo.keys():
numa_topo[node]['process'] = []
if 'node' + src_irq_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + src_irq
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + src_irq
if 'node' + dst_irq_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + dst_irq
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + dst_irq
if 'node' + src_vhost_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + src_vhost
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + src_vhost
if 'node' + dst_vhost_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + dst_vhost
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + dst_vhost
if 'node' + qemu_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + qemu_list
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + qemu_list
loan_cores = ''
for node in numa_topo.keys():
- if len(numa_topo[node]['process']) > len(numa_topo[node]['phy_cores']):
+ if len(
+ numa_topo[node]['process']) > len(
+ numa_topo[node]['phy_cores']):
# length distance
- diff = len(numa_topo[node]['process']) - len(numa_topo[node]['phy_cores'])
+ diff = len(numa_topo[node]['process']) - \
+ len(numa_topo[node]['phy_cores'])
# first deep copy
- numa_topo['node' + loan_numa]['process'] = numa_topo['node' + loan_numa]['process'] + copy.deepcopy(
- numa_topo[node]['process'][-diff:])
- cores_str = _tranfer_array_to_range(numa_topo['node' + loan_numa]['phy_cores'][diff:])
+ numa_topo['node' + loan_numa]['process'] = numa_topo['node' + loan_numa][
+ 'process'] + copy.deepcopy(numa_topo[node]['process'][-diff:])
+ cores_str = _tranfer_array_to_range(
+ numa_topo[
+ 'node' +
+ loan_numa]['phy_cores'][
+ diff:])
loan_cores = ','.join([loan_cores, cores_str])
- numa_topo[node]['process'] = numa_topo[node]['process'][0:-diff]
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'][0:-diff]
loan_cores = loan_cores[1:]
loan_bind_list = {}
for proc_loan in qemu_other:
@@ -435,7 +514,8 @@ class TnV(BaseModel):
bind_list = {}
for node in numa_topo.keys():
for i in range(len(numa_topo[node]['process'])):
- bind_list[numa_topo[node]['process'][i]] = str(numa_topo[node]['phy_cores'][i])
+ bind_list[numa_topo[node]['process'][i]] = str(
+ numa_topo[node]['phy_cores'][i])
bind_list.update(loan_bind_list)
for key in bind_list.keys():
self.host_instance.bind_cpu(bind_list[key], key)
@@ -459,8 +539,10 @@ class TnV(BaseModel):
if suite == "throughput":
print("[INFO]!!!!!!!!!!!!!!!Now begin to throughput test")
- ret, result = self.send_instace.run_rfc2544_throughput(forward_init_flows, reverse_init_flows)
+ ret, result = self.send_instace.run_rfc2544_throughput(
+ forward_init_flows, reverse_init_flows)
elif suite == "frameloss":
print("[INFO]!!!!!!!!!!!1!!!Now begin to frameloss test")
- ret, result = self.send_instace.run_rfc2544_frameloss(forward_init_flows, reverse_init_flows)
+ ret, result = self.send_instace.run_rfc2544_frameloss(
+ forward_init_flows, reverse_init_flows)
return ret, result
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/result_analysis.py b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/result_analysis.py
index b09a846d..9003f063 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/result_analysis.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/result_analysis.py
@@ -29,9 +29,11 @@ def restrucData(data_string):
try:
data_dict = {}
p = re.compile('-Columns.*-Output')
- data_dict['Columns'] = p.findall(data_string)[0].strip('-Columns {} -Output')
+ data_dict['Columns'] = p.findall(
+ data_string)[0].strip('-Columns {} -Output')
p = re.compile('-Output.*-State')
- data_dict['Output'] = p.findall(data_string)[0].strip('-Output {} -State')
+ data_dict['Output'] = p.findall(
+ data_string)[0].strip('-Output {} -State')
if data_dict['Columns'] is not None or data_dict['Output'] is not None:
return False, None
return True, data_dict
@@ -90,6 +92,7 @@ def framelossData(column, perfdata):
class analysis(object):
+
def __init__(self):
pass
@@ -148,7 +151,8 @@ class analysis(object):
line[column_name_dict['FrameSize']],
line[column_name_dict['Load(%)']],
line[column_name_dict['Result']],
- str(float(line[column_name_dict['ForwardingRate(mpps)']]) / 1000000),
+ str(float(line[column_name_dict[
+ 'ForwardingRate(mpps)']]) / 1000000),
line[column_name_dict['TxFrameCount']],
line[column_name_dict['RxFrameCount']],
line[column_name_dict['AverageLatency(us)']],
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/flow_producer.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/flow_producer.py
index 4a3b02c2..a4bd1467 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/flow_producer.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/flow_producer.py
@@ -21,6 +21,7 @@ LOG = logging.getLogger(__name__)
class FlowsProducer(object):
+
def __init__(self, conn, flows_settings):
self._perf = flows_settings
self._forwarding = ForwardingSettings().settings
@@ -43,12 +44,13 @@ class FlowsProducer(object):
raise Exception("error devs :%s", devs)
LOG.info(agent)
LOG.info(name)
- if not self._devs_map.has_key((agent, name)):
+ if (agent, name) not in self._devs_map:
query = Fabricant(agent, self._conn)
query.clean_all_namespace()
dev_info = query.get_device_verbose(identity=name)
if not isinstance(dev_info, dict):
- err = "get device detail failed, agent:%s net:%s" % (agent, name)
+ err = "get device detail failed, agent:%s net:%s" % (
+ agent, name)
raise Exception(err)
dev = {
"agent": agent,
@@ -127,7 +129,10 @@ class FlowsProducer(object):
def unit_test():
from vstf.rpc_frame_work.rpc_producer import Server
from vstf.common.log import setup_logging
- setup_logging(level=logging.INFO, log_file="/var/log/vstf/vstf-producer.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.INFO,
+ log_file="/var/log/vstf/vstf-producer.log",
+ clevel=logging.INFO)
conn = Server("192.168.188.10")
flow_settings = FlowsSettings()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/model.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/model.py
index c49df041..8e3e7b22 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/model.py
@@ -17,6 +17,7 @@ LOG = logging.getLogger(__name__)
class NetDeviceMgr(Fabricant):
+
@classmethod
def add(cls, dst, conn, dev):
self = cls(dst, conn)
@@ -38,6 +39,7 @@ class NetDeviceMgr(Fabricant):
class Actor(Fabricant):
+
def __init__(self, dst, conn, tool, params):
super(Actor, self).__init__(dst, conn)
self._tool = tool
@@ -46,12 +48,13 @@ class Actor(Fabricant):
def __repr__(self):
repr_dict = self.__dict__
- repr_keys = list(repr_dict.keys())
- repr_keys.sort()
- return '%s(%s)' % (self.__class__.__name__, ', '.join(['%s=%r' % (k, repr_dict[k]) for k in repr_keys]))
+ repr_keys = sorted(repr_dict.keys())
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(
+ ['%s=%r' % (k, repr_dict[k]) for k in repr_keys]))
class Sender(Actor):
+
def start(self, pktsize, **kwargs):
LOG.info("Sender.start")
if 'ratep' in kwargs and kwargs['ratep']:
@@ -106,6 +109,7 @@ class Sender(Actor):
class Receiver(Actor):
+
def start(self, **kwargs):
LOG.info("Receiver.start")
ret, info = self.perf_run(
@@ -136,6 +140,7 @@ class Receiver(Actor):
class NicWatcher(Fabricant):
+
def __init__(self, dst, conn, params):
super(NicWatcher, self).__init__(dst, conn)
self._params = params
@@ -144,7 +149,9 @@ class NicWatcher(Fabricant):
def start(self):
print "NicWatcher.start"
- self._pid = self.run_vnstat(device=self._params["iface"], namespace=self._params["namespace"])
+ self._pid = self.run_vnstat(
+ device=self._params["iface"],
+ namespace=self._params["namespace"])
print self._pid
def stop(self):
@@ -161,6 +168,7 @@ class NicWatcher(Fabricant):
class CpuWatcher(Fabricant):
+
def __init__(self, dst, conn):
super(CpuWatcher, self).__init__(dst, conn)
self._pid = None
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/perf_provider.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/perf_provider.py
index 396e6eef..3fdbad60 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/perf_provider.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/perf_provider.py
@@ -26,6 +26,7 @@ def get_agent_dict(nodes):
class PerfProvider(object):
+
def __init__(self, flows_info, tool_info, tester_info):
self._flows_info = flows_info
self._tool_info = tool_info
@@ -33,7 +34,8 @@ class PerfProvider(object):
def _islation(self):
flows = self._flows_info["flows"]
- if flows == 2 and self._flows_info["senders"][0]["agent"] == self._flows_info["senders"][1]["agent"]:
+ if flows == 2 and self._flows_info["senders"][0][
+ "agent"] == self._flows_info["senders"][1]["agent"]:
return True
return False
@@ -53,8 +55,10 @@ class PerfProvider(object):
}
}
for i in range(flows):
- sender['params']['src'].append(self._flows_info["senders"][i]['dev'])
- sender['params']['dst'].append(self._flows_info["receivers"][i]['dev'])
+ sender['params']['src'].append(
+ self._flows_info["senders"][i]['dev'])
+ sender['params']['dst'].append(
+ self._flows_info["receivers"][i]['dev'])
result.append(sender)
else:
for i in range(flows):
@@ -63,12 +67,12 @@ class PerfProvider(object):
"params": {
"protocol": protocol,
"namespace": None if "netmap" == tool else self._flows_info["senders"][i]['dev']['namespace'],
- "src": [self._flows_info["senders"][i]['dev']],
- "dst": [self._flows_info["receivers"][i]['dev']],
+ "src": [
+ self._flows_info["senders"][i]['dev']],
+ "dst": [
+ self._flows_info["receivers"][i]['dev']],
"time": self._tool_info[tool]["time"],
- "threads": self._tool_info[tool]["threads"]
- }
- }
+ "threads": self._tool_info[tool]["threads"]}}
result.append(sender)
return result
@@ -91,9 +95,8 @@ class PerfProvider(object):
"params": {
"namespace": None if "netmap" == tool else self._flows_info["receivers"][i]['dev']['namespace'],
"protocol": protocol,
- "dst": [self._flows_info["receivers"][i]['dev']]
- }
- }
+ "dst": [
+ self._flows_info["receivers"][i]['dev']]}}
result.append(receiver)
return result
@@ -104,9 +107,10 @@ class PerfProvider(object):
"agent": watcher["agent"],
"params": {
"iface": watcher['dev']["iface"],
- "namespace": None if tool in ["pktgen", "netmap"] else watcher['dev']["namespace"],
- }
- }
+ "namespace": None if tool in [
+ "pktgen",
+ "netmap"] else watcher['dev']["namespace"],
+ }}
result.append(node)
return result
@@ -118,10 +122,12 @@ class PerfProvider(object):
"agent": watcher["agent"],
"params": {
"iface": watcher['dev']["iface"],
- "namespace": watcher['dev']["namespace"] if tool not in ["pktgen", "netmap"] else None,
- "ip": watcher['dev']["ip"] + '/24',
- }
- }
+ "namespace": watcher['dev']["namespace"] if tool not in [
+ "pktgen",
+ "netmap"] else None,
+ "ip": watcher['dev']["ip"] +
+ '/24',
+ }}
result.append(node)
return result
@@ -176,7 +182,10 @@ class PerfProvider(object):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-perf-provider.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-perf-provider.log",
+ clevel=logging.INFO)
from vstf.controller.settings.flows_settings import FlowsSettings
from vstf.controller.settings.tool_settings import ToolSettings
@@ -186,7 +195,10 @@ def unit_test():
tool_settings = ToolSettings()
tester_settings = TesterSettings()
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
tools = ['pktgen']
protocols = ['udp_bw', 'udp_lat']
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/performance.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/performance.py
index 3fe91e93..7dc426f8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/performance.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/performance.py
@@ -29,6 +29,7 @@ LOG = logging.getLogger(__name__)
class Performance(object):
+
def __init__(self, conn, provider):
self._provider = provider
self._conn = conn
@@ -221,7 +222,8 @@ class Performance(object):
lat_tool = "qperf"
lat_type = 'latency'
lat_tpro = protocol + '_lat'
- self.run_latency_test(lat_tool, lat_tpro, size, ratep=realspeed)
+ self.run_latency_test(
+ lat_tool, lat_tpro, size, ratep=realspeed)
lat_result = self.result(tool, lat_type)
LOG.info(bw_result)
LOG.info(lat_result)
@@ -272,23 +274,32 @@ class Performance(object):
record[mark.txMbps] += nic_data['txmB/s'] * 8
if record[mark.rxMbps] > record[mark.txMbps]:
- record[mark.rxMbps], record[mark.txMbps] = record[mark.txMbps], record[mark.rxMbps]
+ record[
+ mark.rxMbps], record[
+ mark.txMbps] = record[
+ mark.txMbps], record[
+ mark.rxMbps]
if record[mark.rxCount] > record[mark.txCount]:
- record[mark.rxCount], record[mark.txCount] = record[mark.txCount], record[mark.rxCount]
+ record[
+ mark.rxCount], record[
+ mark.txCount] = record[
+ mark.txCount], record[
+ mark.rxCount]
if record[mark.txCount]:
- record[mark.percentLoss] = round(100 * (1 - record[mark.rxCount] / record[mark.txCount]),
- cst.PKTLOSS_ROUND)
+ record[mark.percentLoss] = round(
+ 100 * (1 - record[mark.rxCount] / record[mark.txCount]), cst.PKTLOSS_ROUND)
else:
record[mark.percentLoss] = 100
record[mark.bandwidth] /= 1000000.0
if cpu_mhz and record[mark.cpu]:
- record[mark.mppsGhz] = round(record[mark.bandwidth] / (record[mark.cpu] * cpu_mhz / 100000),
- cst.CPU_USAGE_ROUND)
+ record[mark.mppsGhz] = round(
+ record[mark.bandwidth] / (record[mark.cpu] * cpu_mhz / 100000), cst.CPU_USAGE_ROUND)
- record[mark.bandwidth] = round(record[mark.bandwidth], cst.RATEP_ROUND)
+ record[mark.bandwidth] = round(
+ record[mark.bandwidth], cst.RATEP_ROUND)
elif ttype in {'latency'}:
record = {
@@ -319,7 +330,10 @@ class Performance(object):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-sw_perf.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-sw_perf.log",
+ clevel=logging.INFO)
conn = Server("192.168.188.10")
perf_settings = PerfSettings()
@@ -327,7 +341,10 @@ def unit_test():
tool_settings = ToolSettings()
tester_settings = TesterSettings()
flow_producer = FlowsProducer(conn, flows_settings)
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
perf = Performance(conn, provider)
tests = perf_settings.settings
for scenario, cases in tests.items():
@@ -348,7 +365,10 @@ def unit_test():
def main():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-performance.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-performance.log",
+ clevel=logging.INFO)
from vstf.controller.database.dbinterface import DbManage
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument("case",
@@ -374,9 +394,10 @@ def main():
action="store",
default="64",
help='test size list "64 128"')
- parser.add_argument("--affctl",
- action="store_true",
- help="when input '--affctl', the performance will do affctl before testing")
+ parser.add_argument(
+ "--affctl",
+ action="store_true",
+ help="when input '--affctl', the performance will do affctl before testing")
parser.add_argument("--monitor",
dest="monitor",
default="localhost",
@@ -399,7 +420,10 @@ def main():
tool_settings = ToolSettings()
tester_settings = TesterSettings()
flow_producer = FlowsProducer(conn, flows_settings)
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
perf = Performance(conn, provider)
scenario = db_mgr.query_scenario(casetag)
flow_producer.create(scenario, casetag)
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/raw_data.py b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/raw_data.py
index aefb863d..828981db 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/raw_data.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/sw_perf/raw_data.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class RawDataProcess(object):
+
def __init__(self):
pass
@@ -24,7 +25,9 @@ class RawDataProcess(object):
buf = ' '.join(buf)
m = {}
digits = re.compile(r"\d{1,}\.?\d*")
- units = re.compile(r"(?:gib|mib|kib|kbit/s|gbit/s|mbit/s|p/s)", re.IGNORECASE | re.MULTILINE)
+ units = re.compile(
+ r"(?:gib|mib|kib|kbit/s|gbit/s|mbit/s|p/s)",
+ re.IGNORECASE | re.MULTILINE)
units_arr = units.findall(buf)
LOG.debug(units_arr)
digits_arr = digits.findall(buf)
@@ -96,9 +99,9 @@ class RawDataProcess(object):
m = self.process_vnstat(data)
if tool == 'sar' and data_type == 'cpu':
m = self.process_sar_cpu(data)
- if raw.has_key('cpu_num'):
+ if 'cpu_num' in raw:
m['cpu_num'] = raw['cpu_num']
- if raw.has_key('cpu_mhz'):
+ if 'cpu_mhz' in raw:
m['cpu_mhz'] = raw['cpu_mhz']
if tool == 'qperf':
m = self.process_qperf(data)
@@ -121,7 +124,10 @@ if __name__ == '__main__':
print p.process_vnstat(data)
cmd = "sar -u 2"
- child = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ child = subprocess.Popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
import time
import os
from signal import SIGINT
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/configuration.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/configuration.py
index 6312efa2..5131e8d4 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/configuration.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/configuration.py
@@ -18,4 +18,4 @@ source_repo = {
"passwd": "root",
"ip": "192.168.188.10",
"user": "root"
-} \ No newline at end of file
+}
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/model.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/model.py
index 4c38973e..b6e37ff5 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/model.py
@@ -28,4 +28,4 @@ class Test(unittest.TestCase):
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_cfg_intent_parse.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_cfg_intent_parse.py
index a08607bb..a0cf2a33 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_cfg_intent_parse.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_cfg_intent_parse.py
@@ -15,6 +15,7 @@ from vstf.controller.env_build.cfg_intent_parse import IntentParser
class Test(model.Test):
+
def setUp(self):
super(Test, self).setUp()
self.dir = os.path.dirname(__file__)
@@ -33,4 +34,4 @@ if __name__ == "__main__":
import logging
logging.basicConfig(level=logging.INFO)
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_collect.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_collect.py
index 3e84d019..e8e9dd8c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_collect.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_collect.py
@@ -15,31 +15,41 @@ from vstf.controller.unittest import model
class TestCollect(model.Test):
-
+
def setUp(self):
super(TestCollect, self).setUp()
self.obj = env_collect.EnvCollectApi(self.conn)
-
+
def test_collect_host_info(self):
- ret_str = json.dumps(self.obj.collect_host_info(self.tester_host), indent = 4)
- for key in ("CPU INFO","MEMORY INFO","HW_INFO","OS INFO"):
- self.assertTrue(key in ret_str, "collect_host_info failed, ret_str = %s" % ret_str)
-
+ ret_str = json.dumps(
+ self.obj.collect_host_info(
+ self.tester_host), indent=4)
+ for key in ("CPU INFO", "MEMORY INFO", "HW_INFO", "OS INFO"):
+ self.assertTrue(
+ key in ret_str,
+ "collect_host_info failed, ret_str = %s" %
+ ret_str)
+
def test_list_nic_devices(self):
- ret_str = json.dumps(self.obj.list_nic_devices(self.tester_host), indent = 4)
- for key in ("device","mac","bdf","desc"):
- self.assertTrue(key in ret_str, "list_nic_devices failed, ret_str = %s" % ret_str)
+ ret_str = json.dumps(
+ self.obj.list_nic_devices(
+ self.tester_host), indent=4)
+ for key in ("device", "mac", "bdf", "desc"):
+ self.assertTrue(
+ key in ret_str,
+ "list_nic_devices failed, ret_str = %s" %
+ ret_str)
print ret_str
-
+
def test_get_device_detail(self):
identity = "01:00.0"
ret = self.obj.get_device_detail(self.tester_host, "01:00.0")
- for key in ("device","mac","bdf","desc"):
+ for key in ("device", "mac", "bdf", "desc"):
self.assertTrue(key in ret)
self.assertTrue(ret['bdf'] == identity)
if __name__ == "__main__":
import logging
- logging.basicConfig(level = logging.INFO)
- unittest.main() \ No newline at end of file
+ logging.basicConfig(level=logging.INFO)
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_driver_function.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_driver_function.py
index 8d45c7b3..a8b1b018 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_driver_function.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_driver_function.py
@@ -14,19 +14,22 @@ from vstf.controller.functiontest.driver.drivertest import config_setup
from vstf.controller.unittest import model
-class TestDriverFunction(model.Test):
+class TestDriverFunction(model.Test):
+
def setUp(self):
logging.info("start driver function test unit test.")
-
+
def test_config_setup(self):
- config ,_ = config_setup()
- for key in ("test_scene","bond_flag","switch_module"):
- self.assertTrue(key in config.keys(), "config_setup function failure.")
+ config, _ = config_setup()
+ for key in ("test_scene", "bond_flag", "switch_module"):
+ self.assertTrue(
+ key in config.keys(),
+ "config_setup function failure.")
def teardown(self):
logging.info("stop driver function test unit test.")
if __name__ == "__main__":
import logging
- logging.basicConfig(level = logging.INFO)
- unittest.main() \ No newline at end of file
+ logging.basicConfig(level=logging.INFO)
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_env_build.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_env_build.py
index e4529e48..5f9d047f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_env_build.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_env_build.py
@@ -15,45 +15,46 @@ from vstf.controller.env_build import env_build
class TestEnvBuilder(model.Test):
+
def setUp(self):
super(TestEnvBuilder, self).setUp()
self.dir = os.path.dirname(__file__)
-
+
@unittest.skip('for now')
def test_build_tn(self):
- filepath = os.path.join(self.dir,'../../../etc/vstf/env/Tn.json')
+ filepath = os.path.join(self.dir, '../../../etc/vstf/env/Tn.json')
self.mgr = env_build.EnvBuildApi(self.conn, filepath)
ret = self.mgr.build()
self.assertTrue(ret, "build_tn failed,ret = %s" % ret)
-
+
@unittest.skip('for now')
def test_build_tn1v(self):
- filepath = os.path.join(self.dir,'../../../etc/vstf/env/Tnv.json')
+ filepath = os.path.join(self.dir, '../../../etc/vstf/env/Tnv.json')
self.mgr = env_build.EnvBuildApi(self.conn, filepath)
ret = self.mgr.build()
self.assertTrue(ret, "build_tn1v failed,ret = %s" % ret)
-
+
@unittest.skip('for now')
def test_build_ti(self):
- filepath = os.path.join(self.dir,'../../../etc/vstf/env/Ti.json')
+ filepath = os.path.join(self.dir, '../../../etc/vstf/env/Ti.json')
self.mgr = env_build.EnvBuildApi(self.conn, filepath)
ret = self.mgr.build()
self.assertTrue(ret, "build_ti failed,ret = %s" % ret)
-
+
@unittest.skip('for now')
def test_build_tu(self):
- filepath = os.path.join(self.dir,'../../../etc/vstf/env/Tu.json')
+ filepath = os.path.join(self.dir, '../../../etc/vstf/env/Tu.json')
self.mgr = env_build.EnvBuildApi(self.conn, filepath)
ret = self.mgr.build()
self.assertTrue(ret, "build_tu failed,ret = %s" % ret)
-
+
def test_build_tu_bridge(self):
- filepath = os.path.join(self.dir,'../../../etc/vstf/env/Tu_br.json')
+ filepath = os.path.join(self.dir, '../../../etc/vstf/env/Tu_br.json')
self.mgr = env_build.EnvBuildApi(self.conn, filepath)
ret = self.mgr.build()
self.assertTrue(ret, "build_tu failed,ret = %s" % ret)
-
+
if __name__ == "__main__":
import logging
- logging.basicConfig(level = logging.INFO)
- unittest.main() \ No newline at end of file
+ logging.basicConfig(level=logging.INFO)
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_perf.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_perf.py
index 0258ab65..4e2a2ea9 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_perf.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_perf.py
@@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
class TestPerf(model.Test):
-
+
def setUp(self):
LOG.info("start performance unit test.")
super(TestPerf, self).setUp()
@@ -48,7 +48,10 @@ class TestPerf(model.Test):
tool_settings = ToolSettings(path=self.base_path)
tester_settings = TesterSettings(path=self.base_path)
flow_producer = FlowsProducer(self.conn, flows_settings)
- provider = PerfProvider(flows_settings.settings, tool_settings.settings, tester_settings.settings)
+ provider = PerfProvider(
+ flows_settings.settings,
+ tool_settings.settings,
+ tester_settings.settings)
perf = pf.Performance(self.conn, provider)
tests = perf_settings.settings
for scenario, cases in tests.items():
@@ -120,5 +123,8 @@ class TestPerf(model.Test):
if __name__ == "__main__":
- setup_logging(level=logging.INFO, log_file="/var/log/vstf/vstf-unit-test.log", clevel=logging.INFO)
- unittest.main() \ No newline at end of file
+ setup_logging(
+ level=logging.INFO,
+ log_file="/var/log/vstf/vstf-unit-test.log",
+ clevel=logging.INFO)
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_ssh.py b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_ssh.py
index f2403551..c9aadb04 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_ssh.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/unittest/test_ssh.py
@@ -21,16 +21,14 @@ class Test(model.Test):
self.user = self.source_repo["user"]
self.passwd = self.source_repo["passwd"]
-
def tearDown(self):
super(Test, self).tearDown()
-
def test_run_cmd(self):
ssh.run_cmd(self.host, self.user, self.passwd, 'ls')
if __name__ == "__main__":
import logging
- logging.basicConfig(level = logging.INFO)
- unittest.main() \ No newline at end of file
+ logging.basicConfig(level=logging.INFO)
+ unittest.main()
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/vstfadm.py b/testsuites/vstf/vstf_scripts/vstf/controller/vstfadm.py
index 86641e7d..1546b47c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/vstfadm.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/vstfadm.py
@@ -36,7 +36,8 @@ def make_msg(method, **kwargs):
return {"method": method, "args": kwargs}
-@cliutil.arg("--host", dest="host", default="", action="store", help="list nic devices of specified host")
+@cliutil.arg("--host", dest="host", default="", action="store",
+ help="list nic devices of specified host")
def do_list_devs(args):
"""List the host's all netdev."""
ret = call(make_msg("list_devs", host=args.host))
@@ -51,19 +52,44 @@ def do_src_install(args):
"""work agent to pull source code and compile.
use git as underlying mechanism, please make sure the host has access to git repo.
"""
- ret = call(make_msg("src_install", host=args.host, config_file=args.config_file))
+ ret = call(
+ make_msg(
+ "src_install",
+ host=args.host,
+ config_file=args.config_file))
print_stdout(ret)
-@cliutil.arg("--host", dest="host", action="store", default=None,
- help="which host to build, must exists in your config file, use default[None] value to build all hosts.")
-@cliutil.arg("--model", dest="model", action="store", choices=('Tn', 'Ti', 'Tu', 'Tnv'),
- help="which model to build, if specified, the according config file /etc/vstf/env/{model}.json must exist.")
-@cliutil.arg("--config_file", dest="config_file", action="store", default=None,
- help="if specified, the config file will replace the default config file from /etc/vstf/env.")
+@cliutil.arg(
+ "--host",
+ dest="host",
+ action="store",
+ default=None,
+ help="which host to build, must exists in your config file, use default[None] value to build all hosts.")
+@cliutil.arg(
+ "--model",
+ dest="model",
+ action="store",
+ choices=(
+ 'Tn',
+ 'Ti',
+ 'Tu',
+ 'Tnv'),
+ help="which model to build, if specified, the according config file /etc/vstf/env/{model}.json must exist.")
+@cliutil.arg(
+ "--config_file",
+ dest="config_file",
+ action="store",
+ default=None,
+ help="if specified, the config file will replace the default config file from /etc/vstf/env.")
def do_apply_model(args):
"""Apply model to the host."""
- ret = call(make_msg("apply_model", host=args.host, model=args.model, config_file=args.config_file))
+ ret = call(
+ make_msg(
+ "apply_model",
+ host=args.host,
+ model=args.model,
+ config_file=args.config_file))
print_stdout(ret)
@@ -73,7 +99,11 @@ def do_apply_model(args):
help="configuration file for image creation.")
def do_create_images(args):
"""create images on host, images are configed by configuration file."""
- ret = call(make_msg("create_images", host=args.host, config_file=args.config_file))
+ ret = call(
+ make_msg(
+ "create_images",
+ host=args.host,
+ config_file=args.config_file))
print_stdout(ret)
@@ -83,23 +113,49 @@ def do_create_images(args):
help="configuration file for images.")
def do_clean_images(args):
"""clean images on host, images are configed by configuration file."""
- ret = call(make_msg("clean_images", host=args.host, config_file=args.config_file))
+ ret = call(
+ make_msg(
+ "clean_images",
+ host=args.host,
+ config_file=args.config_file))
print_stdout(ret)
-@cliutil.arg("--host", dest="host", action="store", default=None,
- help="which host to clean, must exists in your config file, use default[None] value to clean all hosts.")
-@cliutil.arg("--model", dest="model", action="store", choices=('Tn', 'Ti', 'Tu', 'Tnv'),
- help="if specified, the according config file /etc/vstf/env/{model}.json must exist.")
-@cliutil.arg("--config_file", dest="config_file", action="store", default=None,
- help="if specified, the config file will replace the default config file from /etc/vstf/env.")
+@cliutil.arg(
+ "--host",
+ dest="host",
+ action="store",
+ default=None,
+ help="which host to clean, must exists in your config file, use default[None] value to clean all hosts.")
+@cliutil.arg(
+ "--model",
+ dest="model",
+ action="store",
+ choices=(
+ 'Tn',
+ 'Ti',
+ 'Tu',
+ 'Tnv'),
+ help="if specified, the according config file /etc/vstf/env/{model}.json must exist.")
+@cliutil.arg(
+ "--config_file",
+ dest="config_file",
+ action="store",
+ default=None,
+ help="if specified, the config file will replace the default config file from /etc/vstf/env.")
def do_disapply_model(args):
"""Apply model to the host."""
- ret = call(make_msg("disapply_model", host=args.host, model=args.model, config_file=args.config_file))
+ ret = call(
+ make_msg(
+ "disapply_model",
+ host=args.host,
+ model=args.model,
+ config_file=args.config_file))
print_stdout(ret)
-@cliutil.arg("--host", dest="host", action="store", help="collect host information about cpu/mem etc")
+@cliutil.arg("--host", dest="host", action="store",
+ help="collect host information about cpu/mem etc")
def do_collect_host_info(args):
"""Show the host's CPU/MEN info"""
ret = call(make_msg("collect_host_info", target=args.host))
@@ -113,12 +169,22 @@ def do_show_tasks(args):
print_stdout(ret)
-@cliutil.arg("case", action="store", help="test case like Ti-1, Tn-1, Tnv-1, Tu-1, see case definition in documents")
+@cliutil.arg(
+ "case",
+ action="store",
+ help="test case like Ti-1, Tn-1, Tnv-1, Tu-1, see case definition in documents")
@cliutil.arg("tool", action="store", choices=cst.TOOLS)
@cliutil.arg("protocol", action="store", choices=cst.TPROTOCOLS)
@cliutil.arg("type", action="store", choices=cst.TTYPES)
-@cliutil.arg("sizes", action="store", default="64", help='test size list "64 128"')
-@cliutil.arg("--affctl", action="store_true", help="when affctl is True, it will do affctl before testing")
+@cliutil.arg(
+ "sizes",
+ action="store",
+ default="64",
+ help='test size list "64 128"')
+@cliutil.arg(
+ "--affctl",
+ action="store_true",
+ help="when affctl is True, it will do affctl before testing")
def do_perf_test(args):
"""Runs a quick single software performance test without envbuild and generating reports.
Outputs the result to the stdout immediately."""
@@ -270,7 +336,10 @@ def main():
args = parser.parse_args()
if args.func is None:
sys.exit(-1)
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-adm.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-adm.log",
+ clevel=logging.INFO)
# connect to manage
global CONN
try: