]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_meta_injection.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / qa / tasks / cephfs / test_meta_injection.py
1 from tasks.cephfs.cephfs_test_case import CephFSTestCase
2
3 class TestMetaInjection(CephFSTestCase):
4 def test_meta_injection(self):
5 conf_ori = self.fs.mds_asok(['config', 'show'])
6 self.fs.mds_asok(['config', 'set', 'mds_log_max_segments', '1'])
7 self.mount_a.run_shell(["mkdir", "metadir"])
8 self.mount_a.run_shell(["touch", "metadir/metafile1"])
9 self.mount_a.run_shell(["touch", "metadir/metafile2"])
10 self.fs.mds_asok(['flush', 'journal'])
11 dirino = self.mount_a.path_to_ino("metadir")
12 ino = self.mount_a.path_to_ino("metadir/metafile1")
13
14 # export meta of ino
15 self.fs.meta_tool(['showm', '-i', str(ino), '-o', '/tmp/meta_out'], 0, True)
16 out = self.mount_a.run_shell(['grep', str(ino),'/tmp/meta_out']).stdout.getvalue().strip()
17
18 # check the metadata of ino
19 self.assertNotEqual(out.find(u'"ino":'+ str(ino)), -1)
20
21 # amend info of ino
22 self.fs.get_meta_of_fs_file(dirino, "metafile1", "/tmp/meta_obj")
23 self.fs.meta_tool(['amend', '-i', str(ino), '--in', '/tmp/meta_out', '--yes-i-really-really-mean-it'], 0, True)
24 self.fs.get_meta_of_fs_file(dirino, "metafile1", "/tmp/meta_obj_chg")
25
26 # checkout meta_out after import it
27 ori_mds5 = self.mount_a.run_shell(["md5sum", "/tmp/meta_obj"]).stdout.getvalue().strip().split()
28 chg_mds5 = self.mount_a.run_shell(["md5sum", "/tmp/meta_obj_chg"]).stdout.getvalue().strip().split()
29 print(ori_mds5," ==> ", chg_mds5)
30 self.assertEqual(len(ori_mds5), 2)
31 self.assertEqual(len(chg_mds5), 2)
32 self.assertEqual(ori_mds5[0], chg_mds5[0])
33
34 self.mount_a.run_shell(["rm", "metadir", "-rf"])
35 self.mount_a.run_shell(["rm", "/tmp/meta_obj"])
36 self.mount_a.run_shell(["rm", "/tmp/meta_obj_chg"])
37 # restore config of mds_log_max_segments
38 self.fs.mds_asok(['config', 'set', 'mds_log_max_segments', conf_ori["mds_log_max_segments"]])