spec/smartdc/api/machine/snapshots_spec.rb in smartdc-0.3.0 vs spec/smartdc/api/machine/snapshots_spec.rb in smartdc-0.4.0
- old
+ new
@@ -2,22 +2,33 @@
describe "Smartdc::Api::Machine::Snapshots" do
before(:all) do
@fixture = fixture('tag')
@name = UUID.new.generate
+ client.datasets.find.each do |dataset|
+ if dataset.type == "smartmachine"
+ @dataset_urn = dataset.urn
+ break
+ end
+ end
+
machine = {
'name' => @name,
- 'dataset' => client.datasets.find[0].urn # this is smartmachine
+ 'dataset' => @dataset_urn
}
@machine = client.machines.create machine
machine = client.machines(@machine.id)
- 8.times do |i|
+ 88.times do |i|
break if machine.read.state == 'running'
sleep i
end
+ 88.times do |i|
+ break if machine.read.state == 'running'
+ sleep i
+ end
machine.stop
- 8.times do |i|
+ 88.times do |i|
break if machine.read.state == 'stopped'
sleep i
end
end
@@ -40,17 +51,18 @@
end
end
describe ".delete" do
it "should return true when success" do
- client.machines(@machine.id).snapshots('sample').delete.should be_true
+ client.machines(@machine.id).snapshots('sample').delete.should be_nil
end
end
after(:all) do
+ sleep 8
machine = client.machines(@machine.id)
machine.stop
- 8.times do |i|
+ 88.times do |i|
break if machine.read.state == 'stopped'
sleep i
end
client.machines(@machine.id).delete
end
\ No newline at end of file