summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-09-22 16:15:58 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-09-22 16:15:58 +0800
commite7b7bb64bf2f3f03980504d80f304e4859146ed2 (patch)
treeb51669d1a1932e4397ee366c67f66c6ffad4593e /utils
parent9f7616b1e09a5d1aa2828f91c2b6f0e534e7a85f (diff)
rebuild directory structure of Kibana dashboard
JIRA: FUNCTEST-465 Change-Id: Icecd350b2f67105c8aaa9d71fd76d24827515545 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils')
-rw-r--r--utils/test/dashboard.tar.gzbin0 -> 14627 bytes
-rw-r--r--utils/test/dashboard/backup-db.sh (renamed from utils/test/scripts/backup-db.sh)0
-rw-r--r--utils/test/dashboard/dashboard/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/common/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/common/elastic_access.py (renamed from utils/test/scripts/shared_utils.py)0
-rw-r--r--utils/test/dashboard/dashboard/common/logger_utils.py (renamed from utils/test/scripts/logger_utils.py)4
-rw-r--r--utils/test/dashboard/dashboard/conf/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/conf/config.py (renamed from utils/test/scripts/config.py)2
-rw-r--r--utils/test/dashboard/dashboard/conf/testcases.py (renamed from utils/test/scripts/testcases_parser.py)2
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/main.py (renamed from utils/test/scripts/create_kibana_dashboards.py)32
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana_main.py4
-rw-r--r--utils/test/dashboard/dashboard/functest/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/functest/testcases.yaml (renamed from utils/test/scripts/testcases.yaml)0
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic/__init__.py0
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic/format.py (renamed from utils/test/scripts/mongo2elastic_format.py)0
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic/main.py (renamed from utils/test/scripts/mongo_to_elasticsearch.py)25
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic_main.py4
-rw-r--r--utils/test/dashboard/etc/config.ini (renamed from utils/test/scripts/config.ini)2
-rw-r--r--utils/test/dashboard/kibana_cleanup.py (renamed from utils/test/scripts/kibana_cleanup.py)6
20 files changed, 41 insertions, 40 deletions
diff --git a/utils/test/dashboard.tar.gz b/utils/test/dashboard.tar.gz
new file mode 100644
index 000000000..ef85f90da
--- /dev/null
+++ b/utils/test/dashboard.tar.gz
Binary files differ
diff --git a/utils/test/scripts/backup-db.sh b/utils/test/dashboard/backup-db.sh
index 35c3fbe5a..35c3fbe5a 100644
--- a/utils/test/scripts/backup-db.sh
+++ b/utils/test/dashboard/backup-db.sh
diff --git a/utils/test/dashboard/dashboard/__init__.py b/utils/test/dashboard/dashboard/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/__init__.py
diff --git a/utils/test/dashboard/dashboard/common/__init__.py b/utils/test/dashboard/dashboard/common/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/common/__init__.py
diff --git a/utils/test/scripts/shared_utils.py b/utils/test/dashboard/dashboard/common/elastic_access.py
index e90a17fa3..e90a17fa3 100644
--- a/utils/test/scripts/shared_utils.py
+++ b/utils/test/dashboard/dashboard/common/elastic_access.py
diff --git a/utils/test/scripts/logger_utils.py b/utils/test/dashboard/dashboard/common/logger_utils.py
index 25d28a582..183080810 100644
--- a/utils/test/scripts/logger_utils.py
+++ b/utils/test/dashboard/dashboard/common/logger_utils.py
@@ -57,9 +57,9 @@ class Logger(object):
return self.logger
-class KibanaDashboardLogger(Logger):
+class DashboardLogger(Logger):
file_path = '/var/log/kibana_dashboard'
def __init__(self, logger_name):
- super(KibanaDashboardLogger, self).__init__(logger_name)
+ super(DashboardLogger, self).__init__(logger_name)
diff --git a/utils/test/dashboard/dashboard/conf/__init__.py b/utils/test/dashboard/dashboard/conf/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/conf/__init__.py
diff --git a/utils/test/scripts/config.py b/utils/test/dashboard/dashboard/conf/config.py
index 2d447a7ba..2e0f1cabb 100644
--- a/utils/test/scripts/config.py
+++ b/utils/test/dashboard/dashboard/conf/config.py
@@ -22,7 +22,7 @@ class APIConfig:
"""
def __init__(self):
- self._default_config_location = "./config.ini"
+ self._default_config_location = "../etc/config.ini"
self.elastic_url = 'http://localhost:9200'
self.elastic_creds = None
self.destination = 'elasticsearch'
diff --git a/utils/test/scripts/testcases_parser.py b/utils/test/dashboard/dashboard/conf/testcases.py
index cf9599858..e120987dd 100644
--- a/utils/test/scripts/testcases_parser.py
+++ b/utils/test/dashboard/dashboard/conf/testcases.py
@@ -1,7 +1,7 @@
import yaml
-with open('./testcases.yaml') as f:
+with open('./functest/testcases.yaml') as f:
testcases_yaml = yaml.safe_load(f)
f.close()
diff --git a/utils/test/dashboard/dashboard/elastic2kibana/__init__.py b/utils/test/dashboard/dashboard/elastic2kibana/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/elastic2kibana/__init__.py
diff --git a/utils/test/scripts/create_kibana_dashboards.py b/utils/test/dashboard/dashboard/elastic2kibana/main.py
index 19d5b5e52..c1cbc308e 100644
--- a/utils/test/scripts/create_kibana_dashboards.py
+++ b/utils/test/dashboard/dashboard/elastic2kibana/main.py
@@ -4,12 +4,11 @@ import urlparse
import argparse
-import logger_utils
-import shared_utils
-import testcases_parser
-from config import APIConfig
+from common import logger_utils, elastic_access
+from conf import testcases
+from conf.config import APIConfig
-logger = logger_utils.KibanaDashboardLogger('elastic2kibana').get
+logger = logger_utils.DashboardLogger('elastic2kibana').get
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config-file",
@@ -18,6 +17,11 @@ parser.add_argument("-c", "--config-file",
args = parser.parse_args()
CONF = APIConfig().parse(args.config_file)
+base_elastic_url = CONF.elastic_url
+generate_inputs = CONF.is_js
+input_file_path = CONF.js_path
+kibana_url = CONF.kibana_url
+es_creds = CONF.elastic_creds
_installers = {'fuel', 'apex', 'compass', 'joid'}
@@ -53,7 +57,7 @@ class KibanaDashboard(dict):
for visualization in self._kibana_visualizations:
url = urlparse.urljoin(base_elastic_url, '/.kibana/visualization/{}'.format(visualization.id))
logger.debug("publishing visualization '{}'".format(url))
- shared_utils.publish_json(visualization, es_creds, url)
+ elastic_access.publish_json(visualization, es_creds, url)
def _construct_panels(self):
size_x = 6
@@ -131,7 +135,7 @@ class KibanaDashboard(dict):
def _publish(self):
url = urlparse.urljoin(base_elastic_url, '/.kibana/dashboard/{}'.format(self.id))
logger.debug("publishing dashboard '{}'".format(url))
- shared_utils.publish_json(self, es_creds, url)
+ elastic_access.publish_json(self, es_creds, url)
def publish(self):
self._publish_visualizations()
@@ -282,8 +286,8 @@ def _get_pods_and_scenarios(project_name, case_name, installer):
}
})
- elastic_data = shared_utils.get_elastic_docs(urlparse.urljoin(base_elastic_url, '/test_results/mongo2elastic'),
- es_creds, query_json)
+ elastic_data = elastic_access.get_elastic_docs(urlparse.urljoin(base_elastic_url, '/test_results/mongo2elastic'),
+ es_creds, query_json)
pods_and_scenarios = {}
@@ -312,7 +316,7 @@ def construct_dashboards():
:return: list of KibanaDashboards
"""
kibana_dashboards = []
- for project, case_dicts in testcases_parser.testcases_yaml.items():
+ for project, case_dicts in testcases.testcases_yaml.items():
for case in case_dicts:
case_name = case.get('name')
visualizations = case.get('visualizations')
@@ -359,13 +363,7 @@ def generate_js_inputs(js_file_path, kibana_url, dashboards):
js_file_fdesc.write(str(js_dict).replace("u'", "'"))
-if __name__ == '__main__':
- base_elastic_url = CONF.elastic_url
- generate_inputs = CONF.is_js
- input_file_path = CONF.js_path
- kibana_url = CONF.kibana_url
- es_creds = CONF.elastic_creds
-
+def main():
dashboards = construct_dashboards()
for kibana_dashboard in dashboards:
diff --git a/utils/test/dashboard/dashboard/elastic2kibana_main.py b/utils/test/dashboard/dashboard/elastic2kibana_main.py
new file mode 100644
index 000000000..3ec27cb40
--- /dev/null
+++ b/utils/test/dashboard/dashboard/elastic2kibana_main.py
@@ -0,0 +1,4 @@
+from elastic2kibana.main import main
+
+if __name__ == '__main__':
+ main()
diff --git a/utils/test/dashboard/dashboard/functest/__init__.py b/utils/test/dashboard/dashboard/functest/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/functest/__init__.py
diff --git a/utils/test/scripts/testcases.yaml b/utils/test/dashboard/dashboard/functest/testcases.yaml
index 9c33d2e6b..9c33d2e6b 100644
--- a/utils/test/scripts/testcases.yaml
+++ b/utils/test/dashboard/dashboard/functest/testcases.yaml
diff --git a/utils/test/dashboard/dashboard/mongo2elastic/__init__.py b/utils/test/dashboard/dashboard/mongo2elastic/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/dashboard/dashboard/mongo2elastic/__init__.py
diff --git a/utils/test/scripts/mongo2elastic_format.py b/utils/test/dashboard/dashboard/mongo2elastic/format.py
index ef485bae0..ef485bae0 100644
--- a/utils/test/scripts/mongo2elastic_format.py
+++ b/utils/test/dashboard/dashboard/mongo2elastic/format.py
diff --git a/utils/test/scripts/mongo_to_elasticsearch.py b/utils/test/dashboard/dashboard/mongo2elastic/main.py
index 777eda6ad..25b5320d7 100644
--- a/utils/test/scripts/mongo_to_elasticsearch.py
+++ b/utils/test/dashboard/dashboard/mongo2elastic/main.py
@@ -10,13 +10,12 @@ import uuid
import argparse
-import logger_utils
-import mongo2elastic_format
-import shared_utils
-import testcases_parser
-from config import APIConfig
+from common import logger_utils, elastic_access
+from conf import testcases
+from conf.config import APIConfig
+from mongo2elastic import format
-logger = logger_utils.KibanaDashboardLogger('mongo2elastic').get
+logger = logger_utils.DashboardLogger('mongo2elastic').get
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config-file",
@@ -50,7 +49,7 @@ class DocumentPublisher:
def format(self):
try:
if self._verify_document() and self.fmt:
- self.is_formatted = vars(mongo2elastic_format)[self.fmt](self.doc)
+ self.is_formatted = vars(format)[self.fmt](self.doc)
else:
self.is_formatted = False
except Exception:
@@ -65,7 +64,7 @@ class DocumentPublisher:
self._publish()
def _publish(self):
- status, data = shared_utils.publish_json(self.doc, self.creds, self.to)
+ status, data = elastic_access.publish_json(self.doc, self.creds, self.to)
if status > 300:
logger.error('Publish record[{}] failed, due to [{}]'
.format(self.doc, json.loads(data)['error']['reason']))
@@ -201,7 +200,7 @@ class DocumentsPublisher:
exit(-1)
def get_existed_docs(self):
- self.existed_docs = shared_utils.get_elastic_docs_by_days(self.elastic_url, self.creds, self.days)
+ self.existed_docs = elastic_access.get_elastic_docs_by_days(self.elastic_url, self.creds, self.days)
return self
def publish(self):
@@ -231,10 +230,10 @@ def main():
if to == 'elasticsearch':
to = base_elastic_url
- for project, case_dicts in testcases_parser.testcases_yaml.items():
+ for project, case_dicts in testcases.testcases_yaml.items():
for case_dict in case_dicts:
case = case_dict.get('name')
- fmt = testcases_parser.compose_format(case_dict.get('format'))
+ fmt = testcases.compose_format(case_dict.get('format'))
DocumentsPublisher(project,
case,
fmt,
@@ -242,7 +241,3 @@ def main():
base_elastic_url,
es_creds,
to).export().get_existed_docs().publish()
-
-
-if __name__ == '__main__':
- main() \ No newline at end of file
diff --git a/utils/test/dashboard/dashboard/mongo2elastic_main.py b/utils/test/dashboard/dashboard/mongo2elastic_main.py
new file mode 100644
index 000000000..141d8f3ab
--- /dev/null
+++ b/utils/test/dashboard/dashboard/mongo2elastic_main.py
@@ -0,0 +1,4 @@
+from mongo2elastic.main import main
+
+if __name__ == '__main__':
+ main()
diff --git a/utils/test/scripts/config.ini b/utils/test/dashboard/etc/config.ini
index 63d283dc8..b94ac7b4f 100644
--- a/utils/test/scripts/config.ini
+++ b/utils/test/dashboard/etc/config.ini
@@ -9,6 +9,6 @@ creds =
destination = elasticsearch
[kibana]
-url = http://10.63.243.17/kibana/app/kibana
+url = http://10.63.243.17:5601/app/kibana
js = true
js_path = /usr/share/nginx/html/kibana_dashboards/conf.js
diff --git a/utils/test/scripts/kibana_cleanup.py b/utils/test/dashboard/kibana_cleanup.py
index d87d9a285..9ce4994f5 100644
--- a/utils/test/scripts/kibana_cleanup.py
+++ b/utils/test/dashboard/kibana_cleanup.py
@@ -4,7 +4,7 @@ import urlparse
import argparse
-import shared_utils
+from dashboard.common import elastic_access
logger = logging.getLogger('clear_kibana')
logger.setLevel(logging.DEBUG)
@@ -14,10 +14,10 @@ logger.addHandler(file_handler)
def delete_all(url, es_creds):
- ids = shared_utils.get_elastic_docs(url, es_creds, body=None, field='_id')
+ ids = elastic_access.get_elastic_docs(url, es_creds, body=None, field='_id')
for id in ids:
del_url = '/'.join([url, id])
- shared_utils.delete_request(del_url, es_creds)
+ elastic_access.delete_request(del_url, es_creds)
if __name__ == '__main__':