Showing with 145 additions and 52 deletions.
  1. +8 −0 CHANGELOG.md
  2. +13 −0 manifests/plugin/rpm.pp
  3. +1 −1 metadata.json
  4. +1 −51 spec/acceptance/basic_spec.rb
  5. +51 −0 spec/acceptance/worker_count_spec.rb
  6. +11 −0 spec/classes/plugin_rpm_spec.rb
  7. +60 −0 spec/classes/pulpcore_spec.rb
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [5.1.0](https://github.com/theforeman/puppet-pulpcore/tree/5.1.0) (2022-01-25)

[Full Changelog](https://github.com/theforeman/puppet-pulpcore/compare/5.1.0...5.1.0)

**Implemented enhancements:**

- Fixes [\#34298](https://projects.theforeman.org/issues/34298) - support KEEP\_CHANGELOG\_LIMIT option [\#242](https://github.com/theforeman/puppet-pulpcore/pull/242) ([wbclark](https://github.com/wbclark))

## [5.1.0](https://github.com/theforeman/puppet-pulpcore/tree/5.1.0) (2021-10-29)

[Full Changelog](https://github.com/theforeman/puppet-pulpcore/compare/5.0.0...5.1.0)
Expand Down
13 changes: 13 additions & 0 deletions manifests/plugin/rpm.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# @summary Pulp RPM plugin
# @param use_pulp2_content_route
# Whether to redirect the legacy (Pulp 2) URLs to the content server
#
# @param keep_changelog_limit
# Pulpcore's KEEP_CHANGELOG_LIMIT setting. Uses Pulpcore's default when
# undefined. Increasing this limit will cause pulpcore workers to use more
# memory when more changelogs are available in the repo metadata.
class pulpcore::plugin::rpm (
Boolean $use_pulp2_content_route = false,
Optional[Integer[0]] $keep_changelog_limit = undef,
) {
if $use_pulp2_content_route {
$context = {
Expand All @@ -28,8 +34,15 @@
$content = undef
}

if $keep_changelog_limit {
$rpm_plugin_config = "KEEP_CHANGELOG_LIMIT = ${keep_changelog_limit}"
} else {
$rpm_plugin_config = undef
}

pulpcore::plugin { 'rpm':
http_content => $content,
https_content => $content,
config => $rpm_plugin_config,
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theforeman-pulpcore",
"version": "5.1.0",
"version": "5.2.0",
"author": "theforeman",
"summary": "Installs next generation Pulp server",
"license": "GPL-3.0-or-later",
Expand Down
52 changes: 1 addition & 51 deletions spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 2,
}
include pulpcore
PUPPET
end
end
Expand Down Expand Up @@ -38,11 +36,6 @@ class { 'pulpcore':
it { is_expected.to be_running }
end

describe service('pulpcore-worker@3') do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end

describe port(80) do
it { is_expected.to be_listening }
end
Expand Down Expand Up @@ -86,49 +79,6 @@ class { 'pulpcore':
end
end

describe 'reducing worker count' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-api') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-content') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-resource-manager') do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('pulpcore-worker@2') do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end

end

describe 'with content cache enabled' do
certdir = '/etc/pulpcore-certs'

Expand Down
51 changes: 51 additions & 0 deletions spec/acceptance/worker_count_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'spec_helper_acceptance'

describe 'configures pulpcore worker count', :order => :defined do
context 'initial configuration with 2 pulpcore workers' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 2,
}
PUPPET
end
end

[1,2].each do |i|
describe service("pulpcore-worker@#{i}") do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end

describe service('pulpcore-worker@3') do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end
end

context 'reconfigure to use 1 pulpcore worker' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
worker_count => 1,
}
PUPPET
end
end

describe service('pulpcore-worker@1') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

[2,3].each do |i|
describe service("pulpcore-worker@#{i}") do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end
end
end
end
11 changes: 11 additions & 0 deletions spec/classes/plugin_rpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
is_expected.to contain_pulpcore__plugin('rpm')
.that_subscribes_to('Class[Pulpcore::Install]')
.that_notifies(['Class[Pulpcore::Database]', 'Class[Pulpcore::Service]'])
is_expected.not_to contain_concat__fragment('plugin-rpm')
end

context 'with keep_changelog_limit' do
let(:params) { { keep_changelog_limit: 20 } }

it 'configures pulpcore with KEEP_CHANGELOG_LIMIT' do
is_expected.to compile.with_all_deps
is_expected.to contain_concat__fragment('plugin-rpm')
.with_content("\n# rpm plugin settings\nKEEP_CHANGELOG_LIMIT = 20")
end
end

context 'with pulp2 content route' do
Expand Down
60 changes: 60 additions & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,66 @@
.with_content(%r{^WORKER_TTL = 60$})
end
end

context 'with 24 processors from facts and default worker_count' do
let(:facts) { override_facts(os_facts, processors: {count: 24}) }

it 'enables only 8 pulpcore workers' do
(1..8).each do |i|
is_expected.to contain_service("pulpcore-worker@#{i}.service")
.with_ensure(true)
.with_enable(true)
end

(9..24).each do |i|
is_expected.not_to contain_service("pulpcore-worker@#{i}.service")
end
end
end

context 'with 24 workers previously enabled and reset to default worker_count' do
let(:facts) {
override_facts(
os_facts,
processors: {count: 24},
pulpcore_workers: (1..24).map { |i| "pulpcore-worker@#{i}.service" }
)
}

it 'enables 8 pulpcore workers' do
(1..8).each do |i|
is_expected.to contain_service("pulpcore-worker@#{i}.service")
.with_ensure(true)
.with_enable(true)
end
end

it 'disables existing workers from previous configuration' do
(9..24).each do |i|
is_expected.to contain_service("pulpcore-worker@#{i}.service")
.with_ensure(false)
.with_enable(false)
end
end
end

context 'configured for 12 workers and only 8 processors' do
let(:facts) { override_facts(os_facts, processors: { count: 8 }) }

let(:params) do
{
worker_count: 12
}
end

it 'allows configuring more workers than processors' do
(1..12).each do |i|
is_expected.to contain_service("pulpcore-worker@#{i}.service")
.with_ensure(true)
.with_enable(true)
end
end
end
end
end
end