[PATCH 0 of 2] Add option for running a subset of test directories

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1258580377 28800 # Node ID dfe044c37ec5b9f87db1a377743d9b928180018c # Parent c7907449b007aece4418f03272d8754b5fd41ac2 [TEST] Add get_subset_test_list(): lists the tests in a given set of test dirs This function allows you to get the list of tests in the specified directories. It supports two ways of specifying directories: [dir1:dir2] or [dir1,dir2,dir3] Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c7907449b007 -r dfe044c37ec5 lib/VirtLib/groups.py --- a/lib/VirtLib/groups.py Mon Nov 09 13:24:52 2009 -0800 +++ b/lib/VirtLib/groups.py Wed Nov 18 13:39:37 2009 -0800 @@ -37,7 +37,18 @@ if os.path.isdir(group_p): ret.append(filename) - ret.sort() + #sort() doesn't handle upper and lower case comparisons properly. + #The following manipulation will ensure the list is in the same + #order 'ls' returns on a directory + tmp = [] + for i, group in enumerate(ret): + tmp.append([group.lower(), group]) + + tmp.sort() + ret = [] + for key, group in tmp: + ret.append(group) + return ret def list_tests_in_group(test_suite, group_name): @@ -93,3 +104,46 @@ ret.append({ 'group': group, 'test': test}) return ret + +def get_subset_test_list(test_suite, test_subset): + """Return a list of dictionaries for a specific set of groups. + It will contain the group and test filename + """ + ret = [] + + str = test_subset.strip('[]') + + if test_subset.find(",") >= 0: + groups = str.split(',') + + elif test_subset.find(":") >= 0: + groups = str.split(':') + if len(groups) != 2: + return ret + + all_groups = list_groups(test_suite) + index_start = all_groups.index(groups[0]) + index_end = all_groups.index(groups[1]) + + if index_start < 0: + print "Group %s (%d) was not found" % (groups[0], index_start) + return ret + elif index_end < 0: + print "Group %s (%d) was not found" % (groups[1], index_end) + return ret + elif index_end < index_start: + print "Group %s's index (%d) is < Group %s's index (%d)" % \ + (groups[1], index_end, groups[0], index_start) + return ret + + groups = all_groups[index_start:index_end + 1] + + else: + return ret + + for group in groups: + tmp = get_group_test_list(test_suite, group) + ret = ret + tmp + + return ret +

+1 Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1258580377 28800 # Node ID dfe044c37ec5b9f87db1a377743d9b928180018c # Parent c7907449b007aece4418f03272d8754b5fd41ac2 [TEST] Add get_subset_test_list(): lists the tests in a given set of test dirs
This function allows you to get the list of tests in the specified directories. It supports two ways of specifying directories:
[dir1:dir2] or [dir1,dir2,dir3]
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c7907449b007 -r dfe044c37ec5 lib/VirtLib/groups.py --- a/lib/VirtLib/groups.py Mon Nov 09 13:24:52 2009 -0800 +++ b/lib/VirtLib/groups.py Wed Nov 18 13:39:37 2009 -0800 @@ -37,7 +37,18 @@ if os.path.isdir(group_p): ret.append(filename)
- ret.sort() + #sort() doesn't handle upper and lower case comparisons properly. + #The following manipulation will ensure the list is in the same + #order 'ls' returns on a directory + tmp = [] + for i, group in enumerate(ret): + tmp.append([group.lower(), group]) + + tmp.sort() + ret = [] + for key, group in tmp: + ret.append(group) + return ret
def list_tests_in_group(test_suite, group_name): @@ -93,3 +104,46 @@ ret.append({ 'group': group, 'test': test})
return ret + +def get_subset_test_list(test_suite, test_subset): + """Return a list of dictionaries for a specific set of groups. + It will contain the group and test filename + """ + ret = [] + + str = test_subset.strip('[]') + + if test_subset.find(",") >= 0: + groups = str.split(',') + + elif test_subset.find(":") >= 0: + groups = str.split(':') + if len(groups) != 2: + return ret + + all_groups = list_groups(test_suite) + index_start = all_groups.index(groups[0]) + index_end = all_groups.index(groups[1]) + + if index_start < 0: + print "Group %s (%d) was not found" % (groups[0], index_start) + return ret + elif index_end < 0: + print "Group %s (%d) was not found" % (groups[1], index_end) + return ret + elif index_end < index_start: + print "Group %s's index (%d) is < Group %s's index (%d)" % \ + (groups[1], index_end, groups[0], index_start) + return ret + + groups = all_groups[index_start:index_end + 1] + + else: + return ret + + for group in groups: + tmp = get_group_test_list(test_suite, group) + ret = ret + tmp + + return ret +
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1258580377 28800 # Node ID 95cc631fc4581c9705ae93088688e1d3af28c55a # Parent dfe044c37ec5b9f87db1a377743d9b928180018c [TEST] Add --test_subset option for specifying a bulk run of a subset of dirs You can use this option in the following ways: CIM_NS=root/virt CIM_USER=root CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -d -v KVM --test_subset [LogicalDisk:RASD] -this will run all tests in the LogicalDisk, Memory, NetworkPort, Processor, Profile, and RASD directories CIM_NS=root/virt CIM_USER=root CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -d -v KVM --test_subset [LogicalDisk,RASD,Memory] -this will run all tests in the LogicalDisk, RASD, and Memory dirs Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r dfe044c37ec5 -r 95cc631fc458 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Wed Nov 18 13:39:37 2009 -0800 +++ b/suites/libvirt-cim/main.py Wed Nov 18 13:39:37 2009 -0800 @@ -68,6 +68,8 @@ parser.add_option("--print-exec-time", action="store_true", dest="print_exec_time", help="Print execution time of each test") +parser.add_option("--test_subset", dest="test_subset", + help="Only run specified dirs [dir,dir,...] or [dir:dir]") TEST_SUITE = 'cimtest' CIMTEST_RCFILE = '%s/.cimtestrc' % os.environ['HOME'] @@ -185,6 +187,11 @@ parser.print_help() return 1 + if options.group and options.test_subset: + print "\nPlease specify either a test group or a subset of tests.\n" + parser.print_help() + return 1 + env_ready = pre_check(options.ip, options.virt) if env_ready != None: print "\n%s. Please check your environment.\n" % env_ready @@ -214,17 +221,27 @@ set_python_path() - if options.group and options.test: - test_list = groups.get_one_test(TEST_SUITE, options.group, options.test) - elif options.group and not options.test: - test_list = groups.get_group_test_list(TEST_SUITE, options.group) + if options.group: + if options.test: + test_list = groups.get_one_test(TEST_SUITE, options.group, + options.test) + else: + test_list = groups.get_group_test_list(TEST_SUITE, options.group) + + if not test_list: + print "Test %s:%s not found" % (options.group, options.test) + return 1 + + elif options.test_subset: + test_list = groups.get_subset_test_list(TEST_SUITE, options.test_subset) + + if not test_list: + print "Test subset not found: %s" % (options.test_subset) + return 1 + else: test_list = groups.list_all_tests(TEST_SUITE) - if not test_list: - print "Test %s:%s not found" % (options.group, options.test) - return 1 - if options.clean: remove_old_logs(options.group)

+1 Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1258580377 28800 # Node ID 95cc631fc4581c9705ae93088688e1d3af28c55a # Parent dfe044c37ec5b9f87db1a377743d9b928180018c [TEST] Add --test_subset option for specifying a bulk run of a subset of dirs
You can use this option in the following ways:
CIM_NS=root/virt CIM_USER=root CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -d -v KVM --test_subset [LogicalDisk:RASD] -this will run all tests in the LogicalDisk, Memory, NetworkPort, Processor, Profile, and RASD directories
CIM_NS=root/virt CIM_USER=root CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -d -v KVM --test_subset [LogicalDisk,RASD,Memory] -this will run all tests in the LogicalDisk, RASD, and Memory dirs
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r dfe044c37ec5 -r 95cc631fc458 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Wed Nov 18 13:39:37 2009 -0800 +++ b/suites/libvirt-cim/main.py Wed Nov 18 13:39:37 2009 -0800 @@ -68,6 +68,8 @@ parser.add_option("--print-exec-time", action="store_true", dest="print_exec_time", help="Print execution time of each test") +parser.add_option("--test_subset", dest="test_subset", + help="Only run specified dirs [dir,dir,...] or [dir:dir]")
TEST_SUITE = 'cimtest' CIMTEST_RCFILE = '%s/.cimtestrc' % os.environ['HOME'] @@ -185,6 +187,11 @@ parser.print_help() return 1
+ if options.group and options.test_subset: + print "\nPlease specify either a test group or a subset of tests.\n" + parser.print_help() + return 1 + env_ready = pre_check(options.ip, options.virt) if env_ready != None: print "\n%s. Please check your environment.\n" % env_ready @@ -214,17 +221,27 @@
set_python_path()
- if options.group and options.test: - test_list = groups.get_one_test(TEST_SUITE, options.group, options.test) - elif options.group and not options.test: - test_list = groups.get_group_test_list(TEST_SUITE, options.group) + if options.group: + if options.test: + test_list = groups.get_one_test(TEST_SUITE, options.group, + options.test) + else: + test_list = groups.get_group_test_list(TEST_SUITE, options.group) + + if not test_list: + print "Test %s:%s not found" % (options.group, options.test) + return 1 + + elif options.test_subset: + test_list = groups.get_subset_test_list(TEST_SUITE, options.test_subset) + + if not test_list: + print "Test subset not found: %s" % (options.test_subset) + return 1 + else: test_list = groups.list_all_tests(TEST_SUITE)
- if not test_list: - print "Test %s:%s not found" % (options.group, options.test) - return 1 - if options.clean: remove_old_logs(options.group)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert