Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support operation "clear" on CloudObjectStoreContainer #153

Merged
merged 1 commit into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ class ManageIQ::Providers::Amazon::StorageManager::S3::CloudObjectStoreContainer
end
end

supports :cloud_object_store_container_clear do
unless ext_management_system
unsupported_reason_add(
:cloud_object_store_container_clear,
_("The Storage Container is not connected to an active %{table}") % {
:table => ui_lookup(:table => "ext_management_systems")
}
)
end

unless cloud_object_store_objects.count.positive?
unsupported_reason_add(:cloud_object_store_container_clear, _("The Storage Container is already empty"))
end
end

def provider_object(connection = nil)
connection ||= ext_management_system.connect
connection.bucket(ems_ref)
Expand All @@ -15,4 +30,8 @@ def provider_object(connection = nil)
def raw_delete
with_provider_object(&:delete!)
end

def raw_cloud_object_store_container_clear
with_provider_object(&:clear!)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,42 @@
expect(bucket.supports?(:delete)).to be_falsey
end
end

it "clear bucket (trigger)" do
options = {:ids => [bucket.id], :task => "cloud_object_store_container_clear", :userid => "admin"}

expect { CloudObjectStoreContainer.process_tasks(options) }.to change { MiqQueue.count }.by(1)
end

it "clear bucket (process)" do
with_aws_stubbed(stub_responses) do
# should not remove from MIQ database, we rather rely on refresh
expect { bucket.raw_cloud_object_store_container_clear }.to change { ems.cloud_object_store_objects.count }.by(0)
end
end

it "bucket with s3 should support clear" do
with_aws_stubbed(stub_responses) do
expect(bucket.supports?(:cloud_object_store_container_clear)).to be_truthy
end
end

it "bucket without s3 should not support clear" do
bucket.ext_management_system = nil
with_aws_stubbed(stub_responses) do
expect(bucket.supports?(:cloud_object_store_container_clear)).to be_falsey
end
end

it "bucket without objects should not support clear" do
bucket.cloud_object_store_objects = []

expect(bucket.cloud_object_store_objects.count).to eq(0)

with_aws_stubbed(stub_responses) do
expect(bucket.supports?(:cloud_object_store_container_clear)).to be_falsey
end
end
end

describe "destructive operations (objects)" do
Expand Down