diff options
author | Micah Anderson <micah@riseup.net> | 2016-09-20 14:53:03 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2016-09-20 14:53:03 -0400 |
commit | d8596b38c675309cc4f8ea4041127fcfdd612737 (patch) | |
tree | 12c10ca6643c1069bf9ff2bc806a238857686b77 | |
parent | 1a62fd382bac17adbd9dd7272a056fcbaad168fe (diff) |
add first bits of upgrade test script
-rw-r--r-- | Leapfile | 2 | ||||
-rwxr-xr-x | bin/lut.sh | 104 |
2 files changed, 105 insertions, 1 deletions
@@ -1,2 +1,2 @@ -@platform_directory_path = "../../../../tmp/platform_lut" +@platform_directory_path = "/tmp/lut/leap_platform" # see https://leap.se/en/docs/platform/config for more options
\ No newline at end of file diff --git a/bin/lut.sh b/bin/lut.sh new file mode 100755 index 0000000..4a2d436 --- /dev/null +++ b/bin/lut.sh @@ -0,0 +1,104 @@ +#!/bin/sh -x +# This script lives in the lut provider and should be run from there + +provider_dir=`pwd` +platform_git=https://leap.se/git/leap_platform +cli_git=https://leap.se/git/leap_cli +from_version=$1 +to_version=$2 +#workdir=`mktemp -d` +workdir='/tmp/lut' +platform_link="${workdir}/leap_platform" +platform_from=${workdir}/platform_$1 +platform_to=${workdir}/platform_$1 +cli_from=${workdir}/cli_master +cli_to=${workdir}/cli_develop + + +# If you hit control-c or kill the process, stop the VMs +killed () { + + leap vm stop upgrade + echo "VMs stopped, but not removed. Will still incur charges, please remove them if you are not using them anymore." +} + +trap "{ killed ; }" TERM INT ABRT QUIT + +help () { + cat <<EOF +Usage lut <from version> <to version> + +This script will setup leap platform, leap cli, for the versions required and +perform an upgrade test using leap vm credentials stored in cloud.json. + +Note: the cloud.json file is encrypted with git-crypt. You need to decrypt it +first, just do once: apt install git-crypt and then git-crypt unlock. + +EOF +} + +check_version () { + git ls-remote --refs --heads --tags --exit-code $1 $2 + if [ $? -ne 0 ]; then + echo "unknown <version>: $2 for $1, please use a tag from git tag -l, or specify a branch" + cleanup 2 + fi +} + +get_platform () { + echo "Setup platform, version $2" + git clone $1 ${workdir}/platform_${2} --branch $2 + if [ $? -ne 0 ]; then + echo "Setup failed" + cleanup 2 + fi +} + +get_cli () { + cli_dir=${workdir}/cli_$2 + echo "Setup leap_cli" + git clone $cli_git $cli_dir --branch $2 + cd $cli_dir + rake build + bundle --path vendor/bundle +} + +switch () { + rm -f $platform_link + ln -s platform_${1} $platform_link +} + +cleanup () { +# leap vm stop upgrade + #rm -rf $workdir + exit $1 +} + +case "$1" in + -h | -help | --help ) + help + exit + ;; +esac + +if [ $# -ne 2 ]; then + help +else + check_version $platform_git $from_version + check_version $platform_git $to_version + get_platform $platform_git $from_version + get_platform $platform_git $to_version + get_cli $cli_git master + get_cli $cli_git develop + cd $provider_dir + ln -s platform_$from_version $platform_link + +do stuff + + switch $to_version + +do new stuff + + cleanup 0 +fi + |