From 877bce698a4bda6d79954328fd5ca8aa5aa6f77d Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 8 Sep 2016 13:44:05 -0400 Subject: [PATCH 1/7] Lets see how this test performs --- Jenkinsfile | 31 +++++++++++++++++++++++++++++-- bin/compose.sh | 4 ++++ bin/decompose.sh | 4 ++++ bin/prune.sh | 3 +++ bin/recompose.sh | 3 +++ tests/running.bats | 7 +++++++ 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 bin/compose.sh create mode 100755 bin/decompose.sh create mode 100755 bin/prune.sh create mode 100755 bin/recompose.sh create mode 100644 tests/running.bats diff --git a/Jenkinsfile b/Jenkinsfile index fcbfdfc..9744828 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,22 +40,36 @@ node('docker') { sh 'bin/rebuild.sh &> debug' } catch(error) { def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + def message = "BUILD ERROR: There was a problem building Grouper appliance (${tag}). \n\n ${error_details}" sh "rm -f ./debug" handleError(message) } + stage 'Compose' + try{ + sh 'bin/compose.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem composing Grouper appliance (${tag}). \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } + stage 'Tests' try{ sh 'bin/test.sh &> debug' } catch(error) { def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + def message = "BUILD ERROR: There was a problem testing Grouper appliance :${tag}. \n\n ${error_details}" sh "rm -f ./debug" handleError(message) } + stage 'Clean Up' + + cleanup() + stage 'Notify' slackSend color: 'good', message: "grouper-appliance (${tag}) passes test battery" @@ -77,5 +91,18 @@ def handleError(String message){ currentBuild.setResult("FAILED") slackSend color: 'danger', message: "${message}" //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) + cleanup() sh 'exit 1' +} + +def cleanup() { + try{ + sh 'bin/decompose.sh &> debug' + sh 'bin/prune.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem cleaning up Grouper appliance :${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } } \ No newline at end of file diff --git a/bin/compose.sh b/bin/compose.sh new file mode 100755 index 0000000..edb2141 --- /dev/null +++ b/bin/compose.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Composing" +docker-compose up -d \ No newline at end of file diff --git a/bin/decompose.sh b/bin/decompose.sh new file mode 100755 index 0000000..754e6a4 --- /dev/null +++ b/bin/decompose.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Decomposing" +docker-compose stop \ No newline at end of file diff --git a/bin/prune.sh b/bin/prune.sh new file mode 100755 index 0000000..03fd593 --- /dev/null +++ b/bin/prune.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +result=$(docker volume rm $(docker volume ls -qf dangling=true)) diff --git a/bin/recompose.sh b/bin/recompose.sh new file mode 100755 index 0000000..6392944 --- /dev/null +++ b/bin/recompose.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +source bin/decompose.sh && source bin/prune.sh && source bin/compose.sh \ No newline at end of file diff --git a/tests/running.bats b/tests/running.bats new file mode 100644 index 0000000..27d47cb --- /dev/null +++ b/tests/running.bats @@ -0,0 +1,7 @@ +#!/usr/bin/env bats + +load ../common + +@test "Contains mysql run" { + docker exec -i mariadb mysql -u root -h 127.0.0.1 --password=123321 -e 'SELECT User FROM mysql.user' | grep grouper_user +} From 09e085f16e78ab2905101e2e2c69287e8c07e0ed Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 8 Sep 2016 13:51:35 -0400 Subject: [PATCH 2/7] More work --- bin/prune.sh | 6 +++++- bin/recompose.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/prune.sh b/bin/prune.sh index 03fd593..2efa97c 100755 --- a/bin/prune.sh +++ b/bin/prune.sh @@ -1,3 +1,7 @@ #!/bin/bash -result=$(docker volume rm $(docker volume ls -qf dangling=true)) +result=$(docker volume ls -qf dangling=true) + +if [ ! -z "$result" ]; then + docker volume rm $result +fi diff --git a/bin/recompose.sh b/bin/recompose.sh index 6392944..6749985 100755 --- a/bin/recompose.sh +++ b/bin/recompose.sh @@ -1,3 +1,3 @@ #!/bin/bash -source bin/decompose.sh && source bin/prune.sh && source bin/compose.sh \ No newline at end of file +source bin/decompose.sh && source bin/destroy.sh && source bin/prune.sh && source bin/build.sh && source bin/compose.sh \ No newline at end of file From 283f825641f0b7bf06fdb28e774cd5169b649448 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 8 Sep 2016 14:19:39 -0400 Subject: [PATCH 3/7] Adding additional DB and process check --- tests/running.bats | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/running.bats b/tests/running.bats index 27d47cb..53c5cdd 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -2,6 +2,14 @@ load ../common -@test "Contains mysql run" { +@test "Contains mysql grouper user" { docker exec -i mariadb mysql -u root -h 127.0.0.1 --password=123321 -e 'SELECT User FROM mysql.user' | grep grouper_user } + +@test "Grouper database tables created" { + docker exec -i mariadb mysql -u root -h 127.0.0.1 --password=123321 grouper -e 'show tables' | grep grouper +} + +@test "Continues running grouper container" { + docker ps | grep grouper | grep Up +} \ No newline at end of file From b500af5a27ba5208f923b59d5f74b48bffe15050 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Fri, 9 Sep 2016 12:06:42 -0300 Subject: [PATCH 4/7] Added Certs --- Dockerfile | 1 + conf/grouper.conf | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 079a4b1..d92796a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ENV TOMCAT_VERSION="6.0.35" ADD ./container_files /opt/ COPY conf/grouper.conf /etc/httpd/conf.d/grouper.conf COPY conf/grouper.hibernate.properties /opt/etc +COPY conf/server.* /etc/httpd/certs/ RUN rm /opt/grouper/2.3.0/grouper.apiBinary-2.3.0/conf/grouper.hibernate.properties && \ ln -s /opt/etc/grouper.hibernate.properties /opt/grouper/2.3.0/grouper.apiBinary-2.3.0/conf/grouper.hibernate.properties && \ rm /opt/grouper/2.3.0/grouper.ws-2.3.0/grouper-ws/build/dist/grouper-ws/WEB-INF/classes/grouper.hibernate.properties && \ diff --git a/conf/grouper.conf b/conf/grouper.conf index a960344..8d23907 100644 --- a/conf/grouper.conf +++ b/conf/grouper.conf @@ -1,6 +1,6 @@ Listen 443 - ServerAlias grouper.your.institution.edu + ServerAlias grouper.grouperappliance_i2network SSLEngine on SSLCertificateFile /etc/httpd/certs/server.crt @@ -22,4 +22,4 @@ Listen 443 ProxyPass /grouper-ws/ ajp://localhost:8009/grouper-ws/ retry=0 ProxyPass /examples/ ajp://localhost:8009/examples/ retry=0 - \ No newline at end of file + From 4d693e726f4129c12820344be5e326cf890b0589 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Fri, 9 Sep 2016 12:09:03 -0300 Subject: [PATCH 5/7] added certs --- conf/server.csr | 18 ++++++++++++++++++ conf/server.key | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 conf/server.csr create mode 100644 conf/server.key diff --git a/conf/server.csr b/conf/server.csr new file mode 100644 index 0000000..169be23 --- /dev/null +++ b/conf/server.csr @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIC3TCCAcUCAQAwgZcxCzAJBgNVBAYTAlVTMRcwFQYDVQQIEw5Ob3J0aCBDYXJv +bGluYTESMBAGA1UEBxMJQ2hhcmxvdHRlMQ8wDQYDVQQKEwZMZXZ2ZWwxDzANBgNV +BAsTBkRvY2tlcjERMA8GA1UEAxMIYmlnZmxlZXQxJjAkBgkqhkiG9w0BCQEWF2pp +bS52YW4uZmxlZXRAbGV2dmVsLmlvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEA3t0jXXlV89EBL8CPFkiqd14xdWem2gm4SrZccAnsb7dQm7VJrwTOs7Q5 +mMKnTMCr0Af1H1XYpYFEfGMKOlUE0OKb/sWFQGlU6AFjUf1A9vxfjK4lfpFQy0X3 +qpeKLNAvenOsjbYXtW0G60+AWUdHjk+7wYt6Mzd/BmnFB9vqML9k581adu3Rltli +K1sS/BuPcPicvCv51XaxK+PBf+t+PTR14swXcnKVRjCHQ+tqpgW90nVnsyl5nMzp +R0y7V4SkmTvm0GmAPNbBj5AwezbFJB1dbfJDAbfLAjDz+CuQQKiCXYoIOpwSDSLq +GtJnTCN+1u6YVHC544ORbGVJ/eQzLwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEB +AJ6hDOof0VueZkGT9wIz/5pKJgoTe9kTNnnHfnXitROwxEEF5gyFPICXkALbJkC7 +HqNl+wd/cG010CoeAI5rcoYDvfY5WAmIOXQF2Zo4EV6XgfBwnk/Jz1T6TvryB14o +Pp/jwJzurEi90bCHmxELIJwHQPGxbLdF5ScNTg26xXkt6FI4w9utTzh85Pgmxir6 +7niVc3MvR9eyWVXF3NiakQw9oM8FsfRY2i3c87ugcuH0LDrVUFkz4GqS8vC6N1Ao +L/KAmBvfz25bq+GaXSKb2OQyvNHcM8lquP0vQKsvrs1ecUY4YILBy1yCEGUSxDGM +kH3F2FuaT22hbNM1JxrLo2Q= +-----END CERTIFICATE REQUEST----- diff --git a/conf/server.key b/conf/server.key new file mode 100644 index 0000000..e1de9a0 --- /dev/null +++ b/conf/server.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA3t0jXXlV89EBL8CPFkiqd14xdWem2gm4SrZccAnsb7dQm7VJ +rwTOs7Q5mMKnTMCr0Af1H1XYpYFEfGMKOlUE0OKb/sWFQGlU6AFjUf1A9vxfjK4l +fpFQy0X3qpeKLNAvenOsjbYXtW0G60+AWUdHjk+7wYt6Mzd/Bmn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BR85DLTOt7kMkCgYAHoRjHN53hc2PSUM+6ioBeKL94QE+SUuB9/Smy +XRglXbp/WqPxQweanwtI6+NSukXrZQgyuhpyH4lNTV1pCSfMCykCOiLwthfQdVHW +uSzSgQea2nx9anBYJFZB8Tck5FqDnh4yNJDlTtfx0u+NE0Qcpn9isZP3idPNVZLf +Bx6I4wKBgQDagUD7YJ3oX/4mbBmWJ/z7fAWcUqdRC2kwVfOn2qdeRgVNXQD97u0f +ZUw7fH6MSKHkuQsM0UWxex2dxxfJaFH5aF5EqXzlT/9by4Ela9p6GtecyuNPDnm+ +jReIeDTO73BnM0LJNPPyd/CSHvaVEgvVmjjNTkuBYpyk8HVXf/Cd/A== +-----END RSA PRIVATE KEY----- From e89b5762dfe42c216ee138c3793e12f9987f20f8 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Fri, 9 Sep 2016 12:10:02 -0300 Subject: [PATCH 6/7] Added mor cert:x --- conf/server.crt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 conf/server.crt diff --git a/conf/server.crt b/conf/server.crt new file mode 100644 index 0000000..5a54800 --- /dev/null +++ b/conf/server.crt @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDrDCCApQCCQCqx2/xzYm5ejANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UEBhMC +VVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRIwEAYDVQQHEwlDaGFybG90dGUx +DzANBgNVBAoTBkxldnZlbDEPMA0GA1UECxMGRG9ja2VyMREwDwYDVQQDEwhiaWdm +bGVldDEmMCQGCSqGSIb3DQEJARYXamltLnZhbi5mbGVldEBsZXZ2ZWwuaW8wHhcN +MTYwODEyMTY0MTMyWhcNMTcwODEyMTY0MTMyWjCBlzELMAkGA1UEBhMCVVMxFzAV +BgNVBAgTDk5vcnRoIENhcm9saW5hMRIwEAYDVQQHEwlDaGFybG90dGUxDzANBgNV +BAoTBkxldnZlbDEPMA0GA1UECxMGRG9ja2VyMREwDwYDVQQDEwhiaWdmbGVldDEm +MCQGCSqGSIb3DQEJARYXamltLnZhbi5mbGVldEBsZXZ2ZWwuaW8wggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDe3SNdeVXz0QEvwI8WSKp3XjF1Z6baCbhK +tlxwCexvt1CbtUmvBM6ztDmYwqdMwKvQB/UfVdilgUR8Ywo6VQTQ4pv+xYVAaVTo +AWNR/UD2/F+MriV+kVDLRfeql4os0C96c6yNthe1bQbrT4BZR0eOT7vBi3ozN38G +acUH2+owv2TnzVp27dGW2WIrWxL8G49w+Jy8K/nVdrEr48F/6349NHXizBdycpVG +MIdD62qmBb3SdWezKXmczOlHTLtXhKSZO+bQaYA81sGPkDB7NsUkHV1t8kMBt8sC +MPP4K5BAqIJdigg6nBINIuoa0mdMI37W7phUcLnjg5FsZUn95DMvAgMBAAEwDQYJ +KoZIhvcNAQELBQADggEBAGhWie1wkXg8V3rG4nGvDLVCFi8V4fPLF5dL5HCULGde +i9Xz+v412qt1kxgDDwlSZ3oRP1z/tKIywRgLD0NcBJYHqzJN+5gg+ZJMHLEn/bOf +CS6H91dWD93vlcdBMhyh/rz1PafBWc+TyaNuvihSz4V7kpUdUQ7ovXwv3yeSJelT +OFzQbjx+roSfFOK7CuIEOee42MAcaqD5LpnGCIujPQgAje3OdyDeofoFA0XehY/Y +QzooAqSqYhomN6G4RFRAiYwXVkhKbeLBdOOs3rjdymcrFSvwWUJKx7EtpUegucEw +krFR4hpkGmKABuhVZp/g1zxzeodkwRyJFrQEecFQIN4= +-----END CERTIFICATE----- From baf42db03dd7f39ba16d80bd49a2c92fe62cebfe Mon Sep 17 00:00:00 2001 From: Chris Bynum Date: Wed, 14 Sep 2016 13:35:46 -0400 Subject: [PATCH 7/7] Added URL tests --- tests/running.bats | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/running.bats b/tests/running.bats index 53c5cdd..a9b5699 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -12,4 +12,20 @@ load ../common @test "Continues running grouper container" { docker ps | grep grouper | grep Up -} \ No newline at end of file +} + +@test "curl can connect to Grouper diagnostics URL successfully" { + skip + run docker exec -i grouper curl http://localhost:8080/grouper-ws/status?diagnosticType=all + echo ${output} + [ "$status" -eq 0 ] + [[ ${output} == *"302"* || ${output} == *"200"* ]] +} + +@test "curl can connect to Grouper WS endpoint" { + skip + run docker exec -i grouper curl http://`docker-machine ip`/grouper-ws/ + echo ${output} + [ "$status" -eq 0 ] + [[ ${output} == *"302"* || ${output} == *"200"* ]] +}