diff --git a/definitions/procedures/pulpcore/rpm_datarepair.rb b/definitions/procedures/pulpcore/rpm_datarepair.rb new file mode 100644 index 000000000..b74c189e5 --- /dev/null +++ b/definitions/procedures/pulpcore/rpm_datarepair.rb @@ -0,0 +1,17 @@ +module Procedures::Pulpcore + class RpmDatarepair < ForemanMaintain::Procedure + include ForemanMaintain::Concerns::PulpCommon + + metadata do + description 'Rename ContentArtifact relative_paths to match `{N-V-R.A.rpm}`' + for_feature :pulpcore + end + + def run + with_spinner('Running pulpcore-manager rpm-datarepair 4073') do + # Assumption: services are already started + execute!(pulpcore_manager('rpm-datarepair 4073')) + end + end + end +end diff --git a/definitions/scenarios/foreman_upgrade.rb b/definitions/scenarios/foreman_upgrade.rb index f7ccfa026..ff9c9ad71 100644 --- a/definitions/scenarios/foreman_upgrade.rb +++ b/definitions/scenarios/foreman_upgrade.rb @@ -115,6 +115,7 @@ def compose add_steps( Procedures::RefreshFeatures, Procedures::Service::Start, + Procedures::Pulpcore::RpmDatarepair, Procedures::Crond::Start, Procedures::SyncPlans::Enable, Procedures::MaintenanceMode::DisableMaintenanceMode diff --git a/definitions/scenarios/satellite_upgrade.rb b/definitions/scenarios/satellite_upgrade.rb index 871a74066..94f717c4a 100644 --- a/definitions/scenarios/satellite_upgrade.rb +++ b/definitions/scenarios/satellite_upgrade.rb @@ -120,6 +120,7 @@ def compose add_steps( Procedures::RefreshFeatures, Procedures::Service::Start, + Procedures::Pulpcore::RpmDatarepair, Procedures::Crond::Start, Procedures::SyncPlans::Enable, Procedures::MaintenanceMode::DisableMaintenanceMode, diff --git a/foreman_maintain.gemspec b/foreman_maintain.gemspec index 5b1ecab28..1ce596a38 100644 --- a/foreman_maintain.gemspec +++ b/foreman_maintain.gemspec @@ -26,7 +26,7 @@ the Foreman/Satellite up and running." s.add_dependency 'highline' s.add_development_dependency 'bundler', '>= 1.17' - s.add_development_dependency 'minitest' + s.add_development_dependency 'minitest', '~> 5.0' s.add_development_dependency 'minitest-reporters' s.add_development_dependency 'minitest-stub-const' s.add_development_dependency 'mocha' diff --git a/lib/foreman_maintain/cli/base.rb b/lib/foreman_maintain/cli/base.rb index cb2b34933..ac674d7a6 100644 --- a/lib/foreman_maintain/cli/base.rb +++ b/lib/foreman_maintain/cli/base.rb @@ -137,7 +137,7 @@ def self.label_option option '--label', 'label', 'Run only a specific check with a label. ' \ '(Use "list" command to see available labels)' do |label| - raise ArgumentError, 'value not specified' if label.nil? || label.empty? + raise ArgumentError, 'no value provided' if label.nil? || label.empty? underscorize(label).to_sym end end @@ -147,7 +147,7 @@ def self.tags_option 'Run only those with all specific set of tags. ' \ '(Use list-tags command to see available tags)', :multivalued => true) do |tags| - raise ArgumentError, 'value not specified' if tags.nil? || tags.empty? + raise ArgumentError, 'no value provided' if tags.nil? || tags.empty? tags.map { |tag| underscorize(tag).to_sym } end end @@ -166,7 +166,7 @@ def self.interactive_option(opts = %w[assumeyes whitelist force plaintext]) if opts.include?('whitelist') option(['-w', '--whitelist'], 'whitelist', 'Comma-separated list of labels of steps to be skipped') do |whitelist| - raise ArgumentError, 'value not specified' if whitelist.nil? || whitelist.empty? + raise ArgumentError, 'no value provided' if whitelist.nil? || whitelist.empty? whitelist.split(',').map(&:strip) end end diff --git a/test/definitions/procedures/pulpcore/rpm_datarepair_test.rb b/test/definitions/procedures/pulpcore/rpm_datarepair_test.rb new file mode 100644 index 000000000..cc5157a85 --- /dev/null +++ b/test/definitions/procedures/pulpcore/rpm_datarepair_test.rb @@ -0,0 +1,21 @@ +require 'test_helper' + +describe Procedures::Pulpcore::RpmDatarepair do + include DefinitionsTestHelper + + subject { Procedures::Pulpcore::RpmDatarepair.new } + + it 'runs pulpcore-manager rpm-datarepair 4073' do + assume_feature_present(:pulpcore) + assume_feature_present(:pulpcore_database, :services => []) + assume_feature_present(:service) + + subject.expects(:execute!).with( + 'PULP_SETTINGS=/etc/pulp/settings.py runuser -u pulp -- ' \ + 'pulpcore-manager rpm-datarepair 4073' + ).once + + result = run_procedure(subject) + assert result.success? + end +end diff --git a/test/definitions/scenarios/satellite_upgrade_test.rb b/test/definitions/scenarios/satellite_upgrade_test.rb index 2e68ae82d..66e96a36a 100644 --- a/test/definitions/scenarios/satellite_upgrade_test.rb +++ b/test/definitions/scenarios/satellite_upgrade_test.rb @@ -177,6 +177,7 @@ scenario, Procedures::RefreshFeatures, Procedures::Service::Start, + Procedures::Pulpcore::RpmDatarepair, Procedures::Crond::Start, Procedures::SyncPlans::Enable, Procedures::MaintenanceMode::DisableMaintenanceMode, diff --git a/test/lib/cli/health_command_test.rb b/test/lib/cli/health_command_test.rb index 18c9557c6..c7242379c 100644 --- a/test/lib/cli/health_command_test.rb +++ b/test/lib/cli/health_command_test.rb @@ -89,13 +89,13 @@ module ForemanMaintain it 'raises errors on empty arguments' do assert_cmd <<~OUTPUT, %w[--label] - ERROR: option '--label': value not specified + ERROR: option '--label': no value provided See: 'foreman-maintain health check --help' OUTPUT assert_cmd <<~OUTPUT, %w[--tags] - ERROR: option '--tags': value not specified + ERROR: option '--tags': no value provided See: 'foreman-maintain health check --help' OUTPUT