]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/cephfs/test_mantle.py
update sources to v12.1.1
[ceph.git] / ceph / qa / tasks / cephfs / test_mantle.py
CommitLineData
7c673cae
FG
1from tasks.cephfs.cephfs_test_case import CephFSTestCase
2import json
3import logging
4
5log = logging.getLogger(__name__)
6failure = "using old balancer; mantle failed for balancer="
7success = "mantle balancer version changed: "
8
9class TestMantle(CephFSTestCase):
10 def start_mantle(self):
11 self.wait_for_health_clear(timeout=30)
7c673cae
FG
12 self.fs.set_max_mds(2)
13 self.wait_until_equal(lambda: len(self.fs.get_active_names()), 2, 30,
14 reject_fn=lambda v: v > 2 or v < 1)
15
16 for m in self.fs.get_active_names():
17 self.fs.mds_asok(['config', 'set', 'debug_objecter', '20'], mds_id=m)
18 self.fs.mds_asok(['config', 'set', 'debug_ms', '0'], mds_id=m)
19 self.fs.mds_asok(['config', 'set', 'debug_mds', '0'], mds_id=m)
20 self.fs.mds_asok(['config', 'set', 'debug_mds_balancer', '5'], mds_id=m)
21
22 def push_balancer(self, obj, lua_code, expect):
23 self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer', obj)
24 self.fs.rados(["put", obj, "-"], stdin_data=lua_code)
25 with self.assert_cluster_log(failure + obj + " " + expect):
26 log.info("run a " + obj + " balancer that expects=" + expect)
27
28 def test_version_empty(self):
29 self.start_mantle()
30 expect = " : (2) No such file or directory"
31
32 ret = self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer')
33 assert(ret == 22) # EINVAL
34
35 self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer', " ")
36 with self.assert_cluster_log(failure + " " + expect): pass
37
38 def test_version_not_in_rados(self):
39 self.start_mantle()
40 expect = failure + "ghost.lua : (2) No such file or directory"
41 self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer', "ghost.lua")
42 with self.assert_cluster_log(expect): pass
43
44 def test_balancer_invalid(self):
45 self.start_mantle()
46 expect = ": (22) Invalid argument"
47
48 lua_code = "this is invalid lua code!"
49 self.push_balancer("invalid.lua", lua_code, expect)
50
51 lua_code = "BAL_LOG()"
52 self.push_balancer("invalid_log.lua", lua_code, expect)
53
54 lua_code = "BAL_LOG(0)"
55 self.push_balancer("invalid_log_again.lua", lua_code, expect)
56
57 def test_balancer_valid(self):
58 self.start_mantle()
59 lua_code = "BAL_LOG(0, \"test\")\nreturn {3, 4}"
60 self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer', "valid.lua")
61 self.fs.rados(["put", "valid.lua", "-"], stdin_data=lua_code)
62 with self.assert_cluster_log(success + "valid.lua"):
63 log.info("run a valid.lua balancer")
64
65 def test_return_invalid(self):
66 self.start_mantle()
67 expect = ": (22) Invalid argument"
68
69 lua_code = "return \"hello\""
70 self.push_balancer("string.lua", lua_code, expect)
71
72 lua_code = "return 3"
73 self.push_balancer("number.lua", lua_code, expect)
74
75 lua_code = "return {}"
76 self.push_balancer("dict_empty.lua", lua_code, expect)
77
78 lua_code = "return {\"this\", \"is\", \"a\", \"test\"}"
79 self.push_balancer("dict_of_strings.lua", lua_code, expect)
80
81 lua_code = "return {3, \"test\"}"
82 self.push_balancer("dict_of_mixed.lua", lua_code, expect)
83
84 lua_code = "return {3}"
85 self.push_balancer("not_enough_numbers.lua", lua_code, expect)
86
87 lua_code = "return {3, 4, 5, 6, 7, 8, 9}"
88 self.push_balancer("too_many_numbers.lua", lua_code, expect)
89
90 def test_dead_osd(self):
91 self.start_mantle()
92 expect = " : (110) Connection timed out"
93
94 # kill the OSDs so that the balancer pull from RADOS times out
95 osd_map = json.loads(self.fs.mon_manager.raw_cluster_cmd('osd', 'dump', '--format=json-pretty'))
96 for i in range(0, len(osd_map['osds'])):
97 self.fs.mon_manager.raw_cluster_cmd_result('osd', 'down', str(i))
98 self.fs.mon_manager.raw_cluster_cmd_result('osd', 'out', str(i))
99
100 # trigger a pull from RADOS
101 self.fs.mon_manager.raw_cluster_cmd_result('fs', 'set', self.fs.name, 'balancer', "valid.lua")
102
103 # make the timeout a little longer since dead OSDs spam ceph -w
104 with self.assert_cluster_log(failure + "valid.lua" + expect, timeout=30):
105 log.info("run a balancer that should timeout")
106
107 # cleanup
108 for i in range(0, len(osd_map['osds'])):
109 self.fs.mon_manager.raw_cluster_cmd_result('osd', 'in', str(i))