2011-06-16 19:28:54 -04:00
|
|
|
Shindo.tests("Fog::Compute[:aws] | monitor", ['aws']) do
|
2011-03-21 19:45:52 -04:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
@instance = Fog::Compute[:aws].servers.new
|
2011-05-17 17:50:50 -04:00
|
|
|
|
|
|
|
[:addresses, :flavor, :key_pair, :key_pair=, :volumes].each do |association|
|
2011-03-21 19:45:52 -04:00
|
|
|
responds_to(association)
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('new instance') do
|
|
|
|
|
|
|
|
test('#monitor = true') do
|
|
|
|
@instance.monitor = true
|
|
|
|
@instance.attributes[:monitoring] == true
|
|
|
|
end
|
|
|
|
|
|
|
|
test('#monitor = false') do
|
|
|
|
@instance.monitor = false
|
|
|
|
@instance.attributes[:monitoring] == false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('existing instance') do
|
|
|
|
|
|
|
|
@instance.save
|
|
|
|
|
2011-04-19 15:48:40 -04:00
|
|
|
[:id, :availability_zone, :flavor_id, :kernel_id, :image_id, :state].each do |attr|
|
|
|
|
test("instance##{attr} should not contain whitespace") do
|
|
|
|
nil == @instance.send(attr).match(/\s/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-21 19:45:52 -04:00
|
|
|
test('#monitor = true') do
|
|
|
|
@instance.monitor = true
|
|
|
|
@instance.monitoring == true
|
|
|
|
end
|
|
|
|
|
|
|
|
test('#monitor = false') do
|
|
|
|
@instance.monitor = false
|
|
|
|
@instance.monitoring == false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-04-19 15:22:24 -04:00
|
|
|
@instance.destroy
|
2011-08-08 13:17:14 -04:00
|
|
|
|
|
|
|
tests('tags') do
|
|
|
|
@instance = Fog::Compute[:aws].servers.create(:tags => {'key' => 'value'})
|
|
|
|
|
2011-09-22 20:37:39 -04:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
|
2011-08-08 13:17:14 -04:00
|
|
|
tests('@instance.reload.tags').returns({'key' => 'value'}) do
|
|
|
|
@instance.reload.tags
|
|
|
|
end
|
|
|
|
|
2011-08-16 12:57:34 -04:00
|
|
|
unless Fog.mocking?
|
|
|
|
Fog::Compute[:aws].tags.all('resource-id' => @instance.identity).each {|tag| tag.destroy}
|
|
|
|
end
|
|
|
|
|
2011-08-08 13:17:14 -04:00
|
|
|
@instance.destroy
|
|
|
|
end
|
|
|
|
|
2011-03-21 19:45:52 -04:00
|
|
|
end
|