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