beaker 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/HISTORY.md +366 -2
- data/ext/completion/beaker-completion.bash +1 -1
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +3 -1
- data/lib/beaker/answers/version40.rb +42 -0
- data/lib/beaker/cli.rb +0 -2
- data/lib/beaker/command.rb +10 -2
- data/lib/beaker/dsl/ezbake_utils.rb +195 -157
- data/lib/beaker/dsl/helpers.rb +9 -6
- data/lib/beaker/dsl/install_utils.rb +22 -8
- data/lib/beaker/dsl/structure.rb +67 -0
- data/lib/beaker/host.rb +14 -4
- data/lib/beaker/host/mac.rb +4 -0
- data/lib/beaker/host/pswindows.rb +79 -0
- data/lib/beaker/host/pswindows/exec.rb +29 -0
- data/lib/beaker/host/pswindows/file.rb +15 -0
- data/lib/beaker/host/pswindows/group.rb +36 -0
- data/lib/beaker/host/pswindows/pkg.rb +47 -0
- data/lib/beaker/host/pswindows/user.rb +32 -0
- data/lib/beaker/host/unix.rb +16 -6
- data/lib/beaker/host/windows.rb +6 -2
- data/lib/beaker/host_prebuilt_steps.rb +2 -0
- data/lib/beaker/hypervisor.rb +3 -1
- data/lib/beaker/hypervisor/aws_sdk.rb +6 -1
- data/lib/beaker/hypervisor/docker.rb +6 -1
- data/lib/beaker/hypervisor/vagrant.rb +1 -1
- data/lib/beaker/hypervisor/vagrant_parallels.rb +18 -0
- data/lib/beaker/logger.rb +8 -1
- data/lib/beaker/logger_junit.rb +157 -0
- data/lib/beaker/network_manager.rb +28 -0
- data/lib/beaker/options/presets.rb +6 -0
- data/lib/beaker/test_suite.rb +65 -136
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +74 -0
- data/spec/beaker/dsl/ezbake_utils_spec.rb +167 -126
- data/spec/beaker/dsl/install_utils_spec.rb +5 -4
- data/spec/beaker/dsl/structure_spec.rb +28 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +2 -1
- data/spec/beaker/host_spec.rb +1 -7
- data/spec/beaker/hypervisor/docker_spec.rb +19 -1
- data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +44 -0
- data/spec/beaker/logger_junit_spec.rb +93 -0
- data/spec/beaker/network_manager_spec.rb +52 -0
- metadata +14 -2
@@ -26,7 +26,7 @@ module Beaker
|
|
26
26
|
GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
|
27
27
|
|
28
28
|
# The directories in the module directory that will not be scp-ed to the test system when using `copy_module_to`
|
29
|
-
PUPPET_MODULE_INSTALL_IGNORE = ['.bundle', '.git', '.idea', '.vagrant', '.vendor', 'vendor', 'acceptance', 'spec', 'tests', 'log']
|
29
|
+
PUPPET_MODULE_INSTALL_IGNORE = ['.bundle', '.git', '.idea', '.vagrant', '.vendor', 'vendor', 'acceptance', 'bundle', 'spec', 'tests', 'log']
|
30
30
|
|
31
31
|
# @param [String] uri A uri in the format of <git uri>#<revision>
|
32
32
|
# the `git://`, `http://`, `https://`, and ssh
|
@@ -805,14 +805,28 @@ module Beaker
|
|
805
805
|
if not link_exists?( link )
|
806
806
|
raise "Puppet #{version} at #{link} does not exist!"
|
807
807
|
end
|
808
|
-
on host, "curl -O #{link}"
|
809
|
-
on host, "msiexec /qn /i #{host['dist']}.msi"
|
810
808
|
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
809
|
+
if host['is_cygwin'].nil? or host['is_cygwin'] == true
|
810
|
+
dest = "/cygdrive/c/Windows/Temp/#{host['dist']}.msi"
|
811
|
+
on host, "curl -O #{dest} #{link}"
|
812
|
+
|
813
|
+
#Because the msi installer doesn't add Puppet to the environment path
|
814
|
+
#Add both potential paths for simplicity
|
815
|
+
#NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
|
816
|
+
puppetbin_path = "\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\""
|
817
|
+
on host, %Q{ echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc }
|
818
|
+
else
|
819
|
+
dest = "C:\\Windows\\Temp\\#{host['dist']}.msi"
|
820
|
+
|
821
|
+
on host, "set PATH=\"%PATH%;#{host['puppetbindir']}\""
|
822
|
+
on host, "setx PATH \"%PATH%;#{host['puppetbindir']}\""
|
823
|
+
|
824
|
+
on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')")
|
825
|
+
|
826
|
+
on host, "if not exist #{host['distmoduledir']} (md #{host['distmoduledir']})"
|
827
|
+
end
|
828
|
+
|
829
|
+
on host, "msiexec /qn /i #{dest}"
|
816
830
|
end
|
817
831
|
|
818
832
|
# Installs Puppet and dependencies from dmg
|
data/lib/beaker/dsl/structure.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'beaker/dsl/assertions'
|
1
2
|
module Beaker
|
2
3
|
module DSL
|
3
4
|
# These are simple structural elements necessary for writing
|
@@ -22,6 +23,11 @@ module Beaker
|
|
22
23
|
# step 'Test the things' do
|
23
24
|
# ...tests...
|
24
25
|
# end
|
26
|
+
#
|
27
|
+
# step 'Expect this to fail' do
|
28
|
+
# expect_failure('expected to fail due to PE-1234') do
|
29
|
+
# assert_equal(400, response.code, 'bad response code from API call')
|
30
|
+
# end
|
25
31
|
# end
|
26
32
|
#
|
27
33
|
module Structure
|
@@ -55,9 +61,70 @@ module Beaker
|
|
55
61
|
# on(master, puppet_resource('file', '/etc/puppet/modules',
|
56
62
|
# 'ensure=absent', 'purge=true'))
|
57
63
|
# end
|
64
|
+
# @api dsl
|
58
65
|
def teardown &block
|
59
66
|
@teardown_procs << block
|
60
67
|
end
|
68
|
+
|
69
|
+
# Wrap an assert that is supposed to fail due to a product bug, an
|
70
|
+
# undelivered feature, or some similar situation.
|
71
|
+
#
|
72
|
+
# This converts failing asserts into passing asserts (so we can continue to
|
73
|
+
# run the test even though there are underlying product bugs), and converts
|
74
|
+
# passing asserts into failing asserts (so we know when the underlying product
|
75
|
+
# bug has been fixed).
|
76
|
+
#
|
77
|
+
# Pass an assert as a code block, and pass an explanatory message as a
|
78
|
+
# parameter. The assert's logic will be inverted (so passes turn into fails
|
79
|
+
# and fails turn into passes).
|
80
|
+
#
|
81
|
+
# @example Typical usage
|
82
|
+
# expect_failure('expected to fail due to PE-1234') do
|
83
|
+
# assert_equal(400, response.code, 'bad response code from API call')
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# @example Output when a product bug would normally cause the assert to fail
|
87
|
+
# Warning: An assertion was expected to fail, and did.
|
88
|
+
# This is probably due to a known product bug, and is probably not a problem.
|
89
|
+
# Additional info: 'expected to fail due to PE-6995'
|
90
|
+
# Failed assertion: 'bad response code from API call.
|
91
|
+
# <400> expected but was <409>.'
|
92
|
+
#
|
93
|
+
# @example Output when the product bug has been fixed
|
94
|
+
# <RuntimeError: An assertion was expected to fail, but passed.
|
95
|
+
# This is probably because a product bug was fixed, and "expect_failure()"
|
96
|
+
# needs to be removed from this assert.
|
97
|
+
# Additional info: 'expected to fail due to PE-6996'>
|
98
|
+
#
|
99
|
+
# @param [String] explanation A description of why this assert is expected to
|
100
|
+
# fail
|
101
|
+
# @param block [Proc] block of code is expected to either raise an
|
102
|
+
# {Beaker::Assertions} or else return a value that
|
103
|
+
# will be ignored
|
104
|
+
# @raise [RuntimeError] if the code block passed to this method does not raise
|
105
|
+
# a {Beaker::Assertions} (i.e., if the assert
|
106
|
+
# passes)
|
107
|
+
# @author Chris Cowell-Shah (<tt>ccs@puppetlabs.com</tt>)
|
108
|
+
# @api dsl
|
109
|
+
def expect_failure(explanation, &block)
|
110
|
+
begin
|
111
|
+
yield if block_given? # code block should contain an assert that you expect to fail
|
112
|
+
rescue Beaker::DSL::Assertions, Minitest::Assertion => failed_assertion
|
113
|
+
# Yay! The assert in the code block failed, as expected.
|
114
|
+
# Swallow the failure so the test passes.
|
115
|
+
logger.notify 'An assertion was expected to fail, and did. ' +
|
116
|
+
'This is probably due to a known product bug, ' +
|
117
|
+
'and is probably not a problem. ' +
|
118
|
+
"Additional info: '#{explanation}' " +
|
119
|
+
"Failed assertion: '#{failed_assertion}'"
|
120
|
+
return
|
121
|
+
end
|
122
|
+
# Uh-oh! The assert in the code block unexpectedly passed.
|
123
|
+
fail('An assertion was expected to fail, but passed. ' +
|
124
|
+
'This is probably because a product bug was fixed, and ' +
|
125
|
+
'"expect_failure()" needs to be removed from this test. ' +
|
126
|
+
"Additional info: '#{explanation}'")
|
127
|
+
end
|
61
128
|
end
|
62
129
|
end
|
63
130
|
end
|
data/lib/beaker/host.rb
CHANGED
@@ -28,7 +28,12 @@ module Beaker
|
|
28
28
|
def self.create name, options
|
29
29
|
case options['HOSTS'][name]['platform']
|
30
30
|
when /windows/
|
31
|
-
|
31
|
+
cygwin = options['HOSTS'][name]['is_cygwin']
|
32
|
+
if cygwin.nil? or cygwin == true
|
33
|
+
Windows::Host.new name, options
|
34
|
+
else
|
35
|
+
PSWindows::Host.new name, options
|
36
|
+
end
|
32
37
|
when /aix/
|
33
38
|
Aix::Host.new name, options
|
34
39
|
when /osx/
|
@@ -49,7 +54,6 @@ module Beaker
|
|
49
54
|
# related through 'type' and the differences between the assumption of our two
|
50
55
|
# configurations we have for many of our products
|
51
56
|
type = @options.get_type
|
52
|
-
type = :foss if type == :aio && !@options['HOSTS'][@name]['roles'].include?('agent')
|
53
57
|
@defaults = merge_defaults_for_type @options, type
|
54
58
|
pkg_initialize
|
55
59
|
end
|
@@ -295,7 +299,13 @@ module Beaker
|
|
295
299
|
# @param [String] dir The directory structure to create on the host
|
296
300
|
# @return [Boolean] True, if directory construction succeeded, otherwise False
|
297
301
|
def mkdir_p dir
|
298
|
-
|
302
|
+
if host['is_cygwin'].nil? or host['is_cygwin'] == true
|
303
|
+
cmd = "mkdir -p #{dir}"
|
304
|
+
else
|
305
|
+
cmd = "if not exist #{dir.gsub!('/','\\')} (md #{dir.gsub!('/','\\')})"
|
306
|
+
end
|
307
|
+
|
308
|
+
result = exec(Beaker::Command.new(cmd), :acceptable_exit_codes => [0, 1])
|
299
309
|
result.exit_code == 0
|
300
310
|
end
|
301
311
|
|
@@ -381,7 +391,7 @@ module Beaker
|
|
381
391
|
|
382
392
|
end
|
383
393
|
|
384
|
-
[ 'windows', 'unix', 'aix', 'mac' ].each do |lib|
|
394
|
+
[ 'windows', 'pswindows', 'unix', 'aix', 'mac' ].each do |lib|
|
385
395
|
require "beaker/host/#{lib}"
|
386
396
|
end
|
387
397
|
end
|
data/lib/beaker/host/mac.rb
CHANGED
@@ -25,6 +25,8 @@ module Mac
|
|
25
25
|
'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
|
26
26
|
'puppetservice' => 'pe-httpd',
|
27
27
|
'puppetpath' => '/etc/puppetlabs/puppet',
|
28
|
+
'puppetconfdir' => '/etc/puppetlabs/puppet',
|
29
|
+
'puppetcodedir' => '/etc/puppetlabs/puppet',
|
28
30
|
'puppetbin' => '/opt/puppet/bin/puppet',
|
29
31
|
'puppetbindir' => '/opt/puppet/bin',
|
30
32
|
'puppetsbindir' => '/opt/puppet/sbin',
|
@@ -45,6 +47,8 @@ module Mac
|
|
45
47
|
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
46
48
|
'puppetservice' => 'puppetmaster',
|
47
49
|
'puppetpath' => '/etc/puppet',
|
50
|
+
'puppetconfdir' => '/etc/puppet',
|
51
|
+
'puppetcodedir' => '/etc/puppet',
|
48
52
|
'puppetvardir' => '/var/lib/puppet',
|
49
53
|
'puppetbin' => '/usr/bin/puppet',
|
50
54
|
'puppetbindir' => '/usr/bin',
|
@@ -0,0 +1,79 @@
|
|
1
|
+
[ 'host', 'command_factory', 'command', 'options' ].each do |lib|
|
2
|
+
require "beaker/#{lib}"
|
3
|
+
end
|
4
|
+
|
5
|
+
module PSWindows
|
6
|
+
class Host < Beaker::Host
|
7
|
+
[ 'user', 'group', 'exec', 'pkg', 'file' ].each do |lib|
|
8
|
+
require "beaker/host/pswindows/#{lib}"
|
9
|
+
end
|
10
|
+
|
11
|
+
include PSWindows::User
|
12
|
+
include PSWindows::Group
|
13
|
+
include PSWindows::File
|
14
|
+
include PSWindows::Exec
|
15
|
+
include PSWindows::Pkg
|
16
|
+
|
17
|
+
def self.pe_defaults
|
18
|
+
h = Beaker::Options::OptionsHash.new
|
19
|
+
h.merge({
|
20
|
+
'user' => 'Administrator',
|
21
|
+
'group' => 'Administrators',
|
22
|
+
'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
|
23
|
+
'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
|
24
|
+
'puppetservice' => 'pe-httpd',
|
25
|
+
'pathseparator' => ';',
|
26
|
+
'puppetpath' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
27
|
+
'puppetconfdir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
28
|
+
'puppetcodedir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
29
|
+
'hieraconf' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\hiera.yaml',
|
30
|
+
'puppetvardir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\var',
|
31
|
+
})
|
32
|
+
|
33
|
+
if platform.include?('amd64')
|
34
|
+
h.merge({
|
35
|
+
'puppetbindir' => 'C:\\Program Files (x86)\\PuppetLabs\\Puppet Enterprise\\bin'
|
36
|
+
})
|
37
|
+
else
|
38
|
+
h.merge({
|
39
|
+
'puppetbindir' => 'C:\\Program Files\\PuppetLabs\\Puppet Enterprise\\bin'
|
40
|
+
})
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.foss_defaults
|
45
|
+
h = Beaker::Options::OptionsHash.new
|
46
|
+
h.merge({
|
47
|
+
'user' => 'Administrator',
|
48
|
+
'group' => 'Administrators',
|
49
|
+
'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
|
50
|
+
'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
|
51
|
+
'hieralibdir' => 'C:\\opt\\puppet-git-repos\\hiera\\lib',
|
52
|
+
'hierapuppetlibdir' => 'C:\\opt\\puppet-git-repos\\hiera-puppet\\lib',
|
53
|
+
'hierabindir' => 'C:\\opt\\puppet-git-repos\\hiera\\bin',
|
54
|
+
'pathseparator' => ';'
|
55
|
+
})
|
56
|
+
|
57
|
+
if h['platform'] && h['platform'].include?('amd64')
|
58
|
+
h.merge({
|
59
|
+
'puppetpath' => "C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc",
|
60
|
+
'puppetconfdir' => "C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc",
|
61
|
+
'puppetcodedir' => "C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc",
|
62
|
+
'hieraconf' => "C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc\\hiera.yaml",
|
63
|
+
'puppetvardir' => 'C:\\Program Files (x86)\\Puppet Labs\\Puppet\\var',
|
64
|
+
'puppetbindir' => "C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin"
|
65
|
+
})
|
66
|
+
else
|
67
|
+
h.merge({
|
68
|
+
'puppetpath' => "C:\\Program Files\\Puppet Labs\\Puppet\\etc",
|
69
|
+
'puppetconfdir' => "C:\\Program Files\\Puppet Labs\\Puppet\\etc",
|
70
|
+
'puppetcodedir' => "C:\\Program Files\\Puppet Labs\\Puppet\\etc",
|
71
|
+
'hieraconf' => "C:\\Program Files\\Puppet Labs\\Puppet\\etc\\hiera.yaml",
|
72
|
+
'puppetvardir' => 'C:\\Program Files\\Puppet Labs\\Puppet\\var',
|
73
|
+
'puppetbindir' => "C:\\Program Files\\Puppet Labs\\Puppet\\bin"
|
74
|
+
})
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PSWindows::Exec
|
2
|
+
include Beaker::CommandFactory
|
3
|
+
|
4
|
+
ABS_CMD = 'c:\\\\windows\\\\system32\\\\cmd.exe'
|
5
|
+
CMD = 'cmd.exe'
|
6
|
+
|
7
|
+
def echo(msg, abs=true)
|
8
|
+
(abs ? ABS_CMD : CMD) + " /c echo #{msg}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def touch(file, abs=true)
|
12
|
+
(abs ? ABS_CMD : CMD) + " /c echo. 2> #{file}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
'c:/windows/system32;c:/windows'
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_ip
|
20
|
+
ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IP Address\"') do @echo %f").strip
|
21
|
+
if ip == ''
|
22
|
+
ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IPv4 Address\"') do @echo %f").strip
|
23
|
+
end
|
24
|
+
if ip == ''
|
25
|
+
ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IPv6 Address\"') do @echo %f").strip
|
26
|
+
end
|
27
|
+
ip
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module PSWindows::File
|
2
|
+
include Beaker::CommandFactory
|
3
|
+
|
4
|
+
def tmpfile(name)
|
5
|
+
execute("echo C:\\Windows\\Temp\\#{name}.XXXXXX")
|
6
|
+
end
|
7
|
+
|
8
|
+
def tmpdir(name)
|
9
|
+
execute("echo C:\\Windows\\Temp\\#{name}.XXXXXX")
|
10
|
+
end
|
11
|
+
|
12
|
+
def path_split(paths)
|
13
|
+
paths.split(';')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module PSWindows::Group
|
2
|
+
include Beaker::CommandFactory
|
3
|
+
|
4
|
+
def group_list(&block)
|
5
|
+
execute('cmd /c echo "" | wmic group where localaccount="true" get name /format:value') do |result|
|
6
|
+
groups = []
|
7
|
+
result.stdout.each_line do |line|
|
8
|
+
groups << (line.match(/^Name=(.+)$/) or next)[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
yield result if block_given?
|
12
|
+
|
13
|
+
groups
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def group_get(name, &block)
|
18
|
+
execute("net localgroup \"#{name}\"") do |result|
|
19
|
+
fail_test "failed to get group #{name}" unless result.stdout =~ /^Alias name\s+#{name}/
|
20
|
+
|
21
|
+
yield result if block_given?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def group_gid(name)
|
26
|
+
raise NotImplementedError, "Can't retrieve group gid on a Windows host"
|
27
|
+
end
|
28
|
+
|
29
|
+
def group_present(name, &block)
|
30
|
+
execute("net localgroup /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def group_absent(name, &block)
|
34
|
+
execute("net localgroup /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module PSWindows::Pkg
|
2
|
+
include Beaker::CommandFactory
|
3
|
+
|
4
|
+
def check_for_command(name)
|
5
|
+
result = exec(Beaker::Command.new("where #{name}"), :acceptable_exit_codes => (0...127))
|
6
|
+
result.exit_code == 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_for_package(name)
|
10
|
+
raise "Cannot check for package #{name} on #{self}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_package(name, cmdline_args = '')
|
14
|
+
raise "Package #{name} cannot be installed on #{self}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def uninstall_package(name, cmdline_args = '')
|
18
|
+
raise "Package #{name} cannot be uninstalled on #{self}"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# @api private
|
24
|
+
def identify_windows_architecture
|
25
|
+
arch = nil
|
26
|
+
execute("echo '' | wmic os get osarchitecture",
|
27
|
+
:acceptable_exit_codes => (0...127)) do |result|
|
28
|
+
|
29
|
+
arch = if result.exit_code == 0
|
30
|
+
result.stdout =~ /64/ ? '64' : '32'
|
31
|
+
else
|
32
|
+
identify_windows_architecture_from_os_name_for_win2003
|
33
|
+
end
|
34
|
+
end
|
35
|
+
arch
|
36
|
+
end
|
37
|
+
|
38
|
+
# @api private
|
39
|
+
def identify_windows_architecture_from_os_name_for_win2003
|
40
|
+
arch = nil
|
41
|
+
execute("echo '' | wmic os get name | grep x64",
|
42
|
+
:acceptable_exit_codes => (0...127)) do |result|
|
43
|
+
arch = result.exit_code == 0 ? '64' : '32'
|
44
|
+
end
|
45
|
+
arch
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PSWindows::User
|
2
|
+
include Beaker::CommandFactory
|
3
|
+
|
4
|
+
def user_list(&block)
|
5
|
+
execute('cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value') do |result|
|
6
|
+
users = []
|
7
|
+
result.stdout.each_line do |line|
|
8
|
+
users << (line.match(/^Name=([\w ]+)/) or next)[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
yield result if block_given?
|
12
|
+
|
13
|
+
users
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def user_get(name, &block)
|
18
|
+
execute("net user \"#{name}\"") do |result|
|
19
|
+
fail_test "failed to get user #{name}" unless result.stdout =~ /^User name\s+#{name}/
|
20
|
+
|
21
|
+
yield result if block_given?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_present(name, &block)
|
26
|
+
execute("net user /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_absent(name, &block)
|
30
|
+
execute("net user /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
|
31
|
+
end
|
32
|
+
end
|
data/lib/beaker/host/unix.rb
CHANGED
@@ -22,9 +22,11 @@ module Unix
|
|
22
22
|
'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
|
23
23
|
'puppetservice' => 'pe-httpd',
|
24
24
|
'puppetpath' => '/etc/puppetlabs/puppet',
|
25
|
+
'puppetconfdir' => '/etc/puppetlabs/puppet',
|
25
26
|
'puppetbin' => '/opt/puppet/bin/puppet',
|
26
27
|
'puppetbindir' => '/opt/puppet/bin',
|
27
28
|
'puppetsbindir' => '/opt/puppet/sbin',
|
29
|
+
'systembindir' => '/opt/puppet/bin',
|
28
30
|
'puppetvardir' => '/var/opt/lib/pe-puppet',
|
29
31
|
'hieradatadir' => '/var/lib/hiera',
|
30
32
|
'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
|
@@ -42,9 +44,11 @@ module Unix
|
|
42
44
|
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
43
45
|
'puppetservice' => 'puppetmaster',
|
44
46
|
'puppetpath' => '/etc/puppet',
|
47
|
+
'puppetconfdir' => '/etc/puppet',
|
45
48
|
'puppetvardir' => '/var/lib/puppet',
|
46
49
|
'puppetbin' => '/usr/bin/puppet',
|
47
50
|
'puppetbindir' => '/usr/bin',
|
51
|
+
'systembindir' => '/usr/bin',
|
48
52
|
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
49
53
|
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
50
54
|
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
@@ -58,12 +62,18 @@ module Unix
|
|
58
62
|
|
59
63
|
def self.aio_defaults
|
60
64
|
h = self.foss_defaults
|
61
|
-
h['
|
62
|
-
h['
|
63
|
-
h['
|
64
|
-
h['
|
65
|
-
h['
|
66
|
-
h['
|
65
|
+
h['puppetserver-confdir'] = '/etc/puppetlabs/puppetserver/conf.d'
|
66
|
+
h['puppetservice'] = 'puppetserver'
|
67
|
+
h['puppetbindir'] = '/opt/puppetlabs/agent/bin'
|
68
|
+
h['puppetbin'] = "#{h['puppetbindir']}/puppet"
|
69
|
+
h['puppetpath'] = '/etc/puppetlabs/agent'
|
70
|
+
h['puppetconfdir'] = "#{h['puppetpath']}/config"
|
71
|
+
h['puppetcodedir'] = "#{h['puppetpath']}/code"
|
72
|
+
h['puppetvardir'] = '/opt/puppetlabs/agent/cache'
|
73
|
+
h['distmoduledir'] = "#{h['puppetcodedir']}/modules"
|
74
|
+
h['sitemoduledir'] = '/opt/puppetlabs/agent/modules'
|
75
|
+
h['hieraconf'] = "#{h['puppetcodedir']}/hiera.yaml"
|
76
|
+
h['hieradatadir'] = "#{h['puppetcodedir']}/hieradata"
|
67
77
|
h
|
68
78
|
end
|
69
79
|
end
|