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
|
||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
||||
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
@ -14,11 +15,9 @@ describe 'EC2.associate_address' do
|
|||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually(128) do
|
||||
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,28 +6,26 @@ describe 'EC2.attach_volume' do
|
|||
before(:each) do
|
||||
@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']
|
||||
AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
|
||||
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
eventually do
|
||||
AWS[:ec2].detach_volume(@volume_id)
|
||||
end
|
||||
eventually do
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
AWS[:ec2].terminate_instances(@instance_id)
|
||||
end
|
||||
AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'attached' }
|
||||
AWS[:ec2].detach_volume(@volume_id)
|
||||
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
AWS[:ec2].terminate_instances(@instance_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually(128) do
|
||||
actual = AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['status'].should be_a(String)
|
||||
actual.body['volumeId'].should be_a(String)
|
||||
end
|
||||
actual = AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['status'].should be_a(String)
|
||||
actual.body['volumeId'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,9 +9,8 @@ describe 'EC2.create_snapshot' do
|
|||
|
||||
after(:each) do
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
eventually do
|
||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
end
|
||||
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
|
|
|
@ -13,12 +13,11 @@ describe 'EC2.delete_snapshot' do
|
|||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually do
|
||||
actual = AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
unless actual.body.empty?
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||
actual = AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
unless actual.body.empty?
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,42 +3,37 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'EC2.describe_snapshots' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
before(:all) do
|
||||
@volume_id = AWS[:ec2].create_volume('us-east-1a', 1).body['volumeId']
|
||||
@snapshot_id = AWS[:ec2].create_snapshot(@volume_id).body['snapshotId']
|
||||
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
after(:all) do
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
eventually do
|
||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
end
|
||||
AWS[:ec2].delete_snapshot(@snapshot_id)
|
||||
end
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
eventually do
|
||||
actual = AWS[:ec2].describe_snapshots
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
snapshot['snapshotId'].should be_a(String)
|
||||
snapshot['startTime'].should be_a(Time)
|
||||
snapshot['status'].should be_a(String)
|
||||
snapshot['volumeId'].should be_a(String)
|
||||
end
|
||||
actual = AWS[:ec2].describe_snapshots
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
snapshot['snapshotId'].should be_a(String)
|
||||
snapshot['startTime'].should be_a(Time)
|
||||
snapshot['status'].should be_a(String)
|
||||
snapshot['volumeId'].should be_a(String)
|
||||
end
|
||||
|
||||
it "should return proper attributes with params" do
|
||||
eventually do
|
||||
actual = AWS[:ec2].describe_snapshots([@snapshot_id])
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
snapshot['snapshotId'].should be_a(String)
|
||||
snapshot['startTime'].should be_a(Time)
|
||||
snapshot['status'].should be_a(String)
|
||||
snapshot['volumeId'].should be_a(String)
|
||||
end
|
||||
actual = AWS[:ec2].describe_snapshots([@snapshot_id])
|
||||
actual.body['snapshotSet'].should be_an(Array)
|
||||
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
||||
snapshot['progress'].should be_a(String)
|
||||
snapshot['snapshotId'].should be_a(String)
|
||||
snapshot['startTime'].should be_a(Time)
|
||||
snapshot['status'].should be_a(String)
|
||||
snapshot['volumeId'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,28 +6,26 @@ describe 'EC2.detach_volume' do
|
|||
before(:each) do
|
||||
@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']
|
||||
eventually(128) do
|
||||
AWS[:ec2].attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
||||
end
|
||||
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].volumes.get(@volume_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
eventually do
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
AWS[:ec2].terminate_instances([@instance_id])
|
||||
end
|
||||
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
|
||||
AWS[:ec2].delete_volume(@volume_id)
|
||||
AWS[:ec2].terminate_instances([@instance_id])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
eventually do
|
||||
actual = AWS[:ec2].detach_volume(@volume_id)
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['status'].should be_a(String)
|
||||
actual.body['volumeId'].should be_a(String)
|
||||
end
|
||||
actual = AWS[:ec2].detach_volume(@volume_id)
|
||||
actual.body['attachTime'].should be_a(Time)
|
||||
actual.body['device'].should be_a(String)
|
||||
actual.body['instanceId'].should be_a(String)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
actual.body['status'].should be_a(String)
|
||||
actual.body['volumeId'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,10 +5,9 @@ describe 'EC2.disassociate_address' do
|
|||
|
||||
before(:each) do
|
||||
@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']
|
||||
AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
end
|
||||
@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)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
|
@ -3,11 +3,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'S3.get_service' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
before(:all) do
|
||||
AWS[:s3].put_bucket('foggetservice')
|
||||
wait_for { AWS[:s3].directories.get('foggetservice') }
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
after(:all) do
|
||||
AWS[:s3].delete_bucket('foggetservice')
|
||||
end
|
||||
|
||||
|
@ -23,10 +24,8 @@ describe 'S3.get_service' do
|
|||
end
|
||||
|
||||
it 'should include foggetservice in get_service' do
|
||||
eventually do
|
||||
actual = AWS[:s3].get_service
|
||||
actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
|
||||
end
|
||||
actual = AWS[:s3].get_service
|
||||
actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue