]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/xfstests_dev.py
3 from tasks
.cephfs
.cephfs_test_case
import CephFSTestCase
5 logger
= logging
.getLogger(__name__
)
8 # TODO: add code to run non-ACL tests too.
9 # TODO: get tests running with SCRATCH_DEV and SCRATCH_DIR.
10 # TODO: make xfstests-dev tests running without running `make install`.
11 # TODO: make xfstests-dev compatible with ceph-fuse. xfstests-dev remounts
12 # CephFS before running tests using kernel, so ceph-fuse mounts are never
14 class XFSTestsDev(CephFSTestCase
):
17 super(XFSTestsDev
, self
).setUp()
18 self
.prepare_xfstests_dev()
20 def prepare_xfstests_dev(self
):
22 self
.get_test_and_scratch_dirs_ready()
24 self
.create_reqd_users()
25 self
.write_local_config()
27 # NOTE: On teuthology machines it's necessary to run "make" as
28 # superuser since the repo is cloned somewhere in /tmp.
29 self
.mount_a
.client_remote
.run(args
=['sudo', 'make'],
30 cwd
=self
.repo_path
, stdout
=BytesIO(),
32 self
.mount_a
.client_remote
.run(args
=['sudo', 'make', 'install'],
33 cwd
=self
.repo_path
, omit_sudo
=False,
34 stdout
=BytesIO(), stderr
=BytesIO())
38 Clone xfstests_dev repository. If already present, update it.
40 # TODO: make sure that repo is not cloned for every test. it should
42 remoteurl
= 'https://git.ceph.com/xfstests-dev.git'
43 self
.repo_path
= self
.mount_a
.client_remote
.mkdtemp(suffix
=
45 self
.mount_a
.run_shell(['git', 'clone', remoteurl
, '--depth', '1',
48 def get_admin_key(self
):
51 cp
= configparser
.ConfigParser()
52 cp
.read_string(self
.fs
.mon_manager
.raw_cluster_cmd(
53 'auth', 'get-or-create', 'client.admin'))
55 return cp
['client.admin']['key']
57 def get_test_and_scratch_dirs_ready(self
):
58 """ "test" and "scratch" directories are directories inside Ceph FS.
59 And, test and scratch mounts are path on the local FS where "test"
60 and "scratch" directories would be mounted. Look at xfstests-dev
61 local.config's template inside this file to get some context.
63 from os
.path
import join
65 self
.test_dirname
= 'test'
66 self
.mount_a
.run_shell(['mkdir', self
.test_dirname
])
67 # read var name as "test dir's mount path"
68 self
.test_dirs_mount_path
= self
.mount_a
.client_remote
.mkdtemp(
69 suffix
=self
.test_dirname
)
70 self
.mount_a
.run_shell(['sudo','ln','-s',join(self
.mount_a
.mountpoint
,
72 self
.test_dirs_mount_path
])
74 self
.scratch_dirname
= 'scratch'
75 self
.mount_a
.run_shell(['mkdir', self
.scratch_dirname
])
76 # read var name as "scratch dir's mount path"
77 self
.scratch_dirs_mount_path
= self
.mount_a
.client_remote
.mkdtemp(
78 suffix
=self
.scratch_dirname
)
79 self
.mount_a
.run_shell(['sudo','ln','-s',join(self
.mount_a
.mountpoint
,
80 self
.scratch_dirname
),
81 self
.scratch_dirs_mount_path
])
83 def install_deps(self
):
84 from teuthology
.misc
import get_system_type
86 distro
, version
= get_system_type(self
.mount_a
.client_remote
,
87 distro
=True, version
=True)
88 distro
= distro
.lower()
89 major_ver_num
= int(version
.split('.')[0]) # only keep major release
92 # we keep fedora here so that right deps are installed when this test
93 # is run locally by a dev.
94 if distro
in ('redhatenterpriseserver', 'redhatenterprise', 'fedora',
95 'centos', 'centosstream'):
96 deps
= """acl attr automake bc dbench dump e2fsprogs fio \
97 gawk gcc indent libtool lvm2 make psmisc quota sed \
99 libacl-devel libattr-devel libaio-devel libuuid-devel \
100 xfsprogs-devel btrfs-progs-devel python2 sqlite""".split()
101 deps_old_distros
= ['xfsprogs-qa-devel']
103 if distro
!= 'fedora' and major_ver_num
> 7:
104 deps
.remove('btrfs-progs-devel')
106 args
= ['sudo', 'yum', 'install', '-y'] + deps
+ deps_old_distros
107 elif distro
== 'ubuntu':
108 deps
= """xfslibs-dev uuid-dev libtool-bin \
109 e2fsprogs automake gcc libuuid1 quota attr libattr1-dev make \
110 libacl1-dev libaio-dev xfsprogs libgdbm-dev gawk fio dbench \
111 uuid-runtime python sqlite3""".split()
113 if major_ver_num
>= 19:
114 deps
[deps
.index('python')] ='python2'
115 args
= ['sudo', 'apt-get', 'install', '-y'] + deps
117 raise RuntimeError('expected a yum based or a apt based system')
119 self
.mount_a
.client_remote
.run(args
=args
, omit_sudo
=False)
121 def create_reqd_users(self
):
122 self
.mount_a
.client_remote
.run(args
=['sudo', 'useradd', 'fsgqa'],
123 omit_sudo
=False, check_status
=False)
124 self
.mount_a
.client_remote
.run(args
=['sudo', 'groupadd', 'fsgqa'],
125 omit_sudo
=False, check_status
=False)
126 self
.mount_a
.client_remote
.run(args
=['sudo', 'useradd',
127 '123456-fsgqa'], omit_sudo
=False,
130 def write_local_config(self
):
131 from os
.path
import join
132 from textwrap
import dedent
134 mon_sock
= self
.fs
.mon_manager
.get_msgrv1_mon_socks()[0]
135 self
.test_dev
= mon_sock
+ ':/' + self
.test_dirname
136 self
.scratch_dev
= mon_sock
+ ':/' + self
.scratch_dirname
138 xfstests_config_contents
= dedent('''\
142 #export SCRATCH_DEV={}
143 #export SCRATCH_MNT={}
144 export TEST_FS_MOUNT_OPTS="-o name=admin,secret={}"
145 ''').format(self
.test_dev
, self
.test_dirs_mount_path
, self
.scratch_dev
,
146 self
.scratch_dirs_mount_path
, self
.get_admin_key())
148 self
.mount_a
.client_remote
.write_file(join(self
.repo_path
, 'local.config'),
149 xfstests_config_contents
, sudo
=True)
152 self
.mount_a
.client_remote
.run(args
=['sudo', 'userdel', '--force',
153 '--remove', 'fsgqa'],
154 omit_sudo
=False, check_status
=False)
155 self
.mount_a
.client_remote
.run(args
=['sudo', 'userdel', '--force',
156 '--remove', '123456-fsgqa'],
157 omit_sudo
=False, check_status
=False)
158 self
.mount_a
.client_remote
.run(args
=['sudo', 'groupdel', 'fsgqa'],
159 omit_sudo
=False, check_status
=False)
161 self
.mount_a
.client_remote
.run(args
=['sudo', 'rm', '-rf',
163 omit_sudo
=False, check_status
=False)
165 super(XFSTestsDev
, self
).tearDown()