diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 89b549019..cc2047f72 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 14:44:46 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: 113 # 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: 232 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 44 @@ -214,7 +213,7 @@ RSpec/MultipleDescribes: RSpec/MultipleMemoizedHelpers: Max: 18 -# Offense count: 499 +# Offense count: 495 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -278,7 +277,7 @@ RSpec/SpecFilePathFormat: - 'spec/beaker/host/windows/user_spec.rb' - 'spec/beaker/host_prebuilt_steps_spec.rb' -# Offense count: 177 +# Offense count: 175 RSpec/SubjectStub: Exclude: - 'spec/beaker/dsl/assertions_spec.rb' @@ -336,7 +335,7 @@ Security/Open: Exclude: - 'lib/beaker/dsl/helpers/web_helpers.rb' -# Offense count: 105 +# Offense count: 104 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https diff --git a/docs/how_to/hosts/cisco.md b/docs/how_to/hosts/cisco.md deleted file mode 100644 index b3277dfcf..000000000 --- a/docs/how_to/hosts/cisco.md +++ /dev/null @@ -1,40 +0,0 @@ -# Wind River Linux - -Wind River Linux is an embedded systems OS from Wind, an Intel Company. You can get more details on this from their [product page](http://www.windriver.com/products/linux/). - -Beaker provides support for 2 of Cisco's Wind River Linux platforms. Those platform codenames are `cisco_nexus` for Cisco NX-OS based systems and `cisco_ios_xr` for Cisco IOS XR based systems. - -Beaker currently can install puppet on Cisco Nexus and Cisco IOS XR. - -# Host Requirements - -WRLinux hosts validate their setup once created, and will fail if not setup correctly. There are two conditions that are validated specifically on WRLinux hosts. These conditions are listed below. - -A. All Cisco Nexus hosts will need a `:vrf` value, which determines their virtual routing framework for networking purposes. For our purposes, we tend to use the value `management`, so there is always a hosts file line that looks like this in our configuration: - - HOSTS: - : - ... - vrf: management - -B. All Cisco hosts will also require a user to be set on the hosts. This is because they don't allow ssh'ing as the root user, which is one of the main assumptions that Beaker operates under in the usual case. In order to specify a user to ssh with, add this block to a host: - - HOSTS: - : - ... - ssh: - user: - -# Hypervisors - -WRLinux has only been developed and tested as a [vmpooler](https://github.com/puppetlabs/vmpooler) host. - -This doesn't mean that it can't be used in another hypervisor, but that Beaker doesn't specifically deal with the details of that hypervisor in creating WRLinux hosts, if there is anything specific to WRLinux that will need to be done in provisioning steps. - -# Installation Methods - -## Open Source - -In order to install a puppet-agent against a WRLinux host, you'll have to use the [`install_puppet_agent_on`](blob/master/lib/beaker/dsl/install_utils/foss_utils.rb#L327) method. - -It reaches out to the WRLinux-specific host code for any information that it needs. You can check out [these methods](blob/master/lib/beaker/host/cisco.rb) if you need more information about this. \ No newline at end of file diff --git a/lib/beaker/command.rb b/lib/beaker/command.rb index 68c330799..002cd90fd 100644 --- a/lib/beaker/command.rb +++ b/lib/beaker/command.rb @@ -72,11 +72,7 @@ def cmd_line host, cmd = @command, env = @environment, pc = @prepend_cmds, ac = append_commands = host.append_commands(cmd, ac, :cmd_exe => @cmdexe) # This will cause things like `puppet -t -v agent` which is maybe bad. - cmd_line_array = if host[:platform]&.include?('cisco_ios_xr') - [prepend_commands, env_string, cmd, options_string, args_string, append_commands] - else - [env_string, prepend_commands, cmd, options_string, args_string, append_commands] - end + cmd_line_array = [env_string, prepend_commands, cmd, options_string, args_string, append_commands] cmd_line_array.compact.reject(&:empty?).join(' ') end diff --git a/lib/beaker/host.rb b/lib/beaker/host.rb index 265821d71..502c088ef 100644 --- a/lib/beaker/host.rb +++ b/lib/beaker/host.rb @@ -57,8 +57,6 @@ def self.create name, host_hash, options Mac::Host.new name, host_hash, options when /freebsd/ FreeBSD::Host.new name, host_hash, options - when /cisco/ - Cisco::Host.new name, host_hash, options else Unix::Host.new name, host_hash, options end @@ -574,7 +572,6 @@ def add_env_var(key, val) freebsd windows pswindows - cisco ].each do |lib| require "beaker/host/#{lib}" end diff --git a/lib/beaker/host/cisco.rb b/lib/beaker/host/cisco.rb deleted file mode 100644 index 3309fba01..000000000 --- a/lib/beaker/host/cisco.rb +++ /dev/null @@ -1,159 +0,0 @@ -%w[host command_factory].each do |lib| - require "beaker/#{lib}" -end - -module Cisco - class Host < Unix::Host - # as the cisco hosts tend to have custom - # ssh configuration, the presets - # do not apply where verification of the - # host keys is disabled - def platform_defaults - h = Beaker::Options::OptionsHash.new - h.merge({ - 'ssh' => { - :verify_host_key => false, - }, - }) - end - - # Tells you whether a host platform supports beaker's - # {Beaker::HostPrebuiltSteps#set_env} method - # - # @return [String,nil] Reason message if set_env should be skipped, - # nil if it should run. - def skip_set_env? - 'Cisco does not allow SSH control through the BASH shell' - end - - # Handles host operations needed after an SCP takes place - # - # @param [String] scp_file_actual File path to actual SCP'd file on host - # @param [String] scp_file_target File path to target SCP location on host - # - # @return nil - def scp_post_operations(scp_file_actual, scp_file_target) - execute("mv #{scp_file_actual} #{scp_file_target}") if self[:platform].include?('cisco_nexus') - nil - end - - # Handles any changes needed in a path for SCP - # - # @param [String] path File path to SCP to - # - # @return [String] path, changed if needed due to host - # constraints - def scp_path(path) - if self[:platform].include?('cisco_nexus') - @home_dir ||= execute('pwd') - answer = "#{@home_dir}/#{File.basename(path)}" - answer << '/' if /\/$/.match?(path) - return answer - end - path - end - - # Gets the repo type for the given platform - # - # @raise [ArgumentError] For an unknown platform - # - # @return [String] Type of repo (rpm|deb) - def repo_type - 'rpm' - end - - # Gets the config dir location for package information - # - # @raise [ArgumentError] For an unknown platform - # - # @return [String] Path to package config dir - def package_config_dir - '/etc/yum/repos.d/' - end - - # Gets the specific prepend commands as needed for this host - # - # @param [String] command Command to be executed - # @param [String] user_pc List of user-specified commands to prepend - # @param [Hash] opts optional parameters - # - # @return [String] Command string as needed for this host - def prepend_commands(command = '', user_pc = '', _opts = {}) - return user_pc unless command.index('vsh').nil? - - if self[:platform].include?('cisco_nexus') - return user_pc unless command.index('ntpdate').nil? - end - - prepend_cmds = 'source /etc/profile;' - prepend_cmds << " sudo -E sh -c \"" if self[:user] != 'root' - prepend_cmds << "ip netns exec #{self[:vrf]} " if self[:vrf] - prepend_cmds << "#{user_pc} " if user_pc && !user_pc.empty? - prepend_cmds.strip - end - - # Gets the specific append commands as needed for this host - # - # @param [String] command Command to be executed - # @param [String] user_ac List of user-specified commands to append - # @param [Hash] opts optional parameters - # - # @return [String] Command string as needed for this host - def append_commands(command = '', _user_ac = '', _opts = {}) - command.gsub('"') { '\\"' } - # vsh commands, ntpdate or when user is root commands do not require an appended `"` - return '"' unless /ntpdate|\/isan\/bin\/vsh/.match?(command) || self[:user] == 'root' - end - - # Construct the environment string for this command - # - # @param [Hash{String=>String}] env An optional Hash containing - # key-value pairs to be treated - # as environment variables that - # should be set for the duration - # of the puppet command. - # - # @return [String] Returns a string containing command line arguments that - # will ensure the environment is correctly set for the - # given host. - def environment_string env - prestring = '' - return prestring if env.empty? - - env_array = self.environment_variable_string_pair_array(env) - environment_string = env_array.join(' ') - - prestring << if self[:platform].include?('cisco_nexus') - " export" - else - " env" - end - environment_string = "#{prestring} #{environment_string}" - 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/file.rb b/lib/beaker/host/unix/file.rb index c145adab4..6e577b892 100644 --- a/lib/beaker/host/unix/file.rb +++ b/lib/beaker/host/unix/file.rb @@ -113,19 +113,11 @@ def repo_filename(package_name, build_version) repo_filename = format("pl-%s-%s-", package_name, build_version) case variant - when /amazon|fedora|el|redhat|centos|cisco_nexus|cisco_ios_xr|opensuse|sles/ + when /amazon|fedora|el|redhat|centos|opensuse|sles/ variant = 'el' if %w[centos redhat].include?(variant) variant = 'redhatfips' if self['packaging_platform']&.include?('redhatfips') - if variant == 'cisco_nexus' - variant = 'cisco-wrlinux' - version = '5' - end - if variant == 'cisco_ios_xr' - variant = 'cisco-wrlinux' - version = '7' - end fedora_prefix = (variant == 'fedora' ? 'f' : '') pattern = "%s-%s%s-%s.repo" diff --git a/lib/beaker/host/unix/pkg.rb b/lib/beaker/host/unix/pkg.rb index cc470d8f5..8df96659d 100644 --- a/lib/beaker/host/unix/pkg.rb +++ b/lib/beaker/host/unix/pkg.rb @@ -37,7 +37,7 @@ def check_for_package(name, opts = {}) self[:sles_rpmkeys_nightly_pl_imported] = true end result = execute("zypper --gpg-auto-import-keys se -i --match-exact #{name}", opts) { |result| result } - when /amazon|cisco|fedora|centos|redhat|el-/ + when /amazon|fedora|centos|redhat|el-/ result = execute("rpm -q #{name}", opts) { |result| result } when /ubuntu|debian/ result = execute("dpkg -s #{name}", opts) { |result| result } @@ -85,7 +85,7 @@ def install_package(name, cmdline_args = '', version = nil, opts = {}) when /amazon-2023|el-(8|9|1[0-9])|fedora/ name = "#{name}-#{version}" if version execute("dnf -y #{cmdline_args} install #{name}", opts) - when /cisco|centos|redhat|el-[1-7]-/ + when /centos|redhat|el-[1-7]-/ name = "#{name}-#{version}" if version execute("yum -y #{cmdline_args} install #{name}", opts) when /ubuntu|debian/ @@ -167,7 +167,7 @@ def uninstall_package(name, cmdline_args = '', opts = {}) execute("zypper --non-interactive rm #{name}", opts) when /amazon-2023|el-(8|9|1[0-9])|fedora/ execute("dnf -y #{cmdline_args} remove #{name}", opts) - when /cisco|centos|redhat|el-[1-7]-/ + when /centos|redhat|el-[1-7]-/ execute("yum -y #{cmdline_args} remove #{name}", opts) when /ubuntu|debian/ execute("apt-get purge #{cmdline_args} -y #{name}", opts) @@ -195,7 +195,7 @@ def upgrade_package(name, cmdline_args = '', opts = {}) execute("zypper --non-interactive --no-gpg-checks up #{name}", opts) when /fedora-(2[2-9]|3[0-9])/ execute("dnf -y #{cmdline_args} update #{name}", opts) - when /cisco|fedora|centos|redhat|el-/ + when /fedora|centos|redhat|el-/ execute("yum -y #{cmdline_args} update #{name}", opts) when /ubuntu|debian/ update_apt_if_needed diff --git a/lib/beaker/host_prebuilt_steps.rb b/lib/beaker/host_prebuilt_steps.rb index a26069e2f..c87274f2a 100644 --- a/lib/beaker/host_prebuilt_steps.rb +++ b/lib/beaker/host_prebuilt_steps.rb @@ -52,9 +52,6 @@ def timesync host, opts ntp_command = "chronyc add server #{ntp_server} prefer trust;chronyc makestep;chronyc burst 1/2" elsif /opensuse-|sles-/.match?(host['platform']) ntp_command = "sntp #{ntp_server}" - elsif host['platform'].include?('cisco_nexus') - ntp_server = host.exec(Command.new("getent hosts #{NTPSERVER} | head -n1 |cut -d \" \" -f1"), :acceptable_exit_codes => [0]).stdout - ntp_command = "sudo -E sh -c 'export DCOS_CONTEXT=2;/isan/bin/ntpdate -u -t 20 #{ntp_server}'" else ntp_command = "ntpdate -u -t 20 #{ntp_server}" end @@ -137,7 +134,7 @@ def host_packages(host) when /fedora/ FEDORA_PACKAGES else - if !/aix|solaris|osx-|netscaler|cisco_/.match?(host['platform']) + if !/aix|solaris|osx-|netscaler/.match?(host['platform']) UNIX_PACKAGES else [] diff --git a/lib/beaker/platform.rb b/lib/beaker/platform.rb index 1bb6a7324..d7b005600 100644 --- a/lib/beaker/platform.rb +++ b/lib/beaker/platform.rb @@ -3,7 +3,7 @@ module Beaker # all String methods while adding several platform-specific use cases. class Platform < String # Supported platforms - PLATFORMS = /^(alpine|amazon|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el|netscaler)\-.+\-.+$/ + PLATFORMS = /^(alpine|amazon|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el|netscaler)\-.+\-.+$/ # Platform version numbers vs. codenames conversion hash PLATFORM_VERSION_CODES = { :debian => { "forky" => "14", @@ -58,8 +58,6 @@ class Platform < String # provided meets the platform formatting rules. Platforms name must be of # the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of: # * amazon - # * cisco_nexus - # * cisco_ios_xr # * freebsd # * openbsd # * osx diff --git a/spec/beaker/host/cisco_spec.rb b/spec/beaker/host/cisco_spec.rb deleted file mode 100644 index adf35597b..000000000 --- a/spec/beaker/host/cisco_spec.rb +++ /dev/null @@ -1,332 +0,0 @@ -require 'spec_helper' - -module Cisco - describe Host do - let(:options) do - @options ? @options : { - :user => 'root', - } - end - let(:platform) do - if @platform - { :platform => Beaker::Platform.new(@platform) } - else - { :platform => Beaker::Platform.new('cisco_nexus-vers-arch-extra') } - end - end - let(:host) { make_host('name', options.merge(platform)) } - - describe '#prepend_commands' do - context 'for cisco_nexus-7' do - before do - @platform = 'cisco_nexus-7-x86_64' - end - - it 'starts with sourcing the /etc/profile script' do - answer_correct = 'source /etc/profile;' - answer_test = host.prepend_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'uses `sudo` if not root' do - @options = { :user => 'notroot' } - answer_correct = "source /etc/profile; sudo -E sh -c \"" - answer_test = host.prepend_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'ends with the :vrf host parameter' do - vrf_answer = 'vrf_answer_135246' - @options = { - :vrf => vrf_answer, - } - answer_test = host.prepend_commands('fake_command') - expect(answer_test).to match(/ip netns exec #{vrf_answer}$/) - end - - it 'guards against "vsh" usage (scenario we never want prefixing)' do - answer_user_pc = 'pc_param_unchanged_13584' - answer_test = host.prepend_commands('fake/vsh/command', answer_user_pc) - expect(answer_test).to be === answer_user_pc - end - - it 'guards against "ntpdate" usage (we dont want prefixing on nexus)' do - answer_user_pc = 'user_pc_param_54321' - answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc) - expect(answer_test).to be === answer_user_pc - end - - it 'retains user-specified prepend commands when adding vrf' do - @options = { - :vrf => 'fakevrf', - :user => 'root', - } - answer_prepend_commands = 'prepend' - answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend' - answer_test = host.prepend_commands('fake_command', answer_prepend_commands) - expect(answer_test).to be === answer_correct - end - end - - context 'for cisco_ios_xr-6' do - before do - @platform = 'cisco_ios_xr-6-x86_64' - end - - it 'starts with sourcing the /etc/profile script' do - answer_correct = 'source /etc/profile;' - answer_test = host.prepend_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'does use the :vrf host parameter if provided' do - @options = { :vrf => 'tpnns' } - answer_test = host.prepend_commands('fake_command') - expect(answer_test).to match(/ip netns exec tpnns/) - end - - it 'does not guard "ntpdate" usage' do - answer_user_pc = 'user_pc_param_54321' - answer_correct = 'source /etc/profile;user_pc_param_54321' - answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc) - expect(answer_test).to be === answer_correct - end - - it 'retains user-specified prepend commands when adding vrf' do - @options = { - :vrf => 'fakevrf', - :user => 'root', - } - answer_prepend_commands = 'prepend' - answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend' - answer_test = host.prepend_commands('fake_command', answer_prepend_commands) - expect(answer_test).to be === answer_correct - end - end - end - - describe '#append_commands' do - context 'for cisco_nexus-7' do - before do - @platform = 'cisco_nexus-7-x86_64' - @options = { :user => 'non_root' } - end - - it 'appends `"` for commands' do - answer_correct = '"' - answer_test = host.append_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'returns nil for root user commands' do - @options = { :user => 'root' } - answer_correct = nil - answer_test = host.append_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'returns nil when vsh command' do - answer_correct = nil - answer_test = host.append_commands('/isan/bin/vsh -c foo') - expect(answer_test).to be === answer_correct - end - - it 'returns `"` when command contains vsh' do - answer_correct = '"' - answer_test = host.append_commands('fake_command -c foo vsh') - expect(answer_test).to be === answer_correct - end - - it 'returns nil when ntpdate command' do - answer_correct = nil - answer_test = host.append_commands('fake/ntpdate/command foo') - expect(answer_test).to be === answer_correct - end - end - - context 'for cisco_ios_xr-6' do - before do - @platform = 'cisco_ios_xr-6-x86_64' - @options = { :user => 'non_root' } - end - - it 'appends `"` for commands' do - answer_correct = '"' - answer_test = host.append_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'returns nil for root user commands' do - @options = { :user => 'root' } - answer_correct = nil - answer_test = host.append_commands('fake_command') - expect(answer_test).to be === answer_correct - end - - it 'returns nil when vsh command' do - answer_correct = nil - answer_test = host.append_commands('/isan/bin/vsh -c foo') - expect(answer_test).to be === answer_correct - end - - it 'returns `"` when command contains vsh' do - answer_correct = '"' - answer_test = host.append_commands('fake_command -c foo vsh') - expect(answer_test).to be === answer_correct - end - - it 'returns nil when ntpdate command' do - answer_correct = nil - answer_test = host.append_commands('fake/ntpdate/command foo') - expect(answer_test).to be === answer_correct - end - end - end - - describe '#environment_string' do - context 'for cisco_nexus-7' do - before do - @platform = 'cisco_nexus-7-x86_64' - end - - it 'uses `export` if root' do - @options = { :user => 'root' } - env_map = { 'PATH' => '/opt/pants/2' } - answer_correct = ' export PATH="/opt/pants/2";' - answer_test = host.environment_string(env_map) - expect(answer_test).to be === answer_correct - end - - it 'ends with a semi-colon' do - env_map = { 'PATH' => '/opt/pants/3' } - answer_test = host.environment_string(env_map) - expect(answer_test).to match(/\;$/) - end - - it 'turns env maps into paired strings correctly' do - @options = { :user => 'root' } - env_map = { 'var1' => 'ans1', 'VAR2' => 'ans2' } - answer_correct = ' export var1="ans1" VAR1="ans1" VAR2="ans2";' - answer_test = host.environment_string(env_map) - expect(answer_test).to be === answer_correct - end - end - - context 'for cisco_ios_xr-6' do - before do - @platform = 'cisco_ios_xr-6-x86_64' - end - - it 'uses `sudo` if not root' do - @options = { :user => 'notroot' } - env_map = { 'PATH' => '/opt/pants/2' } - answer_correct = ' env PATH="/opt/pants/2"' - answer_test = host.environment_string(env_map) - expect(answer_test).to be === answer_correct - end - - it 'uses `env` if root' do - @options = { :user => 'root' } - env_map = { 'PATH' => '/opt/pants/1' } - answer_correct = ' env PATH="/opt/pants/1"' - answer_test = host.environment_string(env_map) - expect(answer_test).to be === answer_correct - end - - it 'does not end with a semi-colon' do - env_map = { 'PATH' => '/opt/pants/3' } - answer_test = host.environment_string(env_map) - expect(answer_test).not_to match(/\;$/) - end - - it 'turns env maps into paired strings correctly' do - @options = { :user => 'root' } - env_map = { 'VAR1' => 'ans1', 'var2' => 'ans2' } - answer_correct = ' env VAR1="ans1" var2="ans2" VAR2="ans2"' - answer_test = host.environment_string(env_map) - expect(answer_test).to be === answer_correct - end - end - end - - describe '#package_config_dir' do - it 'returns correctly for cisco platforms' do - @platform = 'cisco_nexus-7-x86_64' - expect(host.package_config_dir).to be === '/etc/yum/repos.d/' - end - end - - describe '#repo_type' do - it 'returns correctly for cisco platforms' do - @platform = 'cisco_nexus-7-x86_64' - 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/exec_spec.rb b/spec/beaker/host/unix/exec_spec.rb index 42ae75ae0..267f8eaad 100644 --- a/spec/beaker/host/unix/exec_spec.rb +++ b/spec/beaker/host/unix/exec_spec.rb @@ -142,8 +142,8 @@ def to_s end describe '#prepend_commands' do - it 'returns the pc parameter unchanged for non-cisco platforms' do - allow(instance).to receive(:[]).with(:platform).and_return('notcisco') + it 'returns the pc parameter unchanged for all platforms' do + allow(instance).to receive(:[]).with(:platform).and_return('unix') answer_prepend_commands = 'pc_param_unchanged_13579' answer_test = instance.prepend_commands('fake_cmd', answer_prepend_commands) expect(answer_test).to be === answer_prepend_commands diff --git a/spec/beaker/host/unix/file_spec.rb b/spec/beaker/host/unix/file_spec.rb index 27344ac74..6e66e7cff 100644 --- a/spec/beaker/host/unix/file_spec.rb +++ b/spec/beaker/host/unix/file_spec.rb @@ -134,13 +134,6 @@ def to_s expect(filename).to be === correct end - it 'adds wrlinux to variant on cisco platforms' do - @platform = 'cisco_nexus-7-x86_64' - allow(instance).to receive(:is_pe?).and_return(false) - filename = instance.repo_filename('pkg_name', 'pkg_version12') - expect(filename).to match(/sion12\-cisco\-wrlinux\-/) - end - it 'errors for non-el or debian-based platforms' do @platform = 'freebsd-22-x86_64' expect do diff --git a/spec/beaker/host/unix/pkg_spec.rb b/spec/beaker/host/unix/pkg_spec.rb index c686772a6..ce9812ffa 100644 --- a/spec/beaker/host/unix/pkg_spec.rb +++ b/spec/beaker/host/unix/pkg_spec.rb @@ -316,15 +316,6 @@ def exec allow(instance).to receive(:[]).with('platform') { Beaker::Platform.new("#{platform}-#{version}-x86_64") } end - it 'rejects unsupported platforms' do - @platform = 'cisco_nexus' - expect do - instance.uncompress_local_tarball(tar_file, base_dir, download_file) - end.to raise_error( - /^Platform #{platform} .* not supported .* uncompress_local_tarball$/, - ) - end - it 'untars the file given' do @platform = 'sles' expect(instance).to receive(:execute).with( 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 diff --git a/spec/beaker/host_prebuilt_steps_spec.rb b/spec/beaker/host_prebuilt_steps_spec.rb index a1e58bceb..5cedb4803 100644 --- a/spec/beaker/host_prebuilt_steps_spec.rb +++ b/spec/beaker/host_prebuilt_steps_spec.rb @@ -376,12 +376,6 @@ subject.validate_host(hosts, options) end - - it 'skips validation on cisco hosts' do - host = make_host('cisco-7', { stdout: stdout, platform: 'cisco_nexus-7-x86_64' }) - expect(subject).to receive(:check_and_install_packages_if_needed).with(host, []).once - subject.validate_host(host, options) - end end context 'get_domain_name' do @@ -557,29 +551,6 @@ test_host_ssh_calls('windows') end - it 'skips a cisco host correctly' do - host = make_host('name', { - :platform => 'cisco_nexus-7-x86_64', - :ssh_env_file => 'ssh_env_file', - :is_cygwin => true, - }) - opts = { - :env1_key => :env1_value, - :env2_key => :env2_value, - } - allow(host).to receive(:skip_set_env?).and_return('cisco say NO') - - expect(subject).to receive(:construct_env).exactly(0).times - expect(Beaker::Command).to receive(:new).exactly(0).times - expect(host).to receive(:add_env_var).exactly(0).times - opts.each_pair do |key, value| - expect(host).to receive(:add_env_var).with(key, value).exactly(0).times - end - expect(host).to receive(:exec).exactly(0).times - - subject.set_env(host, options.merge(opts)) - end - def test_host_ssh_calls(platform_name) host = make_host('name', { :platform => platform_name,