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

Consolidated list tests, added alarm tests.

This commit is contained in:
Daniel Reichert 2013-07-17 14:45:43 -07:00
parent 9be77750cc
commit ff1a04eaab
6 changed files with 94 additions and 62 deletions

View file

@ -0,0 +1,50 @@
Shindo.tests('Fog::Rackspace::Monitoring | check_alarms', ['rackspace','rackspacemonitoring']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]
check_id = account.create_check(entity_id, CHECK_CREATE_OPTIONS).data[:headers]["X-Object-ID"]
alarm_id = nil
##############################################################################
# Notification plan was created externally with raxmon. Should create one on
# the fly once there is support for notifications plans in fog
##############################################################################
np = "npKV0PI5Js"
tests('success') do
tests('#create new alarm').formats(DATA_FORMAT) do
alarm_criteria = "if (metric['code'] == '404') { return new AlarmStatus(CRITICAL, 'Page not found');}"
options = {
:check_id => check_id,
:notification_plan_id => np,
:criteria => alarm_criteria
}
response = account.create_alarm(entity_id,options).data
alarm_id = response[:headers]["X-Object-ID"]
response
end
tests('#update alarm').formats(DATA_FORMAT) do
options = { :label => "Bar"}
account.update_alarm(entity_id,alarm_id,options).data
end
# delete is not currently supported in fog
#tests('#delete alarm').formats(DELETE_DATA_FORMAT) do
#account.delete_alarm(entity_id,check_id).data
#end
end
tests('failure') do
tests('#create new alarm(-1)').raises(Fog::Rackspace::Monitoring::BadRequest) do
account.create_alarm(entity_id, {:type => ""})
end
# Commenting out update because incorrect update throws a 502
#tests('#update invalid alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
#options = { :testing => "Bar" }
#response = account.update_alarm(-1,-1,options)
#end
# delete is not currently supported in fog
#tests('#delete alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
#account.delete_alarm(-1,-1)
#end
end
account.delete_check(entity_id,check_id)
account.delete_entity(entity_id)
end

View file

@ -1,15 +0,0 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_check_type_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get check types').formats(LIST_HEADERS_FORMAT) do
account.list_check_types().data[:headers]
end
end
tests('failure') do
tests('#fail to list check types').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_check_types(-1)
end
end
end

View file

@ -1,17 +0,0 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_checks_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]
tests('success') do
tests('#get list of checks').formats(LIST_HEADERS_FORMAT) do
account.list_checks(entity_id).data[:headers]
end
end
tests('failure') do
tests('#fail to list checks').raises(Fog::Rackspace::Monitoring::NotFound) do
account.list_checks(-1)
end
end
account.delete_entity(entity_id)
end

View file

@ -1,15 +0,0 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_entities_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get list of entities').formats(CHECKS_HEADERS_FORMAT) do
account.list_entities().data[:headers]
end
end
tests('failure') do
tests('#fail to list entities').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_entities(-1)
end
end
end

View file

@ -1,15 +0,0 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_overview_tests', ['rackspace']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
tests('success') do
tests('#get list overview').formats(OVERVIEW_HEADERS_FORMAT) do
account.list_overview().data[:headers]
end
end
tests('failure') do
tests('#fail to list overview').raises(Fog::Rackspace::Monitoring::NoMethodError) do
account.list_overview(-1)
end
end
end

View file

@ -0,0 +1,44 @@
Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspacemonitoring']) do
pending if Fog.mocking?
account = Fog::Rackspace::Monitoring.new
entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]
check_id = account.create_check(entity_id,CHECK_CREATE_OPTIONS).data[:headers]["X-Object-ID"]
tests('success') do
tests('#get list of checks').formats(LIST_HEADERS_FORMAT) do
account.list_checks(entity_id).data[:headers]
end
tests('#get list of check types').formats(LIST_HEADERS_FORMAT) do
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
account.list_metrics(entity_id,check_id).data[:headers]
end
tests('#get overview list').formats(LIST_HEADERS_FORMAT) do
account.list_overview().data[:headers]
end
end
tests('failure') do
tests('#fail to list checks').raises(Fog::Rackspace::Monitoring::NotFound) do
account.list_checks(-1)
end
tests('#fail to list check types').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_check_types(-1)
end
tests('#fail to list entities').raises(Fog::Rackspace::Monitoring::ArgumentError) do
account.list_entities(-1)
end
# This test has been put on hold due to a bug that incorrectly returns 200 OK to this request
#tests('#fail to list metrics').raises(Fog::Rackspace::Monitoring::NotFound) do
#account.list_metrics(-1,-1)
#end
tests('#fail to list overview').raises(Fog::Rackspace::Monitoring::NoMethodError) do
account.list_overview(-1)
end
end
account.delete_check(entity_id,check_id)
account.delete_entity(entity_id)
end