-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
408 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Image[:openstack] | image" do | ||
describe "success" do | ||
before do | ||
@instance = Fog::Image[:openstack].images.create(:name => 'test image') | ||
end | ||
it "#create" do | ||
@instance.id.nil?.wont_be_nil | ||
end | ||
|
||
it "#update" do | ||
@instance.name = 'edit test image' | ||
@instance.update | ||
@instance.name.must_equal 'edit test image' | ||
end | ||
|
||
it "#get image metadata" do | ||
@instance.metadata["X-Image-Meta-Status"].must_equal "active" | ||
end | ||
|
||
it "#add member" do | ||
@instance.add_member(@instance.owner).status.must_equal 200 | ||
end | ||
|
||
it "#show members" do | ||
@instance.members[0]["member_id"].wont_be_empty | ||
end | ||
|
||
it "#remove member" do | ||
@instance.remove_member(@instance.owner).status.must_equal 200 | ||
end | ||
|
||
it "#destroy" do | ||
@instance.destroy.must_equal true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "test_helper" | ||
describe "Fog::Image[:openstack] | images" do | ||
before do | ||
@instance = Fog::Image[:openstack].create_image(:name => "model test image").body | ||
end | ||
|
||
describe "success" do | ||
it "#find_by_id" do | ||
image = Fog::Image[:openstack].images.find_by_id(@instance['image']['id']) | ||
image.id.must_equal @instance['image']['id'] | ||
end | ||
|
||
it "#get" do | ||
image = Fog::Image[:openstack].images.get(@instance['image']['id']) | ||
image.id.must_equal @instance['image']['id'] | ||
end | ||
|
||
it "#destroy" do | ||
Fog::Image[:openstack].images.destroy(@instance['image']['id']).must_equal true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Openstack[:planning] | plan" do | ||
describe "success" do | ||
before do | ||
@planning = Fog::Openstack[:planning] | ||
@instance = @planning.plans.first | ||
@role = @planning.list_roles.body.first | ||
end | ||
|
||
it "#add_role" do | ||
@instance.add_role(@role['uuid']).body["roles"][0]["uuid"].must_equal @role['uuid'] | ||
end | ||
|
||
it "#templates" do | ||
@instance.templates.wont_be_empty | ||
end | ||
|
||
it "#master_template" do | ||
@instance.master_template.must_be_kind_of String | ||
end | ||
|
||
it "#environment" do | ||
@instance.environment.must_be_kind_of String | ||
end | ||
|
||
it "#provider_resource_templates" do | ||
@instance.provider_resource_templates["provider-compute-1.yaml"].wont_be_empty | ||
end | ||
|
||
it "#patch" do | ||
parameter = @instance.parameters.first | ||
@instance.patch( | ||
:parameters => [ | ||
{ | ||
"name" => parameter['name'], | ||
"value" => 'new_value' | ||
} | ||
] | ||
)["uuid"].must_be_kind_of String | ||
end | ||
|
||
it "#remove_role" do | ||
@instance.remove_role(@role['uuid']).status.must_equal 200 | ||
end | ||
|
||
it "#save" do | ||
@instance.save.must_be_kind_of Fog::Openstack::Planning::Plan | ||
end | ||
|
||
it "#update" do | ||
@instance.update.uuid.wont_be_empty | ||
end | ||
|
||
it "#destroy" do | ||
@instance.destroy.must_equal true | ||
end | ||
|
||
it "#create" do | ||
@instance.create.must_be_kind_of Fog::Openstack::Planning::Plan | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Openstack[:planning] | plans" do | ||
describe "success" do | ||
before do | ||
@planning = Fog::Openstack[:planning] | ||
@instance = @planning.plans.all.first | ||
end | ||
|
||
it "#all" do | ||
@instance.uuid.wont_be_empty | ||
end | ||
|
||
it "#get" do | ||
@planning.plans.get(@instance.uuid).uuid.must_equal @instance.uuid | ||
end | ||
|
||
it "#find_by_*" do | ||
plan = @planning.plans.find_by_name(@instance.name) | ||
plan.name.must_equal @instance.name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Openstack[:planning] | plan" do | ||
describe "success" do | ||
before do | ||
@instance = Fog::Openstack[:planning].roles.first | ||
@plan = Fog::Openstack[:planning].list_plans.body.first | ||
end | ||
|
||
it "#add_role" do | ||
@instance.add_to_plan(@plan['uuid']).status.must_equal 201 | ||
end | ||
|
||
it "#remove_role" do | ||
@instance.remove_from_plan(@plan['uuid']).status.must_equal 200 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Image[:openstack] | image requests" do | ||
before(:all) do | ||
openstack = Fog::Identity[:openstack] | ||
|
||
@image_attributes = { | ||
:name => 'new image', | ||
:owner => openstack.current_tenant['id'], | ||
:is_public => true, | ||
:copy_from => 'http://website.com/image.iso', | ||
:disk_format => 'iso', | ||
:properties => { | ||
:user_id => openstack.current_user['id'], | ||
:owner_id => openstack.current_tenant['id'] | ||
}, | ||
:container_format => 'bare' | ||
} | ||
|
||
@image_format = { | ||
'name' => String, | ||
'container_format' => String, | ||
'disk_format' => String, | ||
'checksum' => String, | ||
'id' => String, | ||
'size' => Integer | ||
} | ||
|
||
@detailed_image_format = { | ||
'id' => String, | ||
'name' => String, | ||
'size' => Integer, | ||
'disk_format' => String, | ||
'container_format' => String, | ||
'checksum' => String, | ||
'min_disk' => Integer, | ||
'created_at' => String, | ||
'deleted_at' => Fog::Nullable::String, | ||
'updated_at' => String, | ||
'deleted' => Fog::Boolean, | ||
'protected' => Fog::Boolean, | ||
'is_public' => Fog::Boolean, | ||
'status' => String, | ||
'min_ram' => Integer, | ||
'owner' => Fog::Nullable::String, | ||
'properties' => Hash | ||
} | ||
|
||
@image_meta_format = { | ||
'X-Image-Meta-Is_public' => String, | ||
'X-Image-Meta-Min_disk' => Fog::Nullable::String, | ||
'X-Image-Meta-Property-Ramdisk_id' => Fog::Nullable::String, | ||
'X-Image-Meta-Disk_format' => Fog::Nullable::String, | ||
'X-Image-Meta-Created_at' => String, | ||
'X-Image-Meta-Container_format' => Fog::Nullable::String, | ||
'Etag' => String, | ||
'Location' => String, | ||
'X-Image-Meta-Protected' => String, | ||
'Date' => String, | ||
'X-Image-Meta-Name' => String, | ||
'X-Image-Meta-Min_ram' => String, | ||
'Content-Type' => String, | ||
'X-Image-Meta-Updated_at' => String, | ||
'X-Image-Meta-Property-Kernel_id' => Fog::Nullable::String, | ||
'X-Image-Meta-Size' => String, | ||
'X-Image-Meta-Checksum' => Fog::Nullable::String, | ||
'X-Image-Meta-Deleted' => String, | ||
'Content-Length' => String, | ||
'X-Image-Meta-Status' => String, | ||
'X-Image-Meta-Owner' => String, | ||
'X-Image-Meta-Id' => String | ||
} | ||
|
||
@image_members_format = [ | ||
{ | ||
'can_share' => Fog::Nullable::Boolean, | ||
'member_id' => String | ||
} | ||
] | ||
end | ||
|
||
describe "success" do | ||
it "#list_public_images" do | ||
Fog::Image[:openstack].list_public_images.body.must_match_schema('images' => [@image_format]) | ||
end | ||
|
||
it "#list_public_images_detailed" do | ||
Fog::Image[:openstack].list_public_images_detailed.body. | ||
must_match_schema('images' => [@detailed_image_format]) | ||
end | ||
|
||
before do | ||
if Fog.mocking? | ||
image_attributes = @image_attributes | ||
else | ||
require 'tempfile' | ||
image_attributes = @image_attributes.dup | ||
image_attributes.delete(:copy_from) | ||
@test_iso = Tempfile.new(['fog_test_iso', '.iso']) | ||
@test_iso.write Fog::Mock.random_hex(32) | ||
@test_iso.close | ||
image_attributes[:location] = @test_iso.path | ||
end | ||
|
||
@instance = Fog::Image[:openstack].create_image(image_attributes).body | ||
end | ||
|
||
it "#create_image" do | ||
@instance.must_match_schema('image' => @detailed_image_format) | ||
end | ||
|
||
after do | ||
@test_iso.delete if @test_iso | ||
end | ||
|
||
it "#get_image" do | ||
Fog::Image[:openstack].get_image(@instance['image']['id']).headers. | ||
must_match_schema(@image_meta_format) | ||
end | ||
|
||
it "#update_image" do | ||
Fog::Image[:openstack].update_image( | ||
:id => @instance['image']['id'], | ||
:name => 'edit image' | ||
).body['image'].must_match_schema(@detailed_image_format) | ||
end | ||
|
||
it "#add_member_to_image" do | ||
Fog::Image[:openstack].add_member_to_image( | ||
@instance['image']['id'], @instance['image']['owner'] | ||
).status.must_equal 200 | ||
end | ||
|
||
it "#get_image_members" do | ||
Fog::Image[:openstack].get_image_members(@instance['image']['id']).status.must_equal 200 | ||
end | ||
|
||
it "#get_shared_images" do | ||
Fog::Image[:openstack].get_shared_images(@instance['image']['owner']).status.must_equal 200 | ||
end | ||
|
||
it "#remove_member_from_image" do | ||
Fog::Image[:openstack].remove_member_from_image( | ||
@instance['image']['id'], @instance['image']['owner']).status.must_equal 200 | ||
end | ||
|
||
it "#delete_image" do | ||
Fog::Image[:openstack].delete_image(@instance['image']['id']).status.must_equal 200 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
require "test_helper" | ||
|
||
describe "Fog::Openstack[:planning] | Planning plan requests" do | ||
before do | ||
@plan_format = { | ||
"created_at" => Fog::Nullable::String, | ||
"description" => Fog::Nullable::String, | ||
"name" => String, | ||
"parameters" => Fog::Nullable::Array, | ||
"roles" => Fog::Nullable::Array, | ||
"updated_at" => Fog::Nullable::String, | ||
"uuid" => String, | ||
"version" => Fog::Nullable::Integer | ||
} | ||
|
||
@plan_templates_format = Hash | ||
@plans = Fog::Openstack[:planning].list_plans.body | ||
@instance = @plans.first | ||
@role_instance = Fog::Openstack[:planning].list_roles.body.first | ||
end | ||
|
||
describe "success" do | ||
it "#list_plans" do | ||
@plans.must_match_schema([@plan_format]) | ||
end | ||
|
||
it "#get_plan" do | ||
Fog::Openstack[:planning].get_plan(@instance['uuid']).body.must_match_schema(@plan_format) | ||
end | ||
|
||
it "#delete_plan" do | ||
Fog::Openstack[:planning].delete_plan(@instance['uuid']).status.must_equal 204 | ||
end | ||
|
||
it "#create_plan" do | ||
plan_attributes = { | ||
:name => 'test-plan-name', | ||
:description => 'test-plan-desc', | ||
} | ||
@instance = Fog::Openstack[:planning].create_plan(plan_attributes).body | ||
@instance.must_match_schema(@plan_format) | ||
end | ||
|
||
it "#add_role_to_plan" do | ||
Fog::Openstack[:planning].add_role_to_plan( | ||
@instance['uuid'], | ||
@role_instance['uuid'] | ||
).body.must_match_schema(@plan_format) | ||
end | ||
|
||
it "#patch_plan" do | ||
parameters = Fog::Openstack[:planning].get_plan(@instance['uuid']). | ||
body['parameters'][0..1] | ||
plan_parameters = parameters.collect do |parameter| | ||
{ | ||
"name" => parameter['name'], | ||
"value" => "test-#{parameter['name']}-value", | ||
} | ||
end | ||
Fog::Openstack[:planning].patch_plan(@instance['uuid'], plan_parameters).body. | ||
must_match_schema(@plan_format) | ||
end | ||
|
||
it "#get_plan_templates" do | ||
Fog::Openstack[:planning].get_plan_templates(@instance['uuid']).body. | ||
must_match_schema(@plan_templates_format) | ||
end | ||
|
||
it "#remove_role_from_plan" do | ||
Fog::Openstack[:planning].remove_role_from_plan( | ||
@instance['uuid'], @role_instance['uuid'] | ||
).body.must_match_schema(@plan_format) | ||
end | ||
end | ||
end |
Oops, something went wrong.