beaker 4.40.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +17 -28
- data/Gemfile +12 -7
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +93 -198
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -24
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +22 -27
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -36
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +7 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
data/lib/beaker/host/cisco.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
[
|
1
|
+
%w[host command_factory].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module Cisco
|
6
6
|
class Host < Unix::Host
|
7
|
-
|
8
7
|
# as the cisco hosts tend to have custom
|
9
8
|
# ssh configuration, the presets
|
10
9
|
# do not apply where verification of the
|
@@ -12,10 +11,10 @@ module Cisco
|
|
12
11
|
def platform_defaults
|
13
12
|
h = Beaker::Options::OptionsHash.new
|
14
13
|
h.merge({
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
'ssh' => {
|
15
|
+
:verify_host_key => false,
|
16
|
+
},
|
17
|
+
})
|
19
18
|
end
|
20
19
|
|
21
20
|
# Tells you whether a host platform supports beaker's
|
@@ -34,9 +33,7 @@ module Cisco
|
|
34
33
|
#
|
35
34
|
# @return nil
|
36
35
|
def scp_post_operations(scp_file_actual, scp_file_target)
|
37
|
-
if self[:platform].include?('cisco_nexus')
|
38
|
-
execute( "mv #{scp_file_actual} #{scp_file_target}" )
|
39
|
-
end
|
36
|
+
execute("mv #{scp_file_actual} #{scp_file_target}") if self[:platform].include?('cisco_nexus')
|
40
37
|
nil
|
41
38
|
end
|
42
39
|
|
@@ -48,8 +45,8 @@ module Cisco
|
|
48
45
|
# constraints
|
49
46
|
def scp_path(path)
|
50
47
|
if self[:platform].include?('cisco_nexus')
|
51
|
-
@home_dir ||= execute(
|
52
|
-
answer = "#{@home_dir}/#{File.basename(
|
48
|
+
@home_dir ||= execute('pwd')
|
49
|
+
answer = "#{@home_dir}/#{File.basename(path)}"
|
53
50
|
answer << '/' if /\/$/.match?(path)
|
54
51
|
return answer
|
55
52
|
end
|
@@ -83,18 +80,15 @@ module Cisco
|
|
83
80
|
# @return [String] Command string as needed for this host
|
84
81
|
def prepend_commands(command = '', user_pc = '', _opts = {})
|
85
82
|
return user_pc unless command.index('vsh').nil?
|
83
|
+
|
86
84
|
if self[:platform].include?('cisco_nexus')
|
87
85
|
return user_pc unless command.index('ntpdate').nil?
|
88
86
|
end
|
89
87
|
|
90
88
|
prepend_cmds = 'source /etc/profile;'
|
91
89
|
prepend_cmds << " sudo -E sh -c \"" if self[:user] != 'root'
|
92
|
-
if self[:vrf]
|
93
|
-
|
94
|
-
end
|
95
|
-
if user_pc && !user_pc.empty?
|
96
|
-
prepend_cmds << "#{user_pc} "
|
97
|
-
end
|
90
|
+
prepend_cmds << "ip netns exec #{self[:vrf]} " if self[:vrf]
|
91
|
+
prepend_cmds << "#{user_pc} " if user_pc && !user_pc.empty?
|
98
92
|
prepend_cmds.strip
|
99
93
|
end
|
100
94
|
|
@@ -106,7 +100,7 @@ module Cisco
|
|
106
100
|
#
|
107
101
|
# @return [String] Command string as needed for this host
|
108
102
|
def append_commands(command = '', _user_ac = '', _opts = {})
|
109
|
-
command.gsub('"') {'\\"'}
|
103
|
+
command.gsub('"') { '\\"' }
|
110
104
|
# vsh commands, ntpdate or when user is root commands do not require an appended `"`
|
111
105
|
return '"' unless /ntpdate|\/isan\/bin\/vsh/.match?(command) || self[:user] == 'root'
|
112
106
|
end
|
@@ -125,14 +119,15 @@ module Cisco
|
|
125
119
|
def environment_string env
|
126
120
|
prestring = ''
|
127
121
|
return prestring if env.empty?
|
128
|
-
|
122
|
+
|
123
|
+
env_array = self.environment_variable_string_pair_array(env)
|
129
124
|
environment_string = env_array.join(' ')
|
130
125
|
|
131
|
-
if self[:platform].include?('cisco_nexus')
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
prestring << if self[:platform].include?('cisco_nexus')
|
127
|
+
" export"
|
128
|
+
else
|
129
|
+
" env"
|
130
|
+
end
|
136
131
|
environment_string = "#{prestring} #{environment_string}"
|
137
132
|
environment_string << ';' if prestring.include?('export')
|
138
133
|
environment_string
|
@@ -146,26 +141,19 @@ module Cisco
|
|
146
141
|
def validate_setup
|
147
142
|
msg = nil
|
148
143
|
if self[:platform].include?('cisco_nexus')
|
149
|
-
if !self[:vrf]
|
150
|
-
|
151
|
-
end
|
152
|
-
if !self[:user]
|
153
|
-
msg = 'Cisco hosts must be provided with a :user value'
|
154
|
-
end
|
144
|
+
msg = 'Cisco Nexus hosts must be provided with a :vrf value.' if !self[:vrf]
|
145
|
+
msg = 'Cisco hosts must be provided with a :user value' if !self[:user]
|
155
146
|
end
|
156
147
|
if self[:platform].include?('cisco_ios_xr')
|
157
|
-
if !self[:user]
|
158
|
-
msg = 'Cisco hosts must be provided with a :user value'
|
159
|
-
end
|
148
|
+
msg = 'Cisco hosts must be provided with a :user value' if !self[:user]
|
160
149
|
end
|
161
150
|
|
162
|
-
|
163
|
-
|
151
|
+
return unless msg
|
152
|
+
|
153
|
+
msg << <<-EOF
|
164
154
|
Check https://github.com/puppetlabs/beaker/blob/master/docs/hosts/cisco.md for more info.'
|
165
|
-
|
166
|
-
|
167
|
-
end
|
155
|
+
EOF
|
156
|
+
raise ArgumentError, msg
|
168
157
|
end
|
169
|
-
|
170
158
|
end
|
171
159
|
end
|
data/lib/beaker/host/eos.rb
CHANGED
@@ -1,34 +1,9 @@
|
|
1
|
-
[
|
1
|
+
%w[host command_factory].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module Eos
|
6
6
|
class Host < Unix::Host
|
7
|
-
|
8
|
-
# Gets the path & file name for the puppet agent dev package on EOS
|
9
|
-
#
|
10
|
-
# @param [String] puppet_collection Name of the puppet collection to use
|
11
|
-
# @param [String] puppet_agent_version Version of puppet agent to get
|
12
|
-
# @param [Hash{Symbol=>String}] opts Options hash to provide extra values
|
13
|
-
#
|
14
|
-
# @note EOS doesn't use any additional options at this time, but does require
|
15
|
-
# both puppet_collection & puppet_agent_version, & will fail without them
|
16
|
-
#
|
17
|
-
# @raise [ArgumentError] If one of the two required parameters (puppet_collection,
|
18
|
-
# puppet_agent_version) is either not passed or set to nil
|
19
|
-
#
|
20
|
-
# @return [String, String] Path to the directory and filename of the package, respectively
|
21
|
-
def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, _opts = {} )
|
22
|
-
error_message = "Must provide %s argument to get puppet agent dev package information"
|
23
|
-
raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
|
24
|
-
raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
|
25
|
-
|
26
|
-
variant, version, arch, _ = self['platform'].to_array
|
27
|
-
release_path = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
|
28
|
-
release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.swix"
|
29
|
-
return release_path, release_file
|
30
|
-
end
|
31
|
-
|
32
7
|
# Copies a remote file to the host location specified
|
33
8
|
#
|
34
9
|
# @param [String] remote_url URL to the remote file
|
@@ -38,7 +13,7 @@ module Eos
|
|
38
13
|
# about location, so that parameter is ignored
|
39
14
|
#
|
40
15
|
# @return [Result] The result of copying that file to the host
|
41
|
-
def get_remote_file(
|
16
|
+
def get_remote_file(remote_url, _host_directory = '')
|
42
17
|
commands = ['enable', "copy #{remote_url} extension:"]
|
43
18
|
command = commands.join("\n")
|
44
19
|
execute("Cli -c '#{command}'")
|
@@ -49,11 +24,10 @@ module Eos
|
|
49
24
|
# @param [String] filename Name of the file to install, including file extension
|
50
25
|
#
|
51
26
|
# @return [Result] The result of running the install command on the host
|
52
|
-
def install_from_file(
|
27
|
+
def install_from_file(filename)
|
53
28
|
commands = ['enable', "extension #{filename}"]
|
54
29
|
command = commands.join("\n")
|
55
30
|
execute("Cli -c '#{command}'")
|
56
31
|
end
|
57
|
-
|
58
32
|
end
|
59
|
-
end
|
33
|
+
end
|
@@ -3,7 +3,7 @@ module FreeBSD::Exec
|
|
3
3
|
|
4
4
|
def echo_to_file(str, filename)
|
5
5
|
# FreeBSD gets weird about special characters, we have to go a little OTT here
|
6
|
-
escaped_str = str.gsub(/\t/,'\\t').gsub(/\n/,'\\n')
|
6
|
+
escaped_str = str.gsub(/\t/, '\\t').gsub(/\n/, '\\n')
|
7
7
|
|
8
8
|
exec(Beaker::Command.new("printf \"#{escaped_str}\" > #{filename}"))
|
9
9
|
end
|
@@ -8,11 +8,11 @@ module FreeBSD::Pkg
|
|
8
8
|
|
9
9
|
def check_pkgng_sh
|
10
10
|
'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist ' \
|
11
|
-
|
11
|
+
'pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
|
12
12
|
end
|
13
13
|
|
14
14
|
def pkgng_active?(opts = {})
|
15
|
-
opts = {:accept_all_exit_codes => true}.merge(opts)
|
15
|
+
opts = { :accept_all_exit_codes => true }.merge(opts)
|
16
16
|
execute("/bin/sh -c '#{check_pkgng_sh}'", opts) { |r| r }.exit_code == 0
|
17
17
|
end
|
18
18
|
|
@@ -35,7 +35,7 @@ module FreeBSD::Pkg
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def check_for_package(package, opts = {})
|
38
|
-
opts = {:accept_all_exit_codes => true}.merge(opts)
|
38
|
+
opts = { :accept_all_exit_codes => true }.merge(opts)
|
39
39
|
cmd = if pkgng_active?
|
40
40
|
"pkg info #{package}"
|
41
41
|
else
|
data/lib/beaker/host/freebsd.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
[
|
1
|
+
%w[host command_factory].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module FreeBSD
|
6
6
|
class Host < Unix::Host
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
'pkg',
|
7
|
+
%w[
|
8
|
+
exec
|
9
|
+
pkg
|
11
10
|
].each do |lib|
|
12
|
-
|
11
|
+
require "beaker/host/freebsd/#{lib}"
|
13
12
|
end
|
14
13
|
|
15
14
|
include FreeBSD::Exec
|
@@ -18,12 +17,10 @@ module FreeBSD
|
|
18
17
|
def platform_defaults
|
19
18
|
h = Beaker::Options::OptionsHash.new
|
20
19
|
h.merge({
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
'user' => 'root',
|
21
|
+
'group' => 'root',
|
22
|
+
'pathseparator' => ':',
|
23
|
+
})
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
|
-
|
29
26
|
end
|
data/lib/beaker/host/mac/exec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mac::Exec
|
2
2
|
include Beaker::CommandFactory
|
3
3
|
|
4
|
-
def touch(file, abs=true)
|
4
|
+
def touch(file, abs = true)
|
5
5
|
(abs ? '/usr/bin/touch' : 'touch') + " #{file}"
|
6
6
|
end
|
7
7
|
|
@@ -24,14 +24,14 @@ module Mac::Exec
|
|
24
24
|
ssh_config_file = '/private/etc/ssh/sshd_config' if /^osx-/.match?(self['platform'])
|
25
25
|
|
26
26
|
exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
|
27
|
-
ssh_service_restart
|
27
|
+
ssh_service_restart
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
30
|
+
# Checks if selinux is enabled
|
31
31
|
# selinux is not availble on OS X
|
32
32
|
#
|
33
33
|
# @return [Boolean] false
|
34
|
-
def selinux_enabled?
|
34
|
+
def selinux_enabled?
|
35
35
|
false
|
36
36
|
end
|
37
37
|
|
@@ -6,7 +6,7 @@ module Mac::Group
|
|
6
6
|
# @param [Proc] block Additional actions or insertions
|
7
7
|
#
|
8
8
|
# @return [Array<String>] The list of group names on the system
|
9
|
-
def group_list
|
9
|
+
def group_list
|
10
10
|
execute('dscacheutil -q group') do |result|
|
11
11
|
groups = []
|
12
12
|
result.stdout.each_line do |line|
|
@@ -31,11 +31,11 @@ module Mac::Group
|
|
31
31
|
def group_get(name)
|
32
32
|
execute("dscacheutil -q group -a name #{name}") do |result|
|
33
33
|
fail_test "failed to get group #{name}" unless /^name: #{name}/.match?(result.stdout)
|
34
|
-
gi =
|
35
|
-
result.stdout.each_line
|
34
|
+
gi = {} # group info
|
35
|
+
result.stdout.each_line do |line|
|
36
36
|
pieces = line.split(': ')
|
37
37
|
gi[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
|
38
|
-
|
38
|
+
end
|
39
39
|
answer = "#{gi[:name]}:#{gi[:password]}:#{gi[:gid]}"
|
40
40
|
|
41
41
|
yield answer if block_given?
|
@@ -51,12 +51,12 @@ module Mac::Group
|
|
51
51
|
def group_gid(name)
|
52
52
|
gid = -1
|
53
53
|
execute("dscacheutil -q group -a name #{name}") do |result|
|
54
|
-
result.stdout.each_line
|
54
|
+
result.stdout.each_line do |line|
|
55
55
|
if /^gid:/.match?(line)
|
56
56
|
gid = (line[5, line.length - 5]).chomp
|
57
57
|
break
|
58
58
|
end
|
59
|
-
|
59
|
+
end
|
60
60
|
gid
|
61
61
|
end
|
62
62
|
end
|
@@ -74,7 +74,7 @@ module Mac::Group
|
|
74
74
|
return if group_exists
|
75
75
|
|
76
76
|
gid = gid_next
|
77
|
-
create_cmd
|
77
|
+
create_cmd = "dscl . create /Groups/#{name}"
|
78
78
|
create_cmd << " && dscl . create /Groups/#{name} PrimaryGroupID #{gid}"
|
79
79
|
execute(create_cmd)
|
80
80
|
end
|
data/lib/beaker/host/mac/pkg.rb
CHANGED
@@ -38,116 +38,13 @@ module Mac::Pkg
|
|
38
38
|
# @param [String] cmdline_args Additional command line arguments for
|
39
39
|
# the package manager
|
40
40
|
def upgrade_package(name, _cmdline_args = '')
|
41
|
-
|
41
|
+
raise "Package #{name} cannot be upgraded on #{self}"
|
42
42
|
end
|
43
43
|
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# This method calls one of #deploy_apt_repo, #deploy_yum_repo, or
|
47
|
-
# #deploy_zyp_repo depending on the platform of this Host.
|
48
|
-
#
|
49
|
-
# @note See {Beaker::DSL::Helpers::HostHelpers#deploy_package_repo} for info on
|
50
|
-
# params
|
51
|
-
def deploy_package_repo(_path, _name, _version)
|
52
|
-
raise "Package repo cannot be deployed on #{self}; the platform is not supported"
|
53
|
-
end
|
54
|
-
|
55
|
-
#Examine the host system to determine the architecture
|
56
|
-
#@return [Boolean] true if x86_64, false otherwise
|
44
|
+
# Examine the host system to determine the architecture
|
45
|
+
# @return [Boolean] true if x86_64, false otherwise
|
57
46
|
def determine_if_x86_64
|
58
47
|
result = exec(Beaker::Command.new("uname -a | grep x86_64"), :expect_all_exit_codes => true)
|
59
48
|
result.exit_code == 0
|
60
49
|
end
|
61
|
-
|
62
|
-
# Gets the path & file name for the puppet agent dev package on OSX
|
63
|
-
#
|
64
|
-
# @param [String] puppet_collection Name of the puppet collection to use
|
65
|
-
# @param [String] puppet_agent_version Version of puppet agent to get
|
66
|
-
# @param [Hash{Symbol=>String}] opts Options hash to provide extra values
|
67
|
-
#
|
68
|
-
# @note OSX does require :download_url to be set on the opts argument
|
69
|
-
# in order to check for builds on the builds server
|
70
|
-
#
|
71
|
-
# @raise [ArgumentError] If one of the two required parameters (puppet_collection,
|
72
|
-
# puppet_agent_version) is either not passed or set to nil
|
73
|
-
#
|
74
|
-
# @return [String, String] Path to the directory and filename of the package, respectively
|
75
|
-
def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
|
76
|
-
error_message = "Must provide %s argument to get puppet agent dev package information"
|
77
|
-
raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
|
78
|
-
raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
|
79
|
-
raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
|
80
|
-
|
81
|
-
variant, version, arch, codename = self['platform'].to_array
|
82
|
-
|
83
|
-
mac_pkg_name = "puppet-agent-#{puppet_agent_version}"
|
84
|
-
version = version[0,2] + '.' + version[2,2] unless version.include?(".")
|
85
|
-
# newest hotness
|
86
|
-
path_chunk = "apple/#{version}/#{puppet_collection}/#{arch}"
|
87
|
-
release_path_end = path_chunk
|
88
|
-
# moved to doing this when 'el capitan' came out & the objection was
|
89
|
-
# raised that the code name wasn't a fact, & as such can be hard to script
|
90
|
-
# example: puppet-agent-0.1.0-1.osx10.9.dmg
|
91
|
-
release_file = "#{mac_pkg_name}-1.osx#{version}.dmg"
|
92
|
-
if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # new hotness
|
93
|
-
# little older change involved the code name as only difference from above
|
94
|
-
# example: puppet-agent-0.1.0-1.mavericks.dmg
|
95
|
-
release_file = "#{mac_pkg_name}-1.#{codename}.dmg"
|
96
|
-
end
|
97
|
-
if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # oops, try the old stuff
|
98
|
-
release_path_end = "apple/#{puppet_collection}"
|
99
|
-
# example: puppet-agent-0.1.0-osx-10.9-x86_64.dmg
|
100
|
-
release_file = "#{mac_pkg_name}-#{variant}-#{version}-x86_64.dmg"
|
101
|
-
end
|
102
|
-
return release_path_end, release_file
|
103
|
-
end
|
104
|
-
|
105
|
-
# Gets host-specific information for PE promoted puppet-agent packages
|
106
|
-
#
|
107
|
-
# @param [String] puppet_collection Name of the puppet collection to use
|
108
|
-
# @param [Hash{Symbol=>String}] opts Options hash to provide extra values
|
109
|
-
#
|
110
|
-
# @return [String, String, String] Host-specific information for packages
|
111
|
-
# 1. release_path_end Suffix for the release_path. Used on Windows. Check
|
112
|
-
# {Windows::Pkg#pe_puppet_agent_promoted_package_info} to see usage.
|
113
|
-
# 2. release_file Path to the file on release build servers
|
114
|
-
# 3. download_file Filename for the package itself
|
115
|
-
def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
|
116
|
-
error_message = "Must provide %s argument to get puppet agent dev package information"
|
117
|
-
raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
|
118
|
-
|
119
|
-
variant, version, arch, _codename = self['platform'].to_array
|
120
|
-
release_file = "/repos/apple/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*"
|
121
|
-
|
122
|
-
# macOS puppet-agent tarballs haven't always included arch
|
123
|
-
agent_version = opts[:puppet_agent_version]
|
124
|
-
agent_version_f = agent_version&.to_f
|
125
|
-
|
126
|
-
download_file = if agent_version_f.nil? || (agent_version_f < 6.28 || (agent_version_f >= 7.0 && agent_version_f < 7.18))
|
127
|
-
"puppet-agent-#{variant}-#{version}.tar.gz"
|
128
|
-
else
|
129
|
-
"puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
|
130
|
-
end
|
131
|
-
|
132
|
-
return '', release_file, download_file
|
133
|
-
end
|
134
|
-
|
135
|
-
# Installs a given PE promoted package on a host
|
136
|
-
#
|
137
|
-
# @param [String] onhost_copy_base Base copy directory on the host
|
138
|
-
# @param [String] onhost_copied_download Downloaded file path on the host
|
139
|
-
# @param [String] onhost_copied_file Copied file path once un-compressed
|
140
|
-
# @param [String] download_file File name of the downloaded file
|
141
|
-
# @param [Hash{Symbol=>String}] opts additional options
|
142
|
-
#
|
143
|
-
# @return nil
|
144
|
-
def pe_puppet_agent_promoted_package_install(
|
145
|
-
onhost_copy_base, onhost_copied_download, onhost_copied_file, _download_file, _opts
|
146
|
-
)
|
147
|
-
execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
|
148
|
-
# move to better location
|
149
|
-
execute("mv #{onhost_copied_file}.dmg .")
|
150
|
-
self.install_package("puppet-agent-*")
|
151
|
-
end
|
152
|
-
|
153
50
|
end
|
data/lib/beaker/host/mac/user.rb
CHANGED
@@ -6,7 +6,7 @@ module Mac::User
|
|
6
6
|
# @param [Proc] block Additional actions or insertions
|
7
7
|
#
|
8
8
|
# @return [Array<String>] The list of user names on the system
|
9
|
-
def user_list
|
9
|
+
def user_list
|
10
10
|
execute('dscacheutil -q user') do |result|
|
11
11
|
users = []
|
12
12
|
result.stdout.each_line do |line|
|
@@ -54,7 +54,7 @@ module Mac::User
|
|
54
54
|
|
55
55
|
uid = uid_next
|
56
56
|
gid = gid_next
|
57
|
-
create_cmd
|
57
|
+
create_cmd = "dscl . create /Users/#{name}"
|
58
58
|
create_cmd << " && dscl . create /Users/#{name} NFSHomeDirectory /Users/#{name}"
|
59
59
|
create_cmd << " && dscl . create /Users/#{name} UserShell /bin/bash"
|
60
60
|
create_cmd << " && dscl . create /Users/#{name} UniqueID #{uid}"
|
data/lib/beaker/host/mac.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
[
|
1
|
+
%w[host command_factory command options].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module Mac
|
6
|
-
|
7
|
-
|
8
|
-
[ 'exec', 'user', 'group', 'pkg' ].each do |lib|
|
6
|
+
class Host < Unix::Host
|
7
|
+
%w[exec user group pkg].each do |lib|
|
9
8
|
require "beaker/host/mac/#{lib}"
|
10
9
|
end
|
11
10
|
|
@@ -17,18 +16,18 @@ module Mac
|
|
17
16
|
def platform_defaults
|
18
17
|
h = Beaker::Options::OptionsHash.new
|
19
18
|
h.merge({
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
'user' => 'root',
|
20
|
+
'group' => 'root',
|
21
|
+
'pathseparator' => ':',
|
22
|
+
})
|
24
23
|
end
|
25
24
|
|
26
25
|
attr_reader :external_copy_base
|
26
|
+
|
27
27
|
def initialize name, host_hash, options
|
28
28
|
super
|
29
29
|
|
30
30
|
@external_copy_base = '/var/root'
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
34
33
|
end
|