Remove directory test_list 39/23539/2
authorwu.zhihui <wu.zhihui1@zte.com.cn>
Sat, 22 Oct 2016 06:37:58 +0000 (14:37 +0800)
committerwu.zhihui <wu.zhihui1@zte.com.cn>
Sat, 22 Oct 2016 06:43:55 +0000 (14:43 +0800)
Directory benchmarks/suite will be used instead of test_list.

JIRA: QTIP-131

Change-Id: I2c1f534b72361cb2e6469463ef5e43714d6dc993
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
func/args_handler.py
func/cli.py
restful_server/qtip_server.py
test_list/compute [deleted file]
test_list/network [deleted file]
test_list/storage [deleted file]
tests/cli_test.py

index 5971280..2f7c895 100644 (file)
@@ -14,8 +14,8 @@ from func.spawn_vm import SpawnVM
 from func.driver import Driver
 
 
-def get_files_in_test_list(suite_name, case_type='all'):
-    benchmark_list = json.load(file('test_list/{0}'.format(suite_name)))
+def get_files_in_suite(suite_name, case_type='all'):
+    benchmark_list = json.load(file('benchmarks/suite/{0}'.format(suite_name)))
     return reduce(add, benchmark_list.values()) \
         if case_type == 'all' else benchmark_list[case_type]
 
@@ -30,8 +30,8 @@ def get_benchmark_path(lab, suit, benchmark):
     return './test_cases/{0}/{1}/{2}'.format(lab, suit, benchmark)
 
 
-def check_suite_in_test_list(suite_name):
-    return True if os.path.isfile('test_list/' + suite_name) else False
+def check_suite(suite_name):
+    return True if os.path.isfile('benchmarks/suite/' + suite_name) else False
 
 
 def check_lab_name(lab_name):
index d914a2d..c5f5d2b 100644 (file)
@@ -11,6 +11,9 @@ import sys
 import os
 import args_handler
 import argparse
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('cli').get
 
 
 class Cli:
@@ -26,40 +29,41 @@ class Cli:
                             ' The user should list default after -l . all the fields in'
                             ' the files are necessary and should be filled')
         parser.add_argument('-f', '--file', required=True, help='File in '
-                            'test_list with the list of tests. there are three files'
+                            'benchmarks/suite/ with the list of tests. there are three files'
                             '\n compute '
                             '\n storage '
                             '\n network '
                             'They contain all the tests that will be run. They are listed by suite.'
                             'Please ensure there are no empty lines')
         parser.add_argument('-b', '--benchmark', help='Name of the benchmark.'
-                            'Can be found in test_lists/file_name')
+                            'Can be found in benchmarks/suite/file_name')
 
         return parser.parse_args(args)
 
     def __init__(self, args=sys.argv[1:]):
 
         args = self._parse_args(args)
-        if not args_handler.check_suite_in_test_list(args.file):
-            print('\n\n ERROR: Test File Does not exist in test_list/ please enter correct file \n\n')
+        if not args_handler.check_suite(args.file):
+            logger.error("ERROR: This suite file doesn't exist under benchmarks/suite/.\
+                Please enter correct file." % str(args.file))
             sys.exit(1)
 
         if not args_handler.check_lab_name(args.lab):
-            print('\n\n You have specified a lab that is not present in test_cases/ please enter \
-                   correct file. If unsure how to proceed, use -l default.\n\n')
+            logger.error("You have specified a lab that is not present under test_cases/.\
+                Please enter correct file. If unsure how to proceed, use -l default.")
             sys.exit(1)
         suite = args.file
-        benchmarks = args_handler.get_files_in_test_list(suite)
+        benchmarks = args_handler.get_files_in_suite(suite)
         test_cases = args_handler.get_files_in_test_case(args.lab, suite)
         benchmarks_list = filter(lambda x: x in test_cases, benchmarks)
 
         if args.benchmark:
             if not args_handler.check_benchmark_name(args.lab, args.file, args.benchmark):
-                print('\n\n You have specified an incorrect benchmark. Please'
-                      'enter the correct one.\n\n')
+                logger.error("You have specified an incorrect benchmark.\
+                    Please enter the correct one.")
                 sys.exit(1)
             else:
-                print("Starting with " + args.benchmark)
+                logger.info("Starting with " + args.benchmark)
                 args_handler.prepare_and_run_benchmark(
                     os.environ['INSTALLER_TYPE'], os.environ['PWD'],
                     args_handler.get_benchmark_path(args.lab.lower(), args.file, args.benchmark))
@@ -68,5 +72,5 @@ class Cli:
                 os.environ['INSTALLER_TYPE'], os.environ['PWD'],
                 args_handler.get_benchmark_path(args.lab.lower(), suite, x)), benchmarks_list)
 
-        print('{0} is not a Template in the Directory Enter a Valid file name.'
-              'or use qtip.py -h for list'.format(filter(lambda x: x not in test_cases, benchmarks)))
+        logger.info("{0} is not a Template in the Directory Enter a Valid file name.\
+            or use qtip.py -h for list".format(filter(lambda x: x not in test_cases, benchmarks)))
index d9dc52a..7b55020 100644 (file)
@@ -146,8 +146,8 @@ default is all benchmarks in suite with specified type,
                             help='testdb_url should be test db http url,for example http://testresults.opnfv.org/test/api/v1')
         parser.add_argument('node_name', type=str, required=False, default=None, help='node_name should be string')
         args = parser.parse_args()
-        if not args_handler.check_suite_in_test_list(args["suite_name"]):
-            return abort(404, 'message:Test suite {0} does not exist in test_list'.format(args["suite_name"]))
+        if not args_handler.check_suite(args["suite_name"]):
+            return abort(404, 'message:Test suite {0} does not exist under benchmarks/suite'.format(args["suite_name"]))
         if not args_handler.check_lab_name(args["pod_name"]):
             return abort(404, 'message: You have specified a lab {0}\
                                that is not present in test_cases'.format(args['pod_name']))
@@ -156,8 +156,8 @@ default is all benchmarks in suite with specified type,
         if not job_id:
             return abort(409, 'message:It already has one job running now!')
 
-        benchmarks = args_handler.get_files_in_test_list(args["suite_name"],
-                                                         args["type"].lower())
+        benchmarks = args_handler.get_files_in_suite(args["suite_name"],
+                                                     args["type"].lower())
         test_cases = args_handler.get_files_in_test_case(args["pod_name"],
                                                          args["suite_name"],
                                                          args["type"].lower())
diff --git a/test_list/compute b/test_list/compute
deleted file mode 100644 (file)
index 3bf1b18..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-    "bm": [
-        "dhrystone_bm.yaml",
-        "whetstone_bm.yaml",
-        "ramspeed_bm.yaml",
-        "dpi_bm.yaml",
-        "ssl_bm.yaml"
-    ],
-    "vm": [
-        "dhrystone_vm.yaml",
-        "whetstone_vm.yaml",
-        "ramspeed_vm.yaml",
-        "dpi_vm.yaml",
-        "ssl_vm.yaml"
-    ]
-}
diff --git a/test_list/network b/test_list/network
deleted file mode 100644 (file)
index 58ce5cb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "bm": [
-        "iperf_bm.yaml"
-    ],
-    "vm": [
-        "iperf_vm.yaml",
-        "iperf_vm_2.yaml"
-    ]
-}
diff --git a/test_list/storage b/test_list/storage
deleted file mode 100644 (file)
index f3068dd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "bm": [
-        "fio_bm.yaml"
-    ],
-    "vm": [
-        "fio_vm.yaml"
-    ]
-}
index 43a1108..e47d99a 100644 (file)
@@ -13,7 +13,7 @@ class TestClass:
         (['-l',
           'default',
           '-f',
-          'test'], "Test File Does not exist in test_list")
+          'test'], "This suite file doesn't exist under benchmarks/suite/")
     ])
     def test_cli_error(self, capfd, test_input, expected):
         k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})