diff --git a/scripts/delete-space.sh b/scripts/delete-space.sh index 4038824..546930d 100755 --- a/scripts/delete-space.sh +++ b/scripts/delete-space.sh @@ -1,20 +1,20 @@ -##!/usr/bin/env bash -#set -eux -# -#./cf-space/login -#export SPACE=`cat cf-space/name` -#export DATA=`cf curl "/v2/spaces?q=name%3A${SPACE}&inline-relations-depth=2" | jq '.resources[].entity|{apps:.apps|map(.entity.name), services:.service_instances|map(.entity.name)}'` -# -#for app in `echo $DATA | jq -r '.apps[]'`; do -# cf delete -f $app -#done -# -#for service in `echo $DATA | jq -r '.services[]'`; do -# cf delete-service -f $service -#done -# -#for service in `echo $DATA | jq -r '.services[]'`; do -# cf purge-service-instance -f $service | true -#done -# -#cf delete-space -f $SPACE +#!/usr/bin/env bash +set -eux + +./cf-space/login +export SPACE=`cat cf-space/name` +export DATA=`cf curl "/v2/spaces?q=name%3A${SPACE}&inline-relations-depth=2" | jq '.resources[].entity|{apps:.apps|map(.entity.name), services:.service_instances|map(.entity.name)}'` + +for app in `echo $DATA | jq -r '.apps[]'`; do + cf delete -f $app +done + +for service in `echo $DATA | jq -r '.services[]'`; do + cf delete-service -f $service +done + +for service in `echo $DATA | jq -r '.services[]'`; do + cf purge-service-instance -f $service | true +done + +cf delete-space -f $SPACE diff --git a/scripts/test-app.sh b/scripts/test-app.sh index 50b69e8..6ad9497 100755 --- a/scripts/test-app.sh +++ b/scripts/test-app.sh @@ -1,15 +1,15 @@ -##!/usr/bin/env bash -#set -ex -# -#export URL=`cat cf-push/url` -# -#if [ ! -z "$PRECOND" ]; then -# eval $PRECOND -#fi -# -#if [[ `curl -k https://${URL}${URL_PATH}` == *"${TEXT}"* ]]; then -# echo "Found $TEXT" -#else -# sleep 10 -# exit 1 -#fi +#!/usr/bin/env bash +set -ex + +export URL=`cat cf-push/url` + +if [ ! -z "$PRECOND" ]; then + eval $PRECOND +fi + +if [[ `curl -k https://${URL}${URL_PATH}` == *"${TEXT}"* ]]; then + echo "Found $TEXT" +else + sleep 10 + exit 1 +fi diff --git a/scripts/test-discovery.rb b/scripts/test-discovery.rb index 03a2bfa..b3f398c 100755 --- a/scripts/test-discovery.rb +++ b/scripts/test-discovery.rb @@ -1,24 +1,24 @@ -##!/usr/bin/env ruby -#require 'rubygems' -#require 'net/http' -#require 'json' -#require 'uri' -# -#space = ENV['SPACE'] or raise 'Please specify space' -#uri = URI("http://fortuneui-#{space}.cfapps.pez.pivotal.io/random") -#puts "Check #{uri}" -## => {"id"=>1021, "text"=>"The greatest risk is not taking one."} -#res = Net::HTTP.get_response(uri) -#raise "Received #{res.code}" unless res.is_a?(Net::HTTPSuccess) -#json = JSON.parse(res.body) -# -#json['id'].to_i > 0 or raise "JSON did not return an id" -#json['text'].to_s.length > 0 or raise "JSON did not return text" -# -#system('./cf-space/login') if File.exists?('./cf-space/login') -#system('cf', 'stop', 'fortuneService') -# -#res = Net::HTTP.get_response(uri) -#raise "Expected 500 after stopping service" if res.is_a?(Net::HTTPSuccess) -# -#puts "Success" +#!/usr/bin/env ruby +require 'rubygems' +require 'net/http' +require 'json' +require 'uri' + +space = ENV['SPACE'] or raise 'Please specify space' +uri = URI("http://fortuneui-#{space}.cfapps.pez.pivotal.io/random") +puts "Check #{uri}" +# => {"id"=>1021, "text"=>"The greatest risk is not taking one."} +res = Net::HTTP.get_response(uri) +raise "Received #{res.code}" unless res.is_a?(Net::HTTPSuccess) +json = JSON.parse(res.body) + +json['id'].to_i > 0 or raise "JSON did not return an id" +json['text'].to_s.length > 0 or raise "JSON did not return text" + +system('./cf-space/login') if File.exists?('./cf-space/login') +system('cf', 'stop', 'fortuneService') + +res = Net::HTTP.get_response(uri) +raise "Expected 500 after stopping service" if res.is_a?(Net::HTTPSuccess) + +puts "Success"