-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37864 - API upload of deb-content fails
Actually it does not fail but worse, succeed with broken deb-package in katello due to saving the wrong pulp_href.
- Loading branch information
Showing
17 changed files
with
14,328 additions
and
2 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
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,81 @@ | ||
require 'katello_test_helper' | ||
|
||
module ::Actions::Pulp3 | ||
class DebUploadTest < ActiveSupport::TestCase | ||
include Katello::Pulp3Support | ||
|
||
def setup | ||
@primary = SmartProxy.pulp_primary | ||
@repo = katello_repositories(:debian_10_amd64) | ||
@content = katello_contents(:deb_content) | ||
@repo.content_id = @content.cp_content_id | ||
file1 = File.join(Katello::Engine.root, 'test/fixtures/files/frigg_1.0_ppc64.deb') | ||
file2 = File.join(Katello::Engine.root, 'test/fixtures/files/odin_1.0_ppc64.deb') | ||
@file1 = {path: file1, filename: 'frigg_1.0_ppc64.deb'} | ||
@file2 = {path: file2, filename: 'odin_1.0_ppc64.deb'} | ||
create_repo(@repo, @primary) | ||
::Katello::Resources::Candlepin::Content.stubs(:update) | ||
@content.stubs(:update!) | ||
end | ||
|
||
def teardown | ||
@repo.backend_service(@primary).delete_distributions | ||
@repo.backend_service(@primary).delete_publication | ||
ForemanTasks.sync_task( | ||
::Actions::Pulp3::Orchestration::Repository::Delete, @repo, @primary) | ||
end | ||
|
||
def test_upload | ||
@repo.reload | ||
assert @repo.remote_href | ||
deb_count = @repo.debs.count | ||
|
||
VCR.use_cassette(cassette_name + '_binary', :match_requests_on => [:method, :path, :params]) do | ||
action_result = ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::UploadContent, @repo, @primary, @file1, 'deb') | ||
assert_equal "success", action_result.result | ||
@repo.reload | ||
repository_reference = Katello::Pulp3::RepositoryReference.find_by( | ||
:root_repository_id => @repo.root.id, | ||
:content_view_id => @repo.content_view.id) | ||
assert_equal repository_reference.repository_href + "versions/2/", @repo.version_href | ||
|
||
upload_action = ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::UploadContent, @repo, @primary, @file2, 'deb') | ||
assert_equal "success", upload_action.result | ||
finish_upload_action = ForemanTasks.sync_task(::Actions::Katello::Repository::FinishUpload, @repo, content_type: 'deb', upload_actions: [upload_action.output]) | ||
assert_equal "success", finish_upload_action.result | ||
@repo.reload | ||
repository_reference = Katello::Pulp3::RepositoryReference.find_by( | ||
:root_repository_id => @repo.root.id, | ||
:content_view_id => @repo.content_view.id) | ||
assert_equal repository_reference.repository_href + "versions/3/", @repo.version_href | ||
assert_equal @repo.debs.count, deb_count + 1 | ||
end | ||
end | ||
|
||
def test_duplicate_upload | ||
action_result = "" | ||
@repo.reload | ||
assert @repo.remote_href | ||
|
||
VCR.use_cassette(cassette_name + '_binary', :match_requests_on => [:method, :path, :params]) do | ||
action_result = ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::UploadContent, @repo, @primary, @file1, 'deb') | ||
end | ||
assert_equal "success", action_result.result | ||
@repo.reload | ||
repository_reference = Katello::Pulp3::RepositoryReference.find_by( | ||
:root_repository_id => @repo.root.id, | ||
:content_view_id => @repo.content_view.id) | ||
assert_equal repository_reference.repository_href + "versions/2/", @repo.version_href | ||
|
||
VCR.use_cassette(cassette_name + '_binary_duplicate', :match_requests_on => [:method, :path, :params]) do | ||
action_result = ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::UploadContent, @repo, @primary, @file1, 'deb') | ||
end | ||
assert_equal "success", action_result.result | ||
@repo.reload | ||
repository_reference = Katello::Pulp3::RepositoryReference.find_by( | ||
:root_repository_id => @repo.root.id, | ||
:content_view_id => @repo.content_view.id) | ||
assert_equal repository_reference.repository_href + "versions/2/", @repo.version_href | ||
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,83 @@ | ||
require 'katello_test_helper' | ||
require 'pry' | ||
|
||
module ::Actions::Pulp3 | ||
class ImportUploadTest < ActiveSupport::TestCase | ||
include Katello::Pulp3Support | ||
|
||
def setup | ||
@primary = SmartProxy.pulp_primary | ||
@repo1 = katello_repositories(:debian_10_amd64) | ||
create_repo(@repo1, @primary) | ||
@repo2 = katello_repositories(:fedora_17_x86_64) | ||
create_repo(@repo2, @primary) | ||
@repo3 = katello_repositories(:generic_file) | ||
create_repo(@repo3, @primary) | ||
end | ||
|
||
def upload_file(content_unit_type, filename, repo) | ||
path = File.join(Katello::Engine.root, 'test/fixtures/files/', filename) | ||
content = File.read(path) | ||
file = {path: path, filename: filename, checksum: Digest::SHA256.hexdigest(content)} | ||
|
||
file.merge! repo.backend_content_service(@primary).create_upload( | ||
content.bytesize, | ||
file[:checksum], | ||
content_unit_type, | ||
repo | ||
) | ||
file[:upload_href] = repo.backend_content_service(@primary) | ||
.upload_chunk( | ||
file['upload_id'], 0, content, content.bytesize, | ||
).pulp_href | ||
|
||
file | ||
end | ||
|
||
def teardown | ||
[@repo1,@repo2,@repo3].each do |repo| | ||
Check failure on line 38 in test/actions/pulp3/orchestration/import_upload_test.rb GitHub Actions / Rubocop / Rubocop
|
||
repo.backend_service(@primary).delete_distributions | ||
repo.backend_service(@primary).delete_publication | ||
ForemanTasks.sync_task( | ||
::Actions::Pulp3::Orchestration::Repository::Delete, repo, @primary) | ||
end | ||
# cleanup orphaned content | ||
::Katello::Pulp3::Api::Core.new(@primary).orphans_api.cleanup( | ||
::PulpcoreClient::OrphansCleanup.new(orphan_protection_time: 0) | ||
) | ||
end | ||
|
||
def run_upload_test(content_unit_type, filename, repo, content_path_match) | ||
VCR.use_cassette(cassette_name + '_binary', :match_requests_on => [:method, :path, :params]) do | ||
file = upload_file(content_unit_type, filename, repo) | ||
|
||
action_result = ForemanTasks.sync_task( | ||
::Actions::Pulp3::Orchestration::Repository::ImportUpload, repo, @primary, | ||
{ | ||
unit_type_id: content_unit_type, | ||
upload_id: file['upload_id'], | ||
unit_key: { | ||
name: file[:filename], | ||
checksum: file[:checksum], | ||
} | ||
} | ||
) | ||
|
||
assert_equal 'success', action_result.result | ||
assert_match content_path_match, action_result.output[:content_unit_href] | ||
end | ||
end | ||
|
||
def test_deb_upload | ||
run_upload_test('deb', 'frigg_1.0_ppc64.deb', @repo1, %r{^/pulp/api/v3/content/deb/packages/}) | ||
end | ||
|
||
def test_file_upload | ||
run_upload_test('file', 'frigg_1.0_ppc64.deb', @repo3, %r{^/pulp/api/v3/content/file/files/}) | ||
end | ||
|
||
def test_rpm_upload | ||
run_upload_test('rpm', 'squirrel-0.3-0.8.noarch.rpm', @repo2, %r{^/pulp/api/v3/content/rpm/packages/}) | ||
end | ||
end | ||
end |
Binary file not shown.
Binary file not shown.
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
Oops, something went wrong.