Skip to content

Commit

Permalink
Merge pull request #173 from jpwhite4/xdmodsetup
Browse files Browse the repository at this point in the history
Add support for testing fresh install as well as upgrade.
  • Loading branch information
jpwhite4 authored Jun 28, 2017
2 parents d9c777c + d4564c0 commit 5594794
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 6 deletions.
35 changes: 35 additions & 0 deletions open_xdmod/modules/xdmod/integration_tests/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Bootstrap script that either sets up a fresh XDMoD test instance or upgrades
# an existing one. This code is only designed to work inside the XDMoD test
# docker instances. However, since it is designed to test a real install, the
# set of commands that are run would work on a real production system.

BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REF_DIR=/root/assets/referencedata

set -e
set -o pipefail

if [ "$XDMOD_TEST_MODE" = "fresh_install" ];
then
rpm -qa | grep ^xdmod | xargs yum -y remove
rm -rf /etc/xdmod
rm -rf /var/lib/mysql
yum -y localinstall ~/rpmbuild/RPMS/*/*.rpm
~/bin/services start
expect $BASEDIR/xdmod-setup.tcl | col -b
for resource in $REF_DIR/*.log; do
xdmod-shredder -r `basename $resource .log` -f slurm -i $resource;
done
xdmod-ingestor
xdmod-import-csv -t names -i $REF_DIR/names.csv
xdmod-ingestor
php /root/bin/createusers.php
fi

if [ "$XDMOD_TEST_MODE" = "upgrade" ];
then
rpm -Uvh ~/rpmbuild/RPMS/*/*.rpm
~/bin/services start
xdmod-upgrade --batch-mode | col -b
fi
130 changes: 130 additions & 0 deletions open_xdmod/modules/xdmod/integration_tests/scripts/xdmod-setup.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env expect
# Expect script that run s xdmod-setup to configure a freshly installed
# XDMoD instance. This script will fail if run against an already installed
# XDMoD.

#-------------------------------------------------------------------------------
# Configuration settings for the XDMoD resources
set resources [list]
lappend resources [list frearson Frearson 400 4000]
lappend resources [list mortorq Mortorq 400 4000]
lappend resources [list phillips Phillips 400 4000]
lappend resources [list pozidriv Posidriv 400 4000]
lappend resources [list robertson Robertson 400 4000]

#-------------------------------------------------------------------------------
# Helper functions

proc selectMenuOption { option } {

expect {
-re "\nSelect an option .*: "
}
send $option\n
}

proc answerQuestion { question response } {
expect {
timeout { send_user "\nFailed to get prompt\n"; exit 1 }
-re "\n$question: \\\[.*\\\] "
}
send $response\n
}

proc provideInput { prompt response } {
expect {
timeout { send_user "\nFailed to get prompt\n"; exit 1 }
"\n$prompt "
}
send $response\n
}

proc providePassword { prompt password } {
provideInput $prompt $password
provideInput "(confirm) $prompt" $password

}

proc enterToContinue { } {
expect {
timeout { send_user "\nFailed to get prompt\n"; exit 1 }
"\nPress ENTER to continue. "
}
send \n
}

proc confirmFileWrite { response } {
expect {
timeout { send_user "\nFailed to get prompt\n"; exit 1 }
-re "\nOverwrite config file .*\\\[.*\\\] "
}
send $response\n
}

#-------------------------------------------------------------------------------
# main body - note there are some hardcoded addresses, usernames and passwords here
# they should typically not be changed as they need to match up with the
# settings in the docker container

set timeout 10
spawn "xdmod-setup"

selectMenuOption 1
answerQuestion {Site Address} http://localhost:8080/
provideInput {Email Address:} ccr-xdmod-help@buffalo.edu
answerQuestion {Java Path} /usr/bin/java
answerQuestion {Javac Path} /usr/bin/javac
provideInput {PhantomJS Path:} /usr/local/bin/phantomjs
provideInput {Center Logo Path:} {}
confirmFileWrite yes
enterToContinue

selectMenuOption 2
answerQuestion {DB Hostname or IP} localhost
answerQuestion {DB Port} 3306
answerQuestion {DB Username} xdmod
providePassword {DB Password:} xdmod123
answerQuestion {DB Admin Username} root
providePassword {DB Admin Password:} {}
confirmFileWrite yes
enterToContinue

selectMenuOption 3
provideInput {Organization Name:} Screwdriver
provideInput {Organization Abbreviation:} screw
confirmFileWrite yes
enterToContinue

selectMenuOption 4
foreach resource $resources {
selectMenuOption 1
provideInput {Resource Name:} [lindex $resource 0]
provideInput {Formal Name:} [lindex $resource 1]
provideInput {How many nodes does this resource have?} [lindex $resource 2]
provideInput {How many total processors (cpu cores) does this resource have?} [lindex $resource 3]
}
selectMenuOption s
confirmFileWrite yes
enterToContinue
confirmFileWrite yes
enterToContinue

selectMenuOption 5
provideInput {Username:} admin
providePassword {Password:} admin
provideInput {First name:} Admin
provideInput {Last name:} User
provideInput {Email address:} admin@localhost
enterToContinue

selectMenuOption 6
answerQuestion {Top Level Name} {Decanal Unit}
provideInput {Top Level Description:} {Decanal Unit}
answerQuestion {Middle Level Name} {Department}
provideInput {Middle Level Description:} {Department}
answerQuestion {Bottom Level Name} {PI Group}
provideInput {Bottom Level Description:} {PI Group}
confirmFileWrite yes
enterToContinue

selectMenuOption q
13 changes: 7 additions & 6 deletions shippable.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
language: none
env:
- XDMOD_TEST_MODE=fresh_install
- XDMOD_TEST_MODE=upgrade
build:
cache: true
cache_dir_list:
- /root/.composer
pre_ci_boot:
image_name: tas-tools-ext-01.ccr.xdmod.org/centos7-xdmod6.6.0
image_tag: version3
image_tag: version4
pull: true
options: "--user root -e HOME=/root"
ci:
- composer install
- composer install --no-progress
- ~/bin/buildrpm xdmod
- rpm -Uvh --oldpackage ~/rpmbuild/RPMS/*/*.rpm
- ~/bin/services start
- xdmod-upgrade --batch-mode | col -bx
- ./open_xdmod/modules/xdmod/integration_tests/scripts/bootstrap.sh
- composer install --no-progress
- cp ~/assets/secrets open_xdmod/modules/xdmod/integration_tests/.secrets
- composer --dev install
- ./open_xdmod/modules/xdmod/integration_tests/runtests.sh --log-junit `pwd`/shippable/testresults/results.xml

0 comments on commit 5594794

Please sign in to comment.