From c6755e612b322facefc4edc32e948ab2b00bb3b0 Mon Sep 17 00:00:00 2001 From: liyin Date: Tue, 24 Jan 2017 17:26:21 +0800 Subject: Bottlenecks POSCA testing code reconstruction JIRA:BOTTLENECK-103 This is the foundation of adding stack samples. This code change a lot code. but it's a basic. Those code will be changed in the furture. Change-Id: I8d5bbb9cc401b1aaac54ec4dffc4c005a42d17ac Signed-off-by: liyin --- utils/parser.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'utils/parser.py') diff --git a/utils/parser.py b/utils/parser.py index ce5096a3..c8715859 100644 --- a/utils/parser.py +++ b/utils/parser.py @@ -7,6 +7,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +'''This file realize the function of how to parser a config file. +This contain Two part: +Frist is Init some variables the will be used. +Second is reading config file.''' + import os import yaml @@ -14,6 +19,7 @@ import yaml class Parser(): bottlenecks_config = {} + bottlenecks_test = {} @classmethod def config_init(cls): @@ -35,7 +41,7 @@ class Parser(): cls.config_dir_check(cls.bottlenecks_config["log_dir"]) @classmethod - def config_read(cls, testcase, story_name): + def story_read(cls, testcase, story_name): story_dir = os.path.join( cls.test_dir, testcase, @@ -44,15 +50,23 @@ class Parser(): with open(story_dir) as file: story_parser = yaml.load(file) for case_name in story_parser['testcase']: - testcase_dir = os.path.join( - cls.test_dir, - testcase, - 'testcase_cfg', - case_name) - with open(testcase_dir) as f: - cls.bottlenecks_config[case_name] = yaml.load(f) + Parser.testcase_read(cls, testcase, case_name) + + return cls.bottlenecks_test + + @classmethod + def testcase_read(cls, testcase, testcase_name): - return cls.bottlenecks_config + testcase_dir = os.path.join( + cls.test_dir, + testcase, + 'testcase_cfg', + testcase_name) + testcase_local = testcase_dir + ".yaml" + with open(testcase_local) as f: + cls.bottlenecks_test[testcase_name] = yaml.load(f) + + return cls.bottlenecks_test @classmethod def config_dir_check(cls, dirname): @@ -67,3 +81,4 @@ class Parser(): stack_cfg = testcase_cfg['stack_config'] # TO-DO add cli parameters to stack_config. return test_cfg, stack_cfg + -- cgit 1.2.3-korg