mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|monitoring] adding model tests for metrics and data points
This commit is contained in:
parent
7f0048aefa
commit
e102ba7b0c
3 changed files with 52 additions and 0 deletions
18
tests/rackspace/models/monitoring/data_points_tests.rb
Normal file
18
tests/rackspace/models/monitoring/data_points_tests.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
Shindo.tests('Fog::Rackspace::Monitoring | datapoints', ['rackspace','rackspace_monitoring']) do
|
||||||
|
service = Fog::Rackspace::Monitoring.new
|
||||||
|
|
||||||
|
begin
|
||||||
|
label = "fog_#{Time.now.to_i.to_s}"
|
||||||
|
@entity = service.entities.create :label => label
|
||||||
|
@check = service.checks.create CHECK_CREATE_OPTIONS.merge(:label => label, :entity => @entity)
|
||||||
|
sleep @check.period + 30
|
||||||
|
@metric = service.metrics(:check => @check).first
|
||||||
|
|
||||||
|
tests('#datapoints').succeeds do
|
||||||
|
service.data_points(:metric => @metric).fetch({ :from => ((Time.now.to_i * 1000) - (3600 * 1000)) })
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
@check.destroy rescue nil if @check
|
||||||
|
@entity.destroy rescue nil if @entity
|
||||||
|
end
|
||||||
|
end
|
18
tests/rackspace/models/monitoring/metric_tests.rb
Normal file
18
tests/rackspace/models/monitoring/metric_tests.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
Shindo.tests('Fog::Rackspace::Monitoring | metrics', ['rackspace','rackspace_monitoring']) do
|
||||||
|
service = Fog::Rackspace::Monitoring.new
|
||||||
|
|
||||||
|
begin
|
||||||
|
label = "fog_#{Time.now.to_i.to_s}"
|
||||||
|
@entity = service.entities.create :label => label
|
||||||
|
@check = service.checks.create CHECK_CREATE_OPTIONS.merge(:label => label, :entity => @entity)
|
||||||
|
sleep @check.period + 30
|
||||||
|
@metric = service.metrics(:check => @check).first
|
||||||
|
|
||||||
|
tests('#datapoints').succeeds do
|
||||||
|
@metric.datapoints
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
@check.destroy rescue nil if @check
|
||||||
|
@entity.destroy rescue nil if @entity
|
||||||
|
end
|
||||||
|
end
|
16
tests/rackspace/models/monitoring/metrics_tests.rb
Normal file
16
tests/rackspace/models/monitoring/metrics_tests.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Shindo.tests('Fog::Rackspace::Monitoring | metrics', ['rackspace','rackspace_monitoring']) do
|
||||||
|
service = Fog::Rackspace::Monitoring.new
|
||||||
|
|
||||||
|
begin
|
||||||
|
label = "fog_#{Time.now.to_i.to_s}"
|
||||||
|
@entity = service.entities.create :label => label
|
||||||
|
@check = service.checks.create CHECK_CREATE_OPTIONS.merge(:label => label, :entity => @entity)
|
||||||
|
|
||||||
|
tests('#list_metrics').succeeds do
|
||||||
|
service.metrics(:check => @check).all
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
@check.destroy rescue nil if @check
|
||||||
|
@entity.destroy rescue nil if @entity
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue