2 # Copyright 2021 Orange
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
23 def before_all(context):
24 context.data = {'config': os.getenv('NFVBENCH_CONFIG_PATH', '/etc/nfvbench/nfvbench.cfg')}
26 context.data['PROJECT_NAME'] = os.getenv('PROJECT_NAME', 'nfvbench')
27 context.data['TEST_DB_EXT_URL'] = os.getenv('TEST_DB_EXT_URL')
28 context.data['TEST_DB_URL'] = os.getenv('TEST_DB_URL')
29 context.data['BASE_TEST_DB_URL'] = ''
30 if context.data['TEST_DB_URL']:
31 context.data['BASE_TEST_DB_URL'] = context.data['TEST_DB_URL'].replace('results', '')
32 context.data['INSTALLER_TYPE'] = os.getenv('INSTALLER_TYPE')
33 context.data['DEPLOY_SCENARIO'] = os.getenv('DEPLOY_SCENARIO')
34 context.data['NODE_NAME'] = os.getenv('NODE_NAME', 'nfvbench')
35 context.data['BUILD_TAG'] = os.getenv('BUILD_TAG')
37 # NFVbench server host and port
38 context.host_ip = os.getenv('NFVBENCH_SERVER_HOST', '127.0.0.1')
39 context.port = int(os.getenv('NFVBENCH_SERVER_PORT', '7555'))
42 def before_feature(context, feature):
45 context.start_time = time.time()
46 context.CASE_NAME = feature.name
49 def before_scenario(context, scenario):
50 context.tag = scenario.tags[0]
51 context.json = {'log_file': '/var/lib/xtesting/results/' + context.CASE_NAME + '/nfvbench.log'}
52 user_label = os.getenv('NFVBENCH_USER_LABEL', None)
54 context.json['user_label'] = user_label
55 loopvm_flavor = os.getenv('NFVBENCH_LOOPVM_FLAVOR_NAME', None)
57 context.json['flavor_type'] = loopvm_flavor
58 context.synthesis = {}
61 def after_feature(context, feature):
63 with open(os.path.join(
64 '/var/lib/xtesting/results/' + context.CASE_NAME + '/campaign_result.json'), "w") \
66 json.dump(context.results, outfile)