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

add tests for metrics, types and a few other things

This commit is contained in:
Kevin Olbrich 2014-01-04 03:18:12 +00:00
parent 17137f4f54
commit 716af47b8a
11 changed files with 110 additions and 15 deletions

View file

@ -21,7 +21,7 @@ module Fog
request :list_instrumentations
request :get_instrumentation
request :create_instrumentation
request :delete_instrumentation
request :delete_instrumentation
request :get_instrumentation_value
model_path 'fog/joyent/models/analytics'
@ -73,16 +73,16 @@ module Fog
"name" => "value_raw" }] }
when :values
{
'value' => { 'zoneid' => 0 },
'transformations' => {},
'start_time' => Time.now.utc - 600,
'duration' => 30,
'end_time' => Time.now.utc - 570,
'nsources' => 1,
'minreporting' => 1,
'requested_start_time' => Time.now.utc - 600,
'requested_duration' => 30,
'requested_end_time' => Time.now.utc - 570
'value' => { 'zoneid' => 0 },
'transformations' => {},
'start_time' => Time.now.utc - 600,
'duration' => 30,
'end_time' => Time.now.utc - 570,
'nsources' => 1,
'minreporting' => 1,
'requested_start_time' => Time.now.utc - 600,
'requested_duration' => 30,
'requested_end_time' => Time.now.utc - 570
}
when :describe_analytics
{
@ -100,6 +100,25 @@ module Fog
'cpu' => {
'label' => 'CPU'
}
},
'transformations' => {
'geolocate' => {
'label' => 'geolocate IP addresses',
'fields' => ['raddr'] }
},
'metrics' => [{
"module" => "cpu",
"stat" => "thread_executions",
"label" => "thread executions",
"interval" => "interval",
"fields" => ["hostname", "zonename", "runtime"],
"unit" => "operations"
}],
'types' => {
'string' => {
'arity' => "discrete",
'unit' => ""
}
}
}
else

View file

@ -1,4 +1,4 @@
Shindo.tests("Fog::Joyent[:analytics] | field", %w{joyent analytics}) do
Shindo.tests("Fog::Joyent[:analytics] | field", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@field = @analytics.fields.first

View file

@ -1,4 +1,4 @@
Shindo.tests("Fog::Joyent[:analytics] | instrumentation", %w{joyent analytics instrumentation }) do
Shindo.tests("Fog::Joyent[:analytics] | instrumentation", %w{joyent }) do
model_tests(Fog::Joyent[:analytics].instrumentations, {:joyent_module => 'cpu', :stat => 'usage'}, true)
@analytics = Fog::Joyent[:analytics]

View file

@ -1,3 +1,3 @@
Shindo.tests("Fog::Joyent[:analytics] | instrumentations", %w{joyent models instrumentation }) do
Shindo.tests("Fog::Joyent[:analytics] | instrumentations", %w{joyent}) do
collection_tests(Fog::Joyent[:analytics].instrumentations, {:joyent_module => 'cpu', :stat => 'usage'}, true)
end

View file

@ -1,4 +1,4 @@
Shindo.tests("Fog::Joyent[:analytics] | joyent_module", %w{joyent analytics}) do
Shindo.tests("Fog::Joyent[:analytics] | joyent_module", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@joyent_module = @analytics.joyent_modules.first

View file

@ -0,0 +1,10 @@
Shindo.tests("Fog::Joyent[:analytics] | metric", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@metric = @analytics.metrics.first
tests('read only') do
returns(false, 'should not save') { @metric.respond_to?(:save)}
returns(false, 'should not allow creating a new one') { @metric.respond_to?(:create)}
returns(false, 'should not allow destroying') { @metric.respond_to?(:destroy)}
end
end

View file

@ -0,0 +1,20 @@
Shindo.tests("Fog::Joyent[:analytics] | metrics", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@metrics = @analytics.metrics
tests('#all').succeeds do
@metrics.all
end
tests('#new').succeeds do
@metrics.new({
"module" => "cpu",
"stat" => "thread_executions",
"label" => "thread executions",
"interval" => "interval",
"fields" => ["hostname", "zonename", "runtime"],
"unit" => "operations"
})
end
end

View file

@ -0,0 +1,10 @@
Shindo.tests("Fog::Joyent[:analytics] | transformation", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@transformation = @analytics.transformations.first
tests('read only') do
returns(false, 'should not save') { @transformation.respond_to?(:save)}
returns(false, 'should not allow creating a new one') { @transformation.respond_to?(:create)}
returns(false, 'should not allow destroying') { @transformation.respond_to?(:destroy)}
end
end

View file

@ -0,0 +1,13 @@
Shindo.tests("Fog::Joyent[:analytics] | transformations", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@transformations = @analytics.transformations
tests('#all').succeeds do
@transformations.all
end
tests('#new').succeeds do
@transformations.new(['geolocate', { 'label' => 'geolocate IP addresses', "fields" => ["raddr"] }])
end
end

View file

@ -0,0 +1,10 @@
Shindo.tests("Fog::Joyent[:analytics] | type", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@type = @analytics.types.first
tests('read only') do
returns(false, 'should not save') { @type.respond_to?(:save)}
returns(false, 'should not allow creating a new one') { @type.respond_to?(:create)}
returns(false, 'should not allow destroying') { @type.respond_to?(:destroy)}
end
end

View file

@ -0,0 +1,13 @@
Shindo.tests("Fog::Joyent[:analytics] | types", %w{joyent}) do
@analytics = Fog::Joyent[:analytics]
@types = @analytics.types
tests('#all').succeeds do
@types.all
end
tests('#new').succeeds do
@types.new(['string', {'arity' => 'discrete', 'unit' => ''}])
end
end