From 2d97fce4e959c56e243c56eea29ae97ca55a9024 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:00:16 +0200 Subject: [PATCH 1/3] [twgit] Init feature 'feature-clean'. From c5b29549a22eb33ca1703d2cd4b99fabe77f4e2c Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:52:59 +0200 Subject: [PATCH 2/3] clean --- slapd.sh | 39 +++++++++++++++++++++------------- test.sh | 17 ++++++++++----- test/build.sh | 8 +++++-- test/run-simple.sh | 7 ++++-- test/run-tls.sh | 9 +++++--- test/tools/config.prop | 2 ++ test/tools/delete-container.sh | 10 ++++----- test/tools/delete-image.sh | 10 ++++----- test/tools/end.sh | 4 ++-- test/tools/prepare.sh | 3 ++- 10 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 test/tools/config.prop diff --git a/slapd.sh b/slapd.sh index 4571530..86a98cf 100755 --- a/slapd.sh +++ b/slapd.sh @@ -6,19 +6,17 @@ status () { echo "---> ${@}" >&2 } + +set -x +: LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD} +: LDAP_DOMAIN=${LDAP_DOMAIN} +: LDAP_ORGANISATION=${LDAP_ORGANISATION} + + +############ Base config ############ if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then - status "configuring slapd for first run" + status "configuring slapd database" - set -x - : LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD} - : LDAP_DOMAIN=${LDAP_DOMAIN} - : LDAP_ORGANISATION=${LDAP_ORGANISATION} - - - # permission error on /etc/ldap/slapd.conf if not set?! :'( - adduser openldap root - - ############ Base config ############ cat <&1 - ./test/$1.sh > $out 2>&1 + if [ -z ${verbose} ]; then + ./test/$1.sh > $out 2>&1 + else + ./test/$1.sh | tee $out 2>&1 + fi if [ "$(grep -c "$2" $out)" -eq 0 ]; then echo_error $fction @@ -37,11 +44,11 @@ run_test () { } -./test/tools/prepare.sh +./test/tools/prepare.sh > /dev/null 2>&1 run_test build "Successfully built" run_test run-simple "dn: dc=example,dc=com" run_test run-tls "dn: dc=example,dc=com" -./test/tools/end.sh +./test/tools/end.sh > /dev/null 2>&1 echo "------- Test finished -------" echo $error " failed " $ok " passed" diff --git a/test/build.sh b/test/build.sh index b0c77cb..66aa324 100755 --- a/test/build.sh +++ b/test/build.sh @@ -1,4 +1,8 @@ #!/bin/sh -#sudo docker.io build -t openldap-test . -sudo docker.io build --no-cache=true -t openldap-test . + +dir=$(dirname $0) +. $dir/tools/config.prop + +sudo docker.io build -t $openldapTestImage . +#sudo docker.io build --no-cache=true -t openldap-test . diff --git a/test/run-simple.sh b/test/run-simple.sh index c6f18c1..27a93f1 100755 --- a/test/run-simple.sh +++ b/test/run-simple.sh @@ -1,7 +1,10 @@ #!/bin/sh -docker.io run --name openldap-test-container -p 65389:389 -d openldap-test +dir=$(dirname $0) +. $dir/tools/config.prop + +docker.io run --name $openldapTestContainer -p 65389:389 -d $openldapTestImage sleep 5 ldapsearch -x -h localhost -p 65389 -b dc=example,dc=com -$(pwd)/test/tools/delete-container.sh +$dir/tools/delete-container.sh diff --git a/test/run-tls.sh b/test/run-tls.sh index 45d2a29..b4209a4 100755 --- a/test/run-tls.sh +++ b/test/run-tls.sh @@ -1,8 +1,11 @@ #!/bin/sh -docker.io run --name openldap-test-container --dns=127.0.0.1 -v `pwd`/test/ssl:/etc/ldap/ssl -p 65389:389 -d openldap-test +dir=$(dirname $0) +. $dir/tools/config.prop -cert=$(echo `pwd`/test/ssl/ldap.crt) +docker.io run --name $openldapTestContainer --dns=127.0.0.1 -v `pwd`/test/ssl:/etc/ldap/ssl -p 65389:389 -d $openldapTestImage + +cert=$(echo $dir/ssl/ldap.crt) certCN=$(openssl x509 -in $cert -subject -noout | sed -n 's/.*CN=\(.*\)\/*\(.*\)/\1/p') addLine=$(echo "127.0.0.1" $certCN) @@ -18,4 +21,4 @@ sed -i '/'"$addLine"'/d' /etc/hosts cp /etc/ldap/ldap.conf.old /etc/ldap/ldap.conf rm /etc/ldap/ldap.conf.old -$(pwd)/test/tools/delete-container.sh +$dir/tools/delete-container.sh diff --git a/test/tools/config.prop b/test/tools/config.prop new file mode 100644 index 0000000..2b16157 --- /dev/null +++ b/test/tools/config.prop @@ -0,0 +1,2 @@ +openldapTestImage=openldap-test +openldapTestContainer=openldap-test-container diff --git a/test/tools/delete-container.sh b/test/tools/delete-container.sh index 01fa717..c0a6ad5 100755 --- a/test/tools/delete-container.sh +++ b/test/tools/delete-container.sh @@ -1,11 +1,11 @@ #!/bin/sh -# remove openldap test container -docker.io ps -a > testcontainer.out +. $(dirname $0)/config.prop -if [ "$(grep -c "openldap-test-container" ./testcontainer.out)" -ne 0 ]; then +# remove openldap test container +res=$(docker.io ps -a | grep -c "$openldapTestContainer") + +if [ $res -ne 0 ]; then docker.io stop openldap-test-container docker.io rm openldap-test-container fi - -rm testcontainer.out diff --git a/test/tools/delete-image.sh b/test/tools/delete-image.sh index 48ebc99..8266318 100755 --- a/test/tools/delete-image.sh +++ b/test/tools/delete-image.sh @@ -1,10 +1,10 @@ #!/bin/sh -# remove openldap test image -docker.io images > testimage.out +. $(dirname $0)/config.prop -if [ "$(grep -c "openldap-test" ./testimage.out)" -ne 0 ]; then +# remove openldap test image +res=$(docker.io images | grep -c "$openldapTestImage") + +if [ $res -ne 0 ]; then docker.io rmi openldap-test fi - -rm testimage.out diff --git a/test/tools/end.sh b/test/tools/end.sh index 779dd5a..05428a0 100755 --- a/test/tools/end.sh +++ b/test/tools/end.sh @@ -1,4 +1,4 @@ #!/bin/sh -./test/tools/delete-container.sh -./test/tools/delete-image.sh +$(dirname $0)/delete-container.sh +$(dirname $0)/delete-image.sh diff --git a/test/tools/prepare.sh b/test/tools/prepare.sh index 75fec9d..05428a0 100755 --- a/test/tools/prepare.sh +++ b/test/tools/prepare.sh @@ -1,3 +1,4 @@ #!/bin/sh -./test/tools/delete-container.sh +$(dirname $0)/delete-container.sh +$(dirname $0)/delete-image.sh From 2ceab05d5996fa9882ffe47280db8d98bbda314f Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:53:18 +0200 Subject: [PATCH 3/3] [twgit] Init release 'release-0.4.0'.