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