beaker 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/beaker/dsl/helpers/host_helpers.rb +48 -0
- data/lib/beaker/host/cisco.rb +2 -2
- data/lib/beaker/host/mac/exec.rb +1 -1
- data/lib/beaker/host_prebuilt_steps.rb +12 -7
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/cisco_spec.rb +16 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53eff8a2f49c2dc6d030c7c6032225500ba53bc5
|
4
|
+
data.tar.gz: 0a3ea2358e01984b5d63dc92c2594fca0aee0209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ec5313fa43c0ebccad6f5c3957edd6e185c5f8e1f3468b760201b3ab8b2db6a683fbff91cd346cab9f85ccac2fea985ae932c03f1ea7d89ac4ce2173811d44
|
7
|
+
data.tar.gz: 4758fd7751f6ad3e5af51f07b74d093d1ddd445f030d82b7147b0f4b2f728b9bd1e77082c608af0608c555ae512583d1c1f5cdda6e1011d9de59484822d561d0
|
data/CHANGELOG.md
CHANGED
@@ -11,7 +11,19 @@ Tracking in this Changelog began for this project in version 3.25.0.
|
|
11
11
|
If you're looking for changes from before this, refer to the project's
|
12
12
|
git logs & PR history.
|
13
13
|
|
14
|
-
# [Unreleased](https://github.com/puppetlabs/beaker/compare/4.
|
14
|
+
# [Unreleased](https://github.com/puppetlabs/beaker/compare/4.4.0...master)
|
15
|
+
|
16
|
+
# [4.4.0](https://github.com/puppetlabs/beaker/compare/4.3.0...4.4.0) - 2019.01.09
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Return root considerations for appending on nexus devices (BKR-1526)
|
21
|
+
- Permit user environment on osx-10.14 (BKR-1534)
|
22
|
+
- Add host helpers for working with files (BKR-1560)
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- Replace ntpdate with crony on RHEL-8 (BKR-1555)
|
15
27
|
|
16
28
|
# [4.3.0](https://github.com/puppetlabs/beaker/compare/4.2.0...4.3.0) - 2018.12.12
|
17
29
|
|
@@ -462,6 +462,54 @@ module Beaker
|
|
462
462
|
end
|
463
463
|
end
|
464
464
|
|
465
|
+
# Check whether a file exists on the host
|
466
|
+
#
|
467
|
+
# @param host [Beaker::Host] The target host
|
468
|
+
# @param file_path [String] The absolute path of the file
|
469
|
+
#
|
470
|
+
# @return [Boolean] Whether the file exists on the host (using `test -f`)
|
471
|
+
def file_exists_on(host, file_path)
|
472
|
+
host.execute(%(test -f "#{file_path}"), accept_all_exit_codes: true) do |result|
|
473
|
+
return result.exit_code.zero?
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
# Check whether a directory exists on the host
|
478
|
+
#
|
479
|
+
# @param host [Beaker::Host] The target host
|
480
|
+
# @param dir_path [String] The absolute path of the directory
|
481
|
+
#
|
482
|
+
# @return [Boolean] Whether the directory exists on the host (using `test -d`)
|
483
|
+
def directory_exists_on(host, dir_path)
|
484
|
+
host.execute(%(test -d "#{dir_path}"), accept_all_exit_codes: true) do |result|
|
485
|
+
return result.exit_code.zero?
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
# Check whether a symlink exists on the host
|
490
|
+
#
|
491
|
+
# @param host [Beaker::Host] The target host
|
492
|
+
# @param link_path [String] The absolute path of the symlink
|
493
|
+
#
|
494
|
+
# @return [Boolean] Whether the symlink exists on the host (using `test -L`)
|
495
|
+
def link_exists_on(host, link_path)
|
496
|
+
host.execute(%(test -L "#{link_path}"), accept_all_exit_codes: true) do |result|
|
497
|
+
return result.exit_code.zero?
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
# Get the contents of a file on the host
|
502
|
+
#
|
503
|
+
# @param host [Beaker::Host] The target host
|
504
|
+
# @param file_path [String] The absoltue path to the file
|
505
|
+
#
|
506
|
+
# @return [String] The contents of the file
|
507
|
+
def file_contents_on(host, file_path)
|
508
|
+
host.execute(%(cat "#{file_path}"), acceptable_exit_codes: [0]) do |result|
|
509
|
+
return result.stdout
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
465
513
|
#Run a curl command on the provided host(s)
|
466
514
|
#
|
467
515
|
# @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
data/lib/beaker/host/cisco.rb
CHANGED
@@ -94,8 +94,8 @@ module Cisco
|
|
94
94
|
# @return [String] Command string as needed for this host
|
95
95
|
def append_commands(command = '', user_ac = '', opts = {})
|
96
96
|
command.gsub('"') {'\\"'}
|
97
|
-
# vsh commands
|
98
|
-
return '"' unless command =~ /ntpdate|\/isan\/bin\/vsh/
|
97
|
+
# vsh commands, ntpdate or when user is root commands do not require an appended `"`
|
98
|
+
return '"' unless command =~ /ntpdate|\/isan\/bin\/vsh/ || self[:user] == 'root'
|
99
99
|
end
|
100
100
|
|
101
101
|
# Construct the environment string for this command
|
data/lib/beaker/host/mac/exec.rb
CHANGED
@@ -21,7 +21,7 @@ module Mac::Exec
|
|
21
21
|
# (from {#ssh_service_restart})
|
22
22
|
def ssh_permit_user_environment
|
23
23
|
ssh_config_file = '/etc/sshd_config'
|
24
|
-
ssh_config_file = '/private/etc/ssh/sshd_config' if self['platform'] =~ /osx-10\.*(11|12|13)/
|
24
|
+
ssh_config_file = '/private/etc/ssh/sshd_config' if self['platform'] =~ /osx-10\.*(11|12|13|14)/
|
25
25
|
|
26
26
|
exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
|
27
27
|
ssh_service_restart()
|
@@ -12,6 +12,7 @@ module Beaker
|
|
12
12
|
NTPSERVER = 'pool.ntp.org'
|
13
13
|
SLEEPWAIT = 5
|
14
14
|
TRIES = 5
|
15
|
+
RHEL8_PACKAGES = ['curl', 'chrony']
|
15
16
|
UNIX_PACKAGES = ['curl', 'ntpdate']
|
16
17
|
FREEBSD_PACKAGES = ['curl', 'perl5|perl']
|
17
18
|
OPENBSD_PACKAGES = ['curl']
|
@@ -51,13 +52,15 @@ module Beaker
|
|
51
52
|
logger.notify "NTP date succeeded on #{host}"
|
52
53
|
else
|
53
54
|
case
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
when host['platform'] =~ /el-8/
|
56
|
+
ntp_command = "chronyc add server #{ntp_server} prefer trust;chronyc makestep;chronyc burst 1/2"
|
57
|
+
when host['platform'] =~ /sles-/
|
58
|
+
ntp_command = "sntp #{ntp_server}"
|
59
|
+
when host['platform'] =~ /cisco_nexus/
|
60
|
+
ntp_server = host.exec(Command.new("getent hosts #{NTPSERVER} | head -n1 |cut -d \" \" -f1"), :acceptable_exit_codes => [0]).stdout
|
61
|
+
ntp_command = "sudo -E sh -c 'export DCOS_CONTEXT=2;/isan/bin/ntpdate -u -t 20 #{ntp_server}'"
|
62
|
+
else
|
63
|
+
ntp_command = "ntpdate -u -t 20 #{ntp_server}"
|
61
64
|
end
|
62
65
|
success=false
|
63
66
|
try = 0
|
@@ -98,6 +101,8 @@ module Beaker
|
|
98
101
|
logger = opts[:logger]
|
99
102
|
block_on host do |host|
|
100
103
|
case
|
104
|
+
when host['platform'] =~ /el-8/
|
105
|
+
check_and_install_packages_if_needed(host, RHEL8_PACKAGES)
|
101
106
|
when host['platform'] =~ /sles-10/
|
102
107
|
check_and_install_packages_if_needed(host, SLES10_PACKAGES)
|
103
108
|
when host['platform'] =~ /sles-/
|
data/lib/beaker/version.rb
CHANGED
@@ -107,6 +107,7 @@ module Cisco
|
|
107
107
|
|
108
108
|
before :each do
|
109
109
|
@platform = 'cisco_nexus-7-x86_64'
|
110
|
+
@options = { :user => 'non_root' }
|
110
111
|
end
|
111
112
|
|
112
113
|
it 'appends `"` for commands' do
|
@@ -115,6 +116,13 @@ module Cisco
|
|
115
116
|
expect( answer_test ).to be === answer_correct
|
116
117
|
end
|
117
118
|
|
119
|
+
it 'returns nil for root user commands' do
|
120
|
+
@options = { :user => 'root' }
|
121
|
+
answer_correct = nil
|
122
|
+
answer_test = host.append_commands( 'fake_command' )
|
123
|
+
expect( answer_test ).to be === answer_correct
|
124
|
+
end
|
125
|
+
|
118
126
|
it 'returns nil when vsh command' do
|
119
127
|
answer_correct = nil
|
120
128
|
answer_test = host.append_commands( '/isan/bin/vsh -c foo' )
|
@@ -138,6 +146,7 @@ module Cisco
|
|
138
146
|
|
139
147
|
before :each do
|
140
148
|
@platform = 'cisco_ios_xr-6-x86_64'
|
149
|
+
@options = { :user => 'non_root' }
|
141
150
|
end
|
142
151
|
|
143
152
|
it 'appends `"` for commands' do
|
@@ -146,6 +155,13 @@ module Cisco
|
|
146
155
|
expect( answer_test ).to be === answer_correct
|
147
156
|
end
|
148
157
|
|
158
|
+
it 'returns nil for root user commands' do
|
159
|
+
@options = { :user => 'root' }
|
160
|
+
answer_correct = nil
|
161
|
+
answer_test = host.append_commands( 'fake_command' )
|
162
|
+
expect( answer_test ).to be === answer_correct
|
163
|
+
end
|
164
|
+
|
149
165
|
it 'returns nil when vsh command' do
|
150
166
|
answer_correct = nil
|
151
167
|
answer_test = host.append_commands( '/isan/bin/vsh -c foo' )
|
@@ -11,6 +11,7 @@ describe Beaker do
|
|
11
11
|
let( :windows_pkgs ) { Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES }
|
12
12
|
let( :unix_only_pkgs ) { Beaker::HostPrebuiltSteps::UNIX_PACKAGES }
|
13
13
|
let( :sles_only_pkgs ) { Beaker::HostPrebuiltSteps::SLES_PACKAGES }
|
14
|
+
let( :rhel8_packages ) { Beaker::HostPrebuiltSteps::RHEL8_PACKAGES }
|
14
15
|
let( :platform ) { @platform || 'unix' }
|
15
16
|
let( :ip ) { "ip.address.0.0" }
|
16
17
|
let( :stdout) { @stdout || ip }
|
@@ -149,6 +150,15 @@ describe Beaker do
|
|
149
150
|
|
150
151
|
end
|
151
152
|
|
153
|
+
it "can sync time on RHEL8 hosts" do
|
154
|
+
hosts = make_hosts(:platform => 'el-8-x86_x64')
|
155
|
+
expect(Beaker::Command).to receive(:new)
|
156
|
+
.with("chronyc add server #{ntpserver} prefer trust;chronyc makestep;chronyc burst 1/2")
|
157
|
+
.exactly(3)
|
158
|
+
.times
|
159
|
+
subject.timesync(hosts, options)
|
160
|
+
end
|
161
|
+
|
152
162
|
it "can set time server on unix hosts" do
|
153
163
|
hosts = make_hosts( { :platform => 'unix' } )
|
154
164
|
|
@@ -177,6 +187,15 @@ describe Beaker do
|
|
177
187
|
subject.timesync( hosts, options_ntp )
|
178
188
|
|
179
189
|
end
|
190
|
+
|
191
|
+
it "can set time server on RHEL8 hosts" do
|
192
|
+
hosts = make_hosts(:platform => 'el-8-x86_x64')
|
193
|
+
expect(Beaker::Command).to receive(:new)
|
194
|
+
.with("chronyc add server #{ntpserver_set} prefer trust;chronyc makestep;chronyc burst 1/2")
|
195
|
+
.exactly(3)
|
196
|
+
.times
|
197
|
+
subject.timesync(hosts, options_ntp)
|
198
|
+
end
|
180
199
|
end
|
181
200
|
|
182
201
|
context "apt_get_update" do
|
@@ -445,6 +464,19 @@ describe Beaker do
|
|
445
464
|
|
446
465
|
end
|
447
466
|
|
467
|
+
it "can validate RHEL8 hosts" do
|
468
|
+
@platform = 'el-8-x86_x64'
|
469
|
+
|
470
|
+
hosts.each do |host|
|
471
|
+
rhel8_packages.each do |pkg|
|
472
|
+
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
473
|
+
expect(host).to receive(:install_package).with(pkg).once
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
subject.validate_host(hosts, options)
|
478
|
+
end
|
479
|
+
|
448
480
|
it 'skips validation on cisco hosts' do
|
449
481
|
@platform = 'cisco_nexus-7-x86_64'
|
450
482
|
expect( subject ).to receive( :check_and_install_packages_if_needed ).never
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|