From cafe837d8d6eb881ecf94da6478959b1b78da396 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 May 2024 15:50:45 +0200 Subject: [PATCH] drop system-v leftovers --- .rubocop_todo.yml | 5 ++--- lib/beaker/host/unix/exec.rb | 2 ++ spec/beaker/host/unix/exec_spec.rb | 29 +---------------------------- spec/helpers.rb | 21 +++++---------------- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 08ebdf846..ff6a8c517 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-05-10 15:53:37 UTC using RuboCop version 1.62.1. +# on 2024-05-11 14:14:06 UTC using RuboCop version 1.62.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -244,11 +244,10 @@ RSpec/ReceiveMessages: - 'spec/beaker/test_suite_spec.rb' - 'spec/helpers.rb' -# Offense count: 7 +# Offense count: 4 RSpec/RepeatedDescription: Exclude: - 'spec/beaker/cli_spec.rb' - - 'spec/beaker/host/unix/exec_spec.rb' - 'spec/beaker/host/unix/pkg_spec.rb' # Offense count: 4 diff --git a/lib/beaker/host/unix/exec.rb b/lib/beaker/host/unix/exec.rb index 68f723be1..4dd481bff 100644 --- a/lib/beaker/host/unix/exec.rb +++ b/lib/beaker/host/unix/exec.rb @@ -278,6 +278,8 @@ def clear_env_var key # @return [Result] result of restarting the SSH service def ssh_service_restart case self['platform'] + when /(el|centos|redhat|oracle|scientific)-[0-6]/ + exec(Beaker::Command.new("/sbin/service sshd restart")) when /solaris/ exec(Beaker::Command.new("svcadm restart svc:/network/ssh:default")) when /(free|open)bsd/ diff --git a/spec/beaker/host/unix/exec_spec.rb b/spec/beaker/host/unix/exec_spec.rb index 267f8eaad..04ea84055 100644 --- a/spec/beaker/host/unix/exec_spec.rb +++ b/spec/beaker/host/unix/exec_spec.rb @@ -82,9 +82,7 @@ def to_s let(:ssh_command) { "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" } let(:ssh_move) { "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" } - platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS - - platforms.each do |platform| + PlatformHelpers::SYSTEMDPLATFORMS.each do |platform| it "calls the correct commands for #{platform}" do opts['platform'] = platform expect(instance).to receive(:exec).twice @@ -114,31 +112,6 @@ def to_s expect { instance.ssh_service_restart }.not_to raise_error end end - - PlatformHelpers::DEBIANPLATFORMS.each do |platform| - it "calls the correct command for #{platform}" do - opts['platform'] = platform - expect(instance).to receive(:exec) - expect(Beaker::Command).to receive(:new).with("service ssh restart") - expect { instance.ssh_service_restart }.not_to raise_error - end - end - - PlatformHelpers::SYSTEMVPLATFORMS.each do |platform| - it "calls the correct command for #{platform}" do - opts['platform'] = "#{platform}-arch" - expect(instance).to receive(:exec) - expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart") - expect { instance.ssh_service_restart }.not_to raise_error - end - end - - it 'raises an error on unsupported platforms' do - opts['platform'] = 'notarealthing02-parts-arch' - expect do - instance.ssh_service_restart - end.to raise_error(ArgumentError, /#{opts['platform']}/) - end end describe '#prepend_commands' do diff --git a/spec/helpers.rb b/spec/helpers.rb index 444ea414e..9768bd9fa 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -123,20 +123,9 @@ module PlatformHelpers DEBIANPLATFORMS = %w[debian ubuntu] SYSTEMDPLATFORMS = %w[amazon-2023 - fedora - el-7 - centos-7 - redhat-7 - oracle-7 - scientific-7 - el-8 - centos-8 - redhat-8 - oracle-8] - - SYSTEMVPLATFORMS = ['el-', - 'centos', - 'redhat', - 'oracle', - 'scientific',] + el- + centos + redhat + oracle + scientific].concat(DEBIANPLATFORMS) end