diff --git a/test/requests/metering/event_tests.rb b/test/requests/metering/event_tests.rb new file mode 100644 index 000000000..237c766f9 --- /dev/null +++ b/test/requests/metering/event_tests.rb @@ -0,0 +1,23 @@ +require "test_helper" + +describe "Fog::Metering[:openstack] | event requests" do + before do + @metering = Fog::Metering[:openstack] + @event_format = { + 'message_id' => String, + 'event_type' => String + } + end + + describe "success" do + it "#list_events" do + @metering.list_events.body. + must_match_schema([@event_format]) + end + + it "#get_event" do + @metering.get_event('test').body. + must_match_schema(@event_format) + end + end +end diff --git a/test/requests/metering/meter_tests.rb b/test/requests/metering/meter_tests.rb new file mode 100644 index 000000000..890121dd5 --- /dev/null +++ b/test/requests/metering/meter_tests.rb @@ -0,0 +1,58 @@ +require "test_helper" + +describe "Fog::Metering[:openstack] | meter requests" do + before do + @metering = Fog::Metering[:openstack] + + @sample_format = { + 'counter_name' => String, + 'user_id' => String, + 'resource_id' => String, + 'timestamp' => String, + 'resource_metadata' => Hash, + 'source' => String, + 'counter_unit' => String, + 'counter_volume' => Float, + 'project_id' => String, + 'message_id' => String, + 'counter_type' => String + } + + @meter_format = { + 'user_id' => String, + 'name' => String, + 'resource_id' => String, + 'project_id' => String, + 'type' => String, + 'unit' => String + } + + @statistics_format = { + 'count' => Integer, + 'duration_start' => String, + 'min' => Float, + 'max' => Float, + 'duration_end' => String, + 'period' => Integer, + 'period_end' => String, + 'duration' => Float, + 'period_start' => String, + 'avg' => Float, + 'sum' => Float + } + end + + describe "success" do + it "#list_meters" do + @metering.list_meters.body.must_match_schema([@meter_format]) + end + + it "#get_samples" do + @metering.get_samples('test').body.must_match_schema([@sample_format]) + end + + it "#get_statistics" do + @metering.get_statistics('test').body.must_match_schema([@statistics_format]) + end + end +end diff --git a/test/requests/metering/resource_tests.rb b/test/requests/metering/resource_tests.rb new file mode 100644 index 000000000..0ac533eb8 --- /dev/null +++ b/test/requests/metering/resource_tests.rb @@ -0,0 +1,24 @@ +require "test_helper" + +describe "Fog::Metering[:openstack] | resource requests" do + before do + @metering = Fog::Metering[:openstack] + + @resource_format = { + 'resource_id' => String, + 'project_id' => String, + 'user_id' => String, + 'metadata' => Hash + } + end + + describe "success" do + it "#list_resource" do + @metering.list_resources.body.must_match_schema([@resource_format]) + end + + it "#get_resource" do + @metering.get_resource('test').body.must_match_schema(@resource_format) + end + end +end diff --git a/test/requests/orchestration/stack_tests.rb b/test/requests/orchestration/stack_tests.rb new file mode 100644 index 000000000..462846596 --- /dev/null +++ b/test/requests/orchestration/stack_tests.rb @@ -0,0 +1,70 @@ +require "test_helper" + +describe "Fog::Orchestration[:openstack] | stack requests" do + before do + @orchestration = Fog::Orchestration[:openstack] + + @stack_format = { + 'links' => Array, + 'id' => String, + 'stack_name' => String, + 'description' => Fog::Nullable::String, + 'stack_status' => String, + 'stack_status_reason' => String, + 'creation_time' => Time, + 'updated_time' => Time + } + + @stack_detailed_format = { + "parent" => Fog::Nullable::String, + "disable_rollback" => Fog::Boolean, + "description" => String, + "links" => Array, + "stack_status_reason" => String, + "stack_name" => String, + "stack_user_project_id" => String, + "stack_owner" => String, + "creation_time" => Fog::Nullable::String, + "capabilities" => Array, + "notification_topics" => Array, + "updated_time" => Fog::Nullable::String, + "timeout_mins" => Fog::Nullable::String, + "stack_status" => String, + "parameters" => Hash, + "id" => String, + "outputs" => Array, + "template_description" => String + } + + @create_format = { + 'id' => String, + 'links' => Array, + } + end + + describe "success" do + it "#create_stack" do + @stack = @orchestration.create_stack("teststack").body.must_match_schema(@create_format) + end + + it "#list_stack_data" do + @orchestration.list_stack_data.body.must_match_schema('stacks' => [@stack_format]) + end + + it "#list_stack_data_Detailed" do + @orchestration.list_stack_data_detailed.body.must_match_schema('stacks' => [@stack_detailed_format]) + end + + it "#update_stack" do + @orchestration.update_stack("teststack").body.must_match_schema({}) + end + + it "#patch_stack" do + @orchestration.patch_stack(@stack).body.must_match_schema({}) + end + + it "#delete_stack" do + @orchestration.delete_stack("teststack", "id").body.must_match_schema({}) + end + end +end diff --git a/test/requests/volume/availability_zone_tests.rb b/test/requests/volume/availability_zone_tests.rb new file mode 100644 index 000000000..9d268c91e --- /dev/null +++ b/test/requests/volume/availability_zone_tests.rb @@ -0,0 +1,17 @@ +require 'test_helper' + +describe "Fog::Volume[:openstack] | availability zone requests" do + before do + @flavor_format = { + 'zoneName' => String, + 'zoneState' => Hash + } + end + + describe "success" do + it "#list_zones" do + Fog::Volume[:openstack].list_zones.body. + must_match_schema('availabilityZoneInfo' => [@flavor_format]) + end + end +end diff --git a/test/requests/volume/quota_tests.rb b/test/requests/volume/quota_tests.rb new file mode 100644 index 000000000..5b7690012 --- /dev/null +++ b/test/requests/volume/quota_tests.rb @@ -0,0 +1,36 @@ +require 'test_helper' + +describe "Fog::Volume[:openstack] | quota requests" do + before do + @volume = Fog::Volume[:openstack] + @tenant_id = Fog::Compute[:openstack].list_tenants.body['tenants'].first['id'] + @quota_set_format = { + 'volumes' => Fog::Nullable::Integer, + 'gigabytes' => Fog::Nullable::Integer, + 'snapshots' => Fog::Nullable::Integer, + 'id' => String + } + @quota = @volume.get_quota(@tenant_id).body['quota_set'] + end + + describe "success" do + it "#get_quota_defaults" do + @volume.get_quota_defaults(@tenant_id).body. + must_match_schema('quota_set' => @quota_set_format) + end + + it "#get_quota" do + @quota.must_match_schema(@quota_set_format) + end + + it "updates quota" do + @new_values = @quota.merge( + 'volumes' => @quota['volumes'] / 2, + 'snapshots' => @quota['snapshots'] / 2 + ) + + @volume.update_quota(@tenant_id, @new_values.clone) + @volume.get_quota(@tenant_id).body['quota_set'].must_match_schema @new_values + end + end +end diff --git a/test/requests/volume/volume_type_tests.rb b/test/requests/volume/volume_type_tests.rb new file mode 100644 index 000000000..242f02117 --- /dev/null +++ b/test/requests/volume/volume_type_tests.rb @@ -0,0 +1,42 @@ +require 'test_helper' + +describe "Fog::Volume[:openstack] | volume_type requests" do + before do + @volume = Fog::Volume[:openstack] + + @volume_type_format = { + 'name' => String, + 'extra_specs' => Hash, + 'id' => String + } + + @volume_type = @volume.create_volume_type(:name => 'test_volume_type').body['volume_type'] + end + + describe "success" do + it "#create_volume_type" do + @volume_type.must_match_schema(@volume_type_format) + end + + it "#update_volume_type" do + @volume.update_volume_type( + @volume_type['id'], + :name => 'test_volume_type_1' + ).body['volume_type'].must_match_schema(@volume_type_format) + end + + it "#get_volume_type" do + @volume.get_volume_type_details(@volume_type['id']).body['volume_type']. + must_match_schema(@volume_type_format) + end + + it "#list_volume_type" do + @volume.list_volume_types.body['volume_types']. + must_match_schema([@volume_type_format]) + end + + it 'delete the volute type' do + @volume.delete_volume_type(@volume_type['id']) + end + end +end diff --git a/tests/openstack/requests/metering/event_tests.rb b/tests/openstack/requests/metering/event_tests.rb deleted file mode 100644 index b5f093548..000000000 --- a/tests/openstack/requests/metering/event_tests.rb +++ /dev/null @@ -1,17 +0,0 @@ -Shindo.tests('Fog::Metering[:openstack] | event requests', ['openstack']) do - - @event_format = { - 'message_id' => String, - 'event_type' => String, - } - - tests('success') do - tests('#list_events').formats([@event_format]) do - Fog::Metering[:openstack].list_events.body - end - - tests('#get_event').formats(@event_format) do - Fog::Metering[:openstack].get_event('test').body - end - end -end diff --git a/tests/openstack/requests/metering/meter_tests.rb b/tests/openstack/requests/metering/meter_tests.rb deleted file mode 100644 index 1ae6c3fe5..000000000 --- a/tests/openstack/requests/metering/meter_tests.rb +++ /dev/null @@ -1,52 +0,0 @@ -Shindo.tests('Fog::Metering[:openstack] | meter requests', ['openstack']) do - - @sample_format = { - 'counter_name' => String, - 'user_id' => String, - 'resource_id' => String, - 'timestamp' => String, - 'resource_metadata' => Hash, - 'source' => String, - 'counter_unit' => String, - 'counter_volume' => Float, - 'project_id' => String, - 'message_id' => String, - 'counter_type' => String - } - - @meter_format = { - 'user_id' => String, - 'name' => String, - 'resource_id' => String, - 'project_id' => String, - 'type' => String, - 'unit' => String - } - - @statistics_format = { - 'count' => Integer, - 'duration_start' => String, - 'min' => Float, - 'max' => Float, - 'duration_end' => String, - 'period' => Integer, - 'period_end' => String, - 'duration' => Float, - 'period_start' => String, - 'avg' => Float, - 'sum' => Float - } - tests('success') do - tests('#list_meters').formats([@meter_format]) do - Fog::Metering[:openstack].list_meters.body - end - - tests('#get_samples').formats([@sample_format]) do - Fog::Metering[:openstack].get_samples('test').body - end - - tests('#get_statistics').formats([@statistics_format]) do - Fog::Metering[:openstack].get_statistics('test').body - end - end -end diff --git a/tests/openstack/requests/metering/resource_tests.rb b/tests/openstack/requests/metering/resource_tests.rb deleted file mode 100644 index fc1c85d88..000000000 --- a/tests/openstack/requests/metering/resource_tests.rb +++ /dev/null @@ -1,19 +0,0 @@ -Shindo.tests('Fog::Metering[:openstack] | resource requests', ['openstack']) do - - @resource_format = { - 'resource_id' => String, - 'project_id' => String, - 'user_id' => String, - 'metadata' => Hash, - } - - tests('success') do - tests('#list_resource').formats([@resource_format]) do - Fog::Metering[:openstack].list_resources.body - end - - tests('#get_resource').formats(@resource_format) do - Fog::Metering[:openstack].get_resource('test').body - end - end -end diff --git a/tests/openstack/requests/orchestration/stack_tests.rb b/tests/openstack/requests/orchestration/stack_tests.rb deleted file mode 100644 index c3d3b00c9..000000000 --- a/tests/openstack/requests/orchestration/stack_tests.rb +++ /dev/null @@ -1,64 +0,0 @@ -Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) do - @stack_format = { - 'links' => Array, - 'id' => String, - 'stack_name' => String, - 'description' => Fog::Nullable::String, - 'stack_status' => String, - 'stack_status_reason' => String, - 'creation_time' => Time, - 'updated_time' => Time - } - - @stack_detailed_format = { - "parent" => Fog::Nullable::String, - "disable_rollback" => Fog::Boolean, - "description" => String, - "links" => Array, - "stack_status_reason" => String, - "stack_name" => String, - "stack_user_project_id" => String, - "stack_owner" => String, - "creation_time" => Fog::Nullable::String, - "capabilities" => Array, - "notification_topics" => Array, - "updated_time" => Fog::Nullable::String, - "timeout_mins" => Fog::Nullable::String, - "stack_status" => String, - "parameters" => Hash, - "id" => String, - "outputs" => Array, - "template_description" => String - } - - @create_format = { - 'id' => String, - 'links' => Array, - } - - tests('success') do - tests('#create_stack("teststack")').formats(@create_format) do - @stack = Fog::Orchestration[:openstack].create_stack("teststack").body - end - - tests('#list_stack_data').formats({'stacks' => [@stack_format]}) do - Fog::Orchestration[:openstack].list_stack_data.body - end - - tests('#list_stack_data_Detailed').formats({'stacks' => [@stack_detailed_format]}) do - Fog::Orchestration[:openstack].list_stack_data_detailed.body - end - - tests('#update_stack("teststack")').formats({}) do - Fog::Orchestration[:openstack].update_stack("teststack").body - end - - tests('#patch_stack("teststack")').formats({}) do - Fog::Orchestration[:openstack].patch_stack(@stack).body - end - - tests('#delete_stack("teststack", "id")').formats({}) do - Fog::Orchestration[:openstack].delete_stack("teststack", "id").body - end - end -end diff --git a/tests/openstack/requests/volume/availability_zone_tests.rb b/tests/openstack/requests/volume/availability_zone_tests.rb deleted file mode 100644 index d9f604560..000000000 --- a/tests/openstack/requests/volume/availability_zone_tests.rb +++ /dev/null @@ -1,13 +0,0 @@ -Shindo.tests('Fog::Volume[:openstack] | availability zone requests', ['openstack']) do - - @flavor_format = { - 'zoneName' => String, - 'zoneState' => Hash, - } - - tests('success') do - tests('#list_zones').data_matches_schema({'availabilityZoneInfo' => [@flavor_format]}) do - Fog::Volume[:openstack].list_zones.body - end - end -end diff --git a/tests/openstack/requests/volume/quota_tests.rb b/tests/openstack/requests/volume/quota_tests.rb deleted file mode 100644 index 1531f16b6..000000000 --- a/tests/openstack/requests/volume/quota_tests.rb +++ /dev/null @@ -1,50 +0,0 @@ -Shindo.tests('Fog::Volume[:openstack] | quota requests', ['openstack']) do - - @tenant_id = Fog::Compute[:openstack].list_tenants.body['tenants'].first['id'] - @quota_set_format = { - 'volumes' => Fog::Nullable::Integer, - 'gigabytes' => Fog::Nullable::Integer, - 'snapshots' => Fog::Nullable::Integer, - 'id' => String - } - - tests('success') do - - tests('#get_quota_defaults').formats({ 'quota_set' => @quota_set_format }) do - Fog::Volume[:openstack].get_quota_defaults(@tenant_id).body - end - - tests('#get_quota').formats(@quota_set_format) do - @quota = Fog::Volume[:openstack].get_quota(@tenant_id).body['quota_set'] - @quota - end - - tests('#update_quota') do - - new_values = @quota.merge({ - 'volumes' => @quota['volumes']/2, - 'snapshots' => @quota['snapshots']/2 - }) - - succeeds do - Fog::Volume[:openstack].update_quota(@tenant_id, new_values.clone) - end - - returns(new_values, 'returns new values') do - Fog::Volume[:openstack].get_quota(@tenant_id).body['quota_set'] - end - - # set quota back to old values - succeeds do - Fog::Volume[:openstack].update_quota(@tenant_id, @quota.clone) - end - - # ensure old values are restored - returns(@quota, 'old values restored') do - Fog::Volume[:openstack].get_quota(@tenant_id).body['quota_set'] - end - - end - - end -end diff --git a/tests/openstack/requests/volume/volume_type_tests.rb b/tests/openstack/requests/volume/volume_type_tests.rb deleted file mode 100644 index 6e0a09068..000000000 --- a/tests/openstack/requests/volume/volume_type_tests.rb +++ /dev/null @@ -1,32 +0,0 @@ -Shindo.tests('Fog::Volume[:openstack] | volume_type requests', ['openstack']) do - - @volume_type_format = { - 'name' => String, - 'extra_specs' => Hash, - 'id' => String - } - - tests('success') do - tests('#create_volume_type').formats(@volume_type_format) do - @volume_type = Fog::Volume[:openstack].create_volume_type(:name => 'test_volume_type').body['volume_type'] - @volume_type - end - - tests('#update_volume_type').formats(@volume_type_format) do - Fog::Volume[:openstack].update_volume_type(@volume_type['id'], - :name => 'test_volume_type_1').body['volume_type'] - end - - tests('#get_volume_type').formats(@volume_type_format) do - Fog::Volume[:openstack].get_volume_type_details(@volume_type['id']).body['volume_type'] - end - - tests('#list_volume_type').formats([@volume_type_format]) do - Fog::Volume[:openstack].list_volume_types.body['volume_types'] - end - - succeeds do - Fog::Volume[:openstack].delete_volume_type(@volume_type['id']) - end - end -end