diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-04-22 15:20:50 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-04-22 15:20:50 +0300 |
commit | 37ab98e80409bb8c6fb88cb4ab4f661e53ff7f9c (patch) | |
tree | 48ea3cad9a69a0dd781500bb3aadf819b56da5ed | |
parent | 9e3d232fc23e17a3abec4cc95a36a778073c70d7 (diff) | |
download | ick2-ansible-37ab98e80409bb8c6fb88cb4ab4f661e53ff7f9c.tar.gz |
Add: test-ick
-rwxr-xr-x | test-ick | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/test-ick b/test-ick new file mode 100755 index 0000000..c7b89ec --- /dev/null +++ b/test-ick @@ -0,0 +1,109 @@ +#!/bin/sh +# +# This is a helper script to make it easier for me to test all ick +# compontents together. +# +# This script optionally installs (based on first arg: yes or no) ick +# on a cluster, and then sets up a couple of test projects, and builds +# those. +# +# See the run-cluster.sh file for how the cluster is set up. +# +# The ci-vars.yaml file has the variables for setting up the test +# instance. +# +# See ickdev.yaml for the ick projects that are set up: ick_streatch +# and ick2. If you change the project names, you need to edit this +# file. +# +# This script assume you have icktool installed and configured, and +# that the ick2-ansible repository is checked out at a given location +# (see below). Also the ick rules are checked out (liw-ci repo). Also, +# the cluster hostnames are listed in hosts.ickdev. All of the various +# values work for me. If you'd like to make this more general, that'd +# be fantastic: please submit patches. +# +# Lars Wirzenius + + +set -eu + + +run_ansible="$1" + +ansible="$HOME/code/ick/ick2-ansible" +rules="$HOME/code/ick/liw-ci" +controller="https://ickdev-controller.vm.liw.fi" + +build_status() +{ + icktool -c "$controller" status | awk -v "p=$1" '$1 == p { print $5 }' +} + +current_log() +{ + icktool -c "$controller" status | awk -v "p=$1" '$1 == p { print $7 }' +} + +wait_for_build_to_start() +{ + local project="$1" + local prevlog="$2" + + echo "Waiting for build of $project to start" + while true + do + log="$(current_log "$project")" + [ "$log" != "" ] + [ "$prevlog" != "" ] + if [ "$log" = "$prevlog" ] + then + # Build hasn't started + sleep 5 + continue + fi + break + done + echo "Project $project build has started" +} + +wait_for_build_to_finish() +{ + local project="$1" + + echo "Waiting for build of $project to finish" + while true + do + bs="$(build_status "$project")" + case "$bs" in + OK) echo "Build is finished"; break ;; + building) sleep 5; continue ;; + FAILED*) echo "Build failed: $bs" 1>&2 ; exit 1 ;; + *) echo "Don't understand build status $bs" 1>&2 ; exit 1 ;; + esac + done +} + + +build() +{ + local project="$1" + local log="$(current_log "$project")" + + echo "Triggering $project" + icktool -c "$controller" trigger "$project" + wait_for_build_to_start "$project" "$log" + wait_for_build_to_finish "$project" +} + + +if [ "$run_ansible" = yes ] +then + cd "$ansible" + ./run-cluster.sh hosts.ickdev -e @ci-vars.yml +fi + +icktool -c "$controller" make-it-so < "${rules}/ickdev.yaml" + +build ick_stretch +build ick2 |