Skip to content

Commit

Permalink
drop validate_setup method
Browse files Browse the repository at this point in the history
This wasn't implemented for unix hosts anyways and we're going to drop
the few network operating systems that used it.
  • Loading branch information
bastelfreak committed May 10, 2024
1 parent 8603333 commit 7f33a78
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 112 deletions.
9 changes: 4 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
23 changes: 0 additions & 23 deletions lib/beaker/host/cisco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 0 additions & 9 deletions lib/beaker/host/unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion lib/beaker/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
66 changes: 0 additions & 66 deletions spec/beaker/host/cisco_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 0 additions & 8 deletions spec/beaker/host/unix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f33a78

Please sign in to comment.