1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/ibm/requests/storage/volume_tests.rb

101 lines
3.1 KiB
Ruby
Raw Normal View History

Shindo.tests('Fog::Storage[:ibm] | volume requests', ['ibm']) do
2012-02-13 10:51:03 -05:00
2012-03-12 15:29:18 -04:00
@volume_format = {
2011-12-02 13:27:44 -05:00
"id" => String,
2012-03-12 15:29:18 -04:00
"instanceId" => Fog::Nullable::String,
2012-02-13 10:51:03 -05:00
"name" => String,
"format" => String,
"state" => Integer,
"size" => String,
"offeringId" => String,
"owner" => String,
"createdTime" => Integer,
"location" => String,
"productCodes" => Array,
2012-03-12 15:29:18 -04:00
}
@full_volume_format = @volume_format.merge({
2011-12-02 13:27:44 -05:00
"ioPrice" => {
2012-02-13 10:51:03 -05:00
"rate" => Float,
"unitOfMeasure" => String,
"countryCode" => String,
"effectiveDate" => Integer,
"currencyCode" => String,
2011-12-02 13:27:44 -05:00
"pricePerQuantity" => Integer,
}
2012-03-12 15:29:18 -04:00
})
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
@volumes_format = {
2012-03-12 15:29:18 -04:00
'volumes' => [ @volume_format ]
2011-12-02 13:27:44 -05:00
}
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
tests('success') do
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
@volume_id = nil
@name = "fog-test-volume" + Time.now.to_i.to_s(32)
@format = "RAW"
2012-02-28 23:51:37 -05:00
@location_id = "41"
2011-12-02 13:27:44 -05:00
@size = "256"
@offering_id = "20001208"
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
@instance_id = nil
2012-02-28 23:51:37 -05:00
@image_id = "20010001"
2011-12-02 13:27:44 -05:00
@instance_type = "BRZ32.1/2048/60*175"
# Instance-using tests are pending, so don't create the key now
# @key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
# @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
2012-02-13 10:51:03 -05:00
tests("#create_volume('#{@name}', '#{@offering_id}', '#{@format}', '#{@location_id}', '#{@size}')").formats(@volume_format) do
data = Fog::Storage[:ibm].create_volume(@name, @offering_id, @format, @location_id, @size).body
2011-12-02 13:27:44 -05:00
@volume_id = data['id']
data
end
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
tests("#list_volumes").formats(@volumes_format) do
Fog::Storage[:ibm].list_volumes.body
2011-12-02 13:27:44 -05:00
end
2012-02-13 10:51:03 -05:00
2012-03-12 15:29:18 -04:00
tests("#get_volume('#{@volume_id}')").formats(@full_volume_format) do
Fog::Storage[:ibm].get_volume(@volume_id).body
2011-12-02 13:27:44 -05:00
end
2012-02-13 10:51:03 -05:00
# Tests which use this instance are pending
# @instance_id = Fog::Compute[:ibm].create_instance(
# 'fog-test-volume-instance-' + Time.now.to_i.to_s(32),
# @image_id,
# @instance_type,
# @location_id,
# :key_name => @key_name
# ).body['instances'][0]['id']
2011-12-02 13:27:44 -05:00
tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do
pending
2011-12-02 13:27:44 -05:00
# TODO: Add assertions for this whenever it is properly supported
Fog::Compute[:ibm].modify_instance(@instance_id, 'type' => 'attach', 'volume_id' => @volume_id)
2011-12-02 13:27:44 -05:00
end
2012-02-13 10:51:03 -05:00
2011-12-02 13:27:44 -05:00
tests("#detach_volume('#{@instance_id}','#{@volume_id}')") do
pending
2011-12-02 13:27:44 -05:00
# TODO: Add assertions for this whenever it is properly supported
Fog::Compute[:ibm].modify_instance(@instance_id, 'type' => 'attach', 'volume_id' => @volume_id)
2011-12-02 13:27:44 -05:00
Fog::Compute[:ibm].delete_instance(@instance_id)
end
2012-02-13 10:51:03 -05:00
Fog::Storage[:ibm].volumes.get(@volume_id).wait_for(Fog::IBM.timeout) { ready? }
2011-12-02 13:27:44 -05:00
tests("#delete_volume('#{@volume_id}')") do
2012-02-13 10:51:03 -05:00
returns(true) { Fog::Storage[:ibm].delete_volume(@volume_id).body['success'] }
2011-12-02 13:27:44 -05:00
end
2012-02-13 10:51:03 -05:00
# See above
# @server = Fog::Compute[:ibm].servers.get(@instance_id)
# @server.wait_for(Fog::IBM.timeout) { ready? }
# @server.destroy
# @key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
# @key.destroy
2011-12-02 13:27:44 -05:00
end
2012-02-13 10:51:03 -05:00
end