2011-12-02 13:27:44 -05:00
|
|
|
Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@combined_volume_format = {
|
|
|
|
"id" => String,
|
|
|
|
"instanceId" => 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,
|
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-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@volumes_format = {
|
|
|
|
'volumes' => [ @combined_volume_format.reject { |k,v| k == "ioPrice" } ]
|
|
|
|
}
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@volume_format = @combined_volume_format.reject { |k,v| k == "instanceId" }
|
|
|
|
|
|
|
|
tests('success') do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@volume_id = nil
|
2012-02-13 10:51:03 -05:00
|
|
|
@name = "fog test volume"
|
2011-12-02 13:27:44 -05:00
|
|
|
@format = "raw"
|
|
|
|
@location_id = "101"
|
|
|
|
@size = "256"
|
|
|
|
@offering_id = "20001208"
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@instance_id = nil
|
|
|
|
@image_id = "20015393"
|
|
|
|
@instance_type = "BRZ32.1/2048/60*175"
|
|
|
|
@location = "101"
|
|
|
|
@public_key = "test"
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-02-13 10:03:00 -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::Compute[:ibm].list_volumes.body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#get_volume('#{@volume_id}')").formats(@volume_format) do
|
|
|
|
Fog::Compute[:ibm].get_volume(@volume_id).body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do
|
|
|
|
@instance_id = Fog::Compute[:ibm].create_instance(
|
|
|
|
"fog test volume instance",
|
2012-02-13 10:51:03 -05:00
|
|
|
@image_id,
|
|
|
|
@instance_type,
|
|
|
|
@location,
|
2012-02-13 10:03:00 -05:00
|
|
|
:key_name => @public_key
|
2011-12-02 13:27:44 -05:00
|
|
|
).body['instances'][0]['id']
|
|
|
|
# TODO: Add assertions for this whenever it is properly supported
|
2012-02-13 10:03:00 -05:00
|
|
|
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
|
|
|
|
# TODO: Add assertions for this whenever it is properly supported
|
2012-02-13 10:03:00 -05:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
|
|
|
|
2012-02-13 10:51:03 -05:00
|
|
|
end
|