Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions qa/tasks/cephfs/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ def hadfailover(self, status):
#all matching
return False

def hadfailover_rank(self, fscid, status, rank):
"""
Compares two statuses for mds failovers for a
particular rank
"""
rank_info = self.get_rank(fscid, rank)
orig_rank_info = status.get_rank(fscid, rank)
if ((rank_info['gid'] != orig_rank_info['gid']) or (rank_info['incarnation'] != orig_rank_info['incarnation'])):
return True
return False


class CephCluster(object):
@property
def admin_remote(self):
Expand Down
121 changes: 121 additions & 0 deletions qa/tasks/cephfs/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,124 @@ def test_ephemeral_pin_shrink_mds(self):
log.info("{0} migrations have occured due to the cluster resizing".format(count))
# rebalancing from 3 -> 2 may cause half of rank 0/1 to move and all of rank 2
self.assertLessEqual((count/len(subtrees_old)), (1.0/3.0/2.0 + 1.0/3.0/2.0 + 1.0/3.0)*1.25) # aka .66 with 25% overbudget

class TestKillPoints(CephFSTestCase):
# Two active MDS
MDSS_REQUIRED = 4

init = False

def _setup_cluster(self):
# Set Multi-MDS cluster
self.fs.set_max_mds(2)

self.fs.wait_for_daemons()

# Create test data
if self.init is False:
self._populate_data(8)
self.init = True

return True

def _populate_data(self, nfiles):
size_mb = 8
dname = "abc"
self.mount_a.run_shell(["mkdir", dname])
for i in range(nfiles):
fname = dname + "/" + (str(i)) + ".txt"
self.mount_a.write_n_mb(fname, size_mb)

# Get the list of file to confirm the count of files
self.org_files = self.mount_a.ls()

def _verify_data(self):
s1 = set(self.mount_a.ls())
s2 = set(self.org_files)

if s1.isdisjoint(s2):
log.info("Directory contents org: %s" %str(self.org_files))
log.info("Directory contents new: %s" %str(self.mount_a.ls()))
return False

log.info("Directory contents matches")
return True

def _run_export_dir(self, importv, exportv):

status = self.fs.status()

rank_0 = self.fs.get_rank(status=status, rank = 0)
rank_1 = self.fs.get_rank(status=status, rank = 1)
rank_0_name = rank_0['name']
rank_1_name = rank_1['name']

killpoint = {}
killpoint[0] = ('export', exportv)
killpoint[1] = ('import', importv)

command = ["config", "set", "mds_kill_export_at", str(exportv)]
result = self.fs.rank_asok(command, rank=0, status=status)
assert(result["success"])

command = ["config", "set", "mds_kill_import_at", str(importv)]
result = self.fs.rank_asok(command, rank=1, status=status)
assert(result["success"])

# This should kill either or both MDS process
try:
# This should kill either or both MDS process
self.mount_a.setfattr("abc", "ceph.dir.pin", "1")
except Exception as e:
log.error(e.__str__())

time.sleep(150)
status2 = self.fs.status()

self._wait_subtrees([('/abc', 1)], status2, 1)

#status2 = self.fs.status()

rank_0_new = self.fs.get_rank(status=status2, rank = 0)
rank_1_new = self.fs.get_rank(status=status2, rank = 1)
rank_0_new_name = rank_0_new['name']
rank_1_new_name = rank_1_new['name']

if status2.hadfailover_rank(self.fs.id, status, 0):
log.info("MDS %s crashed and active as MDS %s at type %s killpoint %d"
%(rank_0_name, rank_0_new_name, killpoint[0][0], killpoint[0][1]))

if status2.hadfailover_rank(self.fs.id, status, 1):
log.info("MDS %s crashed and active as MDS %s at type %s killpoint %d"
%(rank_1_name, rank_1_new_name, killpoint[1][0], killpoint[1][1]))

active_mds = self.fs.get_active_names()
if len(active_mds) != 2:
"One or more MDS did not come up"
return False

if not self._verify_data():
return False;

#self.mount_a.run_shell(["rm -rf", "abc"])
return True


def _run_export(self, importv, exportv):
if not(self._run_export_dir(importv, exportv)):
log.error("Error for killpoint %d:%d" %(importv, exportv))
else:
return True

def make_test_killpoints(importv, exportv):
def test_export_killpoints(self):
self.init = False
self._setup_cluster()
assert(self._run_export(importv, exportv))
log.info("Test passed for killpoint (%d, %d)" %(importv, exportv))
return test_export_killpoints

for import_killpoint in range(0, 11):
for export_killpoint in range(2, 14):
test_export_killpoints = make_test_killpoints(import_killpoint, export_killpoint)
setattr(TestKillPoints, "test_export_killpoints_%d_%d" % (import_killpoint, export_killpoint), test_export_killpoints)