summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2019-01-09 09:40:40 +0200
committerMoshe <moshehoa@amdocs.com>2019-01-09 11:53:20 +0200
commitce6df7403af5694aee412836cd3c86e33307e190 (patch)
treecd9799665cba2c44e517419d4d5570f2198939ff
parent6affd662a7793fda0be64ee103d7239702b9722b (diff)
refactor input parameters handling
Change-Id: I599be7b0c0f9724f954fb4790dcd7d03538fdcb7 Issue-ID: VNFSDK-350 Signed-off-by: Moshe <moshehoa@amdocs.com> fix test Issue-ID: VNFSDK-350 Change-Id: I8f3c0b80220e88660f0a0d00c1207abd30ed2208 Signed-off-by: Moshe <moshehoa@amdocs.com> fix test Issue-ID: VNFSDK-350 Change-Id: Ica479453d60129ed033dfcf613dbe73bb1c60bd0 Signed-off-by: Moshe <moshehoa@amdocs.com> fix test Issue-ID: VNFSDK-350 Change-Id: If9470517623074708e1c602b4683a958227d16c6 Signed-off-by: Moshe <moshehoa@amdocs.com>
-rw-r--r--MANIFEST.in1
-rw-r--r--dist/vnftest-0.1.dev0-py2.7.eggbin265336 -> 0 bytes
-rwxr-xr-xsetup.py17
-rw-r--r--vnftest.egg-info/PKG-INFO11
-rw-r--r--vnftest.egg-info/SOURCES.txt124
-rw-r--r--vnftest.egg-info/dependency_links.txt1
-rw-r--r--vnftest.egg-info/entry_points.txt3
-rw-r--r--vnftest.egg-info/top_level.txt3
-rw-r--r--vnftest/cmd/commands/task.py2
-rw-r--r--vnftest/common/constants.py22
-rw-r--r--vnftest/common/rest_client.py19
-rw-r--r--vnftest/common/utils.py31
-rw-r--r--vnftest/contexts/base.py20
-rw-r--r--vnftest/core/__init__.py2
-rw-r--r--vnftest/core/task.py59
-rw-r--r--vnftest/core/testcase.py1
-rw-r--r--vnftest/onap/onboard/v1/upload_package_v1.yaml4
-rw-r--r--vnftest/onap/onboard/v2/upload_package_v2.yaml4
-rw-r--r--vnftest/steps/rest_call.py14
-rw-r--r--vnftest/test_config/onap/test_cases/onap_vnftest_instantiate-v1.yaml16
-rw-r--r--vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v1.yaml4
-rw-r--r--vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v2.yaml3
-rw-r--r--vnftest/test_config/onap/test_cases/onap_vnftest_terminate.yaml6
-rw-r--r--vnftest/tests/unit/core/test_task.py2
-rw-r--r--vnftest/tests/unit/onap/test_rest_call.py2
25 files changed, 108 insertions, 263 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..c7c2157
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+recursive-include app/ * \ No newline at end of file
diff --git a/dist/vnftest-0.1.dev0-py2.7.egg b/dist/vnftest-0.1.dev0-py2.7.egg
deleted file mode 100644
index 74070dd..0000000
--- a/dist/vnftest-0.1.dev0-py2.7.egg
+++ /dev/null
Binary files differ
diff --git a/setup.py b/setup.py
index 6a85dff..c269508 100755
--- a/setup.py
+++ b/setup.py
@@ -22,23 +22,6 @@ setup(
version="1.1.0",
packages=find_packages(),
include_package_data=True,
- package_data={
- 'vnftest': [
- 'onap/onboard/v1/*.yaml',
- 'onap/onboard/v2/*.yaml',
- 'onap/lifecycle/*.yaml',
- 'onap/lifecycle/v1/*.yaml',
- 'onap/lifecycle/v2/*.yaml',
- 'onap/steps/validation/*.yaml',
- 'test_config/onap/test_cases/*.yaml',
- 'test_config/onap/test_suites/*.yaml'
- ],
- 'etc': [
- 'vnftest/*.yaml',
- 'vnftest/*.conf',
- 'vnftest/vnf_descriptors/*.yaml'
- ]
- },
data_files=[('/etc/vnftest/', ['etc/vnftest/vnftest.yaml'])],
url="https://www.onap.org",
entry_points={
diff --git a/vnftest.egg-info/PKG-INFO b/vnftest.egg-info/PKG-INFO
deleted file mode 100644
index 25a1c78..0000000
--- a/vnftest.egg-info/PKG-INFO
+++ /dev/null
@@ -1,11 +0,0 @@
-Metadata-Version: 1.0
-Name: vnftest
-Version: 1.1.0
-Summary: UNKNOWN
-Home-page: https://www.onap.org
-Author: UNKNOWN
-Author-email: UNKNOWN
-License: UNKNOWN
-Description-Content-Type: UNKNOWN
-Description: UNKNOWN
-Platform: UNKNOWN
diff --git a/vnftest.egg-info/SOURCES.txt b/vnftest.egg-info/SOURCES.txt
deleted file mode 100644
index b702fbc..0000000
--- a/vnftest.egg-info/SOURCES.txt
+++ /dev/null
@@ -1,124 +0,0 @@
-setup.py
-api/__init__.py
-api/client.py
-api/server.py
-api/urls.py
-api/database/__init__.py
-api/database/v1/__init__.py
-api/database/v1/handlers.py
-api/database/v1/models.py
-api/resources/__init__.py
-api/resources/v1/__init__.py
-api/resources/v1/environments.py
-api/resources/v1/projects.py
-api/resources/v1/tasks.py
-api/resources/v1/testcases.py
-api/resources/v1/testsuites.py
-api/resources/v1/vnf_descriptors.py
-api/swagger/__init__.py
-api/swagger/models.py
-api/utils/__init__.py
-api/utils/influx.py
-api/utils/thread.py
-etc/__init__.py
-etc/vnftest/vnftest.yaml
-tools/vnftest-img-dpdk-modify
-tools/vnftest-img-lxd-modify
-tools/vnftest-img-modify
-vnftest/__init__.py
-vnftest/main.py
-vnftest/ssh.py
-vnftest.egg-info/PKG-INFO
-vnftest.egg-info/SOURCES.txt
-vnftest.egg-info/dependency_links.txt
-vnftest.egg-info/entry_points.txt
-vnftest.egg-info/top_level.txt
-vnftest/cmd/__init__.py
-vnftest/cmd/cli.py
-vnftest/cmd/commands/__init__.py
-vnftest/cmd/commands/env.py
-vnftest/cmd/commands/plugin.py
-vnftest/cmd/commands/report.py
-vnftest/cmd/commands/runner.py
-vnftest/cmd/commands/step.py
-vnftest/cmd/commands/task.py
-vnftest/cmd/commands/testcase.py
-vnftest/common/__init__.py
-vnftest/common/constants.py
-vnftest/common/exceptions.py
-vnftest/common/html_template.py
-vnftest/common/httpClient.py
-vnftest/common/openstack_utils.py
-vnftest/common/process.py
-vnftest/common/rest_client.py
-vnftest/common/task_template.py
-vnftest/common/template_format.py
-vnftest/common/utils.py
-vnftest/common/yaml_loader.py
-vnftest/contexts/__init__.py
-vnftest/contexts/base.py
-vnftest/contexts/csar.py
-vnftest/contexts/dummy.py
-vnftest/core/__init__.py
-vnftest/core/plugin.py
-vnftest/core/report.py
-vnftest/core/runner.py
-vnftest/core/step.py
-vnftest/core/task.py
-vnftest/core/testcase.py
-vnftest/core/testsuite.py
-vnftest/crawlers/__init__.py
-vnftest/crawlers/base.py
-vnftest/crawlers/default.py
-vnftest/dispatcher/__init__.py
-vnftest/dispatcher/base.py
-vnftest/dispatcher/file.py
-vnftest/dispatcher/http.py
-vnftest/onap/__init__.py
-vnftest/onap/common/__init__.py
-vnftest/onap/common/vf_module_crawler.py
-vnftest/onap/lifecycle/__init__.py
-vnftest/onap/onboard/__init__.py
-vnftest/onap/onboard/v1/__init__.py
-vnftest/onap/onboard/v2/__init__.py
-vnftest/onap/steps/__init__.py
-vnftest/onap/steps/validation/__init__.py
-vnftest/onap/steps/validation/vf_module_validator.py
-vnftest/openstack/__init__.py
-vnftest/openstack/steps/__init__.py
-vnftest/openstack/steps/heat.py
-vnftest/openstack/steps/nova.py
-vnftest/resources/__init__.py
-vnftest/runners/__init__.py
-vnftest/runners/base.py
-vnftest/runners/duration.py
-vnftest/runners/dynamictp.py
-vnftest/runners/iteration.py
-vnftest/runners/search.py
-vnftest/runners/sequence.py
-vnftest/steps/__init__.py
-vnftest/steps/base.py
-vnftest/steps/rest_call.py
-vnftest/steps/dummy/__init__.py
-vnftest/steps/dummy/dummy.py
-vnftest/test_config/__init__.py
-vnftest/test_config/onap/__init__.py
-vnftest/test_config/onap/test_cases/__init__.py
-vnftest/test_config/onap/test_suites/__init__.py
-vnftest/tests/__init__.py
-vnftest/tests/fixture.py
-vnftest/tests/unit/__init__.py
-vnftest/tests/unit/common/__init__.py
-vnftest/tests/unit/common/test_httpClient.py
-vnftest/tests/unit/common/test_process.py
-vnftest/tests/unit/common/test_template_format.py
-vnftest/tests/unit/common/test_utils.py
-vnftest/tests/unit/common/test_yaml_loader.py
-vnftest/tests/unit/core/__init__.py
-vnftest/tests/unit/core/test_commands.py
-vnftest/tests/unit/core/test_plugin.py
-vnftest/tests/unit/core/test_report.py
-vnftest/tests/unit/core/test_task.py
-vnftest/tests/unit/core/test_testcase.py
-vnftest/tests/unit/onap/__init__.py
-vnftest/tests/unit/onap/test_onap_api_call.py \ No newline at end of file
diff --git a/vnftest.egg-info/dependency_links.txt b/vnftest.egg-info/dependency_links.txt
deleted file mode 100644
index 8b13789..0000000
--- a/vnftest.egg-info/dependency_links.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/vnftest.egg-info/entry_points.txt b/vnftest.egg-info/entry_points.txt
deleted file mode 100644
index e1abfaf..0000000
--- a/vnftest.egg-info/entry_points.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-[console_scripts]
-vnftest = vnftest.main:main
-
diff --git a/vnftest.egg-info/top_level.txt b/vnftest.egg-info/top_level.txt
deleted file mode 100644
index b5a830f..0000000
--- a/vnftest.egg-info/top_level.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-api
-etc
-vnftest
diff --git a/vnftest/cmd/commands/task.py b/vnftest/cmd/commands/task.py
index e0bf7e5..e10ac30 100644
--- a/vnftest/cmd/commands/task.py
+++ b/vnftest/cmd/commands/task.py
@@ -29,8 +29,6 @@ class TaskCommands(object): # pragma: no cover
Set of commands to manage benchmark tasks.
"""
- @cliargs("environment", type=str, help="path to environment file", metavar="environment")
- @cliargs("vnfdescriptor", type=str, help="path to vnf descriptor file", metavar="vnf-descriptor")
@cliargs("inputfile", type=str, help="path to task or suite file", metavar="input-file")
@cliargs("--task-args", dest="task_args",
help="Input task args (dict in json). These args are used"
diff --git a/vnftest/common/constants.py b/vnftest/common/constants.py
index acf14ea..9996ca6 100644
--- a/vnftest/common/constants.py
+++ b/vnftest/common/constants.py
@@ -82,23 +82,23 @@ if not SERVER_IP:
# dir
-CONF_DIR = get_param('dir.conf', join(VNFTEST_ROOT_PATH, 'etc/vnftest'))
-IMAGE_DIR = get_param('dir.images', join(VNFTEST_ROOT_PATH, 'home/onap/images/'))
-PACKAGE_DIR = get_param('dir.packages', join(VNFTEST_ROOT_PATH, 'home/onap/packages/'))
+CONF_DIR = get_param('dir.conf', '/etc/vnftest')
+IMAGE_DIR = get_param('dir.images', join(VNFTEST_ROOT_PATH, '../../images/'))
+PACKAGE_DIR = get_param('dir.packages', join(VNFTEST_ROOT_PATH, '../../packages/'))
CONF_FILE = join(CONF_DIR, 'vnftest.conf')
-REPOS_DIR = get_param('dir.repos', join(VNFTEST_ROOT_PATH, 'home/onap/repos/vnftest'))
-LOG_DIR = get_param('dir.log', join(VNFTEST_ROOT_PATH, 'var/log/vnftest/'))
+REPOS_DIR = get_param('dir.repos', join(VNFTEST_ROOT_PATH, '..'))
+LOG_DIR = get_param('dir.log', '/var/log/vnftest/')
-TASK_LOG_DIR = get_param('dir.tasklog', join(VNFTEST_ROOT_PATH, 'var/log/vnftest/'))
+TASK_LOG_DIR = get_param('dir.tasklog', '/var/log/vnftest/')
CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/vnftest/')
SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
-TESTCASE_DIR = join(REPOS_DIR, 'vnftest/test_config/onap/test_cases/')
-TESTSUITE_DIR = join(REPOS_DIR, 'vnftest/test_config/onap/test_suites/')
+TESTCASE_DIR = join(VNFTEST_ROOT_PATH, 'vnftest/test_config/onap/test_cases/')
+TESTSUITE_DIR = join(VNFTEST_ROOT_PATH, 'vnftest/test_config/onap/test_suites/')
# file
-DEFAULT_OUTPUT_FILE = get_param('file.output_file', join(VNFTEST_ROOT_PATH, 'tmp/vnftest.out'))
-DEFAULT_HTML_FILE = get_param('file.html_file', join(VNFTEST_ROOT_PATH, 'tmp/vnftest.htm'))
-REPORTING_FILE = get_param('file.reporting_file', join(VNFTEST_ROOT_PATH, 'tmp/report.html'))
+DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/vnftest.out')
+DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/vnftest.htm')
+REPORTING_FILE = get_param('file.reporting_file', '/tmp/report.html')
# api
API_PORT = 5000
diff --git a/vnftest/common/rest_client.py b/vnftest/common/rest_client.py
index 051f5dd..bd938e4 100644
--- a/vnftest/common/rest_client.py
+++ b/vnftest/common/rest_client.py
@@ -19,7 +19,8 @@ import logging
import os
import urllib2
import requests
-
+import sys
+import traceback
from vnftest.common import utils
logger = logging.getLogger(__name__)
@@ -39,8 +40,9 @@ def call(url, method, headers, data, logger):
f = urllib2.urlopen(req)
return_code = f.code
response_body = f.read()
- headers = f.headers
- content_type = headers.dict['content-type'] if 'content-type' in headers.dict else 'application/json'
+ headers = f.headers.dict
+
+ content_type = headers['content-type'] if 'content-type' in headers else 'application/json'
f.close()
if len(str(response_body)) == 0:
response_body = "{}"
@@ -48,9 +50,12 @@ def call(url, method, headers, data, logger):
response_body = utils.xml_to_dict(response_body)
else:
response_body = json.loads(response_body)
- result = {'return_code': return_code, 'body': response_body}
+ result = {'return_code': return_code, 'body': response_body, 'headers': headers}
return result
-
+ except urllib2.HTTPError as e:
+ error_message = e.read()
+ logger.exception(error_message)
+ raise RuntimeError(error_message)
except Exception as e:
message = "Cannot read content from {}, exception: {}".format(url, e)
logger.exception(message)
@@ -64,8 +69,8 @@ def upload_file(url, headers, file, logger):
logger.debug("Upload file. URL: {}".format(url))
response = None
try:
- response = requests.post(url, headers=headers, files=file)
- return {'return_code': response.status_code, 'body': response.json()}
+ response = requests.post(url, headers=headers, files=file, verify=False)
+ return {'return_code': response.status_code, 'body': response.json(), 'headers': response.headers}
except Exception as e:
message = "Error while uploading file to {}, exception: {}".format(url, e)
logger.exception(message)
diff --git a/vnftest/common/utils.py b/vnftest/common/utils.py
index 9e2496e..eaf184a 100644
--- a/vnftest/common/utils.py
+++ b/vnftest/common/utils.py
@@ -156,7 +156,7 @@ def get_port_mac(sshclient, port):
def get_port_ip(sshclient, port):
cmd = "ifconfig %s |grep 'inet addr' |awk '{print $2}' " \
- "|cut -d ':' -f2 " % port
+ "|cut -d ':' -f2 " % port
status, stdout, stderr = sshclient.execute(cmd)
if status:
@@ -483,24 +483,37 @@ def load_resource(path):
return pkg_resources.resource_stream(package, split_path[1])
-def format(st, params):
- if not isinstance(st, basestring):
- return st
+def format(in_obj, params):
+ if isinstance(in_obj, list):
+ ret_list = []
+ for item in in_obj:
+ item = format(item, params)
+ ret_list.append(item)
+ return ret_list
+ if isinstance(in_obj, dict):
+ ret_dict = {}
+ for k, v in in_obj.items():
+ v = format(v, params)
+ ret_dict[k] = v
+ return ret_dict
+ if not isinstance(in_obj, basestring):
+ return in_obj
+
dotdict(params)
ret_str = ""
ret_obj = None
for literal_text, field_name, format_spec, conversion in \
- Formatter().parse(st):
+ Formatter().parse(in_obj):
if field_name is None:
ret_str = ret_str + literal_text
else:
- dict = ret_obj or params
+ tmp_dict = ret_obj or params
try:
- value = dict[field_name]
+ value = tmp_dict[field_name]
except KeyError:
- dict = dotdict(dict)
+ tmp_dict = dotdict(tmp_dict)
field_name = '{' + field_name + '}'
- value = field_name.format(**dict)
+ value = field_name.format(**tmp_dict)
if isinstance(value, basestring):
ret_str = ret_str + value
else:
diff --git a/vnftest/contexts/base.py b/vnftest/contexts/base.py
index c6f3992..538a2d6 100644
--- a/vnftest/contexts/base.py
+++ b/vnftest/contexts/base.py
@@ -20,29 +20,11 @@ import yaml
import logging
LOG = logging.getLogger(__name__)
+
@six.add_metaclass(abc.ABCMeta)
class Context(object):
"""Class that represents a context in the logical model"""
list = []
- vnf_descriptor = {}
- onap_env_config = {}
- creds = {}
-
- @classmethod
- def initialize(cls, vnf_descriptor_path, environment_path):
- LOG.info('vnf descriptor path: %s', str(vnf_descriptor_path))
- LOG.info('environment path: %s', str(environment_path))
- with open(vnf_descriptor_path) as f:
- cls.vnf_descriptor = yaml.safe_load(f)
- with open(environment_path) as f:
- environment_config = yaml.safe_load(f)
- openstack_env_config = environment_config['openstack']
- openstack_utils.initialize(openstack_env_config)
- cls.onap_env_config = environment_config['onap']
-
- cls.creds = openstack_utils.get_credentials()
-
-
@staticmethod
def split_name(name, sep='.'):
diff --git a/vnftest/core/__init__.py b/vnftest/core/__init__.py
index d734360..c204f9d 100644
--- a/vnftest/core/__init__.py
+++ b/vnftest/core/__init__.py
@@ -25,8 +25,6 @@ class Param(object):
def __init__(self, kwargs):
# list
- self.environment = kwargs.get('environment')
- self.vnfdescriptor = kwargs.get('vnfdescriptor')
self.inputfile = kwargs.get('inputfile')
self.task_args = kwargs.get('task-args')
self.task_args_file = kwargs.get('task-args-file')
diff --git a/vnftest/core/task.py b/vnftest/core/task.py
index 91e3d3c..065ad7e 100644
--- a/vnftest/core/task.py
+++ b/vnftest/core/task.py
@@ -72,7 +72,6 @@ class Task(object): # pragma: no cover
output_config['DEFAULT']['dispatcher'] = out_types
def start(self, args, **kwargs):
- Context.initialize(args.vnfdescriptor, args.environment)
atexit.register(self.atexit_handler)
task_id = getattr(args, 'task_id')
@@ -102,15 +101,15 @@ class Task(object): # pragma: no cover
if args.suite:
# 1.parse suite, return suite_params info
- task_files, task_args, task_args_fnames = \
+ task_files, task_args_list, task_args_fnames = \
parser.parse_suite()
else:
task_files = [parser.path]
- task_args = [args.task_args]
+ task_args_list = [args.task_args]
task_args_fnames = [args.task_args_file]
- LOG.debug("task_files:%s, task_args:%s, task_args_fnames:%s",
- task_files, task_args, task_args_fnames)
+ LOG.debug("task_files:%s, task_args_list:%s, task_args_fnames:%s",
+ task_files, task_args_list, task_args_fnames)
if args.parse_only:
sys.exit(0)
@@ -121,10 +120,18 @@ class Task(object): # pragma: no cover
one_task_start_time = time.time()
# the output of the previous task is the input of the new task
inputs = copy.deepcopy(self.outputs)
+ task_args_file = task_args_fnames[i]
+ task_args = task_args_list[i]
+ try:
+ if task_args_file:
+ with open(task_args_file) as f:
+ inputs.update(parse_task_args("task_args_file", f.read()))
+ inputs.update(parse_task_args("task_args", task_args))
+ except TypeError:
+ raise TypeError()
parser.path = task_files[i]
steps, run_in_parallel, meet_precondition, ret_context = \
- parser.parse_task(self.task_id, task_args[i],
- task_args_fnames[i], inputs)
+ parser.parse_task(self.task_id, inputs)
self.context = ret_context
@@ -135,7 +142,7 @@ class Task(object): # pragma: no cover
case_name = os.path.splitext(os.path.basename(task_files[i]))[0]
try:
- data = self._run(steps, run_in_parallel, args.output_file)
+ data = self._run(steps, run_in_parallel, args.output_file, inputs)
except KeyboardInterrupt:
raise
except Exception:
@@ -256,7 +263,7 @@ class Task(object): # pragma: no cover
for dispatcher in dispatchers:
dispatcher.flush_result_data(result)
- def _run(self, steps, run_in_parallel, output_file):
+ def _run(self, steps, run_in_parallel, output_file, inputs):
"""Deploys context and calls runners"""
if self.context:
self.context.deploy()
@@ -266,14 +273,14 @@ class Task(object): # pragma: no cover
# Start all background steps
for step in filter(_is_background_step, steps):
step["runner"] = dict(type="Duration", duration=1000000000)
- runner = self.run_one_step(step, output_file)
+ runner = self.run_one_step(step, output_file, inputs)
background_runners.append(runner)
runners = []
if run_in_parallel:
for step in steps:
if not _is_background_step(step):
- runner = self.run_one_step(step, output_file)
+ runner = self.run_one_step(step, output_file, inputs)
runners.append(runner)
# Wait for runners to finish
@@ -287,7 +294,7 @@ class Task(object): # pragma: no cover
# run serially
for step in steps:
if not _is_background_step(step):
- runner = self.run_one_step(step, output_file)
+ runner = self.run_one_step(step, output_file, inputs)
status = runner_join(runner, background_runners, self.outputs, result)
if status != 0:
LOG.error('Step NO.%s: "%s" ERROR!',
@@ -331,7 +338,7 @@ class Task(object): # pragma: no cover
else:
return op
- def run_one_step(self, step_cfg, output_file):
+ def run_one_step(self, step_cfg, output_file, inputs):
"""run one step using context"""
# default runner is Iteration
if 'runner' not in step_cfg:
@@ -344,8 +351,8 @@ 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.
- input_params = copy.deepcopy(self.outputs)
- runner.run(step_cfg, self.context, input_params)
+ inputs.update(self.outputs)
+ runner.run(step_cfg, self.context, inputs)
return runner
@@ -388,12 +395,13 @@ class TaskParser(object): # pragma: no cover
with open(self.path) as stream:
cfg = yaml_load(stream)
except IOError as ioerror:
- sys.exit(ioerror)
+ LOG.error("Open suite file failed", ioerror)
+ raise
self._check_schema(cfg["schema"], "suite")
LOG.info("\nStarting step:%s", cfg["name"])
- cur_pod = os.environ.get('NODE_NAME', None)
+ cur_pod = os.environ.get('NODE_NAME', "default")
cur_installer = os.environ.get('INSTALLER_TYPE', None)
valid_task_files = []
@@ -420,21 +428,10 @@ class TaskParser(object): # pragma: no cover
return valid_task_files, valid_task_args, valid_task_args_fnames
- def parse_task(self, task_id, task_args=None, task_args_file=None, inputs=None):
+ def parse_task(self, task_id, inputs=None):
"""parses the task file and return an context and step instances"""
LOG.info("Parsing task config: %s", self.path)
-
- try:
- kw = {}
- kw.update(inputs)
- if task_args_file:
- with open(task_args_file) as f:
- kw.update(parse_task_args("task_args_file", f.read()))
- kw.update(parse_task_args("task_args", task_args))
- kw['vnf_descriptor'] = Context.vnf_descriptor
- except TypeError:
- raise TypeError()
-
+ kw = inputs
try:
with utils.load_resource(self.path) as f:
try:
@@ -460,7 +457,7 @@ class TaskParser(object): # pragma: no cover
name_suffix = '-{}'.format(task_id[:8])
try:
context_cfg['name'] = '{}{}'.format(context_cfg['name'],
- name_suffix)
+ name_suffix)
except KeyError:
pass
# default to CSAR context
diff --git a/vnftest/core/testcase.py b/vnftest/core/testcase.py
index 2cb22ec..2c5c4b4 100644
--- a/vnftest/core/testcase.py
+++ b/vnftest/core/testcase.py
@@ -77,7 +77,6 @@ class Testcase(object):
def _parse_testcase(self, testcase_info):
kw = {}
- kw['vnf_descriptor'] = {}
rendered_testcase = TaskTemplate.render(testcase_info, **kw)
testcase_cfg = yaml_load(rendered_testcase)
diff --git a/vnftest/onap/onboard/v1/upload_package_v1.yaml b/vnftest/onap/onboard/v1/upload_package_v1.yaml
index 33f1b6a..c87ee5c 100644
--- a/vnftest/onap/onboard/v1/upload_package_v1.yaml
+++ b/vnftest/onap/onboard/v1/upload_package_v1.yaml
@@ -19,4 +19,6 @@ headers:
Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
USER_ID: {{sdc_designer_user}}
Accept: application/json
-file: {{package_file_path}} \ No newline at end of file
+file:
+ key: "upload"
+ path: {{package_file_path}} \ No newline at end of file
diff --git a/vnftest/onap/onboard/v2/upload_package_v2.yaml b/vnftest/onap/onboard/v2/upload_package_v2.yaml
index e623438..dc168a8 100644
--- a/vnftest/onap/onboard/v2/upload_package_v2.yaml
+++ b/vnftest/onap/onboard/v2/upload_package_v2.yaml
@@ -19,4 +19,6 @@ headers:
Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
USER_ID: {{sdc_designer_user}}
Accept: application/json
-file: {{package_file_path}} \ No newline at end of file
+file:
+ key: "upload"
+ path: {{package_file_path}} \ No newline at end of file
diff --git a/vnftest/steps/rest_call.py b/vnftest/steps/rest_call.py
index f8b1cf7..7b034ec 100644
--- a/vnftest/steps/rest_call.py
+++ b/vnftest/steps/rest_call.py
@@ -54,10 +54,6 @@ class RestCall(base.Step):
self.input_cfg = options.get("input", {})
self.output_cfg = options.get("output", {})
self.sla_cfg = self.step_cfg.get('sla', {'retries': 0})
- context_dict = {}
- context_dict['creds'] = dotdict(self.context.creds)
- context_dict['vnf_descriptor'] = dotdict(self.context.vnf_descriptor)
- self.input_params['context'] = dotdict(context_dict)
self.setup_done = True
def eval_input(self, params):
@@ -90,10 +86,12 @@ class RestCall(base.Step):
def run_impl(self, result):
if not self.setup_done:
self.setup()
- params = copy.deepcopy(self.context.onap_env_config)
+ params = {}
+ params.update(copy.deepcopy(self.input_params))
self.eval_input(params)
execution_result = self.execute_operation(params)
result_body = execution_result['body']
+ result_body['headers'] = execution_result.get('headers', {})
output = Crawler.crawl(result_body, self.output_cfg)
result.update(output)
return output
@@ -122,9 +120,9 @@ class RestCall(base.Step):
LOG.info(headers)
LOG.info(body)
if 'file' in operation:
- file_path = operation['file']
- LOG.info(file_path)
- files = {'upload': open(file_path)}
+ file_conf = operation['file']
+ LOG.info(file_conf)
+ files = {file_conf['key']: open(file_conf['path'])}
result = rest_client.upload_file(url, headers, files, LOG)
else:
result = rest_client.call(url,
diff --git a/vnftest/test_config/onap/test_cases/onap_vnftest_instantiate-v1.yaml b/vnftest/test_config/onap/test_cases/onap_vnftest_instantiate-v1.yaml
index addee64..c58659f 100644
--- a/vnftest/test_config/onap/test_cases/onap_vnftest_instantiate-v1.yaml
+++ b/vnftest/test_config/onap/test_cases/onap_vnftest_instantiate-v1.yaml
@@ -40,7 +40,11 @@ description: >
{% set resource_model_customization_name = resource_model_customization_name or '\"\u007Bresource_model_customization_name\u007D\"' %}
{% set distributed_service_id = distributed_service_id or '\"\u007Bdistributed_service_id\u007D\"' %}
{% set resource_instance_model_name = resource_instance_model_name or '\"\u007Bresource_instance_model_name\u007D\"' %}
+{% set vf_modules = vf_modules or {} %}
{% set vf_modules_list = vf_modules_list or {}%}
+{% set tenant_id = tenant_id or none %}
+{% set tenant_name = tenant_name or none %}
+
steps:
-
@@ -53,10 +57,10 @@ steps:
value: {{cloud_owner}}
-
parameter_name: "tenant_id"
- value: "{context.creds.tenant_id}"
+ value: {{tenant_id}}
-
parameter_name: "tenant_name"
- value: "{context.creds.tenant_name}"
+ value: {{tenant_name}}
runner:
type: Iteration
run_step: "setup,run"
@@ -82,7 +86,7 @@ steps:
value: {{cloud_owner}}
-
parameter_name: "tenant_id"
- value: "{context.creds.tenant_id}"
+ value: {{tenant_id}}
-
type: RestCall
options:
@@ -169,7 +173,7 @@ steps:
value: {{resource_model_customization_name}}
-
parameter_name: "tenant_id"
- value: "{context.creds.tenant_id}"
+ value: {{tenant_id}}
-
parameter_name: "service_model_name"
value: {{service_model_name}}
@@ -216,7 +220,7 @@ steps:
type: Iteration
run_step: "setup,run"
-{% for vf_module_definition in vnf_descriptor.vf_modules %}
+{% for vf_module_definition in vf_modules %}
{% set vf_module = vf_modules_list[vf_module_definition.module_name] %}
{% set vnf_name = ['test_vnf_', rnd, '_', vf_module_definition.module_name ]|join %}
-
@@ -284,7 +288,7 @@ steps:
value: {{vf_module.customizationUUID}}
-
parameter_name: "tenant_id"
- value: "{context.creds.tenant_id}"
+ value: {{tenant_id}}
-
parameter_name: "service_model_name"
value: {{service_model_name}}
diff --git a/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v1.yaml b/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v1.yaml
index c0fcc84..421ee6e 100644
--- a/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v1.yaml
+++ b/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v1.yaml
@@ -23,6 +23,8 @@ description: >
{% set service_name = service_name or ['test_service_', rnd ]|join %}
{% set resource_instance_name = resource_instance_name or ["test_resource_instance_", rnd ]|join %}
{% set resource_instance_unique_id = resource_instance_unique_id or ['\"\u007Bresource_version_id\u007D_', rnd, '\"']|join %}
+{% set vnf_package_location = vnf_package_location or none %}
+
steps:
-
type: RestCall
@@ -90,7 +92,7 @@ steps:
value: "{vsp_id}"
-
parameter_name: "package_file_path"
- value: "{context.vnf_descriptor.package_location}"
+ value: {{vnf_package_location}}
runner:
type: Iteration
run_step: "setup,run"
diff --git a/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v2.yaml b/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v2.yaml
index 931974e..8891917 100644
--- a/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v2.yaml
+++ b/vnftest/test_config/onap/test_cases/onap_vnftest_onboard-v2.yaml
@@ -23,6 +23,7 @@ description: >
{% set service_name = service_name or ['test_service_', rnd ]|join %}
{% set resource_instance_name = resource_instance_name or ["test_resource_instance_", rnd ]|join %}
{% set resource_instance_unique_id = resource_instance_unique_id or ['\"\u007Bresource_version_id\u007D_', rnd, '\"']|join %}
+{% set vnf_package_location = vnf_package_location or none %}
steps:
-
type: RestCall
@@ -91,7 +92,7 @@ steps:
value: "{vsp_version_id}"
-
parameter_name: "package_file_path"
- value: "{context.vnf_descriptor.package_location}"
+ value: {{vnf_package_location}}
runner:
type: Iteration
run_step: "setup,run"
diff --git a/vnftest/test_config/onap/test_cases/onap_vnftest_terminate.yaml b/vnftest/test_config/onap/test_cases/onap_vnftest_terminate.yaml
index 59aed7b..c930046 100644
--- a/vnftest/test_config/onap/test_cases/onap_vnftest_terminate.yaml
+++ b/vnftest/test_config/onap/test_cases/onap_vnftest_terminate.yaml
@@ -22,10 +22,12 @@ description: >
{% set vnf_instance_id = vnf_instance_id or '\"\u007Bvnf_instance_id\u007D\"' %}
{% set vf_module_instance_id = vf_module_instance_id or '\"\u007Bvf_module_instance_id\u007D\"' %}
{% set service_model_customization_id = service_model_customization_id or '\"\u007Bservice_model_customization_id\u007D\"' %}
+{% set vf_modules = vf_modules or {} %}
{% set vf_modules_list = vf_modules_list or {}%}
+{% set tenant_id = tenant_id or none %}
steps:
-{% for vf_module_definition in vnf_descriptor.vf_modules %}
+{% for vf_module_definition in vf_modules %}
{% set vf_module = vf_modules_list[vf_module_definition.module_name] %}
-
type: RestCall
@@ -58,7 +60,7 @@ steps:
value: {{service_model_customization_id}}
-
parameter_name: "tenant_id"
- value: "{context|creds|tenant_id}"
+ value: {{tenant_id}}
output:
-
diff --git a/vnftest/tests/unit/core/test_task.py b/vnftest/tests/unit/core/test_task.py
index 21947c9..d554951 100644
--- a/vnftest/tests/unit/core/test_task.py
+++ b/vnftest/tests/unit/core/test_task.py
@@ -64,7 +64,7 @@ class TaskTestCase(unittest.TestCase):
runner.get_output.return_value = {}
runner.get_result.return_value = []
mock_base_runner.Runner.get.return_value = runner
- t._run([step], False, "vnftest.out")
+ t._run([step], False, "vnftest.out", {})
self.assertTrue(runner.run.called)
def test_parse_suite_no_constraint_no_args(self):
diff --git a/vnftest/tests/unit/onap/test_rest_call.py b/vnftest/tests/unit/onap/test_rest_call.py
index ec3c88f..13aced7 100644
--- a/vnftest/tests/unit/onap/test_rest_call.py
+++ b/vnftest/tests/unit/onap/test_rest_call.py
@@ -54,5 +54,5 @@ class RestCallTestCase(testtools.TestCase):
context = Context.get("CSAR")
context.init(context_cfg)
t.context = context
- output = t._run([RestCallTestCase.step], False, "vnftest.out")
+ output = t._run([RestCallTestCase.step], False, "vnftest.out", {})
self.assertEquals(output[0]['data']['output1'], 'output1')