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 #37081 - Add a setting to configure PAGE_SIZE #327

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
# STATIC_URL setting. In reality this can also be just the path and doesn't
# have to be a full URL.
#
# @param page_size
# Configure the PAGE_SIZE setting for Pagination.
#
# @param postgresql_db_name
# Name of Pulp PostgreSQL database
#
Expand Down Expand Up @@ -220,6 +223,7 @@
String[1] $apache_vhost_priority = '10',
Stdlib::Absolutepath $api_socket_path = '/run/pulpcore-api.sock',
Stdlib::Absolutepath $content_socket_path = '/run/pulpcore-content.sock',
Optional[Integer[1]] $page_size = undef,
String $postgresql_db_name = 'pulpcore',
String $postgresql_db_user = 'pulp',
String $postgresql_db_password = extlib::cache_data('pulpcore_cache_data', 'db_password', extlib::random_password(32)),
Expand Down
19 changes: 19 additions & 0 deletions spec/acceptance/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ class { 'pulpcore':
end
end

describe 'PAGE_SIZE setting' do
context 'Custom PAGE_SIZE' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'pulpcore':
page_size => 200,
}
PUPPET
end
end

describe file('/etc/pulp/settings.py') do
it { is_expected.to be_file }
its(:content) { is_expected.to match(/^REST_FRAMEWORK__PAGE_SIZE = 200$/) }
end
end
end

describe 'HIDE_GUARDED_DISTRIBUTIONS setting' do
context 'default HIDE_GUARDED_DISTRIBUTIONS' do
it_behaves_like 'an idempotent resource' do
Expand Down
1 change: 1 addition & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
.with_content(%r{CACHE_ENABLED = False})
.without_content(%r{sslmode})
.without_content(%r{WORKER_TTL})
.without_content(%r{REST_FRAMEWORK__PAGE_SIZE})
is_expected.to contain_concat__fragment('logging').with_content(<<~LOGGING)
LOGGING = {
"dynaconf_merge": True,
Expand Down
3 changes: 3 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ WORKING_DIRECTORY = "<%= scope['pulpcore::cache_dir'] %>"
REMOTE_USER_ENVIRON_NAME = '<%= scope['pulpcore::remote_user_environ_name'] %>'
AUTHENTICATION_BACKENDS = ['pulpcore.app.authentication.PulpNoCreateRemoteUserBackend']

<% unless scope['pulpcore::page_size'].nil? -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping conditions simple

Suggested change
<% unless scope['pulpcore::page_size'].nil? -%>
<% if scope['pulpcore::page_size'] -%>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I made the choice to write it this way so that readers know that it's the presence/absence of the value that we care about, not whether the value is truthy/falsy.

REST_FRAMEWORK__PAGE_SIZE = <%= scope['pulpcore::page_size'] %>
<% end -%>
REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = (
'rest_framework.authentication.SessionAuthentication',
'pulpcore.app.authentication.PulpRemoteUserAuthentication'
Expand Down