Skip to content

Commit

Permalink
qa/cephfs: add test for blacklisted client eviction
Browse files Browse the repository at this point in the history
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 8975965)

 Conflicts:
	qa/tasks/cephfs/cephfs_test_case.py
	qa/tasks/cephfs/test_exports.py
  • Loading branch information
ukernel committed Jun 18, 2019
1 parent e5b27cd commit 7b4a610
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
18 changes: 18 additions & 0 deletions qa/tasks/cephfs/cephfs_test_case.py
@@ -1,3 +1,4 @@
import time
import json
import logging
from unittest import case
Expand Down Expand Up @@ -280,3 +281,20 @@ def delete_mds_coredump(self, daemon_id):
])
else:
log.info("No core_pattern directory set, nothing to clear (internal.coredump not enabled?)")

def _wait_subtrees(self, status, rank, test):
timeout = 30
pause = 2
test = sorted(test)
for i in range(timeout/pause):
subtrees = self.fs.mds_asok(["get", "subtrees"], mds_id=status.get_rank(self.fs.id, rank)['name'])
subtrees = filter(lambda s: s['dir']['path'].startswith('/'), subtrees)
filtered = sorted([(s['dir']['path'], s['auth_first']) for s in subtrees])
log.info("%s =?= %s", filtered, test)
if filtered == test:
# Confirm export_pin in output is correct:
for s in subtrees:
self.assertTrue(s['export_pin'] == s['auth_first'])
return subtrees
time.sleep(pause)
raise RuntimeError("rank {0} failed to reach desired subtree state", rank)
17 changes: 0 additions & 17 deletions qa/tasks/cephfs/test_exports.py
Expand Up @@ -9,23 +9,6 @@ class TestExports(CephFSTestCase):
MDSS_REQUIRED = 2
CLIENTS_REQUIRED = 2

def _wait_subtrees(self, status, rank, test):
timeout = 30
pause = 2
test = sorted(test)
for i in range(timeout/pause):
subtrees = self.fs.mds_asok(["get", "subtrees"], mds_id=status.get_rank(self.fs.id, rank)['name'])
subtrees = filter(lambda s: s['dir']['path'].startswith('/'), subtrees)
filtered = sorted([(s['dir']['path'], s['auth_first']) for s in subtrees])
log.info("%s =?= %s", filtered, test)
if filtered == test:
# Confirm export_pin in output is correct:
for s in subtrees:
self.assertTrue(s['export_pin'] == s['auth_first'])
return subtrees
time.sleep(pause)
raise RuntimeError("rank {0} failed to reach desired subtree state", rank)

def test_export_pin(self):
self.fs.set_max_mds(2)
self.fs.wait_for_daemons()
Expand Down
39 changes: 39 additions & 0 deletions qa/tasks/cephfs/test_sessionmap.py
@@ -1,4 +1,5 @@
from StringIO import StringIO
import time
import json
import logging
from unittest import SkipTest
Expand Down Expand Up @@ -216,3 +217,41 @@ def test_session_reject(self):
with self.assert_cluster_log("client session with non-allowable root '/baz' denied"):
with self.assertRaises(CommandFailedError):
self.mount_b.mount(mount_path="/foo/bar")

def test_session_evict_blacklisted(self):
"""
Check that mds evicts blacklisted client
"""
if not isinstance(self.mount_a, FuseMount):
self.skipTest("Requires FUSE client to use is_blacklisted()")

self.fs.set_max_mds(2)
self.fs.wait_for_daemons()
status = self.fs.status()

self.mount_a.run_shell(["mkdir", "d0", "d1"])
self.mount_a.setfattr("d0", "ceph.dir.pin", "0")
self.mount_a.setfattr("d1", "ceph.dir.pin", "1")
self._wait_subtrees(status, 0, [('/d0', 0), ('/d1', 1)])

self.mount_a.run_shell(["touch", "d0/f0"])
self.mount_a.run_shell(["touch", "d1/f0"])
self.mount_b.run_shell(["touch", "d0/f1"])
self.mount_b.run_shell(["touch", "d1/f1"])

self.assert_session_count(2, mds_id=self.fs.get_rank(rank=0, status=status)['name'])
self.assert_session_count(2, mds_id=self.fs.get_rank(rank=1, status=status)['name'])

mount_a_client_id = self.mount_a.get_global_id()
self.fs.mds_asok(['session', 'evict', "%s" % mount_a_client_id],
mds_id=self.fs.get_rank(rank=0, status=status)['name'])
self.wait_until_true(lambda: self.mount_a.is_blacklisted(), timeout=30)

# 10 seconds should be enough for evicting client
time.sleep(10)
self.assert_session_count(1, mds_id=self.fs.get_rank(rank=0, status=status)['name'])
self.assert_session_count(1, mds_id=self.fs.get_rank(rank=1, status=status)['name'])

self.mount_a.kill_cleanup()
self.mount_a.mount()
self.mount_a.wait_until_mounted()

0 comments on commit 7b4a610

Please sign in to comment.