Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qa: simplify TestJournalRepair #15096

Merged
merged 1 commit into from May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions qa/tasks/cephfs/mount.py
Expand Up @@ -436,36 +436,6 @@ def kill_background(self, p):
self._kill_background(p)
self.background_procs.remove(p)

def spam_dir_background(self, path):
"""
Create directory `path` and do lots of metadata operations
in it until further notice.
"""
assert(self.is_mounted())
abs_path = os.path.join(self.mountpoint, path)

pyscript = dedent("""
import sys
import time
import os

abs_path = "{abs_path}"

if not os.path.exists(abs_path):
os.makedirs(abs_path)

n = 0
while True:
file_path = os.path.join(abs_path, "tmp%d" % n)
f = open(file_path, 'w')
f.close()
n = n + 1
""").format(abs_path=abs_path)

rproc = self._run_python(pyscript)
self.background_procs.append(rproc)
return rproc

def get_global_id(self):
raise NotImplementedError()

Expand Down
47 changes: 22 additions & 25 deletions qa/tasks/cephfs/test_journal_repair.py
Expand Up @@ -173,26 +173,33 @@ def test_reset(self):
self.mds_cluster.mds_stop(unneeded_mds)
self.mds_cluster.mds_fail(unneeded_mds)

# Do a bunch of I/O such that at least some will hit the second MDS: create
# lots of directories so that the balancer should find it easy to make a decision
# to allocate some of them to the second mds.
spammers = []
for n in range(0, 16):
dir_name = "spam_{0}".format(n)
spammers.append(self.mount_a.spam_dir_background(dir_name))
# Create a dir on each rank
self.mount_a.run_shell(["mkdir", "alpha"])
self.mount_a.run_shell(["mkdir", "bravo"])
self.mount_a.setfattr("alpha/", "ceph.dir.pin", "0")
self.mount_a.setfattr("bravo/", "ceph.dir.pin", "1")

def subtrees_assigned():
got_subtrees = self.fs.mds_asok(["get", "subtrees"], mds_id=active_mds_names[0])
rank_1_count = len([s for s in got_subtrees if s['auth_first'] == 1])

# Greater than 1, because there is typically 1 for ~mds1, and once it
# has been assigned something in addition to that it means it has been
# assigned a "real" subtree.
return rank_1_count > 1
for s in got_subtrees:
if s['dir']['path'] == '/bravo':
if s['auth_first'] == 1:
return True
else:
# Should not happen
raise RuntimeError("/bravo is subtree but not rank 1!")

# We are waiting for the MDS to respond to hot directories, which
# is not guaranteed to happen at a particular time, so a lengthy timeout here.
self.wait_until_true(subtrees_assigned, 600)
return False

# Ensure the pinning has taken effect and the /bravo dir is now
# migrated to rank 1.
self.wait_until_true(subtrees_assigned, 30)

# Do some IO (this should be split across ranks according to
# the rank-pinned dirs)
self.mount_a.create_n_files("alpha/file", 1000)
self.mount_a.create_n_files("bravo/file", 1000)

# Flush the journals so that we have some backing store data
# belonging to one MDS, and some to the other MDS.
Expand Down Expand Up @@ -229,16 +236,6 @@ def subtrees_assigned():
# killing the mount also means killing the node.
pass

log.info("Terminating spammer processes...")
for spammer_proc in spammers:
spammer_proc.stdin.close()
try:
spammer_proc.wait()
except (CommandFailedError, ConnectionLostError):
# The ConnectionLostError case is for kernel client, where
# killing the mount also means killing the node.
pass

# See that the second MDS will crash when it starts and tries to
# acquire rank 1
damaged_id = active_mds_names[1]
Expand Down