Skip to content

Commit 57be3a0

Browse files
committed
add health to app summary
Change-Id: Ifeb0a784b6afb0ae2d836ec3e05640693fbe4662
1 parent daeb231 commit 57be3a0

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎lib/cloud_controller/api/app_summary.rb‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ module VCAP::CloudController
1616

1717
def summary(id)
1818
app = find_id_and_validate_access(:read, id)
19-
20-
Yajl::Encoder.encode(
19+
app_info = {
2120
:guid => app.guid,
2221
:name => app.name,
2322
:urls => app.routes.map(&:fqdn),
2423
:framework => app.framework.to_hash.merge(:guid => app.framework.guid),
2524
:runtime => app.runtime.to_hash.merge(:guid => app.runtime.guid),
25+
:running_instances => app.running_instances,
2626
:services => app.service_instances.map do |instance|
2727
{
2828
:guid => instance.guid,
@@ -33,8 +33,10 @@ def summary(id)
3333
:plan_guid => instance.service_plan.guid,
3434
:plan_name => instance.service_plan.name,
3535
}
36-
end,
37-
)
36+
end
37+
}.merge(app.to_hash)
38+
39+
Yajl::Encoder.encode(app_info)
3840
end
3941

4042
get "#{path_id}/summary", :summary

‎spec/api/app_summary_spec.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ module VCAP::CloudController
3737
end
3838

3939
describe "GET /v2/apps/:id/summary" do
40-
before :all do
40+
before do
41+
HealthManagerClient.should_receive(:healthy_instances).
42+
and_return(@app.instances)
4143
get "/v2/apps/#{@app.guid}/summary", {}, admin_headers
4244
end
4345

@@ -67,6 +69,16 @@ module VCAP::CloudController
6769
decoded_response["runtime"]["name"].should == @app.runtime.name
6870
end
6971

72+
it "should contain the running instances" do
73+
decoded_response["running_instances"].should == @app.instances
74+
end
75+
76+
it "should contain the basic app attributes" do
77+
@app.to_hash.each do |k, v|
78+
decoded_response[k.to_s].should == v
79+
end
80+
end
81+
7082
it "should return num_services services" do
7183
decoded_response["services"].size.should == num_services
7284
end

0 commit comments

Comments
 (0)