Skip to content

Commit 27a1b1c

Browse files
Merge pull request #91 from pranavprakash20/add_ceph_fsal_test
[Test] Add ceph deployment support
2 parents 2e68944 + 84b8f98 commit 27a1b1c

File tree

1 file changed

+233
-0
lines changed

1 file changed

+233
-0
lines changed

ceph/basic-ceph-cthon.sh

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
#!/bin/sh
2+
3+
# if any command fails, the script should exit
4+
set -e
5+
6+
# enable some more output
7+
set -x
8+
9+
# these variables need to be set
10+
[ -n "${GERRIT_HOST}" ]
11+
[ -n "${GERRIT_PROJECT}" ]
12+
[ -n "${GERRIT_REFSPEC}" ]
13+
14+
# only use https for now
15+
GIT_REPO="https://${GERRIT_HOST}/${GERRIT_PROJECT}"
16+
17+
# enable the Storage SIG Gluster and Ceph repositories
18+
dnf -y install centos-release-ceph epel-release
19+
20+
BUILDREQUIRES="git bison cmake dbus-devel flex gcc-c++ krb5-devel libacl-devel libblkid-devel libcap-devel redhat-rpm-config rpm-build xfsprogs-devel"
21+
22+
#BUILDREQUIRES_EXTRA="libnsl2-devel libnfsidmap-devel libwbclient-devel libcephfs-devel userspace-rcu-devel"
23+
BUILDREQUIRES_EXTRA="libnsl2-devel libnfsidmap-devel libwbclient-devel userspace-rcu-devel"
24+
25+
# basic packages to install
26+
case "${CENTOS_VERSION}" in
27+
7)
28+
yum install -y ${BUILDREQUIRES} ${BUILDREQUIRES_EXTRA} python2-devel
29+
;;
30+
8s)
31+
yum install -y ${BUILDREQUIRES}
32+
yum install --enablerepo=powertools -y ${BUILDREQUIRES_EXTRA}
33+
yum install -y libcephfs-devel
34+
;;
35+
9s)
36+
yum install -y ${BUILDREQUIRES}
37+
yum install --enablerepo=crb -y ${BUILDREQUIRES_EXTRA}
38+
yum install -y libcephfs-devel
39+
;;
40+
esac
41+
42+
git clone --depth=1 ${GIT_REPO}
43+
cd $(basename "${GERRIT_PROJECT}")
44+
git fetch origin ${GERRIT_REFSPEC} && git checkout FETCH_HEAD
45+
46+
# update libntirpc
47+
git submodule update --recursive --init || git submodule sync
48+
49+
# cleanup old build dir
50+
[ -d build ] && rm -rf build
51+
52+
mkdir build
53+
cd build
54+
55+
( cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=ON -DUSE_FSAL_RGW=OFF -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && make) || touch FAILED
56+
make install
57+
58+
# dont vote if the subject of the last change includes the word "WIP"
59+
if ( git log --oneline -1 | grep -q -i -w 'WIP' )
60+
then
61+
echo "Change marked as WIP, not posting result to GerritHub."
62+
touch WIP
63+
fi
64+
65+
# If failure found during build, return the status and skip proceeding
66+
# to ceph configuration
67+
68+
69+
# we accept different return values
70+
# 0 - SUCCESS + VOTE
71+
# 1 - FAILED + VOTE
72+
# 10 - SUCCESS + REPORT ONLY (NO VOTE)
73+
# 11 - FAILED + REPORT ONLY (NO VOTE)
74+
RET=0
75+
if [ -e FAILED ]
76+
then
77+
exit ${RET}
78+
fi
79+
if [ -e WIP ]
80+
then
81+
RET=$[RET + 10]
82+
exit ${RET}
83+
fi
84+
85+
# Install and configure ceph cluster
86+
dnf install -y cephadm
87+
cephadm add-repo --release squid
88+
dnf install -y ceph
89+
cephadm bootstrap --mon-ip $(hostname -I | awk '{print $1}') --single-host-defaults
90+
ceph auth get client.bootstrap-osd -o /var/lib/ceph/bootstrap-osd/ceph.keyring
91+
92+
# Create a virtual disk file (for OSD storage):
93+
truncate -s 35G /tmp/ceph-disk.img
94+
losetup -f /tmp/ceph-disk.img # Attaches as a loop device (e.g., /dev/loop0)
95+
96+
pvcreate /dev/loop0
97+
vgcreate ceph-vg /dev/loop0
98+
lvcreate -L 10G -n osd1 ceph-vg
99+
lvcreate -L 10G -n osd2 ceph-vg
100+
lvcreate -L 10G -n osd3 ceph-vg
101+
102+
ceph-volume lvm create --data /dev/ceph-vg/osd1
103+
ceph-volume lvm create --data /dev/ceph-vg/osd2
104+
ceph-volume lvm create --data /dev/ceph-vg/osd3
105+
106+
# Now auto assign these lvms to the osd's
107+
ceph orch apply osd --all-available-devices
108+
109+
sleep 20
110+
111+
# Create a cephfs volume
112+
ceph fs volume create cephfs
113+
114+
# create ganesha.conf file
115+
touch /etc/ganesha/ganesha.conf
116+
117+
# Update Ganesha.conf file
118+
echo 'EXPORT {
119+
Export_ID = 1;
120+
Path = "/";
121+
Pseudo = "/nfs/cephfs";
122+
Protocols = 4;
123+
Transports = TCP;
124+
Access_Type = RW;
125+
Squash = None;
126+
FSAL {
127+
Name = "CEPH";
128+
User_Id = "admin";
129+
Secret_Access_Key = "";
130+
}
131+
}' > /etc/ganesha/ganesha.conf
132+
133+
mkdir -p /var/run/ganesha
134+
chmod 755 /var/run/ganesha
135+
chown root:root /var/run/ganesha
136+
137+
ganesha.nfsd -f /etc/ganesha/ganesha.conf -L /var/log/ganesha.log
138+
if pgrep ganesha >/dev/null; then
139+
echo "[OK] Service ganesha is running"
140+
else
141+
echo "[ERROR] Service ganesha is NOT running" >&2
142+
exit 1
143+
fi
144+
145+
146+
147+
# Run Cthon post successful cluster creation
148+
149+
# install build and runtime dependencies
150+
yum -y install git gcc nfs-utils time make
151+
152+
if [ "${CENTOS_VERSION}" == "8s" ]; then
153+
ENABLE_REPO="--enablerepo=powertools"
154+
elif [ "${CENTOS_VERSION}" == "9s" ]; then
155+
ENABLE_REPO="--enablerepo=crb"
156+
fi
157+
yum ${ENABLE_REPO} install -y libtirpc-devel
158+
159+
#Logic to generate corefiles
160+
echo "/tmp/cores/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
161+
mkdir -p /tmp/cores
162+
163+
# checkout the connectathon tests
164+
cd
165+
git clone --depth=1 git://git.linux-nfs.org/projects/steved/cthon04.git
166+
cd cthon04
167+
( make all ) || true
168+
169+
170+
# RUN CTHON for v3 < SKIPPING AS CURRENT RUNS FOCUS ON 4 and 4.1 >
171+
#mkdir -p /mnt/nfs_ceph_v3
172+
#if mount -t nfs -o vers=3 $(hostname -I | awk '{print $1}'):/nfs/cephfs /mnt/nfs_ceph_v3; then
173+
# echo "NFS mount successful!"
174+
# if mountpoint -q /mnt/nfs_ceph_v3; then
175+
# echo "Verification: NFS is properly mounted at /mnt/nfs_ceph_v3"
176+
# echo "Mounted NFS details:"
177+
# mount | grep /mnt/nfs_ceph_v3
178+
# else
179+
# echo "ERROR: Mount command succeeded but verification failed!" >&2
180+
# exit 1
181+
# fi
182+
#else
183+
# echo "ERROR: Failed to mount NFS share!" >&2
184+
# touch FAILED
185+
# exit 1
186+
#fi
187+
## Run Cthon
188+
#./server -a -p /nfs/cephfs -m /mnt/nfs_ceph_v3 $(hostname -I | awk '{print $1}')
189+
190+
191+
# Run CTHON for v4.0
192+
mkdir -p /mnt/nfs_ceph_v4
193+
if mount -t nfs -o vers=4 $(hostname -I | awk '{print $1}'):/nfs/cephfs /mnt/nfs_ceph_v4; then
194+
echo "NFS mount successful!"
195+
if mountpoint -q /mnt/nfs_ceph_v4; then
196+
echo "Verification: NFS is properly mounted at /mnt/nfs_ceph_v4"
197+
echo "Mounted NFS details:"
198+
mount | grep /mnt/nfs_ceph_v4
199+
else
200+
echo "ERROR: Mount command succeeded but verification failed!" >&2
201+
exit 1
202+
fi
203+
else
204+
echo "ERROR: Failed to mount NFS share!" >&2
205+
touch FAILED
206+
exit 1
207+
fi
208+
# Run Cthon
209+
./server -a -p /nfs/cephfs -m /mnt/nfs_ceph_v4 $(hostname -I | awk '{print $1}')
210+
211+
212+
# Run CTHON for v4.1
213+
mkdir -p /mnt/nfs_ceph_v41
214+
if mount -t nfs -o vers=4.1 $(hostname -I | awk '{print $1}'):/nfs/cephfs /mnt/nfs_ceph_v41; then
215+
echo "NFS mount successful!"
216+
if mountpoint -q /mnt/nfs_ceph_v41; then
217+
echo "Verification: NFS is properly mounted at /mnt/nfs_ceph_v41"
218+
echo "Mounted NFS details:"
219+
mount | grep /mnt/nfs_ceph_v41
220+
else
221+
echo "ERROR: Mount command succeeded but verification failed!" >&2
222+
exit 1
223+
fi
224+
else
225+
echo "ERROR: Failed to mount NFS share!" >&2
226+
touch FAILED
227+
exit 1
228+
fi
229+
# Run Cthon
230+
./server -a -p /nfs/cephfs -m /mnt/nfs_ceph_v41 $(hostname -I | awk '{print $1}')
231+
232+
exit 0
233+

0 commit comments

Comments
 (0)