From 8037fbd5c0d27b45aa1364548ba2e7d76c86f207 Mon Sep 17 00:00:00 2001 From: Shwetha-H-Panduranga Date: Wed, 4 Jan 2012 18:02:38 +0530 Subject: Automating bugs bug2909, bug3033 Change-Id: Ic56569c9128a9a1c3f355e80c48baa5788b7d2ed Signed-off-by: Shwetha-H-Panduranga --- TestUnits/cli/volume/replace_brick/testcases.py | 179 +++++++++++++++++++++++ TestUnits/cli/volume/replace_brick/testcaseslist | 6 + TestUnits/cli/volume/replace_brick/testenv.cfg | 91 ++++++++++++ TestUnits/cli/volume/replace_brick/testunit.py | 108 ++++++++++++++ 4 files changed, 384 insertions(+) create mode 100644 TestUnits/cli/volume/replace_brick/testcases.py create mode 100644 TestUnits/cli/volume/replace_brick/testcaseslist create mode 100644 TestUnits/cli/volume/replace_brick/testenv.cfg create mode 100644 TestUnits/cli/volume/replace_brick/testunit.py diff --git a/TestUnits/cli/volume/replace_brick/testcases.py b/TestUnits/cli/volume/replace_brick/testcases.py new file mode 100644 index 0000000..06b7867 --- /dev/null +++ b/TestUnits/cli/volume/replace_brick/testcases.py @@ -0,0 +1,179 @@ +"""testcases for cli/volume/replace_brick +""" +import os + +import sys +import time +import glusterutils +import clientutils +import hostutils +import atfutils +import serverutils +import managerutils +import parser +from atfglobals import GlobalObj + +filename = os.path.abspath(__file__) +dir_path = os.path.dirname(filename) + +operation_success_messages = { + 'start' : "started successfully", + 'commit' : "commit successful", + 'status' : "Migration complete", + } + +def initialize(): + """ + """ + logger = GlobalObj.getLoggerObj() + return_status = 1 + testenv_file = GlobalObj.testenv_file + testenv_abspath = os.path.join(dir_path, testenv_file) + + if not (os.path.isfile(testenv_abspath)): + logger.error("%s not found in %s" % (testenv_file, dir_path)) + + if parser.parse_testenv_configfile(testenv_abspath): + return return_status + if managerutils.ssh_connect_allhosts(): + return return_status + + return 0 + +def setup(): + """ + """ + return_status = 1 + if atfutils.set_active_volume("volume1"): + return return_status + return 0 + +def reset_testenv(): + return_status = 1 + if clientutils.umountall(): + return return_status + glusterutils.volume_stop("server1", force=True) + glusterutils.volume_delete("server1") + glusterutils.glusterd_stop_allservers() + glusterutils.glusterd_remove_dir_allservers() + glusterutils.glusterd_remove_logs_allservers() + return 0 + +def setup_testenv(): + """ + """ + return_status = 1 + if glusterutils.glusterd_start_allservers(force=True): + return return_status + if glusterutils.peer_probe("server1"): + return return_status + if glusterutils.create_brick_allservers(): + return return_status + if glusterutils.volume_create("server1"): + return return_status + if glusterutils.volume_start("server1"): + return return_status + return 0 + +def bug2909(): + """ + Note: for replace-brick , we need the fuse module on the servers. + The replace-brick 'start' operation shows successful. + But the replace-brick 'status' operation fails. + """ + return_status = 1 + + if initialize(): + return return_status + if setup(): + return return_status + + if reset_testenv(): + return return_status + if setup_testenv(): + return return_status + + + expect_message = "Number of files migrated = 0 Migration complete" + + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "start") + if atfutils.validate_output(output, 0, "started successfully"): + return return_status + + time.sleep(30) + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "status") + if atfutils.validate_output(output, 0, expect_message): + return return_status + + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "commit") + if atfutils.validate_output(output, 0, "commit successful"): + return return_status + + return 0 + +def bug3033(): + """ + """ + return_status = 1 + + if initialize(): + return return_status + if setup(): + return return_status + + if reset_testenv(): + return return_status + if setup_testenv(): + return return_status + + if clientutils.mount("mount1"): + return 1 + + base_command = "mkdir -p " + for x in range(1, 50): + command = base_command + str(x) + output = clientutils.execute_on_mount("mount1", command) + if output["exitstatus"]: + return return_status + + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "start") + + if atfutils.validate_output(output, 0, "started successfully"): + return return_status + + sleep_time = 10 + timeout = 12 + + while timeout: + time.sleep(sleep_time) + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "status") + if atfutils.validate_output(output, 0, "migration complete"): + timeout -= 1 + continue + else: + break + + output = glusterutils.volume_replacebrick("server1", "brick1", + "brick3", "commit") + if atfutils.validate_output(output, 0, "commit successful"): + return return_status + + bricks = ['brick2', 'brick3'] + + commands = ['getfattr -n trusted.glusterfs.pump-source-complete ', + 'getfattr -n trusted.glusterfs.pump-sink-complete ', + 'getfattr -n trusted.glusterfs.pump-path '] + + for brick in bricks: + for command in commands: + command = command + "<" + brick + ".path>" + output = serverutils.execute_on_brick(brick, command) + if atfutils.validate_output(output, 0, "No such attribute", stream="stderr"): + return return_status + + return 0 diff --git a/TestUnits/cli/volume/replace_brick/testcaseslist b/TestUnits/cli/volume/replace_brick/testcaseslist new file mode 100644 index 0000000..a2abcc9 --- /dev/null +++ b/TestUnits/cli/volume/replace_brick/testcaseslist @@ -0,0 +1,6 @@ +################################################################# +# List of testcases for cli/volume/replace_brick +# TestCaseId : Version : Keyword +################################################################## +bug2909 : >= 3 : art +bug3033 : >= 3 : art diff --git a/TestUnits/cli/volume/replace_brick/testenv.cfg b/TestUnits/cli/volume/replace_brick/testenv.cfg new file mode 100644 index 0000000..9c6adec --- /dev/null +++ b/TestUnits/cli/volume/replace_brick/testenv.cfg @@ -0,0 +1,91 @@ +[DEFAULT] +user = +password = +glusterversion = +installpath = +downloadpath = + +# ExportDir Section. +# Necessary Options: dir +# Optional: fstype, device +[export1] +dir = +fstype = +device = +options = + +[export2] +dir = +fstype = +device = + +[export3] +dir = +fstype = +device = + +# Server Section +# Necessary Options: hostname, username, password, glusterversion. +# The username, password, glusterversion defaults from DEFAULTS Section and +# can be overridden +# Optional: installpath +[server1] +hostname = + +[server2] +hostname = + +[server3] +hostname = + +# Brick Section +# Necessary Options: hostname, path +[brick1] +hostname = server1.hostname +path = export1 + +[brick2] +hostname = server2.hostname +path = export2 + +[brick3] +hostname = server3.hostname +path = export3 + +# Volume Section +# Necessary Options: volumename, bricks +# Optional replica=, stripe= +# +[volume1] +volumename = replicate +replica=2 +stripe= +transporttype = tcp +bricks = brick1, brick2 + +# Client Section +# Necessary Options: hostname, username, password, glusterversion. +# The username, password, glusterversion defaults from DEFAULTS Section and +# can be overridden +# Optional: installpath +[client1] +hostname = + +# MountDevice Section +# Necessary Options: hostname, volume +# The Server1.hostname could be a VIP also. Need not be a server hostname +# IN a general case,(without NFS) we keep the 1st server from serverpool +# The volume specified in this section is the "active_volume" onto which all +# clients will be mounting to. This active volume and hostname can be changed +# during testrun. +[mountdevice1] +hostname = server1.hostname +volumename = volume1.volumename + +# Mount Section +# addMount(dir, type, client, device=master.volume, logfile=None) +[mount1] +dir = +client = +device = mountdevice1 +type = diff --git a/TestUnits/cli/volume/replace_brick/testunit.py b/TestUnits/cli/volume/replace_brick/testunit.py new file mode 100644 index 0000000..222140c --- /dev/null +++ b/TestUnits/cli/volume/replace_brick/testunit.py @@ -0,0 +1,108 @@ +"""testunit.py is the main module for the testunit. + +This module "main" function is called from atfexecute to execute the testunit. +""" +from atfglobals import GlobalObj +import os +import parser +import atfutils +import managerutils +import testcases + +reload(testcases) +filename = os.path.abspath(__file__) +dir_path = os.path.dirname(filename) + +def initialize(): + """ + """ + logger = GlobalObj.getLoggerObj() + return_status = 1 + testenv_file = GlobalObj.testenv_file + testenv_abspath = os.path.join(dir_path, testenv_file) + + if not (os.path.isfile(testenv_abspath)): + logger.error("%s not found in %s" % (testenv_file, dir_path)) + + if parser.parse_testenv_configfile(testenv_abspath): + return return_status + if managerutils.ssh_connect_allhosts(): + return return_status + + return 0 + +def setup(): + """ + """ + return_status = 1 + if atfutils.set_active_volume("volume1"): + return return_status + return 0 + +def execute(): + """ + """ + logger = GlobalObj.getLoggerObj() + return_status = 1 + testcaseslist_file = GlobalObj.testcaseslist_file + testcaseslist_abspath = os.path.join(dir_path, testcaseslist_file) + + if not (os.path.isfile(testcaseslist_abspath)): + logger.error("%s not found in %s" % (testcaseslist_file, dir_path)) + return return_status + + else: + testcaseslist = [] + testcaseslist = parser.parse_testcaseslist_file(testcaseslist_abspath) + if not testcaseslist: + logger.error("Skipping TestUnit %s. No testcases to execute" + % dir_path) + return 0 + else: + passedtestcases = 0 + failedtestcases = 0 + selectedtestcases = len(testcaseslist) + + logger.info("Starting TestUnit: '%s' test execution" % dir_path) + for testcase in testcaseslist: + function_obj = getattr(testcases, testcase) + if function_obj: + logger.debug("Starting Test: ' %s '" % testcase) + return_status = function_obj() + if return_status: + logger.debug("TestCase '%s' Failed" % testcase) + failedtestcases +=1 + else: + logger.debug("TestCase '%s' Passed" % testcase) + passedtestcases +=1 + logger.debug("Ending Test: '%s'" % testcase) + else: + logger.info("TestCase %s not defined in 'testcases' module" + % testcase) + continue + + + logger.info("Selected %d : Passed %d, Failed %d" + % (selectedtestcases, + passedtestcases, + failedtestcases)) + + logger.info("Ending TestUnit: '%s' test execution" % dir_path) + + return 0 + +def cleanup(): + """ + """ + pass + +def main(): + """ + """ + return_status = 1 + if execute(): + return return_status + if cleanup(): + return return_status + + return 0 -- cgit