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

Fixes #18972 - clean hosts with nil sub uuid #6691

Merged
merged 1 commit into from Mar 23, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/katello/tasks/clean_backend_objects.rake
Expand Up @@ -14,17 +14,17 @@ namespace :katello do
if host.content_facet.try(:uuid)
test_method { Katello.pulp_server.extensions.consumer.retrieve(host.content_facet.uuid) }
else
test_method { false }
false
end
end

def test_candlepin(host)
if host.subscription_facet && host.subscription_facet.uuid
test_method { ::Katello::Resources::Candlepin::Consumer.get(host.subscription_facet.uuid) }
elsif host.subscription_facet
test_method { true }
true
else
test_method { false }
false
end
end

Expand Down
13 changes: 13 additions & 0 deletions test/lib/tasks/clean_backend_objects_test.rb
Expand Up @@ -20,6 +20,19 @@ def clear_hosts(except_id = -1)
::Host.where("id != ?", except_id).destroy_all
end

def test_missing_nil_uuid
clear_hosts(@host.id)
ENV['COMMIT'] = 'true'

@host.subscription_facet.update_attributes!(:uuid => nil)

Katello::Candlepin::Consumer.expects(:orphaned_consumer_ids).returns([])

ForemanTasks.expects(:sync_task).with(::Actions::Katello::Host::Unregister, @host)

Rake.application.invoke_task('katello:clean_backend_objects')
end

def test_missing_cp_consumer_commit
clear_hosts(@host.id)
ENV['COMMIT'] = 'true'
Expand Down