diff --git a/lib/fog/rackspace/monitoring.rb b/lib/fog/rackspace/monitoring.rb index b8a7410dd..dda6810f0 100644 --- a/lib/fog/rackspace/monitoring.rb +++ b/lib/fog/rackspace/monitoring.rb @@ -64,6 +64,7 @@ module Fog request :update_entity request :update_alarm + request :delete_agent_token request :delete_check request :delete_entity diff --git a/lib/fog/rackspace/requests/monitoring/delete_agent_token.rb b/lib/fog/rackspace/requests/monitoring/delete_agent_token.rb new file mode 100644 index 000000000..a40b06f17 --- /dev/null +++ b/lib/fog/rackspace/requests/monitoring/delete_agent_token.rb @@ -0,0 +1,17 @@ +module Fog + module Rackspace + class Monitoring + class Real + + def delete_agent_token(token_id) + request( + :expects => [204], + :method => 'DELETE', + :path => "agent_tokens/#{token_id}" + ) + end + end + end + end +end + diff --git a/tests/rackspace/requests/monitoring/agent_tests.rb b/tests/rackspace/requests/monitoring/agent_tests.rb index 79d1c0937..214b1d4e8 100644 --- a/tests/rackspace/requests/monitoring/agent_tests.rb +++ b/tests/rackspace/requests/monitoring/agent_tests.rb @@ -16,6 +16,9 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace tests('#get agent token').formats(LIST_HEADERS_FORMAT) do account.get_agent_token(agent_token).data[:headers] end + tests('#delete agent token').formats(DELETE_HEADERS_FORMAT) do + account.delete_agent_token(agent_token).data[:headers] + end end tests('failure') do tests('#fail to create agent token(-1)').raises(TypeError) do @@ -24,5 +27,8 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace tests('#fail to get agent token(-1)').raises(TypeError) do account.create_agent_token(-1) end + tests('#fail to delete agent token(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do + account.delete_agent_token(-1) + end end end diff --git a/tests/rackspace/requests/monitoring/alarm_tests.rb b/tests/rackspace/requests/monitoring/alarm_tests.rb index 895b6a68f..d9d738201 100644 --- a/tests/rackspace/requests/monitoring/alarm_tests.rb +++ b/tests/rackspace/requests/monitoring/alarm_tests.rb @@ -5,11 +5,7 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace 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" + np = "npTechnicalContactsEmail" tests('success') do tests('#create new alarm').formats(DATA_FORMAT) do alarm_criteria = "if (metric['code'] == '404') { return new AlarmStatus(CRITICAL, 'Page not found');}" @@ -59,4 +55,4 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace end account.delete_check(entity_id,check_id) account.delete_entity(entity_id) -end \ No newline at end of file +end diff --git a/tests/rackspace/requests/monitoring/list_tests.rb b/tests/rackspace/requests/monitoring/list_tests.rb index 7aa6f59a9..5cdfd9527 100644 --- a/tests/rackspace/requests/monitoring/list_tests.rb +++ b/tests/rackspace/requests/monitoring/list_tests.rb @@ -4,6 +4,11 @@ Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspace_ 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"] + metric_name = "idle_percent_average" + now = Time.now.to_i + SLEEP_TIME= 2 + sleep(SLEEP_TIME) + tests('success') do tests('#get list of checks').formats(LIST_HEADERS_FORMAT) do account.list_checks(entity_id).data[:headers] @@ -23,6 +28,14 @@ Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspace_ tests('#list notification plans').formats(LIST_HEADERS_FORMAT) do account.list_notification_plans().data[:headers] end + tests('#get list of data points').formats(LIST_HEADERS_FORMAT) do + options = { + :points => 1, + :from => now, + :to => now+SLEEP_TIME + } + account.list_data_points(entity_id,check_id,metric_name,options).data[:headers] + end end tests('failure') do tests('#fail to list checks').raises(Fog::Rackspace::Monitoring::NotFound) do @@ -41,7 +54,10 @@ Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspace_ tests('#fail: 1 argument instead of 0 for list_notification_plans').raises(ArgumentError) do account.list_notification_plans('fail') end + tests('#fail to get list of data points').raises(Fog::Rackspace::Monitoring::BadRequest) do + account.list_data_points(-1,-1,-1,-1).data + end end account.delete_check(entity_id,check_id) account.delete_entity(entity_id) -end \ No newline at end of file +end