Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bucher committed May 15, 2020
1 parent fc6df6e commit 39113f0
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 1 deletion.
53 changes: 53 additions & 0 deletions test/actions/katello/capsule_content_test.rb
Expand Up @@ -97,6 +97,59 @@ class SyncTest < TestBase
end
end

it 'plans correctly for a pulp3 apt repo' do
with_pulp3_features(capsule_content.smart_proxy)
capsule_content.smart_proxy.add_lifecycle_environment(environment)
repo = katello_repositories(:pulp3_deb_1)
tree = plan_action_tree(action_class, capsule_content.smart_proxy, :repository_id => repo.id)
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
environment_id: nil
}

assert_tree_planned_with(tree, ::Actions::Pulp::Orchestration::Repository::RefreshRepos, options)
assert_tree_planned_with(tree, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, options)

assert_tree_planned_with(tree, ::Actions::Pulp3::CapsuleContent::Sync) do |input|
assert_equal capsule_content.smart_proxy.id, input[:smart_proxy_id]
assert_equal repo.id, input[:repository_id]
end

assert_tree_planned_with(tree, ::Actions::Pulp3::CapsuleContent::GenerateMetadata) do |input|
assert_equal capsule_content.smart_proxy.id, input[:smart_proxy_id]
assert_equal repo.id, input[:repository_id]
end

assert_tree_planned_with(tree, Actions::Pulp3::CapsuleContent::RefreshDistribution) do |input|
assert_equal capsule_content.smart_proxy.id, input[:smart_proxy_id]
assert_equal repo.id, input[:repository_id]
refute input[:options][:use_repository_version]
assert input[:options][:tasks].present?
end
end

it 'plans correctly for a pulp2 apt repo' do
capsule_content.smart_proxy.add_lifecycle_environment(environment)
SmartProxy.any_instance.stubs(:pulp3_support?).returns(false)
repo = katello_repositories(:debian_9_amd64)
tree = plan_action_tree(action_class, capsule_content.smart_proxy, :repository_id => repo.id)
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
environment_id: nil
}

assert_tree_planned_with(tree, ::Actions::Pulp::Orchestration::Repository::RefreshRepos, options)
assert_tree_planned_with(tree, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, options)

assert_tree_planned_with(tree, Actions::Pulp::Consumer::SyncCapsule) do |input|
assert_equal capsule_content.smart_proxy.id, input[:capsule_id]
assert_equal repo.pulp_id, input[:repo_pulp_id]
assert input[:sync_options][:remove_missing]
end
end

it 'plans correctly for a pulp2 yum repo' do
capsule_content.smart_proxy.add_lifecycle_environment(environment)
SmartProxy.any_instance.stubs(:pulp3_support?).returns(false)
Expand Down
36 changes: 36 additions & 0 deletions test/actions/katello/repository_test.rb
Expand Up @@ -14,6 +14,7 @@ class TestBase < ActiveSupport::TestCase
let(:repository) { katello_repositories(:rhel_6_x86_64) }
let(:repository_pulp3) { katello_repositories(:pulp3_file_1) }
let(:repository_ansible_collection_pulp3) { katello_repositories(:pulp3_ansible_collection_1) }
let(:repository_apt_pulp3) { katello_repositories(:pulp3_deb_1) }
let(:custom_repository) { katello_repositories(:fedora_17_x86_64) }
let(:puppet_repository) { katello_repositories(:p_forge) }
let(:docker_repository) { katello_repositories(:redis) }
Expand Down Expand Up @@ -481,6 +482,23 @@ class SyncTest < TestBase
assert_action_planed_with(action, ::Actions::Pulp3::Repository::RefreshDistribution, repository_pulp3, proxy, :contents_changed => true)
end

it 'plans pulp3 orchestration actions with apt repo' do
action = create_action pulp3_action_class
action.stubs(:action_subject).with(repository_apt_pulp3)
plan_action action, repository_apt_pulp3, proxy, {}
assert_action_planed_with(action, ::Actions::Pulp3::Repository::Sync, repository_apt_pulp3, proxy, {})
assert_action_planed action, ::Actions::Pulp3::Repository::SaveVersion
assert_action_planed action, ::Actions::Pulp3::Orchestration::Repository::GenerateMetadata
end

it 'plans pulp3 apt metadata generate with contents_changed' do
action = create_action pulp3_metadata_generate_action_class
action.stubs(:action_subject).with(repository_apt_pulp3)
plan_action action, repository_apt_pulp3, proxy, :contents_changed => true
assert_action_planed_with(action, ::Actions::Pulp3::Repository::CreatePublication, repository_apt_pulp3, proxy, :contents_changed => true)
assert_action_planed_with(action, ::Actions::Pulp3::Repository::RefreshDistribution, repository_apt_pulp3, proxy, :contents_changed => true)
end

it 'plans pulp3 ansible collection metadata generate without publication ' do
action = create_action pulp3_metadata_generate_action_class
action.stubs(:action_subject).with(repository_ansible_collection_pulp3)
Expand Down Expand Up @@ -593,6 +611,24 @@ class SyncTest < TestBase
end
end

describe 'successfully synchronized pulp3 apt repo' do
let(:fixture_variant) { :success_apt }

specify do
assert_equal action.humanized_output, "Total tasks: : 93/93\n"\
"--------------------------------\n"\
"Associating Content: 67/67\n"\
"Downloading Artifacts: 16/16\n"\
"Un-Associating Content: 7/7\n"\
"Update PackageIndex units: 2/2\n"\
"Update ReleaseFile units: 1/1"
end

specify do
pulp3_action.run_progress.must_be_within_delta 1
end
end

describe 'syncing files in progress' do
let(:fixture_variant) { :progress_units_file }

Expand Down
35 changes: 35 additions & 0 deletions test/fixtures/actions/pulp3/repository/sync/success_apt.yaml
@@ -0,0 +1,35 @@
---
pulp_tasks:
- pulp_href: "/pulp/api/v3/tasks/aae95f53-bbdb-4c7a-8795-0da3bc1cf318/"
pulp_created: '2020-04-24T13:47:48.666+00:00'
state: completed
name: pulp_deb.app.tasks.synchronizing.synchronize
started_at: '2020-04-24T13:47:48.783+00:00'
finished_at: '2020-04-24T13:47:56.229+00:00'
worker: "/pulp/api/v3/workers/8fd4352b-d961-4e02-a78e-68b7b79eec60/"
progress_reports:
- message: Downloading Artifacts
code: downloading.artifacts
state: completed
done: 16
- message: Update ReleaseFile units
code: update.release_file
state: completed
done: 1
- message: Update PackageIndex units
code: update.packageindex
state: completed
done: 2
- message: Associating Content
code: associating.content
state: completed
done: 67
- message: Un-Associating Content
code: unassociating.content
state: completed
done: 7
created_resources:
- "/pulp/api/v3/repositories/deb/apt/e1e243cf-b0f9-4036-80b1-8740373b51dc/versions/2/"
reserved_resources_record:
- "/pulp/api/v3/repositories/deb/apt/e1e243cf-b0f9-4036-80b1-8740373b51dc/"
- "/pulp/api/v3/remotes/deb/apt/5fc64e41-baf4-4b8a-b36d-005540ace540/"
7 changes: 7 additions & 0 deletions test/fixtures/models/katello_repositories.yml
Expand Up @@ -375,3 +375,10 @@ pulp3_docker_1:
relative_path: '/Default_Organization/library/pulp3_Docker_1'
environment_id: <%= ActiveRecord::FixtureSet.identify(:library) %>
content_view_version_id: <%= ActiveRecord::FixtureSet.identify(:library_default_version) %>

pulp3_deb_1:
root_id: <%= ActiveRecord::FixtureSet.identify(:pulp3_deb_root_1) %>
pulp_id: "Default_Organization-Cabinet-pulp3_Deb_1"
relative_path: 'Default_Organization/library/pulp3_Deb_1'
environment_id: <%= ActiveRecord::FixtureSet.identify(:library) %>
content_view_version_id: <%= ActiveRecord::FixtureSet.identify(:library_default_version) %>
12 changes: 12 additions & 0 deletions test/fixtures/models/katello_root_repositories.yml
Expand Up @@ -204,3 +204,15 @@ pulp3_docker_root_1:
unprotected: <%= true %>
url: "https://registry-1.docker.io/"
docker_upstream_name: "fedora/ssh"

pulp3_deb_root_1:
name: Pulp3 Deb 1
content_id: 11
content_type: deb
label: Pulp3_Deb_1
product_id: <%= ActiveRecord::FixtureSet.identify(:debian) %>
unprotected: <%= true %>
url: "http://ftp.debian.mymirror.org/debian"
deb_releases: buster
deb_components: main
deb_architectures: amd64

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions test/fixtures/vcr_cassettes/actions/pulp3/file_upload/upload.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions test/fixtures/vcr_cassettes/actions/pulp3/rpm_upload/upload.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39113f0

Please sign in to comment.