* cmdtest.py: Test lsmcli 'pool-raid-info' command. * plugin_test.py: Capability based python API test. * tester.c: C API test for both simulator plugin and simulator C plugin.
Signed-off-by: Gris Ge <f...@redhat.com> --- test/cmdtest.py | 20 ++++++++++++++++++++ test/plugin_test.py | 10 ++++++++++ test/tester.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/test/cmdtest.py b/test/cmdtest.py index e80e027..97c5b88 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -696,6 +696,24 @@ def volume_raid_info_test(cap, system_id): exit(10) return +def pool_raid_info_test(cap, system_id): + if cap['POOL_RAID_INFO']: + out = call([cmd, '-t' + sep, 'list', '--type', 'POOLS'])[1] + pool_list = parse(out) + for pool in pool_list: + out = call( + [cmd, '-t' + sep, 'pool-raid-info', '--pool', pool[0]])[1] + r = parse(out) + if len(r[0]) != 4: + print "pool-raid-info got expected output: %s" % out + exit(10) + if r[0][0] != pool[0]: + print "pool-raid-info output pool ID is not requested " \ + "pool ID %s" % out + exit(10) + return + + def run_all_tests(cap, system_id): test_display(cap, system_id) test_plugin_list(cap, system_id) @@ -709,6 +727,8 @@ def run_all_tests(cap, system_id): volume_raid_info_test(cap, system_id) + pool_raid_info_test(cap,system_id) + if __name__ == "__main__": parser = OptionParser() parser.add_option("-c", "--command", action="store", type="string", diff --git a/test/plugin_test.py b/test/plugin_test.py index 69a45b7..895bec3 100755 --- a/test/plugin_test.py +++ b/test/plugin_test.py @@ -1283,6 +1283,16 @@ def test_create_delete_exports(self): self.c.export_remove(exp) self._fs_delete(fs) + def test_pool_raid_info(self): + for s in self.systems: + cap = self.c.capabilities(s) + if supported(cap, [Cap.POOL_RAID_INFO]): + for pool in self.c.pools(): + (raid_type, member_type, member_ids) = \ + self.c.pool_raid_info(pool) + self.assertTrue(type(raid_type) is int) + self.assertTrue(type(member_type) is int) + self.assertTrue(type(member_ids) is list) def dump_results(): """ diff --git a/test/tester.c b/test/tester.c index 1622a75..9301804 100644 --- a/test/tester.c +++ b/test/tester.c @@ -2887,6 +2887,37 @@ START_TEST(test_volume_raid_info) } END_TEST +START_TEST(test_pool_raid_info) +{ + int rc; + lsm_pool **pools = NULL; + uint32_t poolCount = 0; + printf("querying pools\n"); + G(rc, lsm_pool_list, c, NULL, NULL, &pools, &poolCount, + LSM_CLIENT_FLAG_RSVD); + printf("got pools\n"); + + lsm_volume_raid_type raid_type; + lsm_pool_member_type member_type; + uint32_t member_count; + char **member_ids = NULL; + + int i; + int y; + for (i = 0; i < poolCount; i++) { + printf("Pool: %s\n", lsm_pool_id_get(pools[i])); + G( + rc, lsm_pool_raid_info, c, pools[i], &raid_type, &member_type, + &member_count, &member_ids, LSM_CLIENT_FLAG_RSVD); + for(y = 0; y < member_count; y++){ + free(member_ids[y]); + } + free(member_ids); + G(rc, lsm_pool_record_free, pools[i]); + } +} +END_TEST + Suite * lsm_suite(void) { Suite *s = suite_create("libStorageMgmt"); @@ -2923,6 +2954,7 @@ Suite * lsm_suite(void) tcase_add_test(basic, test_nfs_exports); tcase_add_test(basic, test_invalid_input); tcase_add_test(basic, test_volume_raid_info); + tcase_add_test(basic, test_pool_raid_info); suite_add_tcase(s, basic); return s; -- 1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Libstoragemgmt-devel mailing list Libstoragemgmt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel