mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ec2|s3] replacing eventually with wait_for
This commit is contained in:
parent
b97e4640ac
commit
7f09801b9d
8 changed files with 67 additions and 81 deletions
|
@ -6,6 +6,7 @@ describe 'EC2.associate_address' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||||
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
||||||
|
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
|
@ -14,12 +15,10 @@ describe 'EC2.associate_address' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes" do
|
||||||
eventually(128) do
|
|
||||||
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||||
actual.body['requestId'].should be_a(String)
|
actual.body['requestId'].should be_a(String)
|
||||||
[false, true].should include(actual.body['return'])
|
[false, true].should include(actual.body['return'])
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
describe 'failure' do
|
describe 'failure' do
|
||||||
|
|
|
@ -6,20 +6,19 @@ describe 'EC2.attach_volume' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||||
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
||||||
|
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||||
|
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
eventually do
|
AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'attached' }
|
||||||
AWS[:ec2].detach_volume(@volume_id)
|
AWS[:ec2].detach_volume(@volume_id)
|
||||||
end
|
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||||
eventually do
|
|
||||||
AWS[:ec2].delete_volume(@volume_id)
|
AWS[:ec2].delete_volume(@volume_id)
|
||||||
AWS[:ec2].terminate_instances(@instance_id)
|
AWS[:ec2].terminate_instances(@instance_id)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes" do
|
||||||
eventually(128) do
|
|
||||||
actual = AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
actual = AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
||||||
actual.body['attachTime'].should be_a(Time)
|
actual.body['attachTime'].should be_a(Time)
|
||||||
actual.body['device'].should be_a(String)
|
actual.body['device'].should be_a(String)
|
||||||
|
@ -28,7 +27,6 @@ describe 'EC2.attach_volume' do
|
||||||
actual.body['status'].should be_a(String)
|
actual.body['status'].should be_a(String)
|
||||||
actual.body['volumeId'].should be_a(String)
|
actual.body['volumeId'].should be_a(String)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
describe 'failure' do
|
describe 'failure' do
|
||||||
|
|
|
@ -9,10 +9,9 @@ describe 'EC2.create_snapshot' do
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
AWS[:ec2].delete_volume(@volume_id)
|
AWS[:ec2].delete_volume(@volume_id)
|
||||||
eventually do
|
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes" do
|
||||||
actual = AWS[:ec2].create_snapshot(@volume_id)
|
actual = AWS[:ec2].create_snapshot(@volume_id)
|
||||||
|
|
|
@ -13,14 +13,13 @@ describe 'EC2.delete_snapshot' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes" do
|
||||||
eventually do
|
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||||
actual = AWS[:ec2].delete_snapshot(@snapshot_id)
|
actual = AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||||
unless actual.body.empty?
|
unless actual.body.empty?
|
||||||
actual.body['requestId'].should be_a(String)
|
actual.body['requestId'].should be_a(String)
|
||||||
[false, true].should include(actual.body['return'])
|
[false, true].should include(actual.body['return'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
describe 'failure' do
|
describe 'failure' do
|
||||||
|
|
|
@ -3,20 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||||
describe 'EC2.describe_snapshots' do
|
describe 'EC2.describe_snapshots' do
|
||||||
describe 'success' do
|
describe 'success' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
||||||
@snapshot_id = AWS[:ec2].create_snapshot(@volume_id).body['snapshotId']
|
@snapshot_id = AWS[:ec2].create_snapshot(@volume_id).body['snapshotId']
|
||||||
|
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:all) do
|
||||||
AWS[:ec2].delete_volume(@volume_id)
|
AWS[:ec2].delete_volume(@volume_id)
|
||||||
eventually do
|
|
||||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should return proper attributes with no params" do
|
it "should return proper attributes with no params" do
|
||||||
eventually do
|
|
||||||
actual = AWS[:ec2].describe_snapshots
|
actual = AWS[:ec2].describe_snapshots
|
||||||
actual.body['snapshotSet'].should be_an(Array)
|
actual.body['snapshotSet'].should be_an(Array)
|
||||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||||
|
@ -26,10 +24,8 @@ describe 'EC2.describe_snapshots' do
|
||||||
snapshot['status'].should be_a(String)
|
snapshot['status'].should be_a(String)
|
||||||
snapshot['volumeId'].should be_a(String)
|
snapshot['volumeId'].should be_a(String)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should return proper attributes with params" do
|
it "should return proper attributes with params" do
|
||||||
eventually do
|
|
||||||
actual = AWS[:ec2].describe_snapshots([@snapshot_id])
|
actual = AWS[:ec2].describe_snapshots([@snapshot_id])
|
||||||
actual.body['snapshotSet'].should be_an(Array)
|
actual.body['snapshotSet'].should be_an(Array)
|
||||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||||
|
@ -39,7 +35,6 @@ describe 'EC2.describe_snapshots' do
|
||||||
snapshot['status'].should be_a(String)
|
snapshot['status'].should be_a(String)
|
||||||
snapshot['volumeId'].should be_a(String)
|
snapshot['volumeId'].should be_a(String)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
describe 'failure' do
|
describe 'failure' do
|
||||||
|
|
|
@ -6,20 +6,19 @@ describe 'EC2.detach_volume' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
||||||
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
||||||
eventually(128) do
|
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||||
|
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||||
AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
||||||
end
|
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
eventually do
|
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||||
AWS[:ec2].delete_volume(@volume_id)
|
AWS[:ec2].delete_volume(@volume_id)
|
||||||
AWS[:ec2].terminate_instances([@instance_id])
|
AWS[:ec2].terminate_instances([@instance_id])
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes" do
|
||||||
eventually do
|
|
||||||
actual = AWS[:ec2].detach_volume(@volume_id)
|
actual = AWS[:ec2].detach_volume(@volume_id)
|
||||||
actual.body['attachTime'].should be_a(Time)
|
actual.body['attachTime'].should be_a(Time)
|
||||||
actual.body['device'].should be_a(String)
|
actual.body['device'].should be_a(String)
|
||||||
|
@ -28,7 +27,6 @@ describe 'EC2.detach_volume' do
|
||||||
actual.body['status'].should be_a(String)
|
actual.body['status'].should be_a(String)
|
||||||
actual.body['volumeId'].should be_a(String)
|
actual.body['volumeId'].should be_a(String)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
describe 'failure' do
|
describe 'failure' do
|
||||||
|
|
|
@ -5,11 +5,10 @@ describe 'EC2.disassociate_address' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||||
eventually(128) do
|
|
||||||
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
||||||
|
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||||
AWS[:ec2].associate_address(@instance_id, @public_ip)
|
AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
AWS[:ec2].release_address(@public_ip)
|
AWS[:ec2].release_address(@public_ip)
|
||||||
|
|
|
@ -3,11 +3,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||||
describe 'S3.get_service' do
|
describe 'S3.get_service' do
|
||||||
describe 'success' do
|
describe 'success' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
AWS[:s3].put_bucket('foggetservice')
|
AWS[:s3].put_bucket('foggetservice')
|
||||||
|
wait_for { AWS[:s3].directories.get('foggetservice') }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:all) do
|
||||||
AWS[:s3].delete_bucket('foggetservice')
|
AWS[:s3].delete_bucket('foggetservice')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,11 +24,9 @@ describe 'S3.get_service' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should include foggetservice in get_service' do
|
it 'should include foggetservice in get_service' do
|
||||||
eventually do
|
|
||||||
actual = AWS[:s3].get_service
|
actual = AWS[:s3].get_service
|
||||||
actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
|
actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue