summaryrefslogtreecommitdiffstats
path: root/vnftest/core
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2019-03-18 08:50:46 +0200
committerMoshe <moshehoa@amdocs.com>2019-03-18 08:51:06 +0200
commitae309d644224e1637ece5474abc29a7a6aa6c555 (patch)
tree3f405c92151f95db436f049815d48f2c3eb87094 /vnftest/core
parent946470e3a794cc98e2d5b20af74ae3e5dac7d315 (diff)
introduce heat context
Issue-ID: VNFSDK-350 Change-Id: I2936ba654109475145ad8bd673c944aea3fcac65 Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/core')
-rw-r--r--vnftest/core/task.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/vnftest/core/task.py b/vnftest/core/task.py
index a9718bb..8797eee 100644
--- a/vnftest/core/task.py
+++ b/vnftest/core/task.py
@@ -25,6 +25,7 @@ import copy
import logging
import sys
import time
+import traceback
import uuid
import ipaddress
@@ -32,6 +33,7 @@ import os
import yaml
from jinja2 import Environment
from six.moves import filter
+
from vnftest.runners import base as base_runner
from vnftest.contexts.base import Context
@@ -160,6 +162,7 @@ class Task(object): # pragma: no cover
one_task_end_time - one_task_start_time)
except Exception as e:
LOG.error("Task fatal error: %s", e)
+ traceback.print_exc()
self.task_info.task_fatal()
finally:
self.task_info.task_end()
@@ -170,11 +173,6 @@ class Task(object): # pragma: no cover
total_end_time = time.time()
LOG.info("Total finished in %d secs",
total_end_time - total_start_time)
-
- step = steps[0]
- LOG.info("To generate report, execute command "
- "'vnftest report generate %(task_id)s %(tc)s'", step)
- LOG.info("Task ALL DONE, exiting")
return self.task_info.result()
def _generate_reporting(self):
@@ -279,6 +277,7 @@ class Task(object): # pragma: no cover
return result
except Exception as e:
LOG.exception('Case fatal error: %s', e)
+ traceback.print_exc()
self.task_info.testcase_fatal(case_name)
finally:
self.task_info.testcase_end(case_name)
@@ -316,6 +315,7 @@ class Task(object): # pragma: no cover
LOG.info("Starting runner of type '%s'", runner_cfg["type"])
# Previous steps output is the input of the next step.
inputs.update(self.outputs)
+ _resolve_step_options(step_cfg, self.contexts, inputs)
runner.run(step_cfg, self.contexts, inputs)
return runner
@@ -330,6 +330,22 @@ class Task(object): # pragma: no cover
result.extend(step_result_list)
+def _resolve_step_options(step_cfg, contexts, inputs):
+ inputs = copy.deepcopy(inputs)
+ contexts_dict = {}
+ inputs['context'] = contexts_dict
+ if contexts is not None:
+ for context in contexts:
+ context_as_dict = utils.normalize_data_struct(context)
+ contexts_dict[context.assigned_name] = context_as_dict
+ options = step_cfg.get("options", {})
+ resolved_options = {}
+ for k, v in options.items():
+ v = utils.format(v, inputs)
+ resolved_options[k] = v
+ step_cfg["options"] = resolved_options
+
+
class TaskParser(object): # pragma: no cover
"""Parser for task config files in yaml format"""