mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
added mock data for check tests
This commit is contained in:
parent
f8e855a50d
commit
f723f2f7f5
5 changed files with 123 additions and 1 deletions
|
@ -13,6 +13,34 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_check(entity_id, options = {})
|
||||
|
||||
if options[:type] == ""
|
||||
raise Fog::Rackspace::Monitoring::BadRequest
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 201
|
||||
response.body = ""
|
||||
response.headers = {
|
||||
"Date" => Time.now.utc.to_s,
|
||||
"Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/" + entity_id + "/checks/mock_id",
|
||||
"X-Object-ID" => "mock_id",
|
||||
"X-RateLimit-Limit" => "50000",
|
||||
"X-RateLimit-Remaining" => "49627",
|
||||
"X-RateLimit-Window" => "24 hours",
|
||||
"X-RateLimit-Type" => "global",
|
||||
"X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877",
|
||||
"X-LB" => "ord1-maas-prod-api1",
|
||||
"Content-Length" => "0",
|
||||
"Content-Type" => "text/plain",
|
||||
}
|
||||
response.remote_ip = "1.1.1.1"
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,32 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_check(entity_id, check_id)
|
||||
|
||||
if entity_id == -1 || check_id == -1
|
||||
raise Fog::Rackspace::Monitoring::NotFound
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 204
|
||||
response.body = ""
|
||||
response.headers = {
|
||||
"Date" => Time.now.utc.to_s,
|
||||
"X-RateLimit-Limit" => "50000",
|
||||
"X-RateLimit-Remaining" => "49627",
|
||||
"X-RateLimit-Window" => "24 hours",
|
||||
"X-RateLimit-Type" => "global",
|
||||
"X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877",
|
||||
"X-LB" => "ord1-maas-prod-api1",
|
||||
"Content-Length" => "0",
|
||||
"Content-Type" => "text/plain",
|
||||
}
|
||||
response.remote_ip = "1.1.1.1"
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,48 @@ module Fog
|
|||
:path => "entities/#{entity_id}/checks/#{check_id}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_check(entity_id, check_id)
|
||||
|
||||
if entity_id == -1 || check_id == -1
|
||||
raise Fog::Rackspace::Monitoring::NotFound
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"id" => "mock_id",
|
||||
"label" => nil,
|
||||
"type" => "remote.ping",
|
||||
"details" => {"count"=>5},
|
||||
"monitoring_zones_poll" => ["mzord", "mzdfw", "mziad"],
|
||||
"timeout" => 10,
|
||||
"period" => 30,
|
||||
"target_alias" => nil,
|
||||
"target_hostname" => "1.1.1.1",
|
||||
"target_resolver" => "IPv4",
|
||||
"disabled" => false,
|
||||
"metadata" => nil,
|
||||
"created_at" => Time.now.to_i - 1,
|
||||
"updated_at" => Time.now.to_i
|
||||
},
|
||||
response.headers = {
|
||||
"Date" => Time.now.utc.to_s,
|
||||
"Content-Type" => "application/json; charset=UTF-8",
|
||||
"X-RateLimit-Limit" => "50000",
|
||||
"X-RateLimit-Remaining" => "44676",
|
||||
"X-RateLimit-Window" => "24 hours",
|
||||
"X-RateLimit-Type" => "global",
|
||||
"X-Response-Id" => ".rh-QScV.h-ord1-maas-prod-api0.r-uuWnOhLS.c-206541.ts-1377805994157.v-9c40430",
|
||||
"X-LB" => "ord1-maas-prod-api0",
|
||||
"Vary" => "Accept-Encoding",
|
||||
"Transfer-Encoding" => "chunked"
|
||||
}
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,34 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def update_check(entity_id, id, options)
|
||||
|
||||
if options[:testing] == "Bar"
|
||||
raise Fog::Rackspace::Monitoring::NotFound
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 204
|
||||
response.body = ""
|
||||
response.headers = {
|
||||
"Date" => Time.now.utc.to_s,
|
||||
"Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/entities/" + entity_id + "/checks/mock_id",
|
||||
"X-Object-ID" => "mock_id",
|
||||
"X-RateLimit-Limit" => "50000",
|
||||
"X-RateLimit-Remaining" => "49627",
|
||||
"X-RateLimit-Window" => "24 hours",
|
||||
"X-RateLimit-Type" => "global",
|
||||
"X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877",
|
||||
"X-LB" => "ord1-maas-prod-api1",
|
||||
"Content-Length" => "0",
|
||||
"Content-Type" => "text/plain",
|
||||
}
|
||||
response.remote_ip = "1.1.1.1"
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Shindo.tests('Fog::Rackspace::Monitoring | check_tests', ['rackspace', 'rackspace_monitoring']) do
|
||||
pending if Fog.mocking?
|
||||
|
||||
account = Fog::Rackspace::Monitoring.new
|
||||
entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]
|
||||
|
|
Loading…
Add table
Reference in a new issue