1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge branch 'monitoring_mock' of https://github.com/rackops/fog into monitoring_mock

This commit is contained in:
Ryan Richard 2013-08-30 11:54:27 -05:00
commit 0da5e75431
4 changed files with 185 additions and 4 deletions

View file

@ -10,7 +10,79 @@ module Fog
:path => "check_types"
)
end
end
class Mock
def list_check_types
response = Excon::Response.new
response.status = 200
response.body = {
"values" => [
{
"type" => "remote",
"id" => "remote.dns",
"channel"=> "stable",
"fields" => [
{
"name" => "port",
"description"=> "Port number (default: 53)",
"optional" => true
},
{
"name" => "query",
"description"=> "DNS Query",
"optional" => false
},
{
"name" => "record_type",
"description" => "DNS Record Type",
"optional" => false
}
],
"category" => "remote"
},
{
"type" => "agent",
"id" => "agent.memory",
"channel" =>"stable",
"fields" => [],
"supported_platforms" => [
"Linux",
"Windows"
],
"category" => "agent_system"
}
],
"metadata" => {
"count" => 2,
"limit" => 100,
"marker" => nil,
"next_marker" => nil,
"next_href" => nil
}
}
response.headers = {
"Date" => Time.now.utc.to_s,
"Content-Type" => "application/json; charset=UTF-8",
"X-RateLimit-Limit" => "50000",
"X-RateLimit-Remaining" => "49627",
"X-RateLimit-Window" => "24 hours",
"X-RateLimit-Type" => "global",
"X-Response-Id" =>" zsdvasdtrq345",
"X-LB" => "dfw1-maas-prod-api0",
"Vary" => "Accept-Encoding",
"Transfer-Encoding" => "chunked"
}
response.remote_ip = "1.1.1.1"
response
end
end
end
end

View file

@ -10,7 +10,54 @@ module Fog
:path => "entities/#{entity_id}/checks"
)
end
end
class Mock
def list_checks(entity_id)
response = Excon::Response.new
response.status = 200
response.body = {
"values" => [
{
"id" => "mock_id",
"label" => "load",
"type" => "agent.load_average",
"details" => {},
"monitoring_zones_poll" => nil,
"timeout" => 10,
"period" => 30,
"target_alias" => nil,
"target_hostname" => nil,
"target_resolver" => nil,
"disabled" => false,
"metadata" => nil,
"created_at" => Time.now.to_i - 1,
"updated_at" => Time.now.to_i
}
],
"metadata" => {
"count" => 1,
"limit" => 100,
"marker" => nil,
"next_marker" => nil,
"next_href" => nil
}
}
response.headers = {
"Date" => Time.now.utc.to_s,
"Content-Type" => "application/json; charset=UTF-8",
"X-RateLimit-Limit" => "50000",
"X-RateLimit-Remaining" => "49627",
"X-RateLimit-Window" => "24 hours",
"X-RateLimit-Type" => "global",
"X-Response-Id" =>" j23jlk234jl2j34j",
"X-LB" => "dfw1-maas-prod-api0",
"Vary" => "Accept-Encoding",
"Transfer-Encoding" => "chunked"
}
response.remote_ip = "1.1.1.1"
response
end
end
end
end

View file

@ -10,8 +10,73 @@ module Fog
:path => "entities/#{entity_id}/checks/#{check_id}/metrics"
)
end
end
class Mock
def list_metrics(entity_id, check_id)
response = Excon::Response.new
response.status = 200
response.body = {
"values" => [
{
"name" => "idle_percent_average",
"unit" => "percent"
},
{ "name" => "irq_percent_average",
"unit" => "percent"
},
{ "name" => "max_cpu_usage",
"unit" => "percent"
},
{ "name" => "min_cpu_usage",
"unit" => "percent"
},
{ "name" => "stolen_percent_average",
"unit" => "percent"
},
{ "name" => "sys_percent_average",
"unit" => "percent"
},
{
"name" => "usage_average",
"unit" => "percent"
},
{ "name" => "user_percent_average",
"unit" => "percent"
},
{ "name" => "wait_percent_average",
"unit" => "percent"
}
],
"metadata" => {
"count" => 9,
"limit" => nil,
"marker" => nil,
"next_marker" => nil,
"next_href" => nil
}
}
response.headers = {
"Date" => Time.now.utc.to_s,
"Content-Type" => "application/json; charset=UTF-8",
"X-RateLimit-Limit" => "50000",
"X-RateLimit-Remaining" => "49627",
"X-RateLimit-Window" => "24 hours",
"X-RateLimit-Type" => "global",
"X-Response-Id" =>" zsdvasdtrq345",
"X-LB" => "dfw1-maas-prod-api0",
"Vary" => "Accept-Encoding",
"Transfer-Encoding" => "chunked"
}
response.remote_ip = "1.1.1.1"
response
end
end
end
end
end

View file

@ -16,18 +16,15 @@ Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspace_
tests('success') do
tests('#get list of checks').formats(LIST_HEADERS_FORMAT) do
pending if Fog.mocking?
account.list_checks(entity_id).data[:headers]
end
tests('#get list of check types').formats(LIST_HEADERS_FORMAT) do
pending if Fog.mocking?
account.list_check_types().data[:headers]
end
tests('#get list of entities').formats(LIST_HEADERS_FORMAT) do
account.list_entities().data[:headers]
end
tests('#get list of metrics').formats(LIST_HEADERS_FORMAT) do
pending if Fog.mocking?
account.list_metrics(entity_id,check_id).data[:headers]
end
tests('#get overview list').formats(LIST_HEADERS_FORMAT) do