summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-01-09 18:28:35 +0800
committerAce Lee <liyin11@huawei.com>2017-01-10 08:59:26 +0000
commite1a54d34819563946d1ff1ec673d1d261b826ad8 (patch)
tree4258db2bcfbf9238e0626b296364ac1366fd8656
parent90aee324d326a25ba79b83bf8aceb3bcf3feea9b (diff)
Bottlenecks frame support parser config
JIRA: BOTTLENECK-123 This code is for Bottlenecks to have a common way to parser config. those config are divided into three part: common config, test config and stack config. those function could build a frame of config read. we will modify it after a few times. Change-Id: I7d3ddc2c8af3043dc9cd89b519e506eca6a03514 Signed-off-by: liyin <liyin11@huawei.com>
-rw-r--r--config/config.yaml2
-rw-r--r--utils/parser.py56
2 files changed, 58 insertions, 0 deletions
diff --git a/config/config.yaml b/config/config.yaml
new file mode 100644
index 00000000..cf380e27
--- /dev/null
+++ b/config/config.yaml
@@ -0,0 +1,2 @@
+common_config:
+ log_dir: '/tmp/bottlenecks_POSCA.log' \ No newline at end of file
diff --git a/utils/parser.py b/utils/parser.py
new file mode 100644
index 00000000..7ddf02a2
--- /dev/null
+++ b/utils/parser.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2017 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
+##############################################################################
+from logger import Logger
+import os
+import yaml
+
+
+class Parser():
+ def __init__(self):
+ self.code_dir = os.path.dirname(os.path.abspath(__file__))
+ self.root_dir = os.path.dirname(self.code_dir)
+ self.test_dir = os.path.join(self.root_dir, 'testsuites')
+ config_dir = os.path.join(
+ self.root_dir,
+ 'config',
+ 'config.yaml')
+ with open(config_dir) as file:
+ log_info = yaml.load(file)
+ self.logdir = log_info['common_config']
+ self.LOG = Logger(__name__).getLogger()
+
+ def config_read(self, testcase, story_name):
+ self.LOG.info("begin to parser config file!")
+ testcase_parser = {}
+ self.story_dir = os.path.join(
+ self.test_dir,
+ testcase,
+ 'testsuite_story',
+ story_name)
+ with open(self.story_dir) as file:
+ self.LOG.info('testsuite:' + testcase + 'story:' + story_name)
+ story_parser = yaml.load(file)
+ for case_name in story_parser['testcase']:
+ testcase_dir = os.path.join(
+ self.test_dir,
+ testcase,
+ 'testcase_cfg',
+ case_name)
+ with open(testcase_dir) as f:
+ self.LOG.info('story: %s, testcase: %s' % (story_name, case_name))
+ testcase_parser[case_name] = yaml.load(f)
+
+ return testcase_parser
+
+ def config_parser(self, testcase_cfg, parameters):
+ test_cfg = testcase_cfg['test_config']
+ stack_cfg = testcase_cfg['stack_config']
+ # TO-DO add cli parameters to stack_config.
+ return test_cfg, stack_cfg \ No newline at end of file