mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add tests for instrumentations
This commit is contained in:
parent
a3016d6f50
commit
619a66216c
6 changed files with 56 additions and 1 deletions
|
@ -5,6 +5,8 @@ class Joyent < Fog::Bin
|
|||
case key
|
||||
when :compute
|
||||
Fog::Compute::Joyent
|
||||
when :analytics
|
||||
Fog::Joyent::Analytics
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key}"
|
||||
end
|
||||
|
@ -16,6 +18,8 @@ class Joyent < Fog::Bin
|
|||
when :compute
|
||||
Fog::Logger.warning("Joyent[:compute] is not recommended, use Compute[:joyent] for portability")
|
||||
Fog::Compute.new(:provider => 'Joyent')
|
||||
when :analytics
|
||||
Fog::Joyent::Analytics.new
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
|
|
|
@ -50,7 +50,30 @@ module Fog
|
|||
class Mock
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {}
|
||||
hash[key] =case key
|
||||
when :instrumentation
|
||||
{ 'module' => "cpu",
|
||||
'stat' => "usage",
|
||||
'predicate' => {},
|
||||
'decomposition' => ["zonename"],
|
||||
'value-dimension' => 2,
|
||||
'value-arity' => "discrete-decomposition",
|
||||
'enabled' => true,
|
||||
'retention-time' => 86400,
|
||||
'idle-max' => 86400,
|
||||
'transformations' => [],
|
||||
'nsources' => 3,
|
||||
'granularity' => 30,
|
||||
'persist-data' => false,
|
||||
'crtime' => 1388690982000,
|
||||
'value-scope' => "point",
|
||||
'id' => "63",
|
||||
'uris' =>
|
||||
[{ "uri" => "/#{@joyent_username}/analytics/instrumentations/63/value/raw",
|
||||
"name" => "value_raw" }] }
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,6 +84,8 @@ module Fog
|
|||
def initialize(options = {})
|
||||
@joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username]
|
||||
@joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password]
|
||||
@joyent_url = 'https://us-sw-1.api.joyentcloud.com'
|
||||
@joyent_version = '~7'
|
||||
end
|
||||
|
||||
def request(opts)
|
||||
|
|
|
@ -11,6 +11,15 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_instrumentation(values = {})
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = self.data[:instrumentation]
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,14 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_instrumentation(id)
|
||||
response = Excon::Response.new
|
||||
response.status = 204
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,15 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_instrumentations
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = [self.data[:instrumentation]]
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
0
tests/joyent/requests/analytics/instrumentation_tests.rb
Normal file
0
tests/joyent/requests/analytics/instrumentation_tests.rb
Normal file
Loading…
Add table
Reference in a new issue