[ARVADOS] created: 4a49d13b30772fc50b610af2c5dd85ba089e331a

Git user git at public.curoverse.com
Fri Jun 3 16:43:47 EDT 2016


        at  4a49d13b30772fc50b610af2c5dd85ba089e331a (commit)


commit 4a49d13b30772fc50b610af2c5dd85ba089e331a
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Jun 3 15:34:25 2016 -0400

    9345: Use same script to test all Rails packages.
    
    We want to simplify the SSO test script for a variety of reasons.  We
    don't want the package to depend on the PostgreSQL server; testing
    proper PostgreSQL server configuration is a little out of scope for
    this; and it's difficult to execute the test in a CentOS 7 Docker
    image.  This commit has the SSO server follow the same test strategy
    as other Rails servers.

diff --git a/build/package-testing/test-package-arvados-api-server.sh b/build/package-testing/common-test-rails-server-package.sh
similarity index 50%
copy from build/package-testing/test-package-arvados-api-server.sh
copy to build/package-testing/common-test-rails-server-package.sh
index 66d5969..25a2f2f 100755
--- a/build/package-testing/test-package-arvados-api-server.sh
+++ b/build/package-testing/common-test-rails-server-package.sh
@@ -1,15 +1,24 @@
 #!/bin/sh
+
 set -e
-cd /var/www/arvados-api/current/
+
+if [ 0 = "$#" ]; then
+    PACKAGE_NAME="$(basename "$0" | grep -Eo '\barvados.*$')"
+    PACKAGE_NAME=${PACKAGE_NAME%.sh}
+else
+    PACKAGE_NAME=$1; shift
+fi
+
+cd "/var/www/${PACKAGE_NAME%-server}/current"
 
 case "$TARGET" in
     debian*|ubuntu*)
         apt-get install -y nginx
-        dpkg-reconfigure arvados-api-server
+        dpkg-reconfigure "$PACKAGE_NAME"
         ;;
     centos*)
         yum install --assumeyes httpd
-        yum reinstall --assumeyes arvados-api-server
+        yum reinstall --assumeyes "$PACKAGE_NAME"
         ;;
     *)
         echo -e "$0: Unknown target '$TARGET'.\n" >&2
@@ -17,4 +26,4 @@ case "$TARGET" in
         ;;
 esac
 
-/usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-api-server.gems"
+/usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/$PACKAGE_NAME.gems"
diff --git a/build/package-testing/test-package-arvados-api-server.sh b/build/package-testing/test-package-arvados-api-server.sh
deleted file mode 100755
index 66d5969..0000000
--- a/build/package-testing/test-package-arvados-api-server.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-cd /var/www/arvados-api/current/
-
-case "$TARGET" in
-    debian*|ubuntu*)
-        apt-get install -y nginx
-        dpkg-reconfigure arvados-api-server
-        ;;
-    centos*)
-        yum install --assumeyes httpd
-        yum reinstall --assumeyes arvados-api-server
-        ;;
-    *)
-        echo -e "$0: Unknown target '$TARGET'.\n" >&2
-        exit 1
-        ;;
-esac
-
-/usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-api-server.gems"
diff --git a/build/package-testing/test-package-arvados-api-server.sh b/build/package-testing/test-package-arvados-api-server.sh
new file mode 120000
index 0000000..8bc03bc
--- /dev/null
+++ b/build/package-testing/test-package-arvados-api-server.sh
@@ -0,0 +1 @@
+common-test-rails-server-package.sh
\ No newline at end of file
diff --git a/build/package-testing/test-package-arvados-sso-server.sh b/build/package-testing/test-package-arvados-sso-server.sh
deleted file mode 100755
index ab0b225..0000000
--- a/build/package-testing/test-package-arvados-sso-server.sh
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/bin/bash
-
-set -e
-
-EXITCODE=0
-DEBUG=${ARVADOS_DEBUG:-0}
-
-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
-    debian*|ubuntu*)
-        FORMAT=deb
-        ;;
-    centos*)
-        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
-
-title () {
-    txt="********** $1 **********"
-    printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
-}
-
-checkexit() {
-    if [[ "$1" != "0" ]]; then
-        title "!!!!!! $2 FAILED !!!!!!"
-    fi
-}
-
-
-# Find the SSO server package
-
-cd "$WORKSPACE"
-
-if [[ ! -d "/var/www/arvados-sso" ]]; then
-  echo "/var/www/arvados-sso should exist"
-  exit 1
-fi
-
-if [[ ! -e "/etc/arvados/sso/application.yml" ]]; then
-    mkdir -p /etc/arvados/sso/
-    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
-  # We need to set up our database configuration now.
-  if [[ "$FORMAT" == "rpm" ]]; then
-    service postgresql initdb
-    sed -i -e "s/127.0.0.1\/32          ident/127.0.0.1\/32          md5/" /var/lib/pgsql/data/pg_hba.conf
-    sed -i -e "s/::1\/128               ident/::1\/128               md5/" /var/lib/pgsql/data/pg_hba.conf
-  fi
-  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
-
-  su postgres -c "psql -c \"CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'\""
-  su postgres -c "createdb sso_provider_production -O sso_provider_user"
-fi
-
-if [[ "$FORMAT" == "deb" ]]; then
-  # Test 2: the package should reconfigure cleanly
-  dpkg-reconfigure arvados-sso-server || EXITCODE=3
-
-  cd /var/www/arvados-sso/current/
-  /usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-sso-server.gems"
-
-  # Test 3: the package should remove cleanly
-  apt-get remove arvados-sso-server --yes || EXITCODE=3
-
-  checkexit $EXITCODE "apt-get remove arvados-sso-server --yes"
-
-  # Test 4: the package configuration should remove cleanly
-  dpkg --purge arvados-sso-server || EXITCODE=4
-
-  checkexit $EXITCODE "dpkg --purge arvados-sso-server"
-
-  if [[ -e "/var/www/arvados-sso" ]]; then
-    EXITCODE=4
-  fi
-
-  checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
-
-  # Test 5: the package should remove cleanly with --purge
-
-  apt-get remove arvados-sso-server --purge --yes || EXITCODE=5
-
-  checkexit $EXITCODE "apt-get remove arvados-sso-server --purge --yes"
-
-  if [[ -e "/var/www/arvados-sso" ]]; then
-    EXITCODE=5
-  fi
-
-  checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
-
-elif [[ "$FORMAT" == "rpm" ]]; then
-
-  # Set up Nginx first
-  # (courtesy of https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/el6/install_passenger.html)
-  yum install -q -y epel-release pygpgme curl
-  curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
-  yum install -q -y nginx passenger
-  sed -i -e 's/^# passenger/passenger/' /etc/nginx/conf.d/passenger.conf
-  # Done setting up Nginx
-
-  # Test 2: the package should reinstall cleanly
-  yum --assumeyes reinstall arvados-sso-server || EXITCODE=3
-
-  cd /var/www/arvados-sso/current/
-  /usr/local/rvm/bin/rvm-exec default bundle list >$ARV_PACKAGES_DIR/arvados-sso-server.gems
-
-  # Test 3: the package should remove cleanly
-  yum -q -y remove arvados-sso-server || EXITCODE=3
-
-  checkexit $EXITCODE "yum -q -y remove arvados-sso-server"
-
-  if [[ -e "/var/www/arvados-sso" ]]; then
-    EXITCODE=3
-  fi
-
-  checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
-
-fi
-
-if [[ "$EXITCODE" == "0" ]]; then
-  echo "Testing complete, no errors!"
-else
-  echo "Errors while testing!"
-fi
-
-exit $EXITCODE
diff --git a/build/package-testing/test-package-arvados-sso-server.sh b/build/package-testing/test-package-arvados-sso-server.sh
new file mode 120000
index 0000000..8bc03bc
--- /dev/null
+++ b/build/package-testing/test-package-arvados-sso-server.sh
@@ -0,0 +1 @@
+common-test-rails-server-package.sh
\ No newline at end of file
diff --git a/build/package-testing/test-package-arvados-workbench.sh b/build/package-testing/test-package-arvados-workbench.sh
deleted file mode 100755
index 5deb1a0..0000000
--- a/build/package-testing/test-package-arvados-workbench.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-cd /var/www/arvados-workbench/current/
-
-case "$TARGET" in
-    debian*|ubuntu*)
-        apt-get install -y nginx
-        dpkg-reconfigure arvados-workbench
-        ;;
-    centos*)
-        yum install --assumeyes httpd
-        yum reinstall --assumeyes arvados-workbench
-        ;;
-    *)
-        echo -e "$0: Unknown target '$TARGET'.\n" >&2
-        exit 1
-        ;;
-esac
-
-/usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-workbench.gems"
diff --git a/build/package-testing/test-package-arvados-workbench.sh b/build/package-testing/test-package-arvados-workbench.sh
new file mode 120000
index 0000000..8bc03bc
--- /dev/null
+++ b/build/package-testing/test-package-arvados-workbench.sh
@@ -0,0 +1 @@
+common-test-rails-server-package.sh
\ No newline at end of file

commit 655fc52edc76d208b1b07648d126e15330415524
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Jun 3 14:50:59 2016 -0400

    9309: Add systemd support to Rails package scripts.

diff --git a/build/rails-package-scripts/postinst.sh b/build/rails-package-scripts/postinst.sh
index 6fac26b..884c96d 100644
--- a/build/rails-package-scripts/postinst.sh
+++ b/build/rails-package-scripts/postinst.sh
@@ -141,9 +141,22 @@ prepare_database() {
   fi
 }
 
+find_web_service_and_manager() {
+    # Sets WEB_SERVICE, and echoes the service manager for it.
+    if [ -n "$WEB_SERVICE" ]; then
+        guess_service_manager
+    elif WEB_SERVICE=$(list_services_systemd | grep -E '^(nginx|httpd)'); then
+        echo systemd
+    elif WEB_SERVICE=$(list_services_service \
+                           | grep -Eo '\b(nginx|httpd)[^[:space:]]*'); then
+        echo service
+    else
+        return $?
+    fi
+}
+
 configure_version() {
-  WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
-      | grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
+  local service_manager="$(find_web_service_and_manager || true)"
   if [ -z "$WEB_SERVICE" ]; then
     report_web_service_warning "Web service (Nginx or Apache) not found"
   elif [ "$WEB_SERVICE" != "$(echo "$WEB_SERVICE" | head -n 1)" ]; then
@@ -234,8 +247,8 @@ configure_version() {
 
   setup_before_nginx_restart
 
-  if [ ! -z "$WEB_SERVICE" ]; then
-      service "$WEB_SERVICE" restart
+  if [ -n "$service_manager" ]; then
+      service_command "$service_manager" restart "$WEB_SERVICE"
   fi
 }
 
diff --git a/build/rails-package-scripts/step2.sh b/build/rails-package-scripts/step2.sh
index 816b906..98de494 100644
--- a/build/rails-package-scripts/step2.sh
+++ b/build/rails-package-scripts/step2.sh
@@ -26,3 +26,53 @@ fi
 if ! type setup_before_nginx_restart >/dev/null 2>&1; then
     setup_before_nginx_restart() { return; }
 fi
+
+if [ -e /run/systemd/system ]; then
+    USING_SYSTEMD=1
+else
+    USING_SYSTEMD=0
+fi
+
+if which service >/dev/null 2>&1; then
+    USING_SERVICE=1
+else
+    USING_SERVICE=0
+fi
+
+guess_service_manager() {
+    if [ 1 = "$USING_SYSTEMD" ]; then
+        echo systemd
+    elif [ 1 = "$USING_SERVICE" ]; then
+        echo service
+    else
+        return 1
+    fi
+}
+
+list_services_systemd() {
+    test 1 = "$USING_SYSTEMD" || return
+    # Print only service names, without the `.service` suffix.
+    systemctl list-unit-files '*.service' \
+        | awk '($1 ~ /\.service/){print substr($1, 1, length($1) - 8)}'
+}
+
+list_services_service() {
+    test 1 = "$USING_SERVICE" || return
+    # Output is completely different across Debian and Red Hat.
+    # We can't really parse it.
+    service --status-all 2>/dev/null
+}
+
+service_command() {
+    local service_manager="$1"; shift
+    local command="$1"; shift
+    local service="$1"; shift
+    case "$service_manager" in
+        systemd) systemctl "$command" "$service" ;;
+        service) service "$service" "$command" ;;
+    esac
+}
+
+if ! guess_service_manager >/dev/null; then
+    echo "WARNING: Unsupported init system. Can't manage web service." >&2
+fi

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list