2011-05-19 10:11:50 -04:00
|
|
|
Shindo.tests('AWS::CloudWatch | metric requests', ['aws', 'cloudwatch']) do
|
|
|
|
tests('success') do
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
namespace = 'Custom/Test'
|
|
|
|
@puts_format = {'ResponseMetadata' => {'RequestId' => String}}
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
tests('#puts_value').formats(@puts_format) do
|
2011-07-20 13:11:10 -04:00
|
|
|
pending if Fog.mocking?
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'Value' => 1}]).body
|
2011-05-19 10:11:50 -04:00
|
|
|
end
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
tests('#puts_statistics_set').succeeds do
|
2011-07-20 13:11:10 -04:00
|
|
|
pending if Fog.mocking?
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'StatisticValues' => {'Minimum' => 0, 'Maximum' => 9, 'Sum' => 45, 'SampleCount' => 10, 'Average' => 4.5}}]).body
|
2011-05-19 10:11:50 -04:00
|
|
|
end
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
tests('#puts with dimensions').succeeds do
|
2011-07-20 13:11:10 -04:00
|
|
|
pending if Fog.mocking?
|
2011-05-19 10:11:50 -04:00
|
|
|
dimensions = [{}]
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'Value' => 1, 'Dimensions' => dimensions}]).body
|
2011-05-19 10:11:50 -04:00
|
|
|
end
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
tests('#puts more than one').succeeds do
|
2011-07-20 13:11:10 -04:00
|
|
|
pending if Fog.mocking?
|
2011-05-19 12:12:56 -04:00
|
|
|
datapoints = (0...3).collect do |i|
|
2011-07-11 23:06:26 -04:00
|
|
|
dp = {'MetricName' => "#{i}RequestTest", 'Unit' => 'None', 'Value' => i}
|
2011-05-19 10:11:50 -04:00
|
|
|
if i%2==0
|
|
|
|
dp['Dimensions'] = [{'Name' => 'Ruler', 'Value' => "measurement_#{i}"}]
|
|
|
|
end
|
|
|
|
dp
|
|
|
|
end
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:cloud_watch].put_metric_data(namespace, datapoints).body
|
2011-05-19 10:11:50 -04:00
|
|
|
end
|
2011-07-20 13:11:10 -04:00
|
|
|
|
2011-05-19 10:11:50 -04:00
|
|
|
end
|
2011-07-11 23:06:26 -04:00
|
|
|
end
|