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

1.0 picks #650

Merged
merged 6 commits into from
Oct 6, 2022
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
11 changes: 1 addition & 10 deletions definitions/features/candlepin_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,14 @@ def load_configuration
# rubocop:enable Metrics/MethodLength

def extend_with_db_options
db_options = { '-d' => construct_database_string }
db_options = { '-d' => configuration['database'] }
if check_option_using_cpdb_help('dbhost')
db_options['--dbhost'] = configuration['host']
db_options['--dbport'] = configuration['port']
end
db_options
end

def construct_database_string
db_str = configuration['database']
extra_opts = []
extra_opts << "ssl=#{configuration['ssl']}" if configuration['ssl']
extra_opts << "sslfactory=#{configuration['sslfactory']}" if configuration['sslfactory']
db_str += "?#{extra_opts.join('&')}" unless extra_opts.empty?
db_str
end

def fetch_extra_param(url, key_name)
query_string = url.split('?')[1]
return nil unless query_string
Expand Down
4 changes: 2 additions & 2 deletions definitions/scenarios/self_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module ForemanMaintain::Scenarios
class SelfUpgradeBase < ForemanMaintain::Scenario
include ForemanMaintain::Concerns::Downstream
def target_version
@target_version ||= current_version.bump
@target_version ||= Gem::Version.new(current_version).bump.to_s
end

def current_version
feature(:instance).downstream.current_minor_version
feature(:instance).downstream.current_version.to_s[/^\d+\.\d+\.\d+/]
end

def maintenance_repo_label
Expand Down
1 change: 1 addition & 0 deletions foreman_maintain.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ the Foreman/Satellite up and running."
s.add_development_dependency 'mocha'
s.add_development_dependency 'rake'
s.add_development_dependency 'rubocop', '0.50.0' # rubocop >= 0.51.0 drops support for ruby 2.0
s.add_development_dependency 'minitest-stub-const'
end
5 changes: 2 additions & 3 deletions lib/foreman_maintain/concerns/downstream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def rh_repos(server_version)
server_version_full = "#{server_version.major}.#{server_version.minor}"
rh_repos.concat(product_specific_repos(server_version_full))
if server_version > version('6.3')
rh_repos << ansible_repo(server_version)
ansible_repo = ansible_repo(server_version)
rh_repos << ansible_repo if ansible_repo
end

rh_repos
Expand All @@ -83,8 +84,6 @@ def ansible_repo(server_version)

if el7?
"rhel-#{el_major_version}-server-ansible-#{ansible_version}-rpms"
else
"ansible-#{ansible_version}-for-rhel-#{el_major_version}-x86_64-rpms"
end
end

Expand Down
44 changes: 44 additions & 0 deletions test/definitions/features/candlepin_database_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'test_helper'
require 'minitest/stub_const'

describe Features::CandlepinDatabase do
include DefinitionsTestHelper
subject { Features::CandlepinDatabase.new }
let(:subject_ins) { Features::CandlepinDatabase.any_instance }

let(:cp_config_dir) do
File.expand_path('../../../support/', __FILE__)
end

def stub_with_ssl_config
Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG,
cp_config_dir + '/candlepin_with_ssl.conf') do
yield
end
end

def stub_without_ssl_config
Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG,
cp_config_dir + '/candlepin_without_ssl.conf') do
yield
end
end

describe '.configuration' do
it 'The url includes ssl attributes when ssl is enabled' do
stub_with_ssl_config do
url = subject.configuration['url']
assert_includes url, 'ssl=true'
assert_includes url, 'sslrootcert=/usr/share/foreman/root.crt'
end
end

it 'The url does not include ssl attributes when ssl is disabled' do
stub_without_ssl_config do
url = subject.configuration['url']
refute_includes url, 'ssl=true'
refute_includes url, 'sslrootcert=/usr/share/foreman/root.crt'
end
end
end
end
29 changes: 29 additions & 0 deletions test/definitions/scenarios/self_upgrade_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'test_helper'

module Scenarios
describe ForemanMaintain::Scenarios::SelfUpgradeBase do
include DefinitionsTestHelper

describe 'with default params' do
let(:scenario) do
ForemanMaintain::Scenarios::SelfUpgradeBase.new
end

it 'computes the target version correctly coming from normal release 6.10.0' do
assume_satellite_present do |feature_class|
feature_class.any_instance.stubs(:current_version => version('6.10.0'))
end

assert_equal '6.11', scenario.target_version
end

it 'computes the target version correctly coming from an async release 6.11.1.1' do
assume_satellite_present do |feature_class|
feature_class.any_instance.stubs(:current_version => version('6.11.1.1'))
end

assert_equal '6.12', scenario.target_version
end
end
end
end
5 changes: 2 additions & 3 deletions test/lib/concerns/downstream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ module ForemanMaintain
system.send(:ansible_repo, system.version('6.9'))
end

it 'returns correct ansible 2.9 repo for 6.11 on el8' do
it 'returns no ansible 2.9 repo for 6.11 on el8' do
system.stubs(:el_major_version).returns(8)
assert_equal 'ansible-2.9-for-rhel-8-x86_64-rpms',
system.send(:ansible_repo, system.version('6.11'))
assert_nil system.send(:ansible_repo, system.version('6.11'))
end
end

Expand Down
45 changes: 45 additions & 0 deletions test/support/candlepin_with_ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### File managed with puppet ###
## Module: 'candlepin'

candlepin.consumer_system_name_pattern=.+
candlepin.environment_content_filtering=true
candlepin.auth.basic.enable=false
candlepin.auth.trusted.enable=false

candlepin.audit.hornetq.config_path=/etc/candlepin/broker.xml

candlepin.auth.oauth.enable=true
candlepin.auth.oauth.consumer.katello.secret=abcdabcd

module.config.adapter_module=org.candlepin.katello.KatelloModule

candlepin.ca_key=/etc/candlepin/certs/candlepin-ca.key
candlepin.ca_cert=/etc/candlepin/certs/candlepin-ca.crt
candlepin.crl.file=/var/lib/candlepin/candlepin-crl.crl

candlepin.async.jobs.ExpiredPoolsCleanupJob.schedule=0 0 0 * * ?

# Required for https://hibernate.atlassian.net/browse/HHH-12927
log4j.logger.org.hibernate.internal.SessionImpl=ERROR

# uncomment to enable debug logging in candlepin.log:
#log4j.logger.org.candlepin=DEBUG
jpa.config.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.config.hibernate.connection.driver_class=org.postgresql.Driver
jpa.config.hibernate.connection.url=jdbc:postgresql://host.example.com:5432/candlepin1db?ssl=true&sslrootcert=/usr/share/foreman/root.crt
jpa.config.hibernate.hbm2ddl.auto=validate
jpa.config.hibernate.connection.username=candlepin
jpa.config.hibernate.connection.password=password

org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate

org.quartz.dataSource.myDS.driver=org.postgresql.Driver
org.quartz.dataSource.myDS.URL=jdbc:postgresql://host.example.com:5432/candlepin1db?ssl=true&sslrootcert=/usr/share/foreman/root.crt
org.quartz.dataSource.myDS.user=candlepin
org.quartz.dataSource.myDS.password=password
org.quartz.dataSource.myDS.maxConnections=5
44 changes: 44 additions & 0 deletions test/support/candlepin_without_ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### File managed with puppet ###
## Module: 'candlepin'

candlepin.consumer_system_name_pattern=.+
candlepin.environment_content_filtering=true
candlepin.auth.basic.enable=false
candlepin.auth.trusted.enable=false

candlepin.audit.hornetq.config_path=/etc/candlepin/broker.xml

candlepin.auth.oauth.enable=true
candlepin.auth.oauth.consumer.katello.secret=abcdabcd

module.config.adapter_module=org.candlepin.katello.KatelloModule

candlepin.ca_key=/etc/candlepin/certs/candlepin-ca.key
candlepin.ca_cert=/etc/candlepin/certs/candlepin-ca.crt

candlepin.async.jobs.ExpiredPoolsCleanupJob.schedule=0 0 0 * * ?

# Required for https://hibernate.atlassian.net/browse/HHH-12927
log4j.logger.org.hibernate.internal.SessionImpl=ERROR

# uncomment to enable debug logging in candlepin.log:
#log4j.logger.org.candlepin=DEBUG
jpa.config.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.config.hibernate.connection.driver_class=org.postgresql.Driver
jpa.config.hibernate.connection.url=jdbc:postgresql://localhost:5432/candlepin
jpa.config.hibernate.hbm2ddl.auto=validate
jpa.config.hibernate.connection.username=candlepin
jpa.config.hibernate.connection.password=password

org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate

org.quartz.dataSource.myDS.driver=org.postgresql.Driver
org.quartz.dataSource.myDS.URL=jdbc:postgresql://localhost:5432/candlepin
org.quartz.dataSource.myDS.user=candlepin
org.quartz.dataSource.myDS.password=password
org.quartz.dataSource.myDS.maxConnections=5