Skip to content

Commit

Permalink
(BKR-467) beaker-rspec does not correctly update os when cycling...
Browse files Browse the repository at this point in the history
...through hosts

- found that beaker was unable to complete its acceptance tests when
  provided with multiple SUTs of multiple os types in the same hosts
  file
- need to correctly detectos when we switch to a new os, otherwise we
  assume that we are executing on the same os and generate the wrong
  command strings
- keeps a hash of known hosts associated with their os type so that we
  don't have to run detect_os (which can be somewhat time expensive)
  more than once per-SUT
  • Loading branch information
Alice Nodelman committed Aug 27, 2015
1 parent 261dacd commit a6b3e50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/beaker-rspec/helpers/serverspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ class << self
end

module Specinfra::Helper::Os

@@known_nodes = {}

def os
working_node_name = get_working_node.to_s
if !@@known_nodes[working_node_name] # haven't seen this yet, better detect the os
@@known_nodes[working_node_name] = property[:os] = detect_os
end
@@known_nodes[working_node_name]
end

private

# Override detect_os to look at the node platform, short circuit discoverability
Expand Down Expand Up @@ -265,7 +276,7 @@ def run_command(cmd, opt = {})
def build_command(cmd)
useshell = '/bin/sh'
cmd = cmd.shelljoin if cmd.is_a?(Array)
cmd = "#{useshell.shellescape} -c #{cmd.shellescape}"
cmd = "#{String(useshell).shellescape} -c \"#{String(cmd)}\""

This comment has been minimized.

Copy link
@mcanevet

mcanevet Sep 1, 2015

Member

@anodelman I think it should be:

cmd = "#{String(useshell).shellescape} -c \"#{String(cmd.shellescape)}\""

This comment has been minimized.

Copy link
@mcanevet

mcanevet Sep 1, 2015

Member

PR created: #74


path = Specinfra.configuration.path
if path
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
context "has serverspec support" do
hosts.each do |node|
sshd = case node['platform']
when /windows|el-|redhat|centos|debian/
when /windows|el-|redhat|centos/
'sshd'
else
'ssh'
Expand Down

0 comments on commit a6b3e50

Please sign in to comment.