From d691cc89e106d710f4d36bc3998501415588e2e1 Mon Sep 17 00:00:00 2001 From: "Sridhar K. N. Rao" Date: Tue, 11 Jun 2019 12:53:58 +0530 Subject: Docker: VSPERF Results Container. This patch adds docker-compose.yml and related config files for creating a results container. The container hosts following services: 1. Barometer Grafana. 2. Barometer Influxdb. 2. ELK Stack. 3. OPNFV TestAPI. 4. Jupyter Notebook with VSPERF testresults-analysis. Removed dashboard files, which can be obtained from barometer-grafana. Added comment in tools.rst under pre-deployment Retained only vpserf-cases and vsperf in cases.json and projects.json Changed barometer-influxdb to influxdb:latest. Added README.md file. Added environment variable setting to disable token for jupyter JIRA: VSPERF-602 Change-Id: I37a1391a1f34f834ce0d46def75a9f3454e09772 Signed-off-by: Sridhar K. N. Rao --- tools/docker/results/resultsdb/init_db.py | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tools/docker/results/resultsdb/init_db.py (limited to 'tools/docker/results/resultsdb/init_db.py') diff --git a/tools/docker/results/resultsdb/init_db.py b/tools/docker/results/resultsdb/init_db.py new file mode 100644 index 00000000..40bb4ee2 --- /dev/null +++ b/tools/docker/results/resultsdb/init_db.py @@ -0,0 +1,110 @@ +############################################################################## +# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +""" +Preload the results database with testcases. +""" + +from __future__ import print_function +import json +import sys +import requests + +DB_HOST_IP = sys.argv[1] +TESTAPI_PORT = sys.argv[2] + +TARGET_URL = 'http://{}:{}/api/v1'.format(DB_HOST_IP, TESTAPI_PORT) + + +def get(url): + """ + Get the http response. + """ + return requests.get(url).json() + + +def post(url, data): + """ + Post HTTP request. + """ + headers = {'Content-Type': 'application/json'} + res = requests.post(url, data=json.dumps(data), headers=headers) + print(res.text) + + +def pod(): + """ + Get the PODs. + """ + target = '{}/pods'.format(TARGET_URL) + + with open('pods.json', 'r') as podref: + pods = json.load(podref) + for apod in pods: + post(target, apod) + + add_pod('master', 'metal') + add_pod('virtual_136_2', 'virtual') + + +def project(): + """ + Get the Projects + """ + target = '{}/projects'.format(TARGET_URL) + with open('projects.json', 'r') as projref: + projects = json.load(projref) + for proj in projects: + post(target, proj) + + +def cases(): + """ + Get the Cases + """ + with open('cases.json', 'r') as caseref: + for line in caseref: + subcases = json.loads(line) + for cas in subcases["testcases"]: + target = '{}/projects/{}/cases'.format(TARGET_URL, + cas['project_name']) + post(target, cas) + add_case("functest", "tempest_custom") + + +def add_pod(name, mode): + """ + Add the Pods. + """ + data = { + "role": "", + "name": name, + "details": '', + "mode": mode, + "creation_date": "2017-2-23 11:23:03.765581" + } + pod_url = '{}/pods'.format(TARGET_URL) + post(pod_url, data) + + +def add_case(projectname, casename): + """ + Add a testcase + """ + data = { + "project_name": projectname, + "name": casename, + } + case_url = '{}/projects/{}/cases'.format(TARGET_URL, projectname) + post(case_url, data) + + +if __name__ == '__main__': + pod() + project() + cases() -- cgit 1.2.3-korg