Moon testcase bug fix
[bottlenecks.git] / testsuites / posca / testcase_dashboard / posca_moon_resources.py
1 #!/usr/bin/python
2 ##############################################################################
3 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 '''This file realize a function of creating dashboard of stress ping test'''
11 import ConfigParser
12 from elasticsearch import Elasticsearch
13 import os
14 import utils.logger as log
15 from utils.parser import Parser as conf_parser
16
17 LOG = log.Logger(__name__).getLogger()
18 config = ConfigParser.ConfigParser()
19 es = Elasticsearch()
20 dashboard_path = os.path.join(conf_parser.test_dir,
21                               "posca",
22                               "testcase_dashboard")
23 dashboard_dir = dashboard_path + "/"
24
25
26 def dashboard_send_data(runner_config, test_data):
27     global es
28     print runner_config
29     es_ip = runner_config['dashboard_ip'].split(':')
30     es = Elasticsearch([{'host': es_ip[0]}])
31     print test_data["test_body"]
32     res = es.index(index="bottlenecks",
33                    doc_type=test_data["testcase"],
34                    body=test_data["test_body"][0])
35     if res['created'] == "False":
36         LOG.error("date send to kibana have errors ", test_data["data_body"])