summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2019-04-01 15:13:22 +0300
committerMoshe <moshehoa@amdocs.com>2019-04-01 15:15:41 +0300
commitc9cdbfc69226a34447f7e5be99a8727ac1ece278 (patch)
treefdfe4fe24ac9067edefba8f45f3b6c85c2965b5d
parentdf7d36416fa78c64abb641d5554a8416f4c23247 (diff)
add context info to test output
Change-Id: I6909db816595c7ce2a0cb42610251b2600c6e2e1 Issue-ID: VNFSDK-350 Signed-off-by: Moshe <moshehoa@amdocs.com>
-rw-r--r--vnftest/contexts/dummy.py5
-rw-r--r--vnftest/contexts/heat.py2
-rw-r--r--vnftest/core/task.py33
3 files changed, 30 insertions, 10 deletions
diff --git a/vnftest/contexts/dummy.py b/vnftest/contexts/dummy.py
index 04d63ed..80a97bf 100644
--- a/vnftest/contexts/dummy.py
+++ b/vnftest/contexts/dummy.py
@@ -30,11 +30,10 @@ class DummyContext(Context):
super(DummyContext, self).__init__()
def init(self, attrs):
- pass
+ super(DummyContext, self).init(attrs)
def deploy(self):
- """don't need to deploy"""
- pass
+ return {"out1": "dummy1", "out2": "dummy2"}
def undeploy(self):
"""don't need to undeploy"""
diff --git a/vnftest/contexts/heat.py b/vnftest/contexts/heat.py
index f6ca611..9155b38 100644
--- a/vnftest/contexts/heat.py
+++ b/vnftest/contexts/heat.py
@@ -335,7 +335,6 @@ class HeatContext(Context):
def deploy(self):
"""deploys template into a stack using cloud"""
LOG.info("Deploying context '%s' START", self.name)
-
# self.key_filename = ''.join(
# [consts.VNFTEST_ROOT_PATH,
# '/vnftest/resources/files/vnftest_key-',
@@ -378,6 +377,7 @@ class HeatContext(Context):
self.stack.outputs[server.floating_ip["stack_name"]]
LOG.info("Deploying context '%s' DONE", self.name)
+ return self.stack.outputs
@staticmethod
def _port_net_is_existing(port_info):
diff --git a/vnftest/core/task.py b/vnftest/core/task.py
index 8797eee..de3c177 100644
--- a/vnftest/core/task.py
+++ b/vnftest/core/task.py
@@ -227,17 +227,22 @@ class Task(object): # pragma: no cover
dispatcher.flush_result_data(self.task_id, self.task_info.result())
def _run(self, steps, case_name, run_in_parallel, output_file, inputs):
- """Deploys context and calls runners"""
- if self.contexts is not None:
- for context in self.contexts:
- context.deploy()
-
try:
self.task_info.testcase_start(case_name)
for step in steps:
step_unique_id = self.task_info.step_add(case_name, step['name'])
step['step_unique_id'] = step_unique_id
+ """Deploys context and calls runners"""
+ if self.contexts is not None:
+ for context in self.contexts:
+ output = None
+ try:
+ self.task_info.context_deploy_start(case_name, context.assigned_name)
+ output = context.deploy()
+ finally:
+ self.task_info.context_deploy_end(case_name, context.assigned_name, output)
+
background_runners = []
result = []
# Start all background steps
@@ -509,6 +514,7 @@ class TaskInfo(object):
self.info_dict['testcases'] = self.test_cases_list
self.helper_test_cases_dict = {}
self.helper_test_steps_dict = {}
+ self.helper_contexts_dict = {}
self.step_id_helper = 0
def task_end(self):
@@ -531,7 +537,7 @@ class TaskInfo(object):
testcase_dict['status'] = 'FINISHED'
def testcase_start(self, testcase_name):
- testcase_dict = {'name': testcase_name, 'criteria': 'N/A', 'status': 'IN_PROGRESS', 'steps': []}
+ testcase_dict = {'name': testcase_name, 'criteria': 'N/A', 'status': 'IN_PROGRESS', 'steps': [], 'contexts': []}
self.test_cases_list.append(testcase_dict)
self.helper_test_cases_dict[testcase_name] = testcase_dict
@@ -582,6 +588,21 @@ class TaskInfo(object):
step_dict['criteria'] = 'PASS'
step_dict['status'] = 'FINISHED'
+ def context_deploy_start(self, testcase_name, context_name):
+ context_dict = {'name': context_name, 'status': 'IN_PROGRESS', 'output': []}
+ testcase_dict = self.helper_test_cases_dict[testcase_name]
+ testcase_dict['contexts'].append(context_dict)
+ context_unique_id = testcase_name + '_' + context_name
+ self.helper_contexts_dict[context_unique_id] = context_dict
+
+ def context_deploy_end(self, testcase_name, context_name, output):
+ context_unique_id = testcase_name + '_' + context_name
+ context_dict = self.helper_contexts_dict[context_unique_id]
+ if output is not None:
+ for k, v in output.items():
+ context_dict['output'].append({'type': 'String', 'key': k, 'value': str(v)})
+ context_dict['status'] = 'FINISHED'
+
def result(self):
return copy.deepcopy(self.info_dict)