]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/xfstests_dev.py
fe957b0045e656137f1bfb8eb5b63d1c31e18fc4
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 from teuthology
.orchestra
import run
42 # TODO: make sure that repo is not cloned for every test. it should
44 remoteurl
= 'git://git.ceph.com/xfstests-dev.git'
45 self
.repo_path
= self
.mount_a
.client_remote
.mkdtemp(suffix
=
47 self
.mount_a
.run_shell(['git', 'archive', '--remote=' + remoteurl
,
49 'tar', '-C', self
.repo_path
, '-x', '-f', '-'])
51 def get_admin_key(self
):
54 cp
= configparser
.ConfigParser()
55 cp
.read_string(self
.fs
.mon_manager
.raw_cluster_cmd(
56 'auth', 'get-or-create', 'client.admin'))
58 return cp
['client.admin']['key']
60 def get_test_and_scratch_dirs_ready(self
):
61 """ "test" and "scratch" directories are directories inside Ceph FS.
62 And, test and scratch mounts are path on the local FS where "test"
63 and "scratch" directories would be mounted. Look at xfstests-dev
64 local.config's template inside this file to get some context.
66 from os
.path
import join
68 self
.test_dirname
= 'test'
69 self
.mount_a
.run_shell(['mkdir', self
.test_dirname
])
70 # read var name as "test dir's mount path"
71 self
.test_dirs_mount_path
= self
.mount_a
.client_remote
.mkdtemp(
72 suffix
=self
.test_dirname
)
73 self
.mount_a
.run_shell(['sudo','ln','-s',join(self
.mount_a
.mountpoint
,
75 self
.test_dirs_mount_path
])
77 self
.scratch_dirname
= 'scratch'
78 self
.mount_a
.run_shell(['mkdir', self
.scratch_dirname
])
79 # read var name as "scratch dir's mount path"
80 self
.scratch_dirs_mount_path
= self
.mount_a
.client_remote
.mkdtemp(
81 suffix
=self
.scratch_dirname
)
82 self
.mount_a
.run_shell(['sudo','ln','-s',join(self
.mount_a
.mountpoint
,
83 self
.scratch_dirname
),
84 self
.scratch_dirs_mount_path
])
86 def install_deps(self
):
87 from teuthology
.misc
import get_system_type
89 distro
, version
= get_system_type(self
.mount_a
.client_remote
,
90 distro
=True, version
=True)
91 distro
= distro
.lower()
92 major_ver_num
= int(version
.split('.')[0]) # only keep major release
95 # we keep fedora here so that right deps are installed when this test
96 # is run locally by a dev.
97 if distro
in ('redhatenterpriseserver', 'redhatenterprise', 'fedora',
98 'centos', 'centosstream'):
99 deps
= """acl attr automake bc dbench dump e2fsprogs fio \
100 gawk gcc indent libtool lvm2 make psmisc quota sed \
102 libacl-devel libattr-devel libaio-devel libuuid-devel \
103 xfsprogs-devel btrfs-progs-devel python2 sqlite""".split()
104 deps_old_distros
= ['xfsprogs-qa-devel']
106 if distro
!= 'fedora' and major_ver_num
> 7:
107 deps
.remove('btrfs-progs-devel')
109 args
= ['sudo', 'yum', 'install', '-y'] + deps
+ deps_old_distros
110 elif distro
== 'ubuntu':
111 deps
= """xfslibs-dev uuid-dev libtool-bin \
112 e2fsprogs automake gcc libuuid1 quota attr libattr1-dev make \
113 libacl1-dev libaio-dev xfsprogs libgdbm-dev gawk fio dbench \
114 uuid-runtime python sqlite3""".split()
116 if major_ver_num
>= 19:
117 deps
[deps
.index('python')] ='python2'
118 args
= ['sudo', 'apt-get', 'install', '-y'] + deps
120 raise RuntimeError('expected a yum based or a apt based system')
122 self
.mount_a
.client_remote
.run(args
=args
, omit_sudo
=False)
124 def create_reqd_users(self
):
125 self
.mount_a
.client_remote
.run(args
=['sudo', 'useradd', 'fsgqa'],
126 omit_sudo
=False, check_status
=False)
127 self
.mount_a
.client_remote
.run(args
=['sudo', 'groupadd', 'fsgqa'],
128 omit_sudo
=False, check_status
=False)
129 self
.mount_a
.client_remote
.run(args
=['sudo', 'useradd',
130 '123456-fsgqa'], omit_sudo
=False,
133 def write_local_config(self
):
134 from os
.path
import join
135 from textwrap
import dedent
137 mon_sock
= self
.fs
.mon_manager
.get_msgrv1_mon_socks()[0]
138 self
.test_dev
= mon_sock
+ ':/' + self
.test_dirname
139 self
.scratch_dev
= mon_sock
+ ':/' + self
.scratch_dirname
141 xfstests_config_contents
= dedent('''\
145 #export SCRATCH_DEV={}
146 #export SCRATCH_MNT={}
147 export TEST_FS_MOUNT_OPTS="-o name=admin,secret={}"
148 ''').format(self
.test_dev
, self
.test_dirs_mount_path
, self
.scratch_dev
,
149 self
.scratch_dirs_mount_path
, self
.get_admin_key())
151 self
.mount_a
.client_remote
.write_file(join(self
.repo_path
, 'local.config'),
152 xfstests_config_contents
, sudo
=True)
155 self
.mount_a
.client_remote
.run(args
=['sudo', 'userdel', '--force',
156 '--remove', 'fsgqa'],
157 omit_sudo
=False, check_status
=False)
158 self
.mount_a
.client_remote
.run(args
=['sudo', 'userdel', '--force',
159 '--remove', '123456-fsgqa'],
160 omit_sudo
=False, check_status
=False)
161 self
.mount_a
.client_remote
.run(args
=['sudo', 'groupdel', 'fsgqa'],
162 omit_sudo
=False, check_status
=False)
164 self
.mount_a
.client_remote
.run(args
=['sudo', 'rm', '-rf',
166 omit_sudo
=False, check_status
=False)
168 super(XFSTestsDev
, self
).tearDown()