From 7f33a78c52c733cabc3fdb3821a858bc1cb3ac6e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 May 2024 17:06:16 +0200 Subject: [PATCH] drop validate_setup method This wasn't implemented for unix hosts anyways and we're going to drop the few network operating systems that used it. --- .rubocop_todo.yml | 9 +++-- lib/beaker/host/cisco.rb | 23 ------------ lib/beaker/host/unix.rb | 9 ----- lib/beaker/network_manager.rb | 1 - spec/beaker/host/cisco_spec.rb | 66 ---------------------------------- spec/beaker/host/unix_spec.rb | 8 ----- 6 files changed, 4 insertions(+), 112 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 89b549019..f39a8443d 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 13:25:58 UTC using RuboCop version 1.62.1. +# on 2024-05-10 15:05:57 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 @@ -92,14 +92,13 @@ Minitest/RefuteFalse: - 'acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb' - 'acceptance/tests/base/host/host_test.rb' -# Offense count: 20 +# Offense count: 19 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'Rakefile' - 'acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb' - - 'lib/beaker/host/cisco.rb' - 'spec/beaker/host/mac/group_spec.rb' - 'spec/beaker/host/mac/user_spec.rb' - 'spec/beaker/host/pswindows/user_spec.rb' @@ -144,7 +143,7 @@ RSpec/BeEq: - 'spec/beaker/subcommand/subcommand_util_spec.rb' - 'spec/beaker/test_suite_spec.rb' -# Offense count: 121 +# Offense count: 119 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -156,7 +155,7 @@ RSpec/Eq: Exclude: - 'spec/beaker/logger_spec.rb' -# Offense count: 240 +# Offense count: 236 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 44 diff --git a/lib/beaker/host/cisco.rb b/lib/beaker/host/cisco.rb index 3309fba01..aa3031dd3 100644 --- a/lib/beaker/host/cisco.rb +++ b/lib/beaker/host/cisco.rb @@ -132,28 +132,5 @@ def environment_string env environment_string << ';' if prestring.include?('export') environment_string end - - # Validates that the host was setup correctly - # - # @return nil - # @raise [ArgumentError] If the host is setup incorrectly, - # this will be raised with the appropriate message - def validate_setup - msg = nil - if self[:platform].include?('cisco_nexus') - msg = 'Cisco Nexus hosts must be provided with a :vrf value.' if !self[:vrf] - msg = 'Cisco hosts must be provided with a :user value' if !self[:user] - end - if self[:platform].include?('cisco_ios_xr') - msg = 'Cisco hosts must be provided with a :user value' if !self[:user] - end - - return unless msg - - msg << <<-EOF - Check https://github.com/puppetlabs/beaker/blob/master/docs/hosts/cisco.md for more info.' - EOF - raise ArgumentError, msg - end end end diff --git a/lib/beaker/host/unix.rb b/lib/beaker/host/unix.rb index ca88425f5..ca8cef3bf 100644 --- a/lib/beaker/host/unix.rb +++ b/lib/beaker/host/unix.rb @@ -57,15 +57,6 @@ def skip_set_env? end end - # Validates that the host was setup correctly - # - # @return nil - # @raise [ArgumentError] If the host is setup incorrectly, - # this will be raised with the appropriate message - def validate_setup - nil - end - def initialize name, host_hash, options super diff --git a/lib/beaker/network_manager.rb b/lib/beaker/network_manager.rb index da6ae51f1..10dd96a17 100644 --- a/lib/beaker/network_manager.rb +++ b/lib/beaker/network_manager.rb @@ -61,7 +61,6 @@ def provision @machines[hypervisor] = [] unless @machines[hypervisor] hostless_options[:timesync] = host_hash[:timesync] if host_hash[:timesync] != nil host_itself = Beaker::Host.create(name, host_hash, hostless_options) - host_itself.validate_setup @machines[hypervisor] << host_itself end diff --git a/spec/beaker/host/cisco_spec.rb b/spec/beaker/host/cisco_spec.rb index adf35597b..23721c583 100644 --- a/spec/beaker/host/cisco_spec.rb +++ b/spec/beaker/host/cisco_spec.rb @@ -262,71 +262,5 @@ module Cisco expect(host.repo_type).to be === 'rpm' end end - - describe '#validate_setup' do - context 'on the cisco_nexus-7 platform' do - before do - @platform = 'cisco_nexus-7-x86_64' - end - - it 'errors when no :vrf value is provided' do - expect do - host.validate_setup - end.to raise_error(ArgumentError, /provided\ with\ a\ \:vrf\ value/) - end - - it 'errors when no :user value is provided' do - @options = { - :vrf => 'fake_vrf', - :user => nil, - } - expect do - host.validate_setup - end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/) - end - - it 'does nothing if the host is setup correctly' do - @options = { - :vrf => 'fake_vrf', - :user => 'notroot', - } - validate_test = host.validate_setup - expect(validate_test).to be_nil - end - end - - context 'on the cisco_ios_xr-6 platform' do - before do - @platform = 'cisco_ios_xr-6-x86_64' - end - - it 'does nothing if no :vrf value is provided' do - @options = { - :user => 'notroot', - } - validate_test = host.validate_setup - expect(validate_test).to be_nil - end - - it 'errors when no user is provided' do - @options = { - :vrf => 'fake_vrf', - :user => nil, - } - expect do - host.validate_setup - end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/) - end - - it 'does nothing if the host is setup correctly' do - @options = { - :vrf => 'fake_vrf', - :user => 'notroot', - } - validate_test = host.validate_setup - expect(validate_test).to be_nil - end - end - end end end diff --git a/spec/beaker/host/unix_spec.rb b/spec/beaker/host/unix_spec.rb index 36d72e9ef..5ec61063a 100644 --- a/spec/beaker/host/unix_spec.rb +++ b/spec/beaker/host/unix_spec.rb @@ -37,13 +37,5 @@ module Unix expect(host.determine_ssh_server).to be === :openssh end end - - describe '#validate_setup' do - it 'does nothing for non cisco_nexus-7 platforms' do - @platform = 'el-7-x86_64' - validate_test = host.validate_setup - expect(validate_test).to be_nil - end - end end end