summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/controller
diff options
context:
space:
mode:
authorJun Li <matthew.lijun@huawei.com>2016-01-19 06:49:41 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-01-19 06:49:41 +0000
commit830b8c8c9f158fad8f9b1fc0977ae6deee3e9bed (patch)
tree6b6403f87c494ce2592228560f4078c8d3763ba5 /vstf/vstf/controller
parent61b37f3955ba7abb168fc5bab53a336a20579286 (diff)
parent5b4f794932cb9b28ec679e6dd88e6febb2a5db7b (diff)
Merge " JIRA: BOTTLENECKS-29 add the performance test framework"
Diffstat (limited to 'vstf/vstf/controller')
-rwxr-xr-xvstf/vstf/controller/__init__.py20
-rwxr-xr-xvstf/vstf/controller/api_server.py58
-rwxr-xr-xvstf/vstf/controller/database/__init__.py21
-rwxr-xr-xvstf/vstf/controller/database/constants.py10
-rwxr-xr-xvstf/vstf/controller/database/dbinterface.py398
-rwxr-xr-xvstf/vstf/controller/database/tables.py14
-rwxr-xr-xvstf/vstf/controller/env_build/__init__.py20
-rwxr-xr-xvstf/vstf/controller/env_build/cfg_intent_parse.py12
-rwxr-xr-xvstf/vstf/controller/env_build/env_build.py12
-rwxr-xr-xvstf/vstf/controller/env_build/env_collect.py9
-rwxr-xr-xvstf/vstf/controller/fabricant.py13
-rwxr-xr-xvstf/vstf/controller/reporters/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/mail/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/mail/mail.py9
-rwxr-xr-xvstf/vstf/controller/reporters/mail/sendmail.py15
-rwxr-xr-xvstf/vstf/controller/reporters/report/__init__.py22
-rwxr-xr-xvstf/vstf/controller/reporters/report/candy_generator.py138
-rwxr-xr-xvstf/vstf/controller/reporters/report/data_factory.py131
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/html_base.py40
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/html_text.py68
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/htmlcreator.py162
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/element.py14
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/pdfcreator.py515
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/pdftemplate.py31
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/story.py47
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/styles.py32
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/__init__.py20
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/html_provider.py68
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/pdf_provider.py51
-rwxr-xr-xvstf/vstf/controller/reporters/reporter.py58
-rwxr-xr-xvstf/vstf/controller/res/__init__.py14
-rwxr-xr-xvstf/vstf/controller/settings/__init__.py20
-rwxr-xr-xvstf/vstf/controller/settings/cpu_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/data_settings.py31
-rwxr-xr-xvstf/vstf/controller/settings/device_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/flows_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/forwarding_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/html_settings.py14
-rwxr-xr-xvstf/vstf/controller/settings/mail_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/perf_settings.py17
-rwxr-xr-xvstf/vstf/controller/settings/settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/settings_input.py14
-rwxr-xr-xvstf/vstf/controller/settings/template_settings.py22
-rwxr-xr-xvstf/vstf/controller/settings/tester_settings.py14
-rwxr-xr-xvstf/vstf/controller/settings/tool_settings.py14
-rwxr-xr-xvstf/vstf/controller/spirent/__init__.py21
-rwxr-xr-xvstf/vstf/controller/spirent/appliance.py14
-rwxr-xr-xvstf/vstf/controller/spirent/common/__init__.py20
-rwxr-xr-xvstf/vstf/controller/spirent/common/model.py14
-rwxr-xr-xvstf/vstf/controller/spirent/common/result_analysis.py10
-rwxr-xr-xvstf/vstf/controller/sw_perf/__init__.py21
-rwxr-xr-xvstf/vstf/controller/sw_perf/flow_producer.py14
-rwxr-xr-xvstf/vstf/controller/sw_perf/model.py19
-rwxr-xr-xvstf/vstf/controller/sw_perf/perf_provider.py14
-rwxr-xr-xvstf/vstf/controller/sw_perf/performance.py49
-rwxr-xr-xvstf/vstf/controller/sw_perf/raw_data.py9
-rwxr-xr-xvstf/vstf/controller/unittest/README4
-rwxr-xr-xvstf/vstf/controller/unittest/__init__.py21
-rwxr-xr-xvstf/vstf/controller/unittest/configuration.py12
-rwxr-xr-xvstf/vstf/controller/unittest/model.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_cfg_intent_parse.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_collect.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_driver_function.py13
-rwxr-xr-xvstf/vstf/controller/unittest/test_env_build.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_perf.py14
-rwxr-xr-xvstf/vstf/controller/unittest/test_ssh.py12
-rwxr-xr-xvstf/vstf/controller/vstfadm.py22
69 files changed, 1274 insertions, 1407 deletions
diff --git a/vstf/vstf/controller/__init__.py b/vstf/vstf/controller/__init__.py
index 4dc8a6aa..df7d24d0 100755
--- a/vstf/vstf/controller/__init__.py
+++ b/vstf/vstf/controller/__init__.py
@@ -1,15 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/vstf/vstf/controller/api_server.py b/vstf/vstf/controller/api_server.py
index d3547011..a37bf4c1 100755
--- a/vstf/vstf/controller/api_server.py
+++ b/vstf/vstf/controller/api_server.py
@@ -1,3 +1,13 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
import uuid
import time
import os
@@ -10,7 +20,6 @@ from vstf.common import unix, message, cliutil, excepts
from vstf.common.vstfcli import VstfParser
from vstf.common.log import setup_logging
from vstf.common import daemon
-from vstf.rpc_frame_work import rpc_producer
from vstf.controller.fabricant import Fabricant
from vstf.agent.env.basic.commandline import CommandLine
from vstf.controller.env_build.env_build import EnvBuildApi as Builder
@@ -25,7 +34,9 @@ from vstf.controller.settings.tool_settings import ToolSettings
from vstf.controller.settings.perf_settings import PerfSettings
from vstf.controller.sw_perf.perf_provider import PerfProvider
from vstf.controller.sw_perf.flow_producer import FlowsProducer
+from vstf.controller.settings.forwarding_settings import ForwardingSettings
import vstf.controller.reporters.reporter as rp
+import vstf.rpc_frame_work.rpc_producer as rpc
import vstf.common.constants as cst
import vstf.common.check as chk
@@ -39,12 +50,11 @@ class OpsChains(object):
and setup a thread to watch the queues of rabbitmq
"""
- super(OpsChains, self).__init__()
+ LOG.info("VSTF Manager start to listen to %s", monitor)
if not os.path.exists(cst.VSTFCPATH):
os.mkdir(cst.VSTFCPATH)
- LOG.info("VSTF Manager start to listen to %s", monitor)
- self.chanl = rpc_producer.Server(host=monitor, port=port)
+ self.chanl = rpc.Server(host=monitor, port=port)
self.dbconn = DbManage()
self.collection = EnvCollectApi(self.chanl)
@@ -146,16 +156,25 @@ class OpsChains(object):
nic_info["desc"],
json.dumps(os_info[cst.OS_INFO]))
- self.dbconn.add_extent_2task(taskid, "CETH", "driver", "version 2.0")
- self.dbconn.add_extent_2task(taskid, "EVS", "switch", "version 3.0")
+ self.dbconn.add_extent_2task(taskid, "ixgbe", "driver", "")
+ self.dbconn.add_extent_2task(taskid, "OVS", "switch", "")
return taskid
- def settings(self, mail=False, perf=False):
- LOG.info("mail:%s, perf:%s" % (mail, perf))
- if mail:
- MailSettings().input()
- if perf:
- PerfSettings().input()
+ def settings(self, head, tail):
+
+ forward_settings = ForwardingSettings()
+ head_d = {
+ "ip": head,
+ "namespace":forward_settings.settings["head"]["namespace"]
+ }
+ tail_d = {
+ "ip": tail,
+ "namespace":forward_settings.settings["tail"]["namespace"]
+ }
+ LOG.info(head_d)
+ LOG.info(tail_d)
+ forward_settings.set_head(head_d)
+ forward_settings.set_tail(tail_d)
def report(self, rpath='./', mail_off=False, taskid=-1):
report = rp.Report(self.dbconn, rpath)
@@ -165,13 +184,15 @@ 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))
casetag = case['case']
tool = case['tool']
protocol = case['protocol']
- profile = case['profile']
+ switch = "ovs"
+ provider = None
ttype = case['type']
sizes = case['sizes']
@@ -204,7 +225,7 @@ class OpsChains(object):
LOG.info(result)
if save_on:
taskid = self._create_task(scenario)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, profile, ttype, 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:
@@ -239,7 +260,8 @@ class OpsChains(object):
casetag = case['case']
tool = case['tool']
protocol = case['protocol']
- profile = case['profile']
+ provider = None
+ switch = "ovs"
ttype = case['type']
sizes = case['sizes']
@@ -252,7 +274,7 @@ class OpsChains(object):
result = perf.run(tool, protocol, ttype, sizes, affctl)
LOG.info(result)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, profile, ttype, tool)
+ testid = self.dbconn.add_test_2task(taskid, casetag, protocol, ttype, switch, provider, tool)
LOG.info(testid)
self.dbconn.add_data_2test(testid, result)
@@ -285,7 +307,7 @@ class Manager(daemon.Daemon):
self.run_flag = True
def deal_unknown_obj(self, obj):
- return "unknown response %s" % obj
+ return "unknown response %s:%s" % (self, obj)
def run(self):
signal.signal(signal.SIGTERM, self.daemon_die)
diff --git a/vstf/vstf/controller/database/__init__.py b/vstf/vstf/controller/database/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/database/__init__.py
+++ b/vstf/vstf/controller/database/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/database/constants.py b/vstf/vstf/controller/database/constants.py
index d1aef398..e5070122 100755
--- a/vstf/vstf/controller/database/constants.py
+++ b/vstf/vstf/controller/database/constants.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
SCENARIO_NAME_LEN = 16
DESC_LEN = 256
FIGURE_PATH_LEN = 128
@@ -14,6 +23,7 @@ CPU_INFO_LEN = 1024
NORMAL_VAR_LEN = 32
NORMAL_VAR_LEN1 = 64
+SWITCH_LEN = 16
PROTOCOL_LEN = 16
PROVIDER_LEN = 16
diff --git a/vstf/vstf/controller/database/dbinterface.py b/vstf/vstf/controller/database/dbinterface.py
index ae34c861..d0996c30 100755
--- a/vstf/vstf/controller/database/dbinterface.py
+++ b/vstf/vstf/controller/database/dbinterface.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-07-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__version__ = ''' '''
import os
import logging
@@ -10,7 +14,8 @@ import logging
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import and_
-from vstf.controller.database.tables import *
+import vstf.controller.database.tables as table
+from vstf.controller.database import constants as const
LOG = logging.getLogger(__name__)
@@ -38,7 +43,7 @@ class DbManage(object):
except Exception as e:
raise e
- # if the db is new , cleate all tables and init static tables
+ # if the db is new , create all tables and init static tables
if not db_exists:
self.create_tables()
self.init_tables()
@@ -47,11 +52,11 @@ class DbManage(object):
self._engine.close_all()
def create_tables(self):
- Base.metadata.create_all(self._engine)
+ table.Base.metadata.create_all(self._engine)
self._session.commit()
def drop_tables(self):
- Base.metadata.drop_all(self._engine)
+ table.Base.metadata.drop_all(self._engine)
self._session.commit()
def init_tables(self):
@@ -62,9 +67,9 @@ class DbManage(object):
def init_scenario_table(self):
items = []
for values in const.SCENARIO_INFO_LIST:
- item = TblScenarioInfo(ScenarioName=values[0],
- FigurePath=values[1],
- Description=values[2])
+ item = table.TblScenarioInfo(ScenarioName=values[0],
+ FigurePath=values[1],
+ Description=values[2])
items.append(item)
self._session.add_all(items)
@@ -72,53 +77,53 @@ class DbManage(object):
def init_casetable(self):
items = []
for values in const.CASE_INFO_LIST:
- item = TblCaseInfo(CaseTag=values[0],
- ScenarioName=values[1],
- CaseName=values[2],
- FigurePath=values[3],
- Description=values[4],
- Direction=values[5],
- Directiontag=values[6],
- Configure=values[7])
+ item = table.TblCaseInfo(CaseTag=values[0],
+ ScenarioName=values[1],
+ CaseName=values[2],
+ FigurePath=values[3],
+ Description=values[4],
+ Direction=values[5],
+ Directiontag=values[6],
+ Configure=values[7])
items.append(item)
self._session.add_all(items)
def query_caseinfo(self):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.CaseTag,
- TblCaseInfo.CaseName,
- TblCaseInfo.Direction,
- TblCaseInfo.Configure)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.CaseName,
+ table.TblCaseInfo.Direction,
+ table.TblCaseInfo.Configure)
return query.all()
def query_case(self, casetag):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.Directiontag)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.Directiontag)
return query.first()
# Single TblTaskList API
def get_last_taskid(self):
- query = self._session.query(TblTaskList.TaskID)
+ query = self._session.query(table.TblTaskList.TaskID)
if query:
return query.all()[-1][0]
else:
return 0
def query_tasklist(self):
- query = self._session.query(TblTaskList)
+ query = self._session.query(table.TblTaskList)
return query.all()
def query_taskdate(self, taskid):
- query = self._session.query(TblTaskList.Date).filter(and_(
- TblTaskList.TaskID == taskid))
+ query = self._session.query(table.TblTaskList.Date).filter(and_(
+ table.TblTaskList.TaskID == taskid))
result = ""
if query:
result += query.first()[0]
return result
def query_taskname(self, taskid):
- query = self._session.query(TblTaskList.TaskName).filter(and_(
- TblTaskList.TaskID == taskid))
+ query = self._session.query(table.TblTaskList.TaskName).filter(and_(
+ table.TblTaskList.TaskID == taskid))
result = ""
if query:
result += query.first()[0]
@@ -126,7 +131,7 @@ class DbManage(object):
def create_task(self, name, date, desc):
try:
- item = TblTaskList(name, date, desc)
+ item = table.TblTaskList(name, date, desc)
self._session.add(item)
self._session.commit()
except Exception:
@@ -137,32 +142,33 @@ class DbManage(object):
# Single TblHostInfo API
def add_host_2task(self, taskid, name, machine, cpu, men, nic, os):
"""All var except task must be string"""
- item = TblHostInfo(taskid, name, machine, cpu, men, nic, os)
+ item = table.TblHostInfo(taskid, name, machine, cpu, men, nic, os)
self._session.add(item)
self._session.commit()
def query_task_host_list(self, taskid):
- query = self._session.query(TblHostInfo.HostName,
- TblHostInfo.Server,
- TblHostInfo.CPU,
- TblHostInfo.MEM,
- TblHostInfo.NIC,
- TblHostInfo.OS).filter(
- TblHostInfo.TaskID == taskid)
+ query = self._session.query(table.TblHostInfo.HostName,
+ table.TblHostInfo.Server,
+ table.TblHostInfo.CPU,
+ table.TblHostInfo.MEM,
+ table.TblHostInfo.NIC,
+ table.TblHostInfo.OS).filter(
+ table.TblHostInfo.TaskID == taskid)
return query.all()
# Single TblTestList API
def get_last_testid(self):
- query = self._session.query(TblTestList.TestID)
+ query = self._session.query(table.TblTestList.TestID)
+ print query.all()
if query:
return query.all()[-1][0]
else:
return 0
- def add_test_2task(self, task, case, protocol, provider, typ, tool):
+ def add_test_2task(self, task, case, protocol, typ, switch, provider, tool):
try:
- item = TblTestList(task, case, protocol, provider, typ, tool)
+ item = table.TblTestList(task, case, protocol, typ, switch, provider, tool)
self._session.add(item)
self._session.commit()
except Exception:
@@ -171,12 +177,12 @@ class DbManage(object):
return self.get_last_testid()
def get_test_type(self, testid):
- query = self._session.query(TblTestList.Type).filter(
- TblTestList.TestID == testid)
+ query = self._session.query(table.TblTestList.Type).filter(
+ table.TblTestList.TestID == testid)
return query.first()
def add_extent_2task(self, task, name, content, description):
- item = TblEXTInfo(task, name, content, description)
+ item = table.TblEXTInfo(task, name, content, description)
self._session.add(item)
self._session.commit()
@@ -199,9 +205,9 @@ class DbManage(object):
"""
ptype = self.get_test_type(testid)
instance_map = {
- 'throughput': TblThroughput,
- 'frameloss': TblFrameloss,
- 'latency': TblLatency
+ 'throughput': table.TblThroughput,
+ 'frameloss': table.TblFrameloss,
+ 'latency': table.TblLatency
}
if ptype and ptype[0] not in instance_map:
@@ -228,37 +234,37 @@ class DbManage(object):
def query_tasks(self):
result = []
- ret = self._session.query(TblTaskList)
+ ret = self._session.query(table.TblTaskList)
if ret:
for tmp in ret.all():
result.append([tmp.TaskID, tmp.TaskName, tmp.Date, tmp.EXTInfo])
return result
def query_all_task_id(self):
- query = self._session.query(TblTaskList.TaskID)
+ query = self._session.query(table.TblTaskList.TaskID)
if query:
return query.all()
else:
return []
def get_caseinfo(self):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.CaseTag,
- TblCaseInfo.CaseName,
- TblCaseInfo.Direction,
- TblCaseInfo.Configure)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.CaseName,
+ table.TblCaseInfo.Direction,
+ table.TblCaseInfo.Configure)
return query.all()
def query_scenario(self, casetag):
- query = self._session.query(TblCaseInfo.ScenarioName).filter(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]
return ret
def query_casefigure(self, casetag, tools):
- query = self._session.query(TblCaseInfo.FigurePath).filter(and_(
- TblCaseInfo.CaseTag == casetag))
+ query = self._session.query(table.TblCaseInfo.FigurePath).filter(and_(
+ table.TblCaseInfo.CaseTag == casetag))
result = ""
if query:
result += query.first()[0]
@@ -267,167 +273,183 @@ class DbManage(object):
return result
def query_casename(self, casetag):
- query = self._session.query(TblCaseInfo.CaseName).filter(and_(
- TblCaseInfo.CaseTag == casetag))
+ query = self._session.query(table.TblCaseInfo.CaseName).filter(and_(
+ table.TblCaseInfo.CaseTag == casetag))
result = ""
if query:
result += query.first()[0]
return result
- # Single TblScenarioInfo API
+ # Single TblTestList API
def query_caselist(self, taskid, scenario):
- query = self._session.query(TblTestList.CaseTag).filter(and_(
- TblTestList.CaseTag == TblCaseInfo.CaseTag,
- TblCaseInfo.ScenarioName == scenario,
- TblTestList.TaskID == taskid)).group_by(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):
+ """
+
+ :rtype : object
+ """
+ query = self._session.query(table.TblTestList).filter(and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.ScenarioName == scenario,
+ table.TblTestList.TaskID == taskid))
return query.all()
def query_casetool(self, taskid, casetag, provider, ptype):
- query = self._session.query(TblTestList.Tools).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.Type == ptype))
+ query = self._session.query(table.TblTestList.Tools).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype))
return query.all()
def query_casetools(self, taskid, casetag):
- query = self._session.query(TblTestList.Tools).filter(and_(
- TblTestList.CaseTag == casetag,
- TblTestList.TaskID == taskid)).group_by(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(TblCaseInfo.ScenarioName).filter(and_(
- TblTestList.CaseTag == TblCaseInfo.CaseTag,
- TblTestList.TaskID == taskid)).group_by(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(TblThroughput.AvgFrameSize, TblThroughput.OfferedLoad).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblThroughput.AvgFrameSize, TblThroughput.Bandwidth).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblThroughput.AvgFrameSize,
- TblThroughput.Bandwidth,
- TblThroughput.OfferedLoad,
- TblThroughput.CPU,
- TblThroughput.MppspGhz,
- TblThroughput.MinimumLatency,
- TblThroughput.MaximumLatency,
- TblThroughput.AverageLatency,
+ 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_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ 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(TblThroughput.AvgFrameSize,
- TblThroughput.Bandwidth,
- TblThroughput.OfferedLoad,
- TblThroughput.CPU,
- TblThroughput.MppspGhz,
- TblThroughput.AverageLatency,
+ query = self._session.query(table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth,
+ table.TblThroughput.OfferedLoad,
+ table.TblThroughput.CPU,
+ table.TblThroughput.MppspGhz,
+ table.TblThroughput.AverageLatency,
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ 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):
+ obj = getattr(table, "Tbl%s" % (ptype.title()))
+ query = self._session.query(obj).filter(obj.TestID == testid)
return query.all()
def query_throughput_avg(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize, TblThroughput.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblFrameloss.AvgFrameSize, TblFrameloss.Bandwidth).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblFrameloss.AvgFrameSize, TblFrameloss.OfferedLoad).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblFrameloss.AvgFrameSize,
- TblFrameloss.Bandwidth,
- TblFrameloss.OfferedLoad,
- TblFrameloss.CPU,
- TblFrameloss.MppspGhz,
- TblFrameloss.MinimumLatency,
- TblFrameloss.MaximumLatency,
- TblFrameloss.AverageLatency,
+ 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_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ 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(TblFrameloss.AvgFrameSize,
- TblFrameloss.Bandwidth,
- TblFrameloss.OfferedLoad,
- TblFrameloss.CPU,
- TblFrameloss.MppspGhz,
- TblFrameloss.AverageLatency,
+ query = self._session.query(table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth,
+ table.TblFrameloss.OfferedLoad,
+ table.TblFrameloss.CPU,
+ table.TblFrameloss.MppspGhz,
+ table.TblFrameloss.AverageLatency
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ 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(TblFrameloss.AvgFrameSize, TblFrameloss.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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(TblLatency.AvgFrameSize, TblLatency.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == 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):
@@ -461,50 +483,51 @@ class DbManage(object):
return []
def query_throughput_provider(self, taskid, casetag, provider):
- query = self._session.query(TblThroughput).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == 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(TblFrameloss).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == 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(TblLatency).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == 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(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Type == ptype, 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(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- 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(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Type == ptype,
- TblTestList.Provider == provider,
- 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(TblEXTInfo.EXTName,
- TblEXTInfo.EXTContent,
- TblEXTInfo.Description).filter(TblEXTInfo.TaskID == taskid)
+ query = self._session.query(table.TblEXTInfo.EXTName,
+ table.TblEXTInfo.EXTContent,
+ table.TblEXTInfo.Description).filter(table.TblEXTInfo.TaskID == taskid)
return query.all()
@@ -517,7 +540,7 @@ def unit_test():
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', "rdp", "throughput", "netperf")
+ testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "throughput", "ovs", None, "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -535,7 +558,7 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "rdp", "frameloss", "netperf")
+ testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "frameloss", "ovs", None, "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -553,7 +576,7 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "rdp", "latency", "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},
@@ -561,7 +584,12 @@ def unit_test():
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:
+ print item.Protocol
+ query = dbase.query_testdata(1, "throughput")
+ print query
if __name__ == '__main__':
unit_test()
diff --git a/vstf/vstf/controller/database/tables.py b/vstf/vstf/controller/database/tables.py
index a7658f49..0438d0e9 100755
--- a/vstf/vstf/controller/database/tables.py
+++ b/vstf/vstf/controller/database/tables.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# author: wly
-# date: 2015-07-29
+# date: 2015-12-25
# see license for license details
__version__ = ''' '''
from sqlalchemy import Column, Integer, String, Float, ForeignKey
@@ -127,22 +127,24 @@ class TblTestList(Base):
TaskID = Column(Integer, ForeignKey('TblTaskList.TaskID'))
CaseTag = Column(String(const.CASE_TAG_LEN))
Protocol = Column(String(const.PROTOCOL_LEN))
- Provider = Column(String(const.PROVIDER_LEN))
Type = Column(String(const.TYPE_LEN))
+ Switch = Column(String(const.SWITCH_LEN))
+ Provider = Column(String(const.PROVIDER_LEN))
Tools = Column(String(const.TOOLS_LEN))
- def __init__(self, taskid, casetag, protocol, provider, typ, tools, **kwargs):
+ def __init__(self, taskid, casetag, protocol, typ, switch, provider, tools, **kwargs):
"""Table of test"""
self.TaskID = taskid
self.CaseTag = casetag
self.Protocol = protocol
- self.Provider = provider
self.Type = typ
+ self.Switch = switch
+ self.Provider = provider
self.Tools = tools
def __repr__(self):
- return "<User(TaskID='%d', CaseTag='%s', Protocol='%s', Provider=%s, Type='%s', Tools='%s')>" % (
- self.TaskID, self.CaseTag, self.Protocol, self.Provider, self.Type, self.Tools)
+ return "<User(TaskID='%d', CaseTag='%s', Protocol='%s', Type='%s', Switch=%s, Provider=%s, Tools='%s')>" % (
+ self.TaskID, self.CaseTag, self.Protocol, self.Type, self.Switch, self.Provider, self.Tools)
class TblThroughput(Base):
diff --git a/vstf/vstf/controller/env_build/__init__.py b/vstf/vstf/controller/env_build/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/env_build/__init__.py
+++ b/vstf/vstf/controller/env_build/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/vstf/vstf/controller/env_build/cfg_intent_parse.py b/vstf/vstf/controller/env_build/cfg_intent_parse.py
index 8c7c10b8..b536e3b8 100755
--- a/vstf/vstf/controller/env_build/cfg_intent_parse.py
+++ b/vstf/vstf/controller/env_build/cfg_intent_parse.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-13
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import json
import logging
from vstf.common.utils import randomMAC
diff --git a/vstf/vstf/controller/env_build/env_build.py b/vstf/vstf/controller/env_build/env_build.py
index 85ad5d29..1d201b77 100755
--- a/vstf/vstf/controller/env_build/env_build.py
+++ b/vstf/vstf/controller/env_build/env_build.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import logging
from vstf.controller.fabricant import Fabricant
diff --git a/vstf/vstf/controller/env_build/env_collect.py b/vstf/vstf/controller/env_build/env_collect.py
index 888f71c7..6e32a05d 100755
--- a/vstf/vstf/controller/env_build/env_collect.py
+++ b/vstf/vstf/controller/env_build/env_collect.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
from vstf.rpc_frame_work import rpc_producer
diff --git a/vstf/vstf/controller/fabricant.py b/vstf/vstf/controller/fabricant.py
index c67bfa19..3b1c082f 100755
--- a/vstf/vstf/controller/fabricant.py
+++ b/vstf/vstf/controller/fabricant.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
from vstf.rpc_frame_work import constant as const
import vstf.common.constants as cst
@@ -43,7 +52,9 @@ class Fabricant(object):
def __transfer_msg(self, command):
def infunc(timeout=cst.TIMEOUT, **kwargs):
msg = self.conn.make_msg(command, **kwargs)
- return self.conn.call(msg, self.target, timeout)
+ if self.target:
+ return self.conn.call(msg, self.target, timeout)
+ return None
infunc.__name__ = command
return infunc
diff --git a/vstf/vstf/controller/reporters/__init__.py b/vstf/vstf/controller/reporters/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/__init__.py
+++ b/vstf/vstf/controller/reporters/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/mail/__init__.py b/vstf/vstf/controller/reporters/mail/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/mail/__init__.py
+++ b/vstf/vstf/controller/reporters/mail/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/mail/mail.py b/vstf/vstf/controller/reporters/mail/mail.py
index 42d60b1a..2241d9ad 100755
--- a/vstf/vstf/controller/reporters/mail/mail.py
+++ b/vstf/vstf/controller/reporters/mail/mail.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import smtplib
import logging
import os
diff --git a/vstf/vstf/controller/reporters/mail/sendmail.py b/vstf/vstf/controller/reporters/mail/sendmail.py
index ecc6fe93..a4d7bb0a 100755
--- a/vstf/vstf/controller/reporters/mail/sendmail.py
+++ b/vstf/vstf/controller/reporters/mail/sendmail.py
@@ -1,9 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-07
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
from vstf.controller.reporters.mail.mail import Mail
diff --git a/vstf/vstf/controller/reporters/report/__init__.py b/vstf/vstf/controller/reporters/report/__init__.py
index 89dcd4e2..547db686 100755
--- a/vstf/vstf/controller/reporters/report/__init__.py
+++ b/vstf/vstf/controller/reporters/report/__init__.py
@@ -1,14 +1,10 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
diff --git a/vstf/vstf/controller/reporters/report/candy_generator.py b/vstf/vstf/controller/reporters/report/candy_generator.py
new file mode 100755
index 00000000..ea296550
--- /dev/null
+++ b/vstf/vstf/controller/reporters/report/candy_generator.py
@@ -0,0 +1,138 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.reporters.report.data_factory import TaskData
+from vstf.controller.database.dbinterface import DbManage
+import vstf.common.candy_text as candy
+import logging
+LOG = logging.getLogger(__name__)
+
+
+class CandyGenerator(object):
+ def __init__(self, task):
+ self._task = task
+
+ def create(self, scenario):
+ context = {}
+
+ sn = 1
+ chapterid = 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_env()
+
+ sn += 1
+ chapterid += 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_scenario(scenario)
+
+ template = TemplateSettings()
+ template.set_context(context)
+ LOG.info(template.settings)
+
+ def create_all(self):
+ context = {}
+
+ sn = 1
+ chapterid = 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_env()
+
+ scenarios = self._task.common.get_scenariolist()
+ for scenario in scenarios:
+ sn += 1
+ chapterid += 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_scenario(scenario)
+
+ template = TemplateSettings()
+ template.set_context(context)
+ LOG.info(template.settings)
+
+ def create_env(self):
+ env = {
+ "01##title#1": ["System Environment"],
+ "02##table#2": self._task.common.get_systeminfo()
+ }
+ return env
+
+ def create_scenario(self, scenario):
+ scenario_chapter = {
+ "01##title#1": ["Scenario Result"]
+ }
+ scenario_data = getattr(self._task, scenario)
+ test_list = scenario_data.get_testlist()
+ sectionid = 0
+ sn = 1
+ for test in test_list:
+ sn += 1
+ sectionid += 1
+ name = candy.tuple2text(sn, candy.section, sectionid)
+ testid = test.TestID
+ case = test.CaseTag.decode()
+ ttype = test.Type.decode()
+
+ params_info = [
+ " Case: " + case,
+ " Test tool: " + test.Tools.decode(),
+ " vSwitch: " + test.Switch.decode(),
+ " Protocol: " + test.Protocol.decode(),
+ " Type: " + ttype
+ ]
+ if ttype in ["frameloss", "throughput"]:
+ draw = {
+ "style": 1,
+ "node": candy.plot,
+ "data": scenario_data.get_framerate_chartdata(case, ttype)
+ }
+ table = scenario_data.get_ratedata(testid, ttype)
+ else:
+ draw = {
+ "style": 1,
+ "node": candy.chart,
+ "data": scenario_data.get_latency_bardata(case)
+ }
+ table = scenario_data.get_latency_tabledata(case)
+ test_section = self.create_test(sectionid, params_info, table, draw)
+ scenario_chapter[name] = test_section
+
+ return scenario_chapter
+
+ def create_test(self, section, info, table, draw):
+ """
+
+ :rtype : dict
+ """
+ sn = 7
+ draw_name = candy.tuple2text(sn, draw["node"], draw["style"])
+ case_section = {
+ "01##title#2": ["Test ID: %s" % section],
+ "02##paragraph#2": ["Parameter"],
+ "03##paragraph#3": info,
+ "04##paragraph#2": ["Result"],
+ "05##table#2": table,
+ "06##space#2": 2,
+ draw_name: draw["data"]
+ }
+ return case_section
+
+
+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)
+
+ dbase = DbManage()
+ taskid = dbase.get_last_taskid()
+ task = TaskData(taskid, dbase)
+ creator = CandyGenerator(task)
+
+ creator.create("Tn")
+if __name__ == '__main__':
+ main()
+
diff --git a/vstf/vstf/controller/reporters/report/data_factory.py b/vstf/vstf/controller/reporters/report/data_factory.py
index 39c534b6..f9fc69d9 100755
--- a/vstf/vstf/controller/reporters/report/data_factory.py
+++ b/vstf/vstf/controller/reporters/report/data_factory.py
@@ -1,11 +1,14 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-07-29
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
from vstf.controller.database.dbinterface import DbManage
+import vstf.common.constants as cst
class DataProvider(object):
@@ -15,59 +18,12 @@ class DataProvider(object):
class CommonData(DataProvider):
- def get_components(self):
- result = []
- query = self._dbase.query_exten_info(self._taskid)
- print "CommonData", query
- for item in query:
- if item[2]:
- context = "%s:%s(%s)" % (item[0], item[1], item[2])
- else:
- context = "%s:%s" % (item[0], item[1])
- result.append(context)
- return result
-
- def get_software(self):
- result = [
- " Host OS: ubuntu 14.04.2",
- " Guest OS: ubuntu 12.04.4"
- ]
- return result
-
- def get_hardware(self):
- result = [
- " Server: Dell R920",
- " CPU: E7-8893/2P/3.4GHz/10-Cores/37.5M-L3C",
- " MEM: 128G",
- " NIC: Intel 82599"
- ]
- return result
-
def get_taskname(self):
return self._dbase.query_taskname(self._taskid)
- def get_gitinfo_tabledata(self):
- result = []
- return result
-
- def get_profileparameters_tabledData(self):
- result = [
- ]
- return result
-
- def get_testingoptions_tabledata(self):
- result = [
- ]
- return result
-
- def get_systeminfo_tabledata(self):
- result = [
- ]
- return result
-
def get_systeminfo(self):
systable = [
- ['host', 'Server', 'CPU', 'MEM', 'NIC', 'OS'],
+ ['Host', 'Server', 'CPU', 'MEM', 'NIC', 'OS'],
]
query = self._dbase.query_task_host_list(self._taskid)
query = map(lambda x: list(x), query)
@@ -103,14 +59,6 @@ class CommonData(DataProvider):
return True
return False
- def get_contact(self):
- result = [
- "Name: xxx",
- "ID: xxxxxxxx",
- "Email: xxxx@xxx.com"
- ]
- return result
-
def get_casename(self, case):
return self._dbase.query_casename(case)
@@ -124,23 +72,6 @@ class ScenarioData(DataProvider):
DataProvider.__init__(self, taskid, dbase)
self._scenario = scenario
- def get_covertitle(self):
- result = [
- "",
- "",
- "Elastic Virtual Switching Performance "
- "Test Report",
- "Scenario %s" % (self._scenario)
- ]
- return result
-
- def get_test(self):
- result = [
- "Scenario: %s" % (self._scenario),
- "Configuration: without VLAN",
- ]
- return result
-
def get_test_tools(self, case):
query = self._dbase.query_casetools(self._taskid, case)
result = map(lambda x: list(x), query)
@@ -157,6 +88,13 @@ class ScenarioData(DataProvider):
else:
return result
+ def get_testlist(self):
+ query = self._dbase.query_testlist(self._taskid, self._scenario)
+ result = []
+ for item in query:
+ result.append(item.__dict__)
+ return query
+
def is_provider_start(self, case, provider):
count = self._dbase.query_case_provider_count(self._taskid, case, provider)
if count:
@@ -231,12 +169,27 @@ class ScenarioData(DataProvider):
]
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)"],
+ ]
+ 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,
+ item.AverageLatency])
+ result = []
+ if table_body:
+ result = table_head + table_body
+ return result
+
def get_tabledata(self, case, test_type, item):
type_dict = {
"FrameSize": "FrameSize (byte)",
"fastlink": "fastlink",
"l2switch": "l2switch",
"rdp": "kernel rdp",
+ None: "ovs",
"line": "line speed"
}
item_dict = {
@@ -244,11 +197,10 @@ class ScenarioData(DataProvider):
"Mpps": " ",
"Avg": " ",
}
- provider_list = ["fastlink", "rdp", "l2switch"]
table = []
line_speed = 20.0 if case in ["Tn-2v", "Tn-2"] else 10.0
- for provider in provider_list:
+ 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)
@@ -260,9 +212,9 @@ class ScenarioData(DataProvider):
if query:
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])
table.append([type_dict[provider]] + data)
@@ -362,7 +314,7 @@ class TaskData(object):
class HistoryData(DataProvider):
def get_data(self, task_list, case, provider, ttype, item):
"""
- @provider in ["fastlink", "rdp", "l2switch"]
+ @provider in ["fastlink", "rdp", "l2switch", ""]
@ttype in ["throughput", "frameloss", "latency"]
@item in ["avg", "ratep", "load"]
"""
@@ -415,7 +367,6 @@ class HistoryData(DataProvider):
return task_list
def get_history_info(self, case):
- providers = ["fastlink", "rdp", "l2switch"]
provider_dict = {"fastlink": "Fast Link ", "l2switch": "L2Switch ", "rdp": "Kernel RDP "}
ttype_dict = {
"throughput": "Throughput Testing ",
@@ -431,15 +382,14 @@ class HistoryData(DataProvider):
task_list = self.get_tasklist()
result = []
- ttypes = ["throughput", "frameloss", "latency"]
- for ttype in ttypes:
+ for ttype in cst.TTYPES:
content = {}
if ttype == "latency":
item = "avg"
else:
item = "ratep"
- for provider in providers:
+ for provider in cst.PROVIDERS:
table_data = self.get_data(task_list, case, provider, ttype, item)
if table_data:
data = {
@@ -451,9 +401,7 @@ class HistoryData(DataProvider):
content["data"].append(data)
if content:
result.append(content)
- print "xxxxxxxxxxxxxx"
print result
- print "xxxxxxxxxxxxxx"
return result
@@ -475,11 +423,10 @@ def unit_test():
case = "Tn-1"
- providers = ["fastlink", "rdp", "l2switch"]
ttypes = ["throughput", "frameloss"]
items = ["ratep", "load"]
- for provider in providers:
+ for provider in cst.PROVIDERS:
for ttype in ttypes:
for item in items:
print provider
diff --git a/vstf/vstf/controller/reporters/report/html/__init__.py b/vstf/vstf/controller/reporters/report/html/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/report/html/__init__.py
+++ b/vstf/vstf/controller/reporters/report/html/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/report/html/html_base.py b/vstf/vstf/controller/reporters/report/html/html_base.py
index 270ef394..36be5981 100755
--- a/vstf/vstf/controller/reporters/report/html/html_base.py
+++ b/vstf/vstf/controller/reporters/report/html/html_base.py
@@ -1,41 +1,43 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09.25
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__version__ = ''' '''
import os
-from vstf.common.pyhtml import *
+import vstf.common.pyhtml as pyhtm
class HtmlBase(object):
- def __init__(self, provider, ofile='text.html'):
- self._page = PyHtml('HtmlBase Text')
- self._ofile = ofile
+ def __init__(self, provider):
+ self._page = pyhtm.PyHtml('Html Text')
self._provider = provider
- self._chapter = 1
- def save(self):
- if self._ofile:
- os.system('rm -rf %s' % self._ofile)
- self._page.output(self._ofile)
+ def save(self, ofile):
+ if ofile:
+ os.system('rm -rf %s' % ofile)
+ self._page.output(ofile)
def as_string(self):
return self._page.as_string()
def add_table(self, data):
- self._page.add_table(data)
+ if data and zip(*data):
+ self._page.add_table(data)
def add_style(self):
- style = self._provider.get_style()
+ style = self._provider.get_style
self._page.add_style(style)
- def create(self, is_save=True):
+ def create(self, ofile='text.html'):
self.add_style()
self.create_story()
- if is_save:
- self.save()
+ self.save(ofile)
return self.as_string()
def create_story(self):
diff --git a/vstf/vstf/controller/reporters/report/html/html_text.py b/vstf/vstf/controller/reporters/report/html/html_text.py
deleted file mode 100755
index 86505b8f..00000000
--- a/vstf/vstf/controller/reporters/report/html/html_text.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-24
-# see license for license details
-__version__ = ''' '''
-
-import logging
-
-LOG = logging.getLogger(__name__)
-import vstf.common.constants as cst
-from vstf.controller.reporters.report.html.html_base import *
-
-
-class HtmlCreator(HtmlBase):
- def add_subject(self):
- title = self._provider.get_subject()
- self._page << H1(title)
-
- def add_ovs(self):
- title = "%s %s" % (self._chapter, self._provider.get_ovs_title())
- self._page << H2(title)
- data = self._provider.get_ovs_table()
- self.add_table(data)
- self._chapter += 1
-
- def add_result(self):
- title = "%s %s" % (self._chapter, self._provider.get_result_title())
- self._page << H2(title)
-
- section = 1
- for ttype in cst.TTYPES:
- data = self._provider.get_result_table(ttype)
- if data:
- title = "%s.%s %s" % (self._chapter, section, ttype.title())
- self._page << H3(title)
- self.add_table(data)
- section += 1
- self._chapter += 1
-
- def create_story(self):
- self.add_subject()
- self.add_ovs()
- self.add_result()
-
-
-def unit_test():
- from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/html-test.log", clevel=logging.INFO)
-
- from vstf.controller.settings.html_settings import HtmlSettings
- from vstf.controller.settings.data_settings import DataSettings
-
- html_settings = HtmlSettings()
- LOG.info(html_settings.settings)
- data_settings = DataSettings()
- LOG.info(data_settings.settings)
-
- from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
- provider = HtmlProvider(data_settings.settings, html_settings.settings)
- html = HtmlCreator(provider)
-
- result = html.create()
- print result
-
-
-if __name__ == '__main__':
- unit_test()
diff --git a/vstf/vstf/controller/reporters/report/html/htmlcreator.py b/vstf/vstf/controller/reporters/report/html/htmlcreator.py
index e6c75caf..1d150e28 100755
--- a/vstf/vstf/controller/reporters/report/html/htmlcreator.py
+++ b/vstf/vstf/controller/reporters/report/html/htmlcreator.py
@@ -1,117 +1,85 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-08-04
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__version__ = ''' '''
import logging
-from vstf.controller.reporters.report.data_factory import TaskData
-from vstf.controller.database.dbinterface import DbManage
-from vstf.controller.reporters.report.html.html_base import *
+import vstf.common.candy_text as candy
+from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.settings.html_settings import HtmlSettings
+from vstf.controller.reporters.report.html.html_base import HtmlBase, pyhtm
LOG = logging.getLogger(__name__)
-class HtmlvSwitchCreator(HtmlBase):
- def __init__(self, task_data, provider, ofile='creator.html'):
- HtmlBase.__init__(self, provider, ofile)
- self._task = task_data
- self._table_type = 'html'
-
+class HtmlCreator(HtmlBase):
def create_story(self):
- self.add_subject()
- self.add_gitinfo()
- self.add_envinfo()
- self.add_scenarios()
-
- def add_subject(self):
- job_name = "JOB_NAME: " + self._task.common.get_taskname()
- self._page << H2(job_name)
-
- def add_gitinfo(self):
- self._page << H2("Trigger and Repository Info")
-
- git_table = self._task.common.get_gitinfo_tabledata()
- if git_table:
- self.add_table(git_table)
-
- def add_envinfo(self):
- self._page << H2("System Environment Information")
- env_table = self._task.common.get_systeminfo()
- LOG.info(env_table)
- if env_table:
- self.add_table(env_table)
-
- def add_scenarios(self):
- scenario_list = self._task.common.get_scenariolist()
- self._page << H2("Scenario List: " + ', '.join(scenario_list))
- for scenario in scenario_list:
- self._page << H2("Scenario: " + scenario)
- data = getattr(self._task, scenario)
- self.add_scenario(data)
-
- def add_scenario(self, scenario_data):
- case_list = scenario_data.get_caselist()
- for case in case_list:
- self.add_case(scenario_data, case)
-
- def add_case(self, scenario_data, case):
- case_name = self._task.common.get_casename(case)
- title = "Case : %s (%s)" % (case, case_name)
- self._page << H2(title)
-
- provider_list = ["fastlink", "rdp", "l2switch"]
- provider_dict = {"fastlink": "Fast Link", "l2switch": "L2Switch", "rdp": "Kernel RDP"}
-
- for provider in provider_list:
- if scenario_data.is_provider_start(case, provider):
- title = " %s (%s_%s)" % (provider_dict[provider], case_name, provider)
- self._page << H3(title)
- test_types = ["throughput", "frameloss"]
- for test_type in test_types:
- if scenario_data.is_type_provider_start(case, provider, test_type):
- self.add_casedata(scenario_data, case, provider, test_type)
-
- if scenario_data.is_latency_start(case):
- self.add_latency_result(scenario_data, case)
-
- def add_casedata(self, scenario_data, case, provider, test_type):
- table_content = scenario_data.get_summary_tabledata(case, provider, test_type, self._table_type)
- if table_content:
- title = "Test type:%s" % (test_type)
- self._page << H4(title)
- self.add_table(table_content)
-
- def add_latency_result(self, scenario_data, case):
- title = "Average Latency Summary"
- table_content = scenario_data.get_latency_tabledata(case)
- if table_content:
- self._page << H2(title)
- self.add_table(table_content)
+ self.add_context()
+
+ def add_context(self):
+ context = self._provider.get_context
+ self._raw_context(context)
+
+ def _raw_context(self, context, ci=0, si=0, ui=0, level=-1):
+ _story = []
+ for key, value in sorted(context.items()):
+ LOG.info(key)
+ LOG.info(value)
+ _sn, _node, _style = candy.text2tuple(key)
+ if _node in candy.dom:
+ if _node == candy.chapter:
+ ci = _style
+ elif _node == candy.section:
+ si = _style
+ else:
+ ui = _style
+ self._raw_context(value, ci, si, ui, level + 1)
+
+ else:
+ LOG.info("node: %s %s" % (_node, candy.title))
+ if _node == candy.title:
+ assert value
+ if level in range(len(candy.dom)):
+ if level == 0:
+ value[0] = "Chapter %s %s" % (ci, value[0])
+ for title in value:
+ self._page << pyhtm.H2(title)
+ elif level == 1:
+ value[0] = "%s.%s %s" % (ci, si, value[0])
+ for title in value:
+ self._page << pyhtm.H3(title)
+ else:
+ value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0])
+ for title in value:
+ self._page << pyhtm.H3(title)
+
+ elif _node == candy.table:
+ self.add_table(value)
+ elif _node == candy.paragraph:
+ for para in value:
+ para = pyhtm.space(2) + para
+ self._page << pyhtm.P(para)
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)
- dbase = DbManage()
- taskid = dbase.get_last_taskid()
- task_data = TaskData(taskid, dbase)
-
- from vstf.controller.settings.html_settings import HtmlSettings
- from vstf.controller.reporters.report.provider.html_provider import StyleProvider
+ out_file = "vstf_report.html"
+ info = TemplateSettings()
html_settings = HtmlSettings()
- LOG.info(html_settings.settings)
-
- provider = StyleProvider(html_settings.settings)
- html = HtmlvSwitchCreator(task_data, provider)
-
- result = html.create(True)
- print result
-
+ provider = HtmlProvider(info.settings, html_settings.settings)
+ reporter = HtmlCreator(provider)
+ reporter.create(out_file)
if __name__ == '__main__':
unit_test()
diff --git a/vstf/vstf/controller/reporters/report/pdf/__init__.py b/vstf/vstf/controller/reporters/report/pdf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/report/pdf/__init__.py
+++ b/vstf/vstf/controller/reporters/report/pdf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/report/pdf/element.py b/vstf/vstf/controller/reporters/report/pdf/element.py
index 2528f2c5..78d1c59b 100755
--- a/vstf/vstf/controller/reporters/report/pdf/element.py
+++ b/vstf/vstf/controller/reporters/report/pdf/element.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-04
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__version__ = ''' '''
__doc__ = """
it contains the base element for pdf
diff --git a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
index 50b3bc65..4f7bd2a8 100755
--- a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
+++ b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
@@ -1,446 +1,129 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__version__ = ''' '''
-import os
-from vstf.controller.reporters.report.pdf.styles import TemplateStyle
from vstf.controller.reporters.report.pdf.pdftemplate import PdfVswitch
-from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, LineChartStory, \
- LinePlotStory, uTableStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory, cTableStory
-from vstf.controller.reporters.report.data_factory import CommonData, ScenarioData, HistoryData
-from vstf.controller.database.dbinterface import DbManage
-import vstf.controller
-
+from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, TableStory, \
+ LinePlotStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory
+import vstf.common.candy_text as candy
+from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider
+from vstf.controller.settings.template_settings import TemplateSettings
-class LetterOrder(object):
- def __init__(self):
- self.lettertable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- self._cur = 0
- self._len = len(self.lettertable)
-
- def get(self):
- return self.lettertable[self._cur]
-
- def pre(self):
- self._cur = (self._cur + self._len - 1) % self._len
+import os
+import logging
- def next(self):
- self._cur = (self._cur + 1) % self._len
+LOG = logging.getLogger(__name__)
-class PdfBase(object):
- def __init__(self):
- self._case = ''
- self._ofile = ''
- self._title = []
+class PdfCreator(object):
+ def __init__(self, provider):
+ self._provider = provider
self._story = []
- self._rootdir = os.path.dirname(vstf.controller.__file__) + '/'
self._pdf = None
def create_pdf(self):
- style = TemplateStyle(name='default')
- title = self._title
- logo = [self._rootdir + "res/logo.jpg"]
- header = ['']
- footer = [""]
- note = ['', '']
- output = [self._ofile]
- self._pdf = PdfFrameLoss(style, title, logo, header, footer, output, note)
+ theme = self._provider.get_theme
+ self._pdf = PdfVswitch(theme["title"],
+ theme["logo"],
+ theme["header"],
+ theme["footer"],
+ theme["note"],
+ theme["style"])
- def save_pdf(self):
- self._pdf.generate(self._story)
+ def save_pdf(self, ofile):
+ self._pdf.generate(self._story, ofile)
def add_coverpage(self):
story = Story()
story = PageBreakStory(story)
self._story += story.storylist
- def create_story(self):
- raise NotImplementedError("abstract PdfBase")
-
- def create(self):
- self.create_pdf()
- self.create_story()
- self.save_pdf()
-
-
-class PdfvSwitchCreator(PdfBase):
- def __init__(self, ofile, common_data, scenario_data, history_data):
- PdfBase.__init__(self)
- self._common = common_data
- self._result = scenario_data
- self._history = history_data
- self._ofile = ofile
- self._chapterid = 0
- self._appendixid = LetterOrder()
-
- def create_pdf(self):
- style = TemplateStyle(name='default')
- title = self._result.get_covertitle()
- logo = [self._rootdir + "res/logo.jpg"]
- header = ['']
- footer = [""]
- note = ['', '']
- output = [self._ofile]
- self._pdf = PdfVswitch(style, title, logo, header, footer, output, note)
-
- def get_chapterid(self):
- self._chapterid = self._chapterid + 1
- return self._chapterid
+ def add_contents(self):
+ if self._provider.ifcontents:
+ story = Story()
+ story = TableOfContentsStory(story)
+ self._story += story.storylist
def create_story(self):
self.add_coverpage()
- self.add_table_of_contents()
- # self.add_contact()
- # self.add_overview()
- self.add_scenario()
- # self.add_info()
- # self.add_appendix()
- self.add_historys()
-
- def add_info(self):
- self.add_systeminfo()
- self.add_gitinfo()
- self.add_profile_parameters()
- self.add_testing_options()
-
- def add_contact(self):
- story = Story()
- story = SpaceStory(story)
- title = ["", "", "", "Reporter"]
- body = self._common.get_contact()
- story = TitleStory(story, data=title, style=7)
- story = ParagraphStory(story, data=body)
- self._story += story.storylist
-
- def add_table_of_contents(self):
- story = Story()
- story = TableOfContentsStory(story)
- self._story += story.storylist
-
- def add_overview(self):
- story = Story()
- story = PageBreakStory(story)
-
- chapterid = self.get_chapterid()
- title = ["%d.Overview" % (chapterid)]
- body = [""]
- story = TitleStory(story, data=title, style=1)
- story = ParagraphStory(story, data=body)
-
- sectionid = 1
- title = ["%d.%d Components under Test" % (chapterid, sectionid)]
- body = self._common.get_components()
- story = TitleStory(story, data=title, style=2)
- story = ParagraphStory(story, data=body)
-
- sectionid = sectionid + 1
- title = ["%d.%d Test" % (chapterid, sectionid)]
- body = self._result.get_test()
- story = TitleStory(story, data=title, style=2)
- story = ParagraphStory(story, data=body)
-
- sectionid = sectionid + 1
- title = ["%d.%d Configuration" % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
-
- title = ["Software"]
- body = self._common.get_software()
- story = TitleStory(story, data=title, style=6)
- story = ParagraphStory(story, data=body)
-
- title = ["Hardware"]
- body = self._common.get_hardware()
- story = TitleStory(story, data=title, style=6)
- story = ParagraphStory(story, data=body)
- self._story += story.storylist
-
- def add_scenario(self):
- case_list = self._result.get_caselist()
- for case in case_list:
- self.add_case(case)
-
- def add_case(self, case):
- story = Story()
- chapterid = self.get_chapterid()
-
- title = ["%d. Case : %s (%s)" % (chapterid, case, self._common.get_casename(case))]
-
- tools = self._result.get_test_tools(case)
- pic = self._common.get_casefigure(case, tools)
- print pic
-
- story = TitleStory(story, data=title, style=1)
- story = SpaceStory(story)
- story = ImageStory(story, data=[self._rootdir + pic])
- story = SpaceStory(story)
-
- sectionid = 1
- story = self.add_summary(story, chapterid, sectionid, case)
- story = SpaceStory(story)
-
- if self._result.is_throughput_start(case):
- sectionid = sectionid + 1
- story = self.add_throughput_result(story, chapterid, sectionid, case)
-
- if self._result.is_frameloss_start(case):
- sectionid = sectionid + 1
- story = self.add_frameloss_result(story, chapterid, sectionid, case)
-
- if self._result.is_latency_start(case):
- sectionid = sectionid + 1
- story = self.add_latency_result(story, chapterid, sectionid, case)
-
- story = SpaceStory(story)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_summary(self, story, chapterid, sectionid, case):
- title = ["%d.%d Summary" % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- provider_list = ["fastlink", "rdp", "l2switch"]
- provider_dict = {"fastlink": "Fast Link", "l2switch": "L2Switch", "rdp": "Kernel RDP"}
- unitid = 1
- case_name = self._common.get_casename(case)
- for provider in provider_list:
- if self._result.is_provider_start(case, provider):
- title = ["%d.%d.%d %s (%s_%s)" % (
- chapterid, sectionid, unitid, provider_dict[provider], case_name, provider)]
- unitid = unitid + 1
- story = TitleStory(story, data=title, style=6)
- test_types = ["throughput", "frameloss"]
- for test_type in test_types:
- if self._result.is_type_provider_start(case, provider, test_type):
- story = self.add_summary_type(story, case, provider, test_type)
- return story
-
- def add_summary_type(self, story, case, provider, test_type):
- bar_list = [test_type, "latency"]
- for item in bar_list:
- bar_data = self._result.get_bardata(case, provider, item)
- story = SpaceStory(story)
- story = BarChartStory(story, data=bar_data)
-
- table_content = self._result.get_summary_tabledata(case, provider, test_type)
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=3)
- story = SpaceStory(story)
- return story
+ self.add_contents()
+ self.add_context()
- def add_throughput_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Throughput " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "throughput"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_frameloss_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Frame Loss Rate " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "frameloss"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_latency_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Latency " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- unit = 'Average Latency'
- title = [unit + ' (uSec)']
- # chart_data = self._result.get_latency_chartdata(case)
- bar_data = self._result.get_latency_bardata(case)
- table_data = self._result.get_latency_tabledata(case)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = BarChartStory(story, data=bar_data)
-
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_systeminfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. System Information " % (chapterid)]
- story = PageBreakStory(story)
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_systeminfo_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=0)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_gitinfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- title = ["%d. Git Repository Information " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
-
- table_content = self._common.get_gitinfo_tabledata()
- if table_content:
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=5)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_testing_options(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. Testing Options" % (chapterid)]
-
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_testingoptions_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=1)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_profile_parameters(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = PageBreakStory(story)
- title = ["%d. " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_profileparameters_tabledData()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=2)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_appendix(self):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s: vSwitching Testing Methodology</b>" % (self._appendixid.get())]
- self._appendixid.next()
- story = TitleStory(story, data=title, style=1)
- filename = "res/Traffic-types.jpg"
- story = SpaceStory(story)
- story = ImageStory(story, data=[self._rootdir + filename])
- # story = SpaceStory(story)
-
- title = ["Traffic Patterns: "]
- story = TitleStory(story, data=title, style=6)
-
- body = [
- "<b>Ti</b> - South North Traffic",
- "<b>Tu</b> - East Eest Traffic",
- "<b>Tn</b> - Physical host or VM loop back",
- "<b>Tnv</b> - Virtual Machine loop back",
- ]
- story = ParagraphStory(story, data=body)
-
- title = ["<b>Performance Testing Coverage </b> (version 0.1):"]
- story = TitleStory(story, data=title, style=6)
-
- table_content = self._common.get_introduct_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=4)
- self._story += story.storylist
-
- def add_historys(self):
- case_list = self._result.get_caselist()
- for case in case_list:
- history = self._history.get_history_info(case)
- if history:
- self.add_history(case, history)
-
- def add_history(self, case, history):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s : %s History Records</b>" % (self._appendixid.get(), case)]
- story = TitleStory(story, data=title, style=1)
-
- for i in range(len(history)):
- title = ["%s.%s %s" % (self._appendixid.get(), i, history[i]["title"])]
- story = TitleStory(story, data=title, style=2)
-
- section = history[i]["data"]
- for unit in section:
- title = [unit['title']]
- story = TitleStory(story, data=title, style=6)
- content = unit['data']
- story = uTableStory(story, data=content)
-
- self._appendixid.next()
- self._story += story.storylist
+ def create(self, ofile):
+ self.create_pdf()
+ self.create_story()
+ self.save_pdf(ofile)
+
+ def add_context(self):
+ context = self._provider.get_context
+ self._story += self._raw_context(context)
+
+ def _raw_context(self, context, ci=0, si=0, ui=0, level=-1):
+ _story = []
+ for key, value in sorted(context.items()):
+ LOG.info(key)
+ LOG.info(value)
+ _sn, _node, _style = candy.text2tuple(key)
+ if _node in candy.dom:
+ if _node == candy.chapter:
+ ci = _style
+ elif _node == candy.section:
+ si = _style
+ else:
+ ui = _style
+ _story += self._raw_context(value, ci, si, ui, level + 1)
+
+ else:
+ story = Story()
+ LOG.info("node: %s %s" % (_node, candy.title))
+ if _node == candy.title:
+ assert value
+ if level in range(len(candy.dom)):
+ if level == 0:
+ value[0] = "Chapter %s %s" % (ci, value[0])
+ story = PageBreakStory(story)
+ elif level == 1:
+ value[0] = "%s.%s %s" % (ci, si, value[0])
+ else:
+ value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0])
+ LOG.info(value)
+ story = TitleStory(story, data=value, style=_style)
+ elif _node == candy.table:
+ story = TableStory(story, data=value, style=_style)
+ elif _node == candy.figure:
+ story = ImageStory(story, data=value, style=_style)
+ elif _node == candy.paragraph:
+ story = ParagraphStory(story, data=value, style=_style)
+ elif _node == candy.plot:
+ story = LinePlotStory(story, data=value, style=_style)
+ elif _node == candy.chart:
+ story = BarChartStory(story, data=value, style=_style)
+ elif _node == candy.space:
+ assert isinstance(value, int)
+ for i in range(value):
+ story = SpaceStory(story)
+ _story += story.storylist
+ return _story
def main():
- dbase = DbManage()
- taskid = dbase.get_last_taskid()
- common_data = CommonData(taskid, dbase)
- scenario_list = common_data.get_scenariolist()
- history_data = HistoryData(taskid, dbase)
- for scenario in scenario_list:
- out_file = "vstf_report_%s.pdf" % (scenario)
- scenario_data = ScenarioData(taskid, dbase, scenario)
- reporter = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data)
- if reporter:
- reporter.create()
+ from vstf.common.log import setup_logging
+ setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-creator.log", clevel=logging.INFO)
+
+ out_file = "vstf_report.pdf"
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ reporter = PdfCreator(provider)
+ reporter.create(out_file)
if __name__ == '__main__':
main()
diff --git a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
index 819a5c57..69c65401 100755
--- a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
+++ b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
@@ -1,13 +1,21 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import time
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
-class MyDocTemplate(SimpleDocTemplate):
+class BaseDocTemplate(SimpleDocTemplate):
def __init__(self, filename, **kw):
self.allowSplitting = 0
SimpleDocTemplate.__init__(self, filename, **kw)
@@ -25,17 +33,16 @@ class MyDocTemplate(SimpleDocTemplate):
self.notify('TOCEntry', (2, text, self.page - 1))
-class PdfTemplate:
- def __init__(self, style, title, logo, header, footer, output, note=None):
- self._style = style
+class PdfTemplate(object):
+ def __init__(self, title, logo, header, footer, note=[], style="default"):
+ self._style = TemplateStyle(name=style)
self._title = title
self._logo = logo[0]
- self._header = header[0]
+ #self._header = header[0]
self._footer = footer
- self._output = output[0]
self._note = note
- info = " Generated on %s " % time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())
- self._note[0] += info
+ info = " Generated on %s " % time.strftime(cst.TIME_FORMAT2, time.localtime())
+ self._note += [info]
def myFirstPage(self, canvas, doc):
raise NotImplementedError("abstract StoryDecorator")
@@ -43,9 +50,9 @@ class PdfTemplate:
def myLaterPages(self, canvas, doc):
raise NotImplementedError("abstract StoryDecorator")
- def generate(self, story):
+ def generate(self, story, output):
sizes = (self._style.page_wight, self._style.page_height)
- doc = MyDocTemplate(self._output, pagesize=sizes)
+ doc = BaseDocTemplate(output, pagesize=sizes)
# doc.build(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
doc.multiBuild(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
diff --git a/vstf/vstf/controller/reporters/report/pdf/story.py b/vstf/vstf/controller/reporters/report/pdf/story.py
index 3e56e185..940c20fb 100755
--- a/vstf/vstf/controller/reporters/report/pdf/story.py
+++ b/vstf/vstf/controller/reporters/report/pdf/story.py
@@ -1,5 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
__doc__ = """
Story Decorator contains ImageStory, HeaderStory, PageBreakStory,
TableStory, LinePlotStory, TitleStory, ParagraphStory
@@ -88,44 +95,32 @@ class TableOfContentsStory(StoryDecorator):
self._story.storylist.append(toc)
-class uTableStory(StoryDecorator):
- def new_story(self):
- print "utable story"
- style = ts_left
- if not self._data:
- print "data error "
- return
- self._story.storylist.append(eCommonTable(self._data, style).table)
-
-
-class TableStory(StoryDecorator):
- def new_story(self):
- print "table story"
- style = ts_default
- self._story.storylist.append(eDataTable(self._data, style).table)
-
-
class SpaceStory(StoryDecorator):
def new_story(self):
style = ps_space
self._story.storylist.append(eParagraph([" ", " "], style).para)
-class cTableStory(StoryDecorator):
+class TableStory(StoryDecorator):
def new_story(self):
print "table story"
style = ts_default
- if self._style == 0:
+ if self._style == 1:
+ self._story.storylist.append(eDataTable(self._data, style).table)
+ 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 == 1:
+ elif self._style == 4:
self._story.storylist.append(eOptionsTable(self._data, style).table)
- elif self._style == 2:
+ elif self._style == 5:
self._story.storylist.append(eProfileTable(self._data, style).table)
- elif self._style == 3:
+ elif self._style == 6:
self._story.storylist.append(eSummaryTable(self._data, style).table)
- elif self._style == 4:
+ elif self._style == 7:
self._story.storylist.append(eScenarioTable(self._data, style).table)
- elif self._style == 5:
+ elif self._style == 8:
self._story.storylist.append(eGitInfoTable(self._data, style).table)
diff --git a/vstf/vstf/controller/reporters/report/pdf/styles.py b/vstf/vstf/controller/reporters/report/pdf/styles.py
index d54ee8ab..2860c245 100755
--- a/vstf/vstf/controller/reporters/report/pdf/styles.py
+++ b/vstf/vstf/controller/reporters/report/pdf/styles.py
@@ -1,10 +1,17 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
from reportlab.lib.styles import PropertySet
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import ParagraphStyle
-from reportlab.lib.enums import TA_LEFT
+import reportlab.lib.enums as ens
class TemplateStyle(PropertySet):
@@ -108,20 +115,14 @@ class BarChartStyle(PropertySet):
"fastlink": (colors.pink, '%4.1f'),
"l2switch": (colors.lightblue, '%4.1f'),
"kernel rdp": (colors.lightgreen, '%4.1f'),
+ "ovs": (colors.purple, '%4.1f')
},
background=colors.lightgrey,
labelsfont=6,
)
-ts_left = TableStyle(
- name='left',
- table_hAlign='LEFT', # LEFT,CENTRE or RIGHT
- table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP
- table_colWidths=None,
- table_rowHeights=None
-)
-
+tes_default = TemplateStyle(name='default')
is_default = ImageStyle(name='default')
is_traffic = ImageStyle(name='traffic',
image_height=150,
@@ -129,12 +130,19 @@ is_traffic = ImageStyle(name='traffic',
image_hAlign='CENTRE')
ts_default = TableStyle(name='default')
+ts_left = TableStyle(
+ name='left',
+ table_hAlign='LEFT', # LEFT,CENTRE or RIGHT
+ table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP
+ table_colWidths=None,
+ table_rowHeights=None
+)
lps_default = LinePlotStyle(name='default')
lcs_default = LineChartStyle(name='default')
bcs_default = BarChartStyle(name='default')
ps_head_lv1 = ParagraphStyle(name='ps_head_lv1',
fontName='Courier-Bold',
- alignment=TA_LEFT, # TA_CENTRE,
+ alignment=ens.TA_CENTER, # TA_LEFT, TA_RIGHT
fontSize=13,
leading=22,
leftIndent=0)
diff --git a/vstf/vstf/controller/reporters/report/provider/__init__.py b/vstf/vstf/controller/reporters/report/provider/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/reporters/report/provider/__init__.py
+++ b/vstf/vstf/controller/reporters/report/provider/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/vstf/vstf/controller/reporters/report/provider/html_provider.py b/vstf/vstf/controller/reporters/report/provider/html_provider.py
index b0b07432..74c4c593 100755
--- a/vstf/vstf/controller/reporters/report/provider/html_provider.py
+++ b/vstf/vstf/controller/reporters/report/provider/html_provider.py
@@ -1,63 +1,45 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
LOG = logging.getLogger(__name__)
from vstf.controller.settings.html_settings import HtmlSettings
-from vstf.controller.settings.data_settings import DataSettings
+from vstf.controller.settings.template_settings import TemplateSettings
class HtmlProvider(object):
- def __init__(self, content, style):
- self._content = content
+ def __init__(self, info, style):
+ self._info = info
self._style = style
+ @property
def get_style(self):
+ assert "style" in self._style
return self._style["style"]
- def get_subject(self):
- return self._content["subject"]
-
- def get_ovs_title(self):
- return self._content["ovs"]["title"]
-
- def get_ovs_table(self):
- return map(lambda x: list(x), self._content["ovs"]["content"].items())
-
- def get_result_title(self):
- return self._content["result"]["title"]
-
- def get_result_table(self, ttype):
- result = []
- content = self._content["result"]["content"]
- if ttype in content:
- result.append(content[ttype]["columns"])
- result.extend(content[ttype]["data"])
-
- result = map(lambda x: list(x), zip(*result))
- return result
-
-
-class StyleProvider(object):
- def __init__(self, style):
- self._style = style
-
- def get_style(self):
- return self._style["style"]
+ @property
+ def get_context(self):
+ assert "context" in self._info
+ return self._info["context"]
-def unit_test():
+def main():
from vstf.common.log import setup_logging
setup_logging(level=logging.DEBUG, log_file="/var/log/html-provder.log", clevel=logging.INFO)
html_settings = HtmlSettings()
LOG.info(html_settings.settings)
- data_settings = DataSettings()
- LOG.info(data_settings.settings)
+ info = TemplateSettings()
+ provider = HtmlProvider(info.settings, html_settings.settings)
+ LOG.info(provider.get_style)
+ LOG.info(provider.get_context)
- hprovider = HtmlProvider(data_settings.settings, html_settings.settings)
- sprovider = StyleProvider(html_settings.settings)
+if __name__ == '__main__':
+ main() \ No newline at end of file
diff --git a/vstf/vstf/controller/reporters/report/provider/pdf_provider.py b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py
new file mode 100755
index 00000000..bc9f0e96
--- /dev/null
+++ b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py
@@ -0,0 +1,51 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+
+__version__ = ''' '''
+import logging
+
+LOG = logging.getLogger(__name__)
+from vstf.controller.settings.template_settings import TemplateSettings
+
+
+class PdfProvider(object):
+ def __init__(self, info):
+ self._info = info
+
+ @property
+ def get_theme(self):
+ assert "theme" in self._info
+ return self._info["theme"]
+
+ @property
+ def ifcontents(self):
+ assert "contents" in self._info
+ assert "enable" in self._info["contents"]
+ return self._info["contents"]["enable"]
+
+ @property
+ def get_context(self):
+ assert "context" in self._info
+ return self._info["context"]
+
+
+def main():
+ from vstf.common.log import setup_logging
+ setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO)
+
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ LOG.info(provider.get_theme)
+ LOG.info(provider.ifcontents)
+ LOG.info(provider.get_context)
+
+if __name__ == '__main__':
+ main() \ No newline at end of file
diff --git a/vstf/vstf/controller/reporters/reporter.py b/vstf/vstf/controller/reporters/reporter.py
index 1c256c61..e77ae349 100755
--- a/vstf/vstf/controller/reporters/reporter.py
+++ b/vstf/vstf/controller/reporters/reporter.py
@@ -1,21 +1,28 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import os
import argparse
import logging
import time
-from vstf.controller.reporters.report.pdf.pdfcreator import PdfvSwitchCreator
-from vstf.controller.reporters.report.html.htmlcreator import HtmlvSwitchCreator
-from vstf.controller.reporters.report.data_factory import CommonData, TaskData, ScenarioData, HistoryData
+from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
+from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.reporters.report.data_factory import TaskData
+from vstf.controller.reporters.report.html.htmlcreator import HtmlCreator
+from vstf.controller.reporters.report.pdf.pdfcreator import PdfCreator
from vstf.controller.database.dbinterface import DbManage
from vstf.controller.settings.mail_settings import MailSettings
from vstf.controller.reporters.mail.sendmail import SendMail
from vstf.controller.settings.html_settings import HtmlSettings
-from vstf.controller.reporters.report.provider.html_provider import StyleProvider
+from vstf.controller.reporters.report.candy_generator import CandyGenerator
import vstf.common.constants as cst
@@ -31,37 +38,44 @@ class Report(object):
"""
self._dbase = dbase
self._rpath = "."
+ self._mail_settings = MailSettings()
if os.path.exists(rpath):
self._rpath = rpath
def create_pdf(self, taskid):
- common_data = CommonData(taskid, self._dbase)
- scenario_list = common_data.get_scenariolist()
- history_data = HistoryData(taskid, self._dbase)
+ task = TaskData(taskid, self._dbase)
+ scenario_list = task.common.get_scenariolist()
+ 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_STR)))
+ out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_FORMAT3)))
LOG.info(out_file)
- scenario_data = ScenarioData(taskid, self._dbase, scenario)
- pdf = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data)
- if pdf:
- pdf.create()
- attach_list.append(out_file)
+ creator.create(scenario)
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ reporter = PdfCreator(provider)
+ reporter.create(out_file)
+ attach_list.append(out_file)
+
if attach_list:
self._mail_settings.mset_attach(attach_list)
def create_html(self, taskid):
- task_data = TaskData(taskid, self._dbase)
+ task = TaskData(taskid, self._dbase)
+
+ creator = CandyGenerator(task)
+ creator.create_all()
html_settings = HtmlSettings()
+ info = TemplateSettings()
LOG.info(html_settings.settings)
- provider = StyleProvider(html_settings.settings)
+ provider = HtmlProvider(info.settings, html_settings.settings)
out_file = os.path.join(self._rpath, "mail.html")
LOG.info(out_file)
- html = HtmlvSwitchCreator(task_data, provider, out_file)
- content = html.create()
+ html = HtmlCreator(provider)
+ content = html.create(out_file)
self._mail_settings.mset_subtype('html')
self._mail_settings.mset_content(content)
diff --git a/vstf/vstf/controller/res/__init__.py b/vstf/vstf/controller/res/__init__.py
deleted file mode 100755
index 89dcd4e2..00000000
--- a/vstf/vstf/controller/res/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
diff --git a/vstf/vstf/controller/settings/__init__.py b/vstf/vstf/controller/settings/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/settings/__init__.py
+++ b/vstf/vstf/controller/settings/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/vstf/vstf/controller/settings/cpu_settings.py b/vstf/vstf/controller/settings/cpu_settings.py
index c69742ad..a25af4c1 100755
--- a/vstf/vstf/controller/settings/cpu_settings.py
+++ b/vstf/vstf/controller/settings/cpu_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
import pprint
diff --git a/vstf/vstf/controller/settings/data_settings.py b/vstf/vstf/controller/settings/data_settings.py
deleted file mode 100755
index d9878bf2..00000000
--- a/vstf/vstf/controller/settings/data_settings.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-
-import logging
-
-import vstf.controller.settings.settings as sets
-
-LOG = logging.getLogger(__name__)
-
-
-class DataSettings(sets.Settings):
- def __init__(self, path="/etc/vstf/reporter/",
- filename="reporters.html.data-settings",
- mode=sets.SETS_SINGLE):
- super(DataSettings, self).__init__(path, filename, mode)
-
- def _register_func(self):
- super(DataSettings, self)._register_func()
- items = {"ovs", "result"}
- fkeys = {"title", "content"}
- for item in items:
- item = item.encode()
- for key in fkeys:
- key = key.encode()
- func_name = "set_%s_%s" % (item, key)
- setattr(self, func_name, self._setting_file(func_name, self._mset[item], self._fset[item], key))
- func_name = "mset_%s_%s" % (item, key)
- setattr(self, func_name, self._setting_memory(func_name, self._mset[item], key)) \ No newline at end of file
diff --git a/vstf/vstf/controller/settings/device_settings.py b/vstf/vstf/controller/settings/device_settings.py
index 45bc9eb1..25f2c5bf 100755
--- a/vstf/vstf/controller/settings/device_settings.py
+++ b/vstf/vstf/controller/settings/device_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
diff --git a/vstf/vstf/controller/settings/flows_settings.py b/vstf/vstf/controller/settings/flows_settings.py
index b2bec625..9cd1a1b7 100755
--- a/vstf/vstf/controller/settings/flows_settings.py
+++ b/vstf/vstf/controller/settings/flows_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-18
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
diff --git a/vstf/vstf/controller/settings/forwarding_settings.py b/vstf/vstf/controller/settings/forwarding_settings.py
index 67ec3f85..636ddfda 100755
--- a/vstf/vstf/controller/settings/forwarding_settings.py
+++ b/vstf/vstf/controller/settings/forwarding_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
diff --git a/vstf/vstf/controller/settings/html_settings.py b/vstf/vstf/controller/settings/html_settings.py
index 7e715100..ce87733e 100755
--- a/vstf/vstf/controller/settings/html_settings.py
+++ b/vstf/vstf/controller/settings/html_settings.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
diff --git a/vstf/vstf/controller/settings/mail_settings.py b/vstf/vstf/controller/settings/mail_settings.py
index fd66b5c2..a2d2d6df 100755
--- a/vstf/vstf/controller/settings/mail_settings.py
+++ b/vstf/vstf/controller/settings/mail_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-06
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
import pprint
diff --git a/vstf/vstf/controller/settings/perf_settings.py b/vstf/vstf/controller/settings/perf_settings.py
index c0c8123b..610cb4ae 100755
--- a/vstf/vstf/controller/settings/perf_settings.py
+++ b/vstf/vstf/controller/settings/perf_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-28
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import pprint
import logging
@@ -50,7 +53,7 @@ class PerfSettings(sets.Settings):
@deco.dcheck('sizes')
@deco.dcheck("type", choices=cst.TTYPES)
- @deco.dcheck("profile", choices=cst.PROFILES)
+ @deco.dcheck("profile", choices=cst.PROVIDERS)
@deco.dcheck("protocol", choices=cst.TPROTOCOLS)
@deco.dcheck("tool", choices=cst.TOOLS)
@deco.dcheck('case')
@@ -74,7 +77,7 @@ class PerfSettings(sets.Settings):
@deco.vstf_input('sizes', types=list)
@deco.vstf_input("type", types=str, choices=cst.TTYPES)
- @deco.vstf_input("profile", types=str, choices=cst.PROFILES)
+ @deco.vstf_input("profile", types=str, choices=cst.PROVIDERS)
@deco.vstf_input("protocol", types=str, choices=cst.TPROTOCOLS)
@deco.vstf_input("tool", types=str, choices=cst.TOOLS)
@deco.vstf_input('case')
diff --git a/vstf/vstf/controller/settings/settings.py b/vstf/vstf/controller/settings/settings.py
index 4730c8db..2c712bb2 100755
--- a/vstf/vstf/controller/settings/settings.py
+++ b/vstf/vstf/controller/settings/settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-06
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import json
import re
diff --git a/vstf/vstf/controller/settings/settings_input.py b/vstf/vstf/controller/settings/settings_input.py
index 2c262842..59652ed5 100755
--- a/vstf/vstf/controller/settings/settings_input.py
+++ b/vstf/vstf/controller/settings/settings_input.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-10-16
-# see license for license details
-
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import clize
from sigtools.modifiers import autokwoargs
diff --git a/vstf/vstf/controller/settings/template_settings.py b/vstf/vstf/controller/settings/template_settings.py
new file mode 100755
index 00000000..b677c539
--- /dev/null
+++ b/vstf/vstf/controller/settings/template_settings.py
@@ -0,0 +1,22 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+import logging
+
+import vstf.controller.settings.settings as sets
+
+LOG = logging.getLogger(__name__)
+
+
+class TemplateSettings(sets.Settings):
+ def __init__(self, path="/etc/vstf/reporter/",
+ filename="reporters.template-settings",
+ mode=sets.SETS_SINGLE):
+ super(TemplateSettings, self).__init__(path, filename, mode)
diff --git a/vstf/vstf/controller/settings/tester_settings.py b/vstf/vstf/controller/settings/tester_settings.py
index fb116a8d..554c8042 100755
--- a/vstf/vstf/controller/settings/tester_settings.py
+++ b/vstf/vstf/controller/settings/tester_settings.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/17
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
diff --git a/vstf/vstf/controller/settings/tool_settings.py b/vstf/vstf/controller/settings/tool_settings.py
index 1d543e6a..a84bc59f 100755
--- a/vstf/vstf/controller/settings/tool_settings.py
+++ b/vstf/vstf/controller/settings/tool_settings.py
@@ -1,8 +1,12 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-18
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
import pprint
diff --git a/vstf/vstf/controller/spirent/__init__.py b/vstf/vstf/controller/spirent/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/spirent/__init__.py
+++ b/vstf/vstf/controller/spirent/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/spirent/appliance.py b/vstf/vstf/controller/spirent/appliance.py
index a06bf452..d4c5be64 100755
--- a/vstf/vstf/controller/spirent/appliance.py
+++ b/vstf/vstf/controller/spirent/appliance.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-"""
- @author: l00190809
- @group: Huawei Ltd
-"""
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import os
import logging
diff --git a/vstf/vstf/controller/spirent/common/__init__.py b/vstf/vstf/controller/spirent/common/__init__.py
index 0e98d82e..c354d1f9 100755
--- a/vstf/vstf/controller/spirent/common/__init__.py
+++ b/vstf/vstf/controller/spirent/common/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License. \ No newline at end of file
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/vstf/vstf/controller/spirent/common/model.py b/vstf/vstf/controller/spirent/common/model.py
index 511eab40..a29794f4 100755
--- a/vstf/vstf/controller/spirent/common/model.py
+++ b/vstf/vstf/controller/spirent/common/model.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-"""
- @author: l00190809
- @group: Huawei Ltd
-"""
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import re
import copy
import time
diff --git a/vstf/vstf/controller/spirent/common/result_analysis.py b/vstf/vstf/controller/spirent/common/result_analysis.py
index 162e3888..b09a846d 100755
--- a/vstf/vstf/controller/spirent/common/result_analysis.py
+++ b/vstf/vstf/controller/spirent/common/result_analysis.py
@@ -1,4 +1,12 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import re
diff --git a/vstf/vstf/controller/sw_perf/__init__.py b/vstf/vstf/controller/sw_perf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/sw_perf/__init__.py
+++ b/vstf/vstf/controller/sw_perf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/sw_perf/flow_producer.py b/vstf/vstf/controller/sw_perf/flow_producer.py
index 1de4161c..4a3b02c2 100755
--- a/vstf/vstf/controller/sw_perf/flow_producer.py
+++ b/vstf/vstf/controller/sw_perf/flow_producer.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-11-19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
diff --git a/vstf/vstf/controller/sw_perf/model.py b/vstf/vstf/controller/sw_perf/model.py
index 672daade..c49df041 100755
--- a/vstf/vstf/controller/sw_perf/model.py
+++ b/vstf/vstf/controller/sw_perf/model.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date:
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
@@ -161,7 +164,11 @@ class CpuWatcher(Fabricant):
def __init__(self, dst, conn):
super(CpuWatcher, self).__init__(dst, conn)
self._pid = None
- self._data = {}
+ self._data = {
+ "cpu_num": 0,
+ "idle": 0,
+ "cpu_mhz": 0
+ }
def start(self):
print "CpuWatcher.start"
diff --git a/vstf/vstf/controller/sw_perf/perf_provider.py b/vstf/vstf/controller/sw_perf/perf_provider.py
index bd1027ad..396e6eef 100755
--- a/vstf/vstf/controller/sw_perf/perf_provider.py
+++ b/vstf/vstf/controller/sw_perf/perf_provider.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-21
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import logging
diff --git a/vstf/vstf/controller/sw_perf/performance.py b/vstf/vstf/controller/sw_perf/performance.py
index 6ca8160e..7e6467ee 100755
--- a/vstf/vstf/controller/sw_perf/performance.py
+++ b/vstf/vstf/controller/sw_perf/performance.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import time
import argparse
@@ -11,6 +15,7 @@ import logging
from vstf.controller.sw_perf import model
from vstf.common import perfmark as mark
import vstf.common.constants as cst
+import vstf.common.decorator as deco
from vstf.rpc_frame_work.rpc_producer import Server
from vstf.controller.settings.flows_settings import FlowsSettings
from vstf.controller.settings.tool_settings import ToolSettings
@@ -137,12 +142,12 @@ class Performance(object):
for watcher in self._watchers:
watcher.stop()
- def start_cpuwatcher(self):
- if self._cpuwatcher:
+ def start_cpuwatcher(self, enable=True):
+ if self._cpuwatcher and enable:
self._cpuwatcher.start()
- def stop_cpuwatcher(self):
- if self._cpuwatcher:
+ def stop_cpuwatcher(self, enable=True):
+ if self._cpuwatcher and enable:
self._cpuwatcher.stop()
def getlimitspeed(self, ptype, size):
@@ -167,22 +172,26 @@ class Performance(object):
self.destory(tool)
LOG.info("run_pre_affability_settings end")
+ @deco.check("ratep", defaults=0)
+ @deco.check("cpu_watch", defaults=False)
def run_bandwidth_test(self, tool, tpro, pktsize, **kwargs):
LOG.info("run_bandwidth_test ")
+ cpu_watch = kwargs.pop("cpu_watch")
self.create(tool, tpro)
self.start_receivers()
self.start_senders(pktsize, **kwargs)
time.sleep(self._provider.wait_balance(tool))
self.start_watchers()
- self.start_cpuwatcher()
+ self.start_cpuwatcher(cpu_watch)
time.sleep(self._provider.duration(tool))
self.stop_watchers()
- self.stop_cpuwatcher()
+ self.stop_cpuwatcher(cpu_watch)
self.stop_senders()
self.stop_receivers()
self.destory(tool)
LOG.info("run_bandwidth_test end")
+ @deco.check("ratep", defaults=0)
def run_latency_test(self, tool, tpro, pktsize, **kwargs):
LOG.info("run_latency_test start")
self.create(tool, tpro)
@@ -223,7 +232,7 @@ class Performance(object):
elif ttype in ['latency']:
lat_tpro = protocol + '_lat'
lat_type = ttype
- self.run_latency_test(tool, lat_tpro, size, ratep=None)
+ self.run_latency_test(tool, lat_tpro, size, ratep=0)
lat_result = self.result(tool, lat_type)
result[size] = lat_result
else:
@@ -242,8 +251,8 @@ class Performance(object):
mark.avgLatency: 0,
mark.maxLatency: 0,
mark.minLatency: 0,
- mark.rxMbps:0,
- mark.txMbps:0
+ mark.rxMbps: 0,
+ mark.txMbps: 0
}
cpu_data = self._cpuwatcher.result()
@@ -262,16 +271,22 @@ class Performance(object):
record[mark.rxMbps] += nic_data['rxmB/s']
record[mark.txMbps] += nic_data['txmB/s']
+ if record[mark.rxMbps] > record[mark.txMbps]:
+ 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]
+
if record[mark.txCount]:
record[mark.percentLoss] = round(100 * (1 - record[mark.rxCount] / record[mark.txCount]),
- cst.PKTLOSS_ROUND)
+ 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)
+ cst.CPU_USAGE_ROUND)
record[mark.bandwidth] = round(record[mark.bandwidth], cst.RATEP_ROUND)
@@ -349,7 +364,7 @@ def main():
)
parser.add_argument("profile",
action="store",
- choices=cst.PROFILES,
+ choices=cst.PROVIDERS,
)
parser.add_argument("type",
action="store",
diff --git a/vstf/vstf/controller/sw_perf/raw_data.py b/vstf/vstf/controller/sw_perf/raw_data.py
index dab749eb..aefb863d 100755
--- a/vstf/vstf/controller/sw_perf/raw_data.py
+++ b/vstf/vstf/controller/sw_perf/raw_data.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import subprocess
import re
import logging
diff --git a/vstf/vstf/controller/unittest/README b/vstf/vstf/controller/unittest/README
index f9414e95..61ef1a24 100755
--- a/vstf/vstf/controller/unittest/README
+++ b/vstf/vstf/controller/unittest/README
@@ -1,8 +1,4 @@
-"""
-Created on 2015-9-28
-@author: y00228926
-"""
the procedure to integrate a module unit testing into the unit testing framework:
diff --git a/vstf/vstf/controller/unittest/__init__.py b/vstf/vstf/controller/unittest/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/unittest/__init__.py
+++ b/vstf/vstf/controller/unittest/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
diff --git a/vstf/vstf/controller/unittest/configuration.py b/vstf/vstf/controller/unittest/configuration.py
index 9364bbbf..6312efa2 100755
--- a/vstf/vstf/controller/unittest/configuration.py
+++ b/vstf/vstf/controller/unittest/configuration.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-24
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
rabbit_mq_server = '192.168.188.10'
diff --git a/vstf/vstf/controller/unittest/model.py b/vstf/vstf/controller/unittest/model.py
index c4e992ce..4c38973e 100755
--- a/vstf/vstf/controller/unittest/model.py
+++ b/vstf/vstf/controller/unittest/model.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import unittest
from vstf.rpc_frame_work import rpc_producer
diff --git a/vstf/vstf/controller/unittest/test_cfg_intent_parse.py b/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
index 665732aa..a08607bb 100755
--- a/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
+++ b/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-14
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import os
import unittest
diff --git a/vstf/vstf/controller/unittest/test_collect.py b/vstf/vstf/controller/unittest/test_collect.py
index f1d54a95..3e84d019 100755
--- a/vstf/vstf/controller/unittest/test_collect.py
+++ b/vstf/vstf/controller/unittest/test_collect.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import unittest
import json
diff --git a/vstf/vstf/controller/unittest/test_driver_function.py b/vstf/vstf/controller/unittest/test_driver_function.py
index 05804421..8d45c7b3 100755
--- a/vstf/vstf/controller/unittest/test_driver_function.py
+++ b/vstf/vstf/controller/unittest/test_driver_function.py
@@ -1,7 +1,12 @@
-"""
-Created on 2015-10-27
-@author: l00190809
-"""
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import unittest
import json
diff --git a/vstf/vstf/controller/unittest/test_env_build.py b/vstf/vstf/controller/unittest/test_env_build.py
index 2d2d882b..e4529e48 100755
--- a/vstf/vstf/controller/unittest/test_env_build.py
+++ b/vstf/vstf/controller/unittest/test_env_build.py
@@ -1,8 +1,12 @@
-'''
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-'''
import unittest
import os
diff --git a/vstf/vstf/controller/unittest/test_perf.py b/vstf/vstf/controller/unittest/test_perf.py
index 5a54b826..0258ab65 100755
--- a/vstf/vstf/controller/unittest/test_perf.py
+++ b/vstf/vstf/controller/unittest/test_perf.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-10-30
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import unittest
import os
diff --git a/vstf/vstf/controller/unittest/test_ssh.py b/vstf/vstf/controller/unittest/test_ssh.py
index 844f8ff5..f2403551 100755
--- a/vstf/vstf/controller/unittest/test_ssh.py
+++ b/vstf/vstf/controller/unittest/test_ssh.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-10
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
-@author: y00228926
-"""
import unittest
from vstf.common import ssh
diff --git a/vstf/vstf/controller/vstfadm.py b/vstf/vstf/controller/vstfadm.py
index 068ab2e0..86641e7d 100755
--- a/vstf/vstf/controller/vstfadm.py
+++ b/vstf/vstf/controller/vstfadm.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import sys
import logging
import json
@@ -105,9 +114,8 @@ def do_show_tasks(args):
@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("profile", action="store", choices=cst.PROFILES, )
+@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")
@@ -118,7 +126,6 @@ def do_perf_test(args):
'case': args.case,
'tool': args.tool,
'protocol': args.protocol,
- 'profile': args.profile,
'type': args.type,
'sizes': map(lambda x: int(x), args.sizes.strip().split())
}
@@ -250,6 +257,13 @@ def do_affctl_list(args):
print_stdout(ret)
+@cliutil.arg("head", action="store", help="ip of head")
+@cliutil.arg("tail", action="store", help="ip of tail")
+def do_settings(args):
+ ret = call(make_msg("settings", head=args.head, tail=args.tail))
+ print_stdout(ret)
+
+
def main():
parser = VstfParser(prog="vstfadm", description="vstf administration")
parser.set_subcommand_parser(sys.modules[__name__], "functions")