Skip to content

Commit

Permalink
adding an help in the test script
Browse files Browse the repository at this point in the history
  • Loading branch information
kakwa committed May 24, 2017
1 parent 12ea677 commit 154a149
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pipeline {
sh 'git config --global user.name "[email protected]"'
git(url: 'https://github.com/kakwa/puppet-samba', poll: true, changelog: true, branch: "${env.BRANCH_NAME}")
sh 'git clean -fdx'
sh 'export OS=centos-7; ./tests/tests.sh'
sh './tests/tests.sh -C'
}


Expand All @@ -21,7 +21,7 @@ pipeline {
sh 'git config --global user.name "[email protected]"'
git(url: 'https://github.com/kakwa/puppet-samba', poll: true, changelog: true, branch: "${env.BRANCH_NAME}")
sh 'git clean -fdx'
sh 'export OS=debian-8; ./tests/tests.sh'
sh './tests/tests.sh -CD'
}


Expand Down
143 changes: 106 additions & 37 deletions tests/tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,65 @@
#!/bin/sh

help(){
cat <<EOF
usage: `basename $0` -[nCDc]
Test script for kakwa/puppet-samba module
arguments:
-n: disable cleaning
-c: do only cleaning, no tests
-C: enable samba classic tests
-D: enable samba AD/DC tests
EOF
exit 1
}

NO_CLEAN=0
CLASSIC_TEST=0
DC_TEST=0
CLEAN_ONLY=0

while getopts ":hCDnc" opt; do
case $opt in

h)
help
;;
n)
NO_CLEAN=1
;;
C)
CLASSIC_TEST=1
;;
D)
DC_TEST=1
;;
c)
CLEAN_ONLY=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
help
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
help
exit 1
;;
esac
done


cleanup(){

if [ $NO_CLEAN -eq 1 ]
then
echo "Cleaning step skipped"
return
fi

# some clean up
/etc/init.d/samba stop
/etc/init.d/samba-ad-dc stop
Expand Down Expand Up @@ -33,60 +92,70 @@ run(){
[ $ret -eq 6 ] && exit_error "$message"
}

cd `dirname $0`/..
mkdir `pwd`/modules
puppet module install puppetlabs-stdlib --modulepath=`pwd`/modules
puppet module install herculesteam-augeasproviders_pam --modulepath=`pwd`/modules
ln -s ../ ./modules/samba
if [ $CLEAN_ONLY -eq 1 ]
then
echo "Cleaning up, and exiting fater"
cleanup
exit 0
fi

echo
echo "#####################################################"
echo "#####################################################"
echo
if [ $CLASSIC_TEST -eq 1 ]
then
cd `dirname $0`/..
mkdir `pwd`/modules
puppet module install puppetlabs-stdlib --modulepath=`pwd`/modules
puppet module install herculesteam-augeasproviders_pam --modulepath=`pwd`/modules
ln -s ../ ./modules/samba

run tests/init.pp "classic test failed"
echo
echo "#####################################################"
echo "#####################################################"
echo

echo
echo "#####################################################"
echo "#####################################################"
echo
run tests/init.pp "classic test failed"

cleanup >/dev/null 2>&1
echo
echo "#####################################################"
echo "#####################################################"
echo

echo
echo "#####################################################"
echo "#####################################################"
echo
cleanup >/dev/null 2>&1

echo
echo "#####################################################"
echo "#####################################################"
echo
fi


if [ "$OS" = "debian-8" ]
if [ $DC_TEST -eq 1 ]
then
run tests/dc.pp "AD test failed"

netstat -apn | grep ':389' || exit_error "should listen on 389"
netstat -apn | grep ':53' || exit_error "should listen on 53"
netstat -apn | grep ':636' || exit_error "should listen on 636"
netstat -apn | grep ':464' || exit_error "should listen on 464"

echo
echo "#####################################################"
echo "#####################################################"
echo

echo
echo "#####################################################"
echo "#####################################################"
echo


# testing password setting for samba AD password
run tests/smb_user.pp "smb_user test failed (apply 1)"

netstat -apn | grep ':389' || exit_error "should listen on 389"
netstat -apn | grep ':53' || exit_error "should listen on 53"
netstat -apn | grep ':636' || exit_error "should listen on 636"
netstat -apn | grep ':464' || exit_error "should listen on 464"

####
# test the force_password = false setting
# check that we can connect
Expand All @@ -106,42 +175,42 @@ then
smbclient '//localhost/netlogon' "c0mPL3xe_P455woRd2" -Utest2 -c ls || exit_error "failed to login 2 test2"
smbclient '//localhost/netlogon' "c0mPL3xe_P455woRd2" -Utest3 -c ls || exit_error "failed to login 2 test3"
###

echo
echo "#####################################################"
echo "#####################################################"
echo

cleanup >/dev/null 2>&1

echo
echo "#####################################################"
echo "#####################################################"
echo

run tests/no_winbind.pp "winbind test failed"

echo
echo "#####################################################"
echo "#####################################################"
echo

cleanup >/dev/null 2>&1

echo
echo "#####################################################"
echo "#####################################################"
echo

run tests/smb_acl.pp "acl test failed"

echo
echo "#####################################################"
echo "#####################################################"
echo

cleanup >/dev/null 2>&1
fi

cleanup >/dev/null 2>&1

exit 0

0 comments on commit 154a149

Please sign in to comment.