summaryrefslogtreecommitdiffstats
path: root/vnftest/core
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2018-03-25 17:00:40 +0300
committerMoshe <moshehoa@amdocs.com>2018-03-25 18:07:32 +0300
commitea90f9ba9d0e317dfc5521dda9946844b7336abd (patch)
tree24b8d699b7d8166f9b8597d1f72c4557db3906bf /vnftest/core
parent583448a180e36b5b406fa9542392ea0400914700 (diff)
Add unit tests and handle coverage
Issue-ID: VNFSDK-183 Change-Id: I228576f5c06b371164bcd653d23cf169098436a8 Signed-off-by: Moshe <moshehoa@amdocs.com> handle coverage Issue-ID: VNFSDK-183 Change-Id: I3d78293fdf5cb8bc57caa4078ab8fa5baa429a0d Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/core')
-rw-r--r--vnftest/core/report.py62
-rw-r--r--vnftest/core/task.py28
2 files changed, 32 insertions, 58 deletions
diff --git a/vnftest/core/report.py b/vnftest/core/report.py
index bb791dc..b8f8bb7 100644
--- a/vnftest/core/report.py
+++ b/vnftest/core/report.py
@@ -18,14 +18,14 @@
from __future__ import absolute_import
from __future__ import print_function
-import ast
+# import ast
import re
import uuid
from django.conf import settings
from django.template import Context
from django.template import Template
-from oslo_utils import encodeutils
+# from oslo_utils import encodeutils
from oslo_utils import uuidutils
from vnftest.common import constants as consts
@@ -37,8 +37,6 @@ settings.configure()
class Report(object):
"""Report commands.
-
- Set of commands to manage benchmark tasks.
"""
def __init__(self):
@@ -83,39 +81,39 @@ class Report(object):
"""Start report generation."""
self._validate(args.yaml_name[0], args.task_id[0])
- self.db_fieldkeys = self._get_fieldkeys()
+ # self.db_fieldkeys = self._get_fieldkeys()
- self.db_task = self._get_tasks()
+ # self.db_task = self._get_tasks()
- field_keys = []
+ # field_keys = []
temp_series = []
table_vals = {}
- field_keys = [encodeutils.to_utf8(field['fieldKey'])
- for field in self.db_fieldkeys]
-
- for key in field_keys:
- self.Timestamp = []
- series = {}
- values = []
- for task in self.db_task:
- task_time = encodeutils.to_utf8(task['time'])
- if not isinstance(task_time, str):
- task_time = str(task_time, 'utf8')
- key = str(key, 'utf8')
- task_time = task_time[11:]
- head, sep, tail = task_time.partition('.')
- task_time = head + "." + tail[:6]
- self.Timestamp.append(task_time)
- if isinstance(task[key], float) is True:
- values.append(task[key])
- else:
- values.append(ast.literal_eval(task[key]))
- table_vals['Timestamp'] = self.Timestamp
- table_vals[key] = values
- series['name'] = key
- series['data'] = values
- temp_series.append(series)
+ # field_keys = [encodeutils.to_utf8(field['fieldKey'])
+ # for field in self.db_fieldkeys]
+
+ # for key in field_keys:
+ # self.Timestamp = []
+ # series = {}
+ # values = []
+ # for task in self.db_task:
+ # task_time = encodeutils.to_utf8(task['time'])
+ # if not isinstance(task_time, str):
+ # task_time = str(task_time, 'utf8')
+ # key = str(key, 'utf8')
+ # task_time = task_time[11:]
+ # head, sep, tail = task_time.partition('.')
+ # task_time = head + "." + tail[:6]
+ # self.Timestamp.append(task_time)
+ # if isinstance(task[key], float) is True:
+ # values.append(task[key])
+ # else:
+ # values.append(ast.literal_eval(task[key]))
+ # table_vals['Timestamp'] = self.Timestamp
+ # table_vals[key] = values
+ # series['name'] = key
+ # series['data'] = values
+ # temp_series.append(series)
Template_html = Template(template)
Context_html = Context({"series": temp_series,
diff --git a/vnftest/core/task.py b/vnftest/core/task.py
index a2963a5..8ce897b 100644
--- a/vnftest/core/task.py
+++ b/vnftest/core/task.py
@@ -258,7 +258,8 @@ class Task(object): # pragma: no cover
def _run(self, steps, run_in_parallel, output_file):
"""Deploys context and calls runners"""
- self.context.deploy()
+ if self.context:
+ self.context.deploy()
background_runners = []
result = []
@@ -547,31 +548,6 @@ def _is_background_step(step):
return False
-def parse_nodes_with_context(step_cfg):
- """parse the 'nodes' fields in step """
- # ensure consistency in node instantiation order
- return OrderedDict((nodename, Context.get_server(step_cfg["nodes"][nodename]))
- for nodename in sorted(step_cfg["nodes"]))
-
-
-def get_networks_from_nodes(nodes):
- """parse the 'nodes' fields in step """
- networks = {}
- for node in nodes.values():
- if not node:
- continue
- interfaces = node.get('interfaces', {})
- for interface in interfaces.values():
- # vld_id is network_name
- network_name = interface.get('network_name')
- if not network_name:
- continue
- network = Context.get_network(network_name)
- if network:
- networks[network['name']] = network
- return networks
-
-
def runner_join(runner, background_runners, outputs, result):
"""join (wait for) a runner, exit process at runner failure
:param background_runners: