Test that UI fails after other service is stopped [#128524555]

Signed-off-by: Dave Goddard <dave@goddard.id.au>
This commit is contained in:
Keaty Gross 2016-09-29 15:13:08 -04:00 коммит произвёл Dave Goddard
Родитель 1bf170896f
Коммит 11d715da64
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -2,15 +2,23 @@
require 'rubygems'
require 'net/http'
require 'json'
require 'uri'
space = ENV['SPACE'] or raise 'Please specify space'
puts "Check http://fortuneui-#{space}.pcfdev.shoetree.io/random"
uri = URI("http://fortuneui-#{space}.pcfdev.shoetree.io/random")
puts "Check #{uri}"
# => {"id"=>1021, "text"=>"The greatest risk is not taking one."}
body Net::HTTP.get("fortuneui-#{space}.pcfdev.shoetree.io", '/random')
json = JSON.parse(body)
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"