[ARVADOS-DEV] updated: f23d3167e9163944b7a52ce9d822b930053bb957

git at public.curoverse.com git at public.curoverse.com
Sun Sep 27 16:00:10 EDT 2015


Summary of changes:
 .../arvados-sso-server.postinst                    |  24 +-
 jenkins/run-test-packages-sso.sh                   | 242 +++++++++++++++++++++
 2 files changed, 256 insertions(+), 10 deletions(-)
 create mode 100755 jenkins/run-test-packages-sso.sh

       via  f23d3167e9163944b7a52ce9d822b930053bb957 (commit)
       via  170c33818a1ac6a3e35f411d80cf77a008bd6e07 (commit)
      from  c21753f5f91a3144395f4b259b09fb16b39b4b2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f23d3167e9163944b7a52ce9d822b930053bb957
Author: Ward Vandewege <ward at curoverse.com>
Date:   Sun Sep 27 15:59:56 2015 -0400

    Initial version of run-test-packages-sso.sh
    
    refs #7330

diff --git a/jenkins/run-test-packages-sso.sh b/jenkins/run-test-packages-sso.sh
new file mode 100755
index 0000000..b9476bb
--- /dev/null
+++ b/jenkins/run-test-packages-sso.sh
@@ -0,0 +1,242 @@
+#!/bin/bash
+
+. `dirname "$(readlink -f "$0")"`/run-library.sh
+
+read -rd "\000" helpmessage <<EOF
+$(basename $0): Test Arvados SSO package
+
+Syntax:
+        WORKSPACE=/path/to/arvados-sso $(basename $0) [options]
+
+Options:
+
+--debug
+    Output debug information (default: false)
+--target
+    Distribution to build packages for (default: debian7)
+
+WORKSPACE=path         Path to the Arvados SSO source tree
+
+EOF
+
+EXITCODE=0
+DEBUG=${ARVADOS_DEBUG:-0}
+BUILD_BUNDLE_PACKAGES=0
+TARGET=debian7
+SUDO=/usr/bin/sudo
+
+if [[ ! -e "$SUDO" ]]; then
+  SUDO=
+fi
+
+PARSEDOPTS=$(getopt --name "$0" --longoptions \
+    help,build-bundle-packages,debug,target: \
+    -- "" "$@")
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+eval set -- "$PARSEDOPTS"
+while [ $# -gt 0 ]; do
+    case "$1" in
+        --help)
+            echo >&2 "$helpmessage"
+            echo >&2
+            exit 1
+            ;;
+        --target)
+            TARGET="$2"; shift
+            ;;
+        --debug)
+            DEBUG=1
+            ;;
+        --build-bundle-packages)
+            BUILD_BUNDLE_PACKAGES=1
+            ;;
+        --)
+            if [ $# -gt 1 ]; then
+                echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
+                exit 1
+            fi
+            ;;
+    esac
+    shift
+done
+
+STDOUT_IF_DEBUG=/dev/null
+STDERR_IF_DEBUG=/dev/null
+DASHQ_UNLESS_DEBUG=-q
+if [[ "$DEBUG" != 0 ]]; then
+    STDOUT_IF_DEBUG=/dev/stdout
+    STDERR_IF_DEBUG=/dev/stderr
+    DASHQ_UNLESS_DEBUG=
+fi
+
+case "$TARGET" in
+    debian7)
+        FORMAT=deb
+        ;;
+    debian8)
+        FORMAT=deb
+        ;;
+    ubuntu1204)
+        FORMAT=deb
+        ;;
+    ubuntu1404)
+        FORMAT=deb
+        ;;
+    centos6)
+        FORMAT=rpm
+        ;;
+    *)
+        echo -e "$0: Unknown target '$TARGET'.\n" >&2
+        exit 1
+        ;;
+esac
+
+if ! [[ -n "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: WORKSPACE environment variable not set"
+  echo >&2
+  exit 1
+fi
+
+if ! [[ -d "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: $WORKSPACE is not a directory"
+  echo >&2
+  exit 1
+fi
+
+install_package() {
+  PACKAGES=$@
+  if [[ "$FORMAT" == "deb" ]]; then
+    $SUDO apt-get install $PACKAGES --yes
+  elif [[ "$FORMAT" == "rpm" ]]; then
+    $SUDO yum -q -y install $PACKAGES
+  fi
+}
+
+# Find the SSO server package
+
+cd "$WORKSPACE"
+
+SSO_VERSION=$(version_from_git)
+PACKAGE_NAME=arvados-sso
+
+if [[ "$FORMAT" == "deb" ]]; then
+  PACKAGE_PATH=$WORKSPACE/packages/$TARGET/arvados-sso_${SSO_VERSION}_amd64.deb
+elif [[ "$FORMAT" == "rpm" ]]; then
+  PACKAGE_PATH=$WORKSPACE/packages/$TARGET/arvados-sso-${SSO_VERSION}.x86_64.rpm
+fi
+
+# Test 1a: the package to test must exist
+if [[ ! -f $PACKAGE_PATH ]]; then
+  echo "Latest package not found at $PACKAGE_PATH. Please build the package first."
+  exit 1
+fi
+
+if [[ "$FORMAT" == "deb" ]]; then
+  # Test 1b: the system/container where we're running the tests must be clean
+  set +e
+  dpkg -l |grep arvados-sso -q
+  if [[ "$?" != "1" ]]; then
+    echo "Please make sure the arvados-sso package is not installed before running this script"
+    exit 1
+  fi
+  set -e
+fi
+
+if [[ -e "/var/www/arvados-sso" ]]; then
+  echo "Please make sure /var/www/arvados-sso does not exist before running this script"
+  exit 1
+fi
+
+# Prepare the machine
+if [[ "$FORMAT" == "deb" ]]; then
+  $SUDO apt-get update
+elif [[ "$FORMAT" == "rpm" ]]; then
+  $SUDO yum check-update
+fi
+$SUDO mkdir -p /etc/arvados/sso
+
+if [[ ! -e "/etc/arvados/sso/application.yml" ]]; then
+  RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
+  cp config/application.yml.example /etc/arvados/sso/application.yml
+  sed -i -e 's/uuid_prefix: ~/uuid_prefix: zzzzz/' /etc/arvados/sso/application.yml
+  sed -i -e "s/secret_token: ~/secret_token: $RANDOM_PASSWORD/" /etc/arvados/sso/application.yml
+fi
+
+if [[ ! -e "/etc/arvados/sso/database.yml" ]]; then
+  install_package postgresql
+  $SUDO service postgresql start
+
+  RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
+  cat >/etc/arvados/sso/database.yml <<EOF
+production:
+  adapter: postgresql
+  encoding: utf8
+  database: sso_provider_production
+  username: sso_provider_user
+  password: $RANDOM_PASSWORD
+  host: localhost
+EOF
+  if [[ "$SUDO" != '' ]]; then
+    $SUDO -u postgres psql -c "CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'"
+    $SUDO -u postgres createdb sso_provider_production -O sso_provider_user
+  else
+    install_package sudo
+    /usr/bin/sudo -u postgres psql -c "CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'"
+    /usr/bin/sudo -u postgres createdb sso_provider_production -O sso_provider_user
+  fi
+fi
+
+
+if [[ "$FORMAT" == "deb" ]]; then
+  # Test 2: the package should install cleanly
+  # In order to get the package dependencies, we need to first do an install
+  # with dpkg that will fail, then run apt-get to install the dependencies,
+  # and the subsequent dpkg installation should succeed.
+  set +e
+  $SUDO dpkg -i $PACKAGE_PATH > /dev/null 2>&1
+  $SUDO apt-get -f install --yes
+  set -e
+  $SUDO dpkg -i $PACKAGE_PATH
+
+  # Test 3: the package should remove cleanly
+  $SUDO apt-get remove arvados-sso --yes
+
+  # Test 4: the package configuration should remove cleanly
+  $SUDO dpkg --purge arvados-sso
+
+  if [[ -e "/var/www/arvados-sso" ]]; then
+    echo "Error: leftover items under /var/www/arvados-sso."
+    exit 4
+  fi
+
+  # Test 5: the package should remove cleanly with --purge
+  $SUDO dpkg -i $PACKAGE_PATH
+  $SUDO apt-get remove arvados-sso --purge --yes
+
+  if [[ -e "/var/www/arvados-sso" ]]; then
+    echo "Error: leftover items under /var/www/arvados-sso."
+    exit 5
+  fi
+
+elif [[ "$FORMAT" == "rpm" ]]; then
+  # Test 2: the package should install cleanly
+  $SUDO yum -q -y --nogpgcheck localinstall $PACKAGE_PATH
+
+  # Test 3: the package should remove cleanly
+  $SUDO yum -q -y remove arvados-sso
+
+  if [[ -e "/var/www/arvados-sso" ]]; then
+    echo "Error: leftover items under /var/www/arvados-sso."
+    exit 3
+  fi
+
+fi
+
+exit $EXITCODE

commit 170c33818a1ac6a3e35f411d80cf77a008bd6e07
Author: Ward Vandewege <ward at curoverse.com>
Date:   Sun Sep 27 15:29:15 2015 -0400

    Remove bash-ism from arvados-sso-server.postinst.
    
    refs #7330

diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index e6db44c..cc23396 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -108,17 +108,21 @@ EOF
   chmod 644 $SHARED_PATH/log/*
   echo "... done."
 
-  # If we use `grep -q`, rake will write a backtrace on EPIPE.
-  if $COMMAND_PREFIX bundle exec rake db:migrate:status | grep '^database: ' >/dev/null; then
-      echo -n "Running db:migrate ..."
-      $COMMAND_PREFIX bundle exec rake db:migrate || exit $?
-  elif [ 0 -eq ${PIPESTATUS[0]} ]; then
-      # The database exists, but the migrations table doesn't.
-      echo -n "Setting up database ..."
-      $COMMAND_PREFIX bundle exec rake db:schema:load db:seed || exit $?
+  set +e
+  DB_MIGRATE_STATUS=`$COMMAND_PREFIX bundle exec rake db:migrate:status 2>/dev/null`
+  DB_MIGRATE_STATUS_CODE=$?
+  set -e
+
+  if echo $DB_MIGRATE_STATUS | grep 'Schema migrations table does not exist yet.' >/dev/null; then
+    # The database exists, but the migrations table doesn't.
+    echo -n "Setting up database ..."
+    $COMMAND_PREFIX bundle exec rake db:schema:load db:seed || exit $?
+  elif echo $DB_MIGRATE_STATUS | grep '^database: ' >/dev/null; then
+    echo -n "Running db:migrate ..."
+    $COMMAND_PREFIX bundle exec rake db:migrate || exit $?
   else
-      echo "Error: Database is not ready to set up. Aborting." >&2
-      exit 1
+    echo "Error: Database is not ready to set up. Aborting." >&2
+    exit 1
   fi
   echo "... done."
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list