aboutsummaryrefslogtreecommitdiffstats
path: root/behave_tests/features/environment.py
diff options
context:
space:
mode:
authorfmenguy <francoisregis.menguy@orange.com>2021-03-11 20:33:36 +0100
committerfmenguy <francoisregis.menguy@orange.com>2021-04-27 16:22:39 +0200
commitfc792bba0bfaaaeca8a9a1b6ca47c9cd9303d41f (patch)
tree2042fd7846251f5f8dc56343400afbd315dc5377 /behave_tests/features/environment.py
parent8755c892f6cfbfb8ca4f3405675dfe770c769605 (diff)
NFVBENCH-205 - Add behave tests for characterization and non-regression
Change-Id: I708eee21a9fd11e7a276707fb0b43d8598381ce7 Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
Diffstat (limited to 'behave_tests/features/environment.py')
-rw-r--r--behave_tests/features/environment.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/behave_tests/features/environment.py b/behave_tests/features/environment.py
new file mode 100644
index 0000000..ee1aa17
--- /dev/null
+++ b/behave_tests/features/environment.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# Copyright 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+
+import json
+import os
+import time
+
+
+def before_all(context):
+ context.data = {'config': os.getenv('NFVBENCH_CONFIG_PATH', '/etc/nfvbench/nfvbench.cfg')}
+
+ context.data['PROJECT_NAME'] = os.getenv('PROJECT_NAME', 'nfvbench')
+ context.data['TEST_DB_EXT_URL'] = os.getenv('TEST_DB_EXT_URL')
+ context.data['TEST_DB_URL'] = os.getenv('TEST_DB_URL')
+ context.data['BASE_TEST_DB_URL'] = ''
+ if context.data['TEST_DB_URL']:
+ context.data['BASE_TEST_DB_URL'] = context.data['TEST_DB_URL'].replace('results', '')
+ context.data['INSTALLER_TYPE'] = os.getenv('INSTALLER_TYPE')
+ context.data['DEPLOY_SCENARIO'] = os.getenv('DEPLOY_SCENARIO')
+ context.data['NODE_NAME'] = os.getenv('NODE_NAME', 'nfvbench')
+ context.data['BUILD_TAG'] = os.getenv('BUILD_TAG')
+
+
+def before_feature(context, feature):
+ context.rates = {}
+ context.results = {}
+ context.start_time = time.time()
+ context.CASE_NAME = feature.name
+
+
+def before_scenario(context, scenario):
+ context.tag = scenario.tags[0]
+ context.json = {'log_file': '/var/lib/xtesting/results/' + context.CASE_NAME + '/nfvbench.log'}
+ user_label = os.getenv('NFVBENCH_USER_LABEL', None)
+ if user_label:
+ context.json['user_label'] = user_label
+ loopvm_flavor = os.getenv('NFVBENCH_LOOPVM_FLAVOR_NAME', None)
+ if loopvm_flavor:
+ context.json['flavor_type'] = loopvm_flavor
+ context.synthesis = {}
+
+
+def after_feature(context, feature):
+ if context.results:
+ with open(os.path.join(
+ '/var/lib/xtesting/results/' + context.CASE_NAME + '/campaign_result.json'), "w") \
+ as outfile:
+ json.dump(context.results, outfile)