diff --git a/tests/rackspace/requests/monitoring/alarm_tests.rb b/tests/rackspace/requests/monitoring/alarm_tests.rb new file mode 100644 index 000000000..6418ff8d8 --- /dev/null +++ b/tests/rackspace/requests/monitoring/alarm_tests.rb @@ -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 diff --git a/tests/rackspace/requests/monitoring/list_check_type_tests.rb b/tests/rackspace/requests/monitoring/list_check_type_tests.rb deleted file mode 100644 index 478cb8c8f..000000000 --- a/tests/rackspace/requests/monitoring/list_check_type_tests.rb +++ /dev/null @@ -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 diff --git a/tests/rackspace/requests/monitoring/list_checks_tests.rb b/tests/rackspace/requests/monitoring/list_checks_tests.rb deleted file mode 100644 index ce416caa0..000000000 --- a/tests/rackspace/requests/monitoring/list_checks_tests.rb +++ /dev/null @@ -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 diff --git a/tests/rackspace/requests/monitoring/list_entities_tests.rb b/tests/rackspace/requests/monitoring/list_entities_tests.rb deleted file mode 100644 index 0a6ed3ff8..000000000 --- a/tests/rackspace/requests/monitoring/list_entities_tests.rb +++ /dev/null @@ -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 diff --git a/tests/rackspace/requests/monitoring/list_overview_tests.rb b/tests/rackspace/requests/monitoring/list_overview_tests.rb deleted file mode 100644 index a40f6337b..000000000 --- a/tests/rackspace/requests/monitoring/list_overview_tests.rb +++ /dev/null @@ -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 diff --git a/tests/rackspace/requests/monitoring/list_tests.rb b/tests/rackspace/requests/monitoring/list_tests.rb new file mode 100644 index 000000000..787bf0c88 --- /dev/null +++ b/tests/rackspace/requests/monitoring/list_tests.rb @@ -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