-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server Reboot test for nfs-ganesha #27
base: centos-ci
Are you sure you want to change the base?
Changes from all commits
9f3fc0f
0d7bc92
6f2b410
bf553f3
5dae0a3
bd59578
ddec14b
154367f
28a7cd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
# | ||
# Environment variables used: | ||
# - SERVER: hostname or IP-address of the NFS-server | ||
# - EXPORT: NFS-export to test (should start with "/") | ||
|
||
# if any command fails, the script should exit | ||
set -e | ||
|
||
# enable some more output | ||
set -x | ||
|
||
[ -n "${SERVER}" ] | ||
[ -n "${EXPORT}" ] | ||
|
||
# install build and runtime dependencies | ||
echo "Install build and runtime dependencies" | ||
yum -y install nfs-utils time | ||
|
||
echo "--------------------------------------------------" | ||
echo "Running test on Mount Version $1" | ||
echo "--------------------------------------------------" | ||
|
||
# mount | ||
mkdir -p /mnt/nfs | ||
mount -t nfs -o vers=$1 ${SERVER}:${EXPORT} /mnt/nfs | ||
status=$? | ||
if [ $status -eq 0 ] | ||
then | ||
# creating and performing io operation on file | ||
touch test_file.txt | ||
for ((i=1;i<=100;i++)); | ||
do | ||
echo "$i " >> test_file.txt | ||
sleep 1 | ||
done | ||
cat test_file.txt | ||
#unmount | ||
umount -l /mnt/nfs | ||
else | ||
echo "Failed Mounting for version $1" | ||
echo "Server Reboot Test: FAILURE" | ||
exit $status | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import json, urllib, subprocess, sys, os, time | ||
|
||
url_base="http://admin.ci.centos.org:8080" | ||
ver=os.getenv("CENTOS_VERSION") | ||
arch=os.getenv("CENTOS_ARCH") | ||
count=2 | ||
server_script=os.getenv("SERVER_TEST_SCRIPT") | ||
server_restart_script=os.getenv("SERVER_AFTER_RESTART_TEST_SCRIPT") | ||
client_script=os.getenv("CLIENT_TEST_SCRIPT") | ||
# delay for 5 minutes (duffy timeout for rate limiting) | ||
retry_delay=300 | ||
# retry maximum 3 hours, that is 3 x 60 x 60 seconds | ||
max_retries=((3 * 60 * 60) / retry_delay) | ||
|
||
# read the API key for Duffy from the ~/duffy.key file | ||
fo=open("/home/nfs-ganesha/duffy.key") | ||
api=fo.read().strip() | ||
fo.close() | ||
|
||
# build the URL to request the system(s) | ||
get_nodes_url="%s/Node/get?key=%s&ver=%s&arch=%s&count=%s" % (url_base,api,ver,arch,count) | ||
|
||
# request the system(s) | ||
retries=0 | ||
while retries < max_retries: | ||
try: | ||
dat=urllib.urlopen(get_nodes_url).read() | ||
b=json.loads(dat) | ||
# all is fine, break out of the loop | ||
break | ||
except ValueError, ve: | ||
print("Failed to parse Duffy response: %s" % (dat)) | ||
except Error, e: | ||
print("An unexpected error occured: %s" % (e)) | ||
|
||
retries+=1 | ||
print("Waiting %d seconds before retrying #%d..." % (retry_delay, retries)) | ||
time.sleep(retry_delay) | ||
|
||
|
||
# NFS-Ganesha Server (parameters need double escape, passed on ssh commandline) | ||
server_env="export GERRIT_HOST='%s'" % os.getenv("GERRIT_HOST") | ||
server_env+=" GERRIT_PROJECT='%s'" % os.getenv("GERRIT_PROJECT") | ||
server_env+=" GERRIT_REFSPEC='%s'" % os.getenv("GERRIT_REFSPEC") | ||
server_env+=" YUM_REPO='%s'" % os.getenv("YUM_REPO", "") | ||
server_env+=" GLUSTER_VOLUME='%s'" % os.getenv("EXPORT") | ||
server_env+=" ENABLE_ACL='%s'" % os.getenv("ENABLE_ACL", "") | ||
|
||
# add the export with environment to ~/.bashrc | ||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
tee -a ~/.bashrc' <<< "%s" | ||
""" % (b['hosts'][0], server_env) | ||
subprocess.call(cmd, shell=True) | ||
|
||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
yum -y install curl && | ||
curl %s | bash - | ||
'""" % (b['hosts'][0], server_script) | ||
rtn_code=subprocess.call(cmd, shell=True) | ||
|
||
|
||
# check rtn_code and skip client part after failure | ||
if rtn_code == 0: | ||
# NFS-Client (parameters need double escape, passed on ssh commandline) | ||
client_env="export SERVER='%s'" % b['hosts'][0] | ||
client_env+=" EXPORT='/%s'" % os.getenv("EXPORT") | ||
client_env+=" TEST_PARAMETERS='%s'" % os.getenv("TEST_PARAMETERS", "") | ||
|
||
# add the export with environment to ~/.bashrc | ||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
tee -a ~/.bashrc' <<< "%s" | ||
""" % (b['hosts'][1], client_env) | ||
subprocess.call(cmd, shell=True) | ||
|
||
if rtn_code == 0: | ||
client_script = client_script.strip(" ") | ||
if client_script.endswith(".py"): | ||
interpreter_to_run = "python" | ||
elif client_script.endswith(".sh"): | ||
interpreter_to_run = "bash" | ||
versions = [3 , 4.0, 4.1] | ||
for version in versions: | ||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
curl -o client_script %s && %s client_script %.1f | ||
'""" % (b['hosts'][1], client_script, interpreter_to_run, version) | ||
rtn_code=subprocess.Popen(cmd, shell=True) | ||
|
||
# client setting up time | ||
time.sleep(30) | ||
|
||
# rebooting server | ||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
systemctl reboot | bash - | ||
'""" % (b['hosts'][0]) | ||
subprocess.call(cmd, shell=True) | ||
|
||
# time for rebooting server | ||
time.sleep(90) | ||
|
||
# disable the firewall on server, otherwise the client can not connect | ||
cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
curl %s | bash - | ||
'""" % (b['hosts'][0], server_restart_script) | ||
rtn_code=subprocess.call(cmd, shell=True) | ||
|
||
# disable the firewall on server, otherwise the client can not connect | ||
#cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' | ||
# (systemctl stop firewalld || service iptables stop) && | ||
# setenforce 0 | bash - | ||
#'""" % (b['hosts'][0]) | ||
#rtn_code=subprocess.call(cmd, shell=True) | ||
|
||
|
||
# return the system(s) to duffy | ||
done_nodes_url="%s/Node/done?key=%s&ssid=%s" % (url_base, api, b['ssid']) | ||
das=urllib.urlopen(done_nodes_url).read() | ||
|
||
sys.exit(rtn_code) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same counts for this one, is it different from common-scripts/basic-gluster.sh? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, all scripts should have a #! for the interpreter (/bin/sh in this case, since they're sh scripts) |
||
# | ||
# Start gluster and NFS-Ganesh and export a volume through NFS-Ganesha | ||
|
||
# abort if anything fails | ||
set -e | ||
|
||
[ -n "${GLUSTER_VOLUME}" ] | ||
|
||
# be a little bit more verbose | ||
set -x | ||
|
||
|
||
# starting glusterd and nfs-ganesh | ||
systemctl start glusterd | ||
systemctl start nfs-ganesha | ||
|
||
# disable the firewall, otherwise the client can not connect | ||
systemctl stop firewalld || service iptables stop | ||
|
||
# TODO: SELinux prevents creating special files on Gluster bricks (bz#1331561) | ||
setenforce 0 | ||
|
||
#Enabling ACL for the volume if ENABLE_ACL param is set to True | ||
if [ "${ENABLE_ACL}" == "True" ] | ||
then | ||
conf_file="/etc/ganesha/exports/export."${GLUSTER_VOLUME}".conf" | ||
sed -i s/'Disable_ACL = .*'/'Disable_ACL = false;'/g ${conf_file} | ||
cat ${conf_file} | ||
|
||
#Parsing export id from volume export conf file | ||
export_id=$(grep 'Export_Id' ${conf_file} | sed 's/^[[:space:]]*Export_Id.*=[[:space:]]*\([0-9]*\).*/\1/') | ||
|
||
dbus-send --type=method_call --print-reply --system --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.UpdateExport string:${conf_file} string:"EXPORT(Export_Id = ${export_id})" | ||
fi | ||
|
||
|
||
/usr/libexec/ganesha/create-export-ganesha.sh /etc/ganesha on ${GLUSTER_VOLUME} | ||
/usr/libexec/ganesha/dbus-send.sh /etc/ganesha on ${GLUSTER_VOLUME} | ||
|
||
# wait till server comes out of grace period | ||
sleep 10 | ||
|
||
# basic check if the export is available, some debugging if not | ||
if ! showmount -e | grep -q -w -e "${GLUSTER_VOLUME}" | ||
then | ||
echo "+++ /var/log/ganesha.log +++" | ||
cat /var/log/ganesha.log | ||
echo | ||
echo "+++ /etc/ganesha/ganesha.conf +++" | ||
grep --with-filename -e '' /etc/ganesha/ganesha.conf | ||
echo | ||
echo "+++ /etc/ganesha/exports/*.conf +++" | ||
grep --with-filename -e '' /etc/ganesha/exports/*.conf | ||
echo | ||
echo "Export ${GLUSTER_VOLUME} is not available" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this file should be included, can't you use the common-scripts/basic-gluster-duffy.py instead? If you made modifications, maybe those can be merged into that one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modification in these are only required for this particular test. https://github.com/nfs-ganesha/ci-tests/blob/centos-ci/common-scripts/basic-gluster-duffy.py is used by other tests so can not modify it.