summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuyang <Gabriel.yuyang@huawei.com>2017-05-22 19:19:56 +0800
committeryuyang <Gabriel.yuyang@huawei.com>2017-05-25 15:32:21 +0800
commit8fd28cfeaca4ac29f4357c51eb0c0374d0d0a409 (patch)
tree88b646af98e564139a5b74d08489f8efe1481e89
parent95748aca5de2e906b0f555e7dbf3829e397d6415 (diff)
Add reporting to MongoDB
JIRA: BOTTLENECK-158 Add reporting function to community MongoDB Change-Id: Idebc191b20ad238dbdd129ce38131b79e7133e35 Signed-off-by: yuyang <Gabriel.yuyang@huawei.com>
-rw-r--r--config/__init__.py0
-rw-r--r--docker/bottleneck-compose/docker-compose.yml4
-rwxr-xr-xrun_tests.sh19
-rwxr-xr-xtestsuites/posca/run_posca.py60
-rw-r--r--utils/parser.py2
5 files changed, 72 insertions, 13 deletions
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/config/__init__.py
diff --git a/docker/bottleneck-compose/docker-compose.yml b/docker/bottleneck-compose/docker-compose.yml
index 98d12976..31f83698 100644
--- a/docker/bottleneck-compose/docker-compose.yml
+++ b/docker/bottleneck-compose/docker-compose.yml
@@ -40,3 +40,7 @@ bottlenecks:
- INSTALLER_IP=192.168.200.2
- INSTALLER_TYPE=compass
- DEBUG=true
+ - NODE_NAME=${NODE_NAME}
+ - DEPLOY_SCENARIO=${DEPLOY_SCENARIO}
+ - BUILD_TAG=${BUILD_TAG}
+ - BRANCH=$(basename ${BRANCH})
diff --git a/run_tests.sh b/run_tests.sh
index 7e4be373..41104208 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -37,10 +37,9 @@ POSCA_TESTCASE="/home/opnfv/bottlenecks/testsuites/posca/testcase_cfg"
POSCA_TESTSTORY="/home/opnfv/bottlenecks/testsuites/posca/testsuite_story"
BASEDIR=`dirname $0`
-report=false
+REPORT="False"
cleanup=false
-
# Define alias for log printing
info () {
logger -s -t "bottlenecks.info" "$*"
@@ -109,8 +108,8 @@ function run_test(){
info "Pulling tutum/influxdb for yardstick"
docker pull tutum/influxdb:0.13
sleep 5
- info "Running posca test story: $test_exec"
- docker exec bottleneckcompose_bottlenecks_1 python ${POSCA_SUITE}/run_posca.py $test_level $test_exec
+ info "Running posca $test_level: $test_exec"
+ docker exec bottleneckcompose_bottlenecks_1 python ${POSCA_SUITE}/run_posca.py $test_level $test_exec $REPORT
;;
esac
}
@@ -134,7 +133,7 @@ while [[ $# > 0 ]]
shift
;;
--report)
- report=true
+ REPORT="True"
;;
--cleanup)
cleanup=true
@@ -148,11 +147,11 @@ while [[ $# > 0 ]]
done
# Clean up related docker images
-bash ${BASEDIR}/docker/docker_cleanup.sh -d bottlenecks --debug
-bash ${BASEDIR}/docker/docker_cleanup.sh -d yardstick --debug
-bash ${BASEDIR}/docker/docker_cleanup.sh -d kibana --debug
-bash ${BASEDIR}/docker/docker_cleanup.sh -d elasticsearch --debug
-bash ${BASEDIR}/docker/docker_cleanup.sh -d influxdb --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d bottlenecks --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d yardstick --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d kibana --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d elasticsearch --debug
+#bash ${BASEDIR}/docker/docker_cleanup.sh -d influxdb --debug
# Run tests
if [ "${teststory}" != "" ]; then
diff --git a/testsuites/posca/run_posca.py b/testsuites/posca/run_posca.py
index 3e23a37a..18325b04 100755
--- a/testsuites/posca/run_posca.py
+++ b/testsuites/posca/run_posca.py
@@ -17,6 +17,12 @@ posca_factor_system_bandwidth by default.'''
import importlib
import sys
+import os
+
+from oslo_serialization import jsonutils
+import requests
+import datetime
+
import utils.parser as conf_parser
import utils.logger as log
INTERPRETER = "/usr/bin/python"
@@ -34,7 +40,42 @@ def posca_testcase_run(testcase_script, test_config):
module.run(test_config)
-def posca_run(test_level, test_name):
+def report(testcase, start_date, stop_date, criteria, details_doc):
+ headers = {'Content-type': 'application/json'}
+ results = {
+ "project_name": "bottlenecks",
+ "case_name": testcase,
+ "description": ("test results for " + testcase),
+ "pod_name": os.environ.get('NODE_NAME', 'unknown'),
+ "installer": os.environ.get('INSTALLER_TYPE', 'unknown'),
+ "version": os.environ.get('BRANCH', 'unknown'),
+ "build_tag": os.environ.get('BUILD_TAG', 'unknown'),
+ "stop_date": stop_date,
+ "start_date": start_date,
+ "criteria": criteria,
+ "scenario": os.environ.get('DEPLOY_SCENARIO', 'unknown')
+ }
+ results['details'] = {"test_results": details_doc}
+
+ target = "http://testresults.opnfv.org/test/api/v1/results"
+ timeout = 5
+
+ try:
+ LOG.debug('Test result : %s', jsonutils.dump_as_bytes(results))
+ print ('Start posting test results to community MongoDB')
+ res = requests.post(target,
+ data=jsonutils.dump_as_bytes(results),
+ headers=headers,
+ timeout=timeout)
+ LOG.debug('Test result posting finished with status code'
+ ' %d.' % res.status_code)
+ print ('Test results posting finished with status code'
+ ' %d.' % res.status_code)
+ except Exception as err:
+ LOG.exception('Failed to record result data: %s', err)
+
+
+def posca_run(test_level, test_name, REPORT="False"):
if test_level == "testcase":
config = conf_parser.Parser.testcase_read("posca", test_name)
elif test_level == "teststory":
@@ -43,14 +84,29 @@ def posca_run(test_level, test_name):
LOG.info("Begin to run %s testcase in POSCA testsuite", testcase)
config[testcase]['out_file'] =\
conf_parser.Parser.testcase_out_dir(testcase)
+ start_date = datetime.datetime.now()
posca_testcase_run(testcase, config[testcase])
+ stop_date = datetime.datetime.now()
LOG.info("End of %s testcase in POSCA testsuite", testcase)
+ criteria = "FAIL"
+ if REPORT == "True":
+ details_doc = []
+ if os.path.exists(config[testcase]['out_file']):
+ with open(config[testcase]['out_file']) as details_result:
+ lines = details_result.readlines()
+ if len(lines):
+ criteria = "PASS"
+ for l in lines:
+ details_doc.append(l.replace('\n', ''))
+ report(testcase, start_date, stop_date, criteria, details_doc)
+
def main():
test_level = sys.argv[1]
test_name = sys.argv[2]
- posca_run(test_level, test_name)
+ REPORT = sys.argv[3]
+ posca_run(test_level, test_name, REPORT)
if __name__ == '__main__':
diff --git a/utils/parser.py b/utils/parser.py
index 48f705b0..ad141acb 100644
--- a/utils/parser.py
+++ b/utils/parser.py
@@ -49,7 +49,7 @@ class Parser():
cls.test_dir,
testcase,
'testsuite_story',
- story_name)
+ story_name + '.yaml')
with open(story_dir) as file:
story_parser = yaml.load(file)
for case_name in story_parser['testcase']: