From 70463aa7a2ea9804a3672398b2e5733dd2e97c69 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Fri, 7 Dec 2012 13:45:00 +0000 Subject: [PATCH] Initialise config file on selfupdate. --- src/main/resources/scripts/selfupdate.sh | 8 ++++++- src/test/cucumber/gvm/upgrade.feature | 14 +++++++++++- src/test/resources/gvm/env.groovy | 3 ++- src/test/resources/gvm/upgrade_steps.groovy | 24 ++++++++++++++++++++- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/main/resources/scripts/selfupdate.sh b/src/main/resources/scripts/selfupdate.sh index e0698247..9d7a08d6 100755 --- a/src/main/resources/scripts/selfupdate.sh +++ b/src/main/resources/scripts/selfupdate.sh @@ -20,14 +20,20 @@ echo "Updating gvm scripts..." TMP_ZIP="/tmp/res.zip" PLATFORM=$(uname) -GVM_DIR="$HOME/.gvm" mkdir -p "${GVM_DIR}/ext" +mkdir -p "${GVM_DIR}/etc" mkdir -p "${GVM_DIR}/groovy" mkdir -p "${GVM_DIR}/groovy" mkdir -p "${GVM_DIR}/grails" mkdir -p "${GVM_DIR}/griffon" mkdir -p "${GVM_DIR}/vert.x" + +CONFIG_FILE="${GVM_DIR}/etc/config" +if [[ ! -f "${CONFIG_FILE}" ]]; then + echo "isolated_mode=0" > "${CONFIG_FILE}" +fi + BIN_FOLDER="${GVM_DIR}/bin" mkdir -p "${BIN_FOLDER}" curl -s "${GVM_SERVICE}/res?platform=${PLATFORM}" > "${TMP_ZIP}" diff --git a/src/test/cucumber/gvm/upgrade.feature b/src/test/cucumber/gvm/upgrade.feature index 30f4e0bb..cdffe63c 100644 --- a/src/test/cucumber/gvm/upgrade.feature +++ b/src/test/cucumber/gvm/upgrade.feature @@ -1,6 +1,5 @@ Feature: Upgrade - @manual Scenario: Upgrade an outdated installation Given an initialised system When I enter "gvm selfupdate" @@ -8,3 +7,16 @@ Feature: Upgrade Then I see "Successfully upgraded GVM." Then the gvm scripts are up to date + Scenario: Upgrade an installation without configuration + Given an initialised system + And the configuration file has not been primed + When I enter "gvm selfupdate" + Then the configuration file is present + And the configuration file contains "isolated_mode=0" + + Scenario: Upgrade an installation with configuration + Given an initialised system + And the configuration file has been primed + When I enter "gvm selfupdate" + Then the configuration file is present + And the configuration file contains "isolated_mode=1" diff --git a/src/test/resources/gvm/env.groovy b/src/test/resources/gvm/env.groovy index e18c03b5..6a4342cb 100644 --- a/src/test/resources/gvm/env.groovy +++ b/src/test/resources/gvm/env.groovy @@ -2,7 +2,6 @@ package gvm import static cucumber.runtime.groovy.Hooks.* import static gvm.VertxUtils.* -import gvm.BashEnv baseDir = new File("build/scripts") @@ -12,6 +11,7 @@ serviceUrlEnv = "http://localhost:8080" gvmDir = new File("${gvmDirEnv}") binDir = new File("${gvmDirEnv}/bin") varDir = new File("${gvmDirEnv}/var") +envDir = new File("${gvmDirEnv}/etc") broadcastFile = new File("${gvmDirEnv}/var/broadcast") server = null @@ -22,6 +22,7 @@ Before(){ server = startServer() binDir.mkdirs() varDir.mkdirs() + envDir.mkdirs() // Copy the scripts into the gvm bin directory. for (f in baseDir.listFiles()) { diff --git a/src/test/resources/gvm/upgrade_steps.groovy b/src/test/resources/gvm/upgrade_steps.groovy index bf125a69..f8fe9753 100644 --- a/src/test/resources/gvm/upgrade_steps.groovy +++ b/src/test/resources/gvm/upgrade_steps.groovy @@ -1,6 +1,6 @@ package gvm -import static cucumber.runtime.groovy.EN.Then +import static cucumber.runtime.groovy.EN.* Then(~'^the gvm scripts are up to date$') { -> def gvm = new File("$gvmDir/bin/gvm") @@ -9,3 +9,25 @@ Then(~'^the gvm scripts are up to date$') { -> def gvmInit = new File("$gvmDir/bin/gvm-init.sh") assert gvmInit.exists() } + +And(~'^the configuration file has been primed$') { -> + def configFile = "$gvmDir/etc/config" as File + configFile << "isolated_mode=1" +} + +And(~'^the configuration file has not been primed$') { -> + def configFile = "$gvmDir/etc/config" as File + if (configFile.exists()) { + configFile.delete() + } +} + +Then(~'^the configuration file is present$') { -> + def configFile = "$gvmDir/etc/config" as File + assert configFile.exists() +} + +And(~'^the configuration file contains "([^"]*)"$') { String content -> + def configFile = "$gvmDir/etc/config" as File + assert configFile.text.contains(content) +}