|
|
f338ef |
From c2decfb59bd1be7cd2b0d792fd2ca2627913638a Mon Sep 17 00:00:00 2001
|
|
|
f338ef |
From: Sunny Kumar <sunkumar@redhat.com>
|
|
|
f338ef |
Date: Tue, 24 Sep 2019 18:22:13 +0530
|
|
|
f338ef |
Subject: [PATCH 310/313] tests : test case for non-root geo-rep setup
|
|
|
f338ef |
|
|
|
f338ef |
Added test case for non-root geo-rep setup.
|
|
|
f338ef |
|
|
|
f338ef |
Backport of:
|
|
|
f338ef |
> Patch: https://review.gluster.org/22902
|
|
|
f338ef |
> Change-Id: Ib6ebee79949a9f61bdc5c7b5e11b51b262750e98
|
|
|
f338ef |
> fixes: bz#1717827
|
|
|
f338ef |
> Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
f338ef |
|
|
|
f338ef |
Change-Id: Ib6ebee79949a9f61bdc5c7b5e11b51b262750e98
|
|
|
f338ef |
BUG: 1763412
|
|
|
f338ef |
Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
f338ef |
Reviewed-on: https://code.engineering.redhat.com/gerrit/183664
|
|
|
f338ef |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
f338ef |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
f338ef |
---
|
|
|
f338ef |
tests/00-geo-rep/00-georep-verify-non-root-setup.t | 251 +++++++++++++++++++++
|
|
|
f338ef |
1 file changed, 251 insertions(+)
|
|
|
f338ef |
create mode 100644 tests/00-geo-rep/00-georep-verify-non-root-setup.t
|
|
|
f338ef |
|
|
|
f338ef |
diff --git a/tests/00-geo-rep/00-georep-verify-non-root-setup.t b/tests/00-geo-rep/00-georep-verify-non-root-setup.t
|
|
|
f338ef |
new file mode 100644
|
|
|
f338ef |
index 0000000..e753c1f
|
|
|
f338ef |
--- /dev/null
|
|
|
f338ef |
+++ b/tests/00-geo-rep/00-georep-verify-non-root-setup.t
|
|
|
f338ef |
@@ -0,0 +1,251 @@
|
|
|
f338ef |
+#!/bin/bash
|
|
|
f338ef |
+
|
|
|
f338ef |
+. $(dirname $0)/../include.rc
|
|
|
f338ef |
+. $(dirname $0)/../volume.rc
|
|
|
f338ef |
+. $(dirname $0)/../geo-rep.rc
|
|
|
f338ef |
+. $(dirname $0)/../env.rc
|
|
|
f338ef |
+
|
|
|
f338ef |
+SCRIPT_TIMEOUT=500
|
|
|
f338ef |
+
|
|
|
f338ef |
+### Basic Non-root geo-rep setup test with Distribute Replicate volumes
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Cleanup and start glusterd
|
|
|
f338ef |
+cleanup;
|
|
|
f338ef |
+TEST glusterd;
|
|
|
f338ef |
+TEST pidof glusterd
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Variables
|
|
|
f338ef |
+GEOREP_CLI="$CLI volume geo-replication"
|
|
|
f338ef |
+master=$GMV0
|
|
|
f338ef |
+SH0="127.0.0.1"
|
|
|
f338ef |
+slave=${SH0}::${GSV0}
|
|
|
f338ef |
+num_active=2
|
|
|
f338ef |
+num_passive=2
|
|
|
f338ef |
+master_mnt=$M0
|
|
|
f338ef |
+slave_mnt=$M1
|
|
|
f338ef |
+
|
|
|
f338ef |
+##User and group to be used for non-root geo-rep setup
|
|
|
f338ef |
+usr="nroot"
|
|
|
f338ef |
+grp="ggroup"
|
|
|
f338ef |
+
|
|
|
f338ef |
+slave_url=$usr@$slave
|
|
|
f338ef |
+slave_vol=$GSV0
|
|
|
f338ef |
+ssh_url=$usr@$SH0
|
|
|
f338ef |
+
|
|
|
f338ef |
+############################################################
|
|
|
f338ef |
+#SETUP VOLUMES AND VARIABLES
|
|
|
f338ef |
+
|
|
|
f338ef |
+##create_and_start_master_volume
|
|
|
f338ef |
+TEST $CLI volume create $GMV0 replica 2 $H0:$B0/${GMV0}{1,2,3,4};
|
|
|
f338ef |
+TEST $CLI volume start $GMV0
|
|
|
f338ef |
+
|
|
|
f338ef |
+##create_and_start_slave_volume
|
|
|
f338ef |
+TEST $CLI volume create $GSV0 replica 2 $H0:$B0/${GSV0}{1,2,3,4};
|
|
|
f338ef |
+TEST $CLI volume start $GSV0
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Mount master
|
|
|
f338ef |
+#TEST glusterfs -s $H0 --volfile-id $GMV0 $M0
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Mount slave
|
|
|
f338ef |
+#TEST glusterfs -s $H0 --volfile-id $GSV0 $M1
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##########################################################
|
|
|
f338ef |
+#TEST FUNCTIONS
|
|
|
f338ef |
+
|
|
|
f338ef |
+function distribute_key_non_root()
|
|
|
f338ef |
+{
|
|
|
f338ef |
+ ${GLUSTER_LIBEXECDIR}/set_geo_rep_pem_keys.sh $usr $master $slave_vol
|
|
|
f338ef |
+ echo $?
|
|
|
f338ef |
+}
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+function check_status_non_root()
|
|
|
f338ef |
+{
|
|
|
f338ef |
+ local search_key=$1
|
|
|
f338ef |
+ $GEOREP_CLI $master $slave_url status | grep -F "$search_key" | wc -l
|
|
|
f338ef |
+}
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+function check_and_clean_group()
|
|
|
f338ef |
+{
|
|
|
f338ef |
+ if [ $(getent group $grp) ]
|
|
|
f338ef |
+ then
|
|
|
f338ef |
+ groupdel $grp;
|
|
|
f338ef |
+ echo $?
|
|
|
f338ef |
+ else
|
|
|
f338ef |
+ echo 0
|
|
|
f338ef |
+ fi
|
|
|
f338ef |
+}
|
|
|
f338ef |
+
|
|
|
f338ef |
+function clean_lock_files()
|
|
|
f338ef |
+{
|
|
|
f338ef |
+ if [ ! -f /etc/passwd.lock ];
|
|
|
f338ef |
+ then
|
|
|
f338ef |
+ rm -rf /etc/passwd.lock;
|
|
|
f338ef |
+ fi
|
|
|
f338ef |
+
|
|
|
f338ef |
+ if [ ! -f /etc/group.lock ];
|
|
|
f338ef |
+ then
|
|
|
f338ef |
+ rm -rf /etc/group.lock;
|
|
|
f338ef |
+ fi
|
|
|
f338ef |
+
|
|
|
f338ef |
+ if [ ! -f /etc/shadow.lock ];
|
|
|
f338ef |
+ then
|
|
|
f338ef |
+ rm -rf /etc/shadow.lock;
|
|
|
f338ef |
+ fi
|
|
|
f338ef |
+
|
|
|
f338ef |
+ if [ ! -f /etc/gshadow.lock ];
|
|
|
f338ef |
+ then
|
|
|
f338ef |
+ rm -rf /etc/gshadow.lock;
|
|
|
f338ef |
+ fi
|
|
|
f338ef |
+}
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+###########################################################
|
|
|
f338ef |
+#SETUP NON-ROOT GEO REPLICATION
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Create ggroup group
|
|
|
f338ef |
+##First test if group exists and then create new one
|
|
|
f338ef |
+
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 0 check_and_clean_group
|
|
|
f338ef |
+
|
|
|
f338ef |
+##cleanup *.lock files
|
|
|
f338ef |
+
|
|
|
f338ef |
+clean_lock_files
|
|
|
f338ef |
+
|
|
|
f338ef |
+TEST /usr/sbin/groupadd $grp
|
|
|
f338ef |
+
|
|
|
f338ef |
+clean_lock_files
|
|
|
f338ef |
+##Create non-root user and assign it to newly created group
|
|
|
f338ef |
+
|
|
|
f338ef |
+TEST /usr/sbin/useradd -G $grp $usr
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Modify password for non-root user to have control over distributing ssh-key
|
|
|
f338ef |
+echo "$usr:pass" | chpasswd
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Set up mountbroker root
|
|
|
f338ef |
+TEST gluster-mountbroker setup /var/mountbroker-root $grp
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Associate volume and non-root user to the mountbroker
|
|
|
f338ef |
+TEST gluster-mountbroker add $slave_vol $usr
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Check ssh setting for clear text passwords
|
|
|
f338ef |
+sed '/^PasswordAuthentication /{s/no/yes/}' -i /etc/ssh/sshd_config && grep '^PasswordAuthentication ' /etc/ssh/sshd_config && service sshd restart
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Restart glusterd to reflect mountbroker changages
|
|
|
f338ef |
+TEST killall_gluster;
|
|
|
f338ef |
+TEST glusterd;
|
|
|
f338ef |
+TEST pidof glusterd;
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Create, start and mount meta_volume
|
|
|
f338ef |
+TEST $CLI volume create $META_VOL replica 3 $H0:$B0/${META_VOL}{1,2,3};
|
|
|
f338ef |
+TEST $CLI volume start $META_VOL
|
|
|
f338ef |
+TEST mkdir -p $META_MNT
|
|
|
f338ef |
+TEST glusterfs -s $H0 --volfile-id $META_VOL $META_MNT
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Mount master
|
|
|
f338ef |
+TEST glusterfs -s $H0 --volfile-id $GMV0 $M0
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Mount slave
|
|
|
f338ef |
+TEST glusterfs -s $H0 --volfile-id $GSV0 $M1
|
|
|
f338ef |
+
|
|
|
f338ef |
+## Check status of mount-broker
|
|
|
f338ef |
+TEST gluster-mountbroker status
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Setup password-less ssh for non-root user
|
|
|
f338ef |
+#sshpass -p "pass" ssh-copy-id -i ~/.ssh/id_rsa.pub $ssh_url
|
|
|
f338ef |
+##Run ssh agent
|
|
|
f338ef |
+eval "$(ssh-agent -s)"
|
|
|
f338ef |
+PASS="pass"
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Create a temp script to echo the SSH password, used by SSH_ASKPASS
|
|
|
f338ef |
+
|
|
|
f338ef |
+SSH_ASKPASS_SCRIPT=/tmp/ssh-askpass-script
|
|
|
f338ef |
+cat > ${SSH_ASKPASS_SCRIPT} <
|
|
|
f338ef |
+#!/bin/bash
|
|
|
f338ef |
+echo "${PASS}"
|
|
|
f338ef |
+EOL
|
|
|
f338ef |
+chmod u+x ${SSH_ASKPASS_SCRIPT}
|
|
|
f338ef |
+
|
|
|
f338ef |
+##set no display, necessary for ssh to use with setsid and SSH_ASKPASS
|
|
|
f338ef |
+#export DISPLAY=:0
|
|
|
f338ef |
+
|
|
|
f338ef |
+export SSH_ASKPASS=${SSH_ASKPASS_SCRIPT}
|
|
|
f338ef |
+
|
|
|
f338ef |
+DISPLAY=: setsid ssh-copy-id -i ~/.ssh/id_rsa.pub $ssh_url
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Setting up PATH for gluster binaries in case of source installation
|
|
|
f338ef |
+##ssh -oNumberOfPasswordPrompts=0 -oStrictHostKeyChecking=no $ssh_url "echo "export PATH=$PATH:/usr/local/sbin" >> ~/.bashrc"
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Creating secret pem pub file
|
|
|
f338ef |
+TEST gluster-georep-sshkey generate
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Create geo-rep non-root setup
|
|
|
f338ef |
+
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url create push-pem
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Config gluster-command-dir
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url config gluster-command-dir ${GLUSTER_CMD_DIR}
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Config gluster-command-dir
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url config slave-gluster-command-dir ${GLUSTER_CMD_DIR}
|
|
|
f338ef |
+
|
|
|
f338ef |
+## Test for key distribution
|
|
|
f338ef |
+
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 0 distribute_key_non_root
|
|
|
f338ef |
+
|
|
|
f338ef |
+##Wait for common secret pem file to be created
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 0 check_common_secret_file
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Enable_metavolume
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave config use_meta_volume true
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Start_georep
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url start
|
|
|
f338ef |
+
|
|
|
f338ef |
+## Meta volume is enabled so looking for 2 Active and 2 Passive sessions
|
|
|
f338ef |
+
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 2 check_status_non_root "Active"
|
|
|
f338ef |
+
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 2 check_status_non_root "Passive"
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Pause geo-replication session
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url pause
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Resume geo-replication session
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url resume
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Validate failure of volume stop when geo-rep is running
|
|
|
f338ef |
+TEST ! $CLI volume stop $GMV0
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Stop Geo-rep
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url stop
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Delete Geo-rep
|
|
|
f338ef |
+TEST $GEOREP_CLI $master $slave_url delete
|
|
|
f338ef |
+
|
|
|
f338ef |
+#Cleanup authorized_keys
|
|
|
f338ef |
+sed -i '/^command=.*SSH_ORIGINAL_COMMAND#.*/d' ~/.ssh/authorized_keys
|
|
|
f338ef |
+sed -i '/^command=.*gsyncd.*/d' ~/.ssh/authorized_keys
|
|
|
f338ef |
+
|
|
|
f338ef |
+#clear mountbroker
|
|
|
f338ef |
+gluster-mountbroker remove --user $usr
|
|
|
f338ef |
+gluster-mountbroker remove --volume $slave_vol
|
|
|
f338ef |
+
|
|
|
f338ef |
+#delete group and user created for non-root setup
|
|
|
f338ef |
+TEST userdel -r -f $usr
|
|
|
f338ef |
+EXPECT_WITHIN $GEO_REP_TIMEOUT 0 check_and_clean_group
|
|
|
f338ef |
+
|
|
|
f338ef |
+##password script cleanup
|
|
|
f338ef |
+rm -rf /tmp/ssh-askpass-script
|
|
|
f338ef |
+
|
|
|
f338ef |
+
|
|
|
f338ef |
+cleanup;
|
|
|
f338ef |
+
|
|
|
f338ef |
--
|
|
|
f338ef |
1.8.3.1
|
|
|
f338ef |
|