Skip to content
Browse files

include staging log in failed app starts

[finishes #47566635]
  • Loading branch information...
1 parent 8d879d0 commit f14855d8c8580454bf11072e2f7c4d2163d196fd Alex Suraci and Mark Rushakoff committed
Showing with 23 additions and 16 deletions.
  1. +1 −1 Gemfile.lock
  2. +18 −3 lib/harness/app.rb
  3. +4 −12 spec/apps/async_staging_spec.rb
View
2 Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/cloudfoundry/cfoundry.git
- revision: 87c192a714fd6b21bb7bceade789424a9bf779e1
+ revision: 7658f56e45f606093787b058a5a5a37b68b25051
submodules: true
specs:
cfoundry (0.6.1.rc3)
View
21 lib/harness/app.rb
@@ -85,7 +85,7 @@ def stop
end
end
- def start(need_check = true, async = false, &blk)
+ def start(need_check = true, &blk)
unless @app.exists?
@log.error "Application: #{@app.name} does not exist!"
raise RuntimeError, "Application: #{@app.name} does not exist!"
@@ -96,9 +96,18 @@ def start(need_check = true, async = false, &blk)
timeout_retries_remaining = 5
begin
+ log = ""
+
@app.start!(true) do |url|
puts "Pushing #{@app.name} - #{url}"
- blk.call(url) if blk
+
+ if blk
+ blk.call(url)
+ elsif url
+ @app.stream_update_log(log_url) do |chunk|
+ log << chunk
+ end
+ end
end
# When ccng/dea_ng are overloaded app staging will result
@@ -106,15 +115,17 @@ def start(need_check = true, async = false, &blk)
# tests resilient to such failure; however, we want to
# report such failures at the end.
rescue CFoundry::Timeout => e
+ @log.error("Timed out: #{e}")
timeout_retries_remaining -= 1
timeout_retries_remaining > 0 ? retry : raise
rescue Exception => e
# Use e.inspect to capture both message and error class
- msg = <<-MSG
+ msg = <<-MSG.gsub(/^\s+/, "")
Start App: #{@app.name} failed.
#{e.inspect}
#{@session.print_client_logs}
+ #{log}
MSG
@log.error(msg)
raise RuntimeError, msg
@@ -632,6 +643,10 @@ def upload_app(app, path)
end
end
+ # TODO: maybe App#stream_update_log really just belongs on client
+ def stream_log(url, &blk)
+ @app.stream_update_log(url, &blk)
+ end
end
class RestResult
View
16 spec/apps/async_staging_spec.rb
@@ -22,25 +22,17 @@ def step(name)
app.manifest["no_start"] = true
app.create_app("standalone_ruby_app#{rand(65046056)}", app.manifest["path"], nil, false)
- app.start(false, true) do |url|
+ app.start(!:need_check) do |url|
staging_log_url = url
end
end
step "tail staging log" do
- tail_uri = URI.parse(staging_log_url + "&tail_offset=0&tail")
+ tail_uri = staging_log_url + "&tail_offset=0&tail"
tailed_log = ""
- begin
- Net::HTTP.start(tail_uri.host, tail_uri.port) do |http|
- req = Net::HTTP::Get.new(tail_uri.request_uri)
- req["Authorization"] = @session.token.auth_header
-
- http.request(req) do |response|
- response.read_body { |chunk| tailed_log << chunk }
- end
- end
- rescue Timeout::Error
+ app.stream_log(tail_uri) do |chunk|
+ tailed_log << chunk
end
tailed_log.should match /Using Ruby/

0 comments on commit f14855d

Please sign in to comment.
Something went wrong with that request. Please try again.