beaker 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +8 -0
- data/README.md +6 -6
- data/beaker.gemspec +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +34 -7
- data/lib/beaker/answers/version20.rb +124 -0
- data/lib/beaker/answers/version28.rb +21 -0
- data/lib/beaker/answers/version30.rb +24 -5
- data/lib/beaker/cli.rb +55 -41
- data/lib/beaker/command.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +320 -106
- data/lib/beaker/dsl/install_utils.rb +202 -81
- data/lib/beaker/dsl/roles.rb +40 -0
- data/lib/beaker/host.rb +28 -20
- data/lib/beaker/host/unix.rb +7 -4
- data/lib/beaker/host/unix/pkg.rb +42 -12
- data/lib/beaker/host/windows.rb +9 -5
- data/lib/beaker/host/windows/group.rb +1 -1
- data/lib/beaker/host/windows/pkg.rb +41 -8
- data/lib/beaker/hypervisor.rb +23 -10
- data/lib/beaker/hypervisor/aixer.rb +15 -19
- data/lib/beaker/hypervisor/blimper.rb +71 -72
- data/lib/beaker/hypervisor/fusion.rb +11 -10
- data/lib/beaker/hypervisor/solaris.rb +17 -23
- data/lib/beaker/hypervisor/vagrant.rb +27 -12
- data/lib/beaker/hypervisor/vcloud.rb +154 -138
- data/lib/beaker/hypervisor/vcloud_pooled.rb +97 -0
- data/lib/beaker/hypervisor/vsphere.rb +8 -5
- data/lib/beaker/hypervisor/vsphere_helper.rb +43 -33
- data/lib/beaker/network_manager.rb +16 -12
- data/lib/beaker/options/command_line_parser.rb +199 -0
- data/lib/beaker/options/hosts_file_parser.rb +39 -0
- data/lib/beaker/options/options_file_parser.rb +45 -0
- data/lib/beaker/options/options_hash.rb +294 -0
- data/lib/beaker/options/parser.rb +288 -0
- data/lib/beaker/options/pe_version_scraper.rb +35 -0
- data/lib/beaker/options/presets.rb +70 -0
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/host_handler.rb +7 -2
- data/lib/beaker/shared/repetition.rb +1 -0
- data/lib/beaker/shared/timed.rb +14 -0
- data/lib/beaker/test_case.rb +2 -38
- data/lib/beaker/test_suite.rb +11 -25
- data/lib/beaker/utils/repo_control.rb +6 -8
- data/lib/beaker/utils/setup_helper.rb +9 -20
- data/spec/beaker/answers_spec.rb +109 -0
- data/spec/beaker/command_spec.rb +2 -2
- data/spec/beaker/dsl/assertions_spec.rb +1 -3
- data/spec/beaker/dsl/helpers_spec.rb +519 -84
- data/spec/beaker/dsl/install_utils_spec.rb +265 -16
- data/spec/beaker/dsl/roles_spec.rb +31 -10
- data/spec/beaker/host/windows/group_spec.rb +55 -0
- data/spec/beaker/host_spec.rb +130 -40
- data/spec/beaker/hypervisor/aixer_spec.rb +34 -0
- data/spec/beaker/hypervisor/blimper_spec.rb +77 -0
- data/spec/beaker/hypervisor/fusion_spec.rb +26 -0
- data/spec/beaker/hypervisor/hypervisor_spec.rb +66 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +39 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +105 -0
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +60 -0
- data/spec/beaker/hypervisor/vcloud_spec.rb +70 -0
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +162 -0
- data/spec/beaker/hypervisor/vsphere_spec.rb +76 -0
- data/spec/beaker/options/command_line_parser_spec.rb +25 -0
- data/spec/beaker/options/data/LATEST +1 -0
- data/spec/beaker/options/data/badyaml.cfg +21 -0
- data/spec/beaker/options/data/hosts.cfg +21 -0
- data/spec/beaker/options/data/opts.txt +6 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -0
- data/spec/beaker/options/options_file_parser_spec.rb +23 -0
- data/spec/beaker/options/options_hash_spec.rb +111 -0
- data/spec/beaker/options/parser_spec.rb +172 -0
- data/spec/beaker/options/pe_version_scaper_spec.rb +15 -0
- data/spec/beaker/options/presets_spec.rb +24 -0
- data/spec/beaker/puppet_command_spec.rb +54 -21
- data/spec/beaker/shared/error_handler_spec.rb +40 -0
- data/spec/beaker/shared/host_handler_spec.rb +104 -0
- data/spec/beaker/shared/repetition_spec.rb +72 -0
- data/spec/beaker/test_suite_spec.rb +3 -16
- data/spec/beaker/utils/ntp_control_spec.rb +42 -0
- data/spec/beaker/utils/repo_control_spec.rb +168 -0
- data/spec/beaker/utils/setup_helper_spec.rb +82 -0
- data/spec/beaker/utils/validator_spec.rb +58 -0
- data/spec/helpers.rb +97 -0
- data/spec/matchers.rb +39 -0
- data/spec/mock_blimpy.rb +48 -0
- data/spec/mock_fission.rb +60 -0
- data/spec/mock_vsphere.rb +310 -0
- data/spec/mock_vsphere_helper.rb +183 -0
- data/spec/mocks.rb +83 -0
- data/spec/spec_helper.rb +8 -1
- metadata +106 -13
- data/beaker.rb +0 -10
- data/lib/beaker/options_parsing.rb +0 -323
- data/lib/beaker/test_config.rb +0 -148
- data/spec/beaker/options_parsing_spec.rb +0 -37
- data/spec/mocks_and_helpers.rb +0 -34
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Shared
|
5
|
+
describe Repetition do
|
6
|
+
|
7
|
+
context 'repeat_for' do
|
8
|
+
it "repeats a block for 5 seconds" do
|
9
|
+
Time.stub( :now ).and_return( 0, 1, 2, 3, 4, 5, 6 )
|
10
|
+
|
11
|
+
block = double( 'block' )
|
12
|
+
block.should_receive( :exec ).exactly( 5 ).times.and_return( false )
|
13
|
+
|
14
|
+
subject.repeat_for( 5 ) do
|
15
|
+
block.exec
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should short circuit if the block is complete" do
|
20
|
+
Time.stub( :now ).and_return( 0, 1, 2, 3, 4, 5 )
|
21
|
+
|
22
|
+
block = double( 'block' )
|
23
|
+
block.should_receive( :exec ).once.and_return( true )
|
24
|
+
|
25
|
+
subject.repeat_for( 5 ) do
|
26
|
+
block.exec
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'repeat_fibonacci_style_for' do
|
34
|
+
it "sleeps in fibonacci increasing intervals" do
|
35
|
+
|
36
|
+
block = double( 'block' )
|
37
|
+
block.should_receive( :exec ).exactly( 5 ).times.and_return( false )
|
38
|
+
subject.stub( 'sleep' ).and_return( true )
|
39
|
+
subject.should_receive( :sleep ).with( 1 ).exactly( 2 ).times
|
40
|
+
subject.should_receive( :sleep ).with( 2 ).once
|
41
|
+
subject.should_receive( :sleep ).with( 3 ).once
|
42
|
+
subject.should_receive( :sleep ).with( 5 ).once
|
43
|
+
subject.should_receive( :sleep ).with( 8 ).never
|
44
|
+
|
45
|
+
subject.repeat_fibonacci_style_for( 5 ) do
|
46
|
+
block.exec
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should short circuit if the block is complete" do
|
52
|
+
|
53
|
+
block = double( 'block' )
|
54
|
+
block.should_receive( :exec ).once.and_return( true )
|
55
|
+
subject.stub( 'sleep' ).and_return( true )
|
56
|
+
subject.should_receive( :sleep ).with( 1 ).once
|
57
|
+
subject.should_receive( :sleep ).with( 2 ).never
|
58
|
+
subject.should_receive( :sleep ).with( 3 ).never
|
59
|
+
subject.should_receive( :sleep ).with( 5 ).never
|
60
|
+
subject.should_receive( :sleep ).with( 8 ).never
|
61
|
+
|
62
|
+
subject.repeat_fibonacci_style_for( 5 ) do
|
63
|
+
block.exec
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -7,38 +7,25 @@ module Beaker
|
|
7
7
|
context 'new', :use_fakefs => true do
|
8
8
|
let(:test_dir) { 'tmp/tests' }
|
9
9
|
|
10
|
-
let(:options) { {
|
10
|
+
let(:options) { {'name' => create_files(@files)} }
|
11
11
|
let(:rb_test) { File.expand_path(test_dir + '/my_ruby_file.rb') }
|
12
12
|
let(:pl_test) { File.expand_path(test_dir + '/my_perl_file.pl') }
|
13
13
|
let(:sh_test) { File.expand_path(test_dir + '/my_shell_file.sh') }
|
14
14
|
|
15
15
|
it 'fails without test files' do
|
16
16
|
expect { Beaker::TestSuite.new 'name', 'hosts',
|
17
|
-
Hash.new,
|
17
|
+
Hash.new, :stop_on_error }.to raise_error
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'includes specific files as test file when explicitly passed' do
|
21
21
|
@files = [ rb_test ]
|
22
22
|
ts = Beaker::TestSuite.new 'name', 'hosts', options,
|
23
|
-
|
23
|
+
:stop_on_error
|
24
24
|
|
25
25
|
expect { ts.instance_variable_get(:@test_files).
|
26
26
|
include? rb_test }.to be_true
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'includes only .rb files as test files when dir is passed' do
|
30
|
-
create_files [ rb_test, pl_test, sh_test ]
|
31
|
-
@files = [ test_dir ]
|
32
|
-
|
33
|
-
ts = Beaker::TestSuite.new 'name', 'hosts',
|
34
|
-
options, 'config', :stop_on_error
|
35
|
-
|
36
|
-
processed_files = ts.instance_variable_get :@test_files
|
37
|
-
|
38
|
-
expect(processed_files).to include(rb_test)
|
39
|
-
expect(processed_files).to_not include(sh_test)
|
40
|
-
expect(processed_files).to_not include(pl_test)
|
41
|
-
end
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Utils
|
5
|
+
describe NTPControl do
|
6
|
+
let( :ntpserver ) { Beaker::Utils::NTPControl::NTPSERVER }
|
7
|
+
let( :ntp_control ) { Beaker::Utils::NTPControl.new( make_opts, @hosts) }
|
8
|
+
|
9
|
+
it "can sync time on unix hosts" do
|
10
|
+
@hosts = make_hosts( { :platform => 'unix' } )
|
11
|
+
|
12
|
+
Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 3 ).times
|
13
|
+
|
14
|
+
ntp_control.timesync
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can sync time on solaris-10 hosts" do
|
19
|
+
@hosts = make_hosts( { :platform => 'solaris-10' } )
|
20
|
+
|
21
|
+
Command.should_receive( :new ).with("sleep 10 && ntpdate -w #{ntpserver}").exactly( 3 ).times
|
22
|
+
|
23
|
+
ntp_control.timesync
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can sync time on windows hosts" do
|
28
|
+
@hosts = make_hosts( { :platform => 'windows' } )
|
29
|
+
|
30
|
+
Command.should_receive( :new ).with("w32tm /register").exactly( 3 ).times
|
31
|
+
Command.should_receive( :new ).with("net start w32time").exactly( 3 ).times
|
32
|
+
Command.should_receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver} /syncfromflags:manual /update").exactly( 3 ).times
|
33
|
+
Command.should_receive( :new ).with("w32tm /resync").exactly( 3 ).times
|
34
|
+
|
35
|
+
ntp_control.timesync
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Utils
|
5
|
+
describe RepoControl do
|
6
|
+
let( :apt_cfg ) { Beaker::Utils::RepoControl::APT_CFG }
|
7
|
+
let( :ips_pkg_repo ) { Beaker::Utils::RepoControl::IPS_PKG_REPO }
|
8
|
+
let( :repo_control ) { Beaker::Utils::RepoControl.new( make_opts, @hosts) }
|
9
|
+
|
10
|
+
context "epel_info_for!" do
|
11
|
+
|
12
|
+
it "can return the correct url for an el-6 host" do
|
13
|
+
host = make_host( 'testhost', { :platform => 'el-6-platform' } )
|
14
|
+
|
15
|
+
expect( repo_control.epel_info_for!( host )).to be === "http://mirror.itc.virginia.edu/fedora-epel/6/i386/epel-release-6-8.noarch.rpm"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can return the correct url for an el-5 host" do
|
19
|
+
host = make_host( 'testhost', { :platform => 'el-5-platform' } )
|
20
|
+
|
21
|
+
expect( repo_control.epel_info_for!( host )).to be === "http://archive.linux.duke.edu/pub/epel/5/i386/epel-release-5-4.noarch.rpm"
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises an error on non el-5/6 host" do
|
26
|
+
host = make_host( 'testhost', { :platform => 'el-4-platform' } )
|
27
|
+
|
28
|
+
expect{ repo_control.epel_info_for!( host )}.to raise_error
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "apt_get_update" do
|
35
|
+
|
36
|
+
it "can perform apt-get on ubuntu hosts" do
|
37
|
+
host = make_host( 'testhost', { :platform => 'ubuntu' } )
|
38
|
+
|
39
|
+
Command.should_receive( :new ).with("apt-get -y -f -m update").once
|
40
|
+
|
41
|
+
repo_control.apt_get_update( host )
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can perform apt-get on debian hosts" do
|
46
|
+
host = make_host( 'testhost', { :platform => 'debian' } )
|
47
|
+
|
48
|
+
Command.should_receive( :new ).with("apt-get -y -f -m update").once
|
49
|
+
|
50
|
+
repo_control.apt_get_update( host )
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it "does nothing on non debian/ubuntu hosts" do
|
55
|
+
host = make_host( 'testhost', { :platform => 'windows' } )
|
56
|
+
|
57
|
+
Command.should_receive( :new ).never
|
58
|
+
|
59
|
+
repo_control.apt_get_update( host )
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "copy_file_to_remote" do
|
66
|
+
|
67
|
+
it "can copy a file to a remote host" do
|
68
|
+
content = "this is the content"
|
69
|
+
tempfilepath = "/path/to/tempfile"
|
70
|
+
filepath = "/path/to/file"
|
71
|
+
host = make_host( 'testhost', { :platform => 'windows' })
|
72
|
+
tempfile = double( 'tempfile' )
|
73
|
+
tempfile.stub( :path ).and_return( tempfilepath )
|
74
|
+
Tempfile.stub( :open ).and_yield( tempfile )
|
75
|
+
file = double( 'file' )
|
76
|
+
File.stub( :open ).and_yield( file )
|
77
|
+
|
78
|
+
file.should_receive( :puts ).with( content ).once
|
79
|
+
host.should_receive( :do_scp_to ).with( tempfilepath, filepath, repo_control.instance_variable_get( :@options ) ).once
|
80
|
+
|
81
|
+
repo_control.copy_file_to_remote(host, filepath, content)
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context "proxy_config" do
|
89
|
+
|
90
|
+
it "correctly configures ubuntu hosts" do
|
91
|
+
@hosts = make_hosts( { :platform => 'ubuntu', :exit_code => 1 } )
|
92
|
+
|
93
|
+
Command.should_receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 )
|
94
|
+
@hosts.each do |host|
|
95
|
+
repo_control.should_receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
|
96
|
+
repo_control.should_receive( :apt_get_update ).with( host ).once
|
97
|
+
end
|
98
|
+
|
99
|
+
repo_control.proxy_config
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
it "correctly configures debian hosts" do
|
104
|
+
@hosts = make_hosts( { :platform => 'debian' } )
|
105
|
+
|
106
|
+
Command.should_receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
|
107
|
+
@hosts.each do |host|
|
108
|
+
repo_control.should_receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
|
109
|
+
repo_control.should_receive( :apt_get_update ).with( host ).once
|
110
|
+
end
|
111
|
+
|
112
|
+
repo_control.proxy_config
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
it "correctly configures solaris-11 hosts" do
|
117
|
+
@hosts = make_hosts( { :platform => 'solaris-11' } )
|
118
|
+
|
119
|
+
Command.should_receive( :new ).with( "/usr/bin/pkg unset-publisher solaris || :" ).exactly( 3 ).times
|
120
|
+
@hosts.each do |host|
|
121
|
+
Command.should_receive( :new ).with( "/usr/bin/pkg set-publisher -g %s solaris" % ips_pkg_repo ).once
|
122
|
+
end
|
123
|
+
|
124
|
+
repo_control.proxy_config
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
it "does nothing for non ubuntu/debian/solaris-11 hosts" do
|
129
|
+
@hosts = make_hosts( { :platform => 'windows' } )
|
130
|
+
|
131
|
+
Command.should_receive( :new ).never
|
132
|
+
|
133
|
+
repo_control.proxy_config
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "add_el_extras" do
|
139
|
+
|
140
|
+
it "add extras for el-5/6 hosts" do
|
141
|
+
@hosts = make_hosts( { :platform => 'el-5', :exit_code => 1 } )
|
142
|
+
@hosts[0][:platform] = 'el-6'
|
143
|
+
url = "http://el_extras_url"
|
144
|
+
|
145
|
+
repo_control.stub( :epel_info_for! ).and_return( url )
|
146
|
+
|
147
|
+
Command.should_receive( :new ).with("rpm -qa | grep epel-release").exactly( 3 ).times
|
148
|
+
Command.should_receive( :new ).with("rpm -i #{url}").exactly( 3 ).times
|
149
|
+
Command.should_receive( :new ).with("yum clean all && yum makecache").exactly( 3 ).times
|
150
|
+
|
151
|
+
repo_control.add_el_extras
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should do nothing for non el-5/6 hosts" do
|
156
|
+
@hosts = make_hosts( { :platform => 'windows' } )
|
157
|
+
|
158
|
+
Command.should_receive( :new ).never
|
159
|
+
|
160
|
+
repo_control.add_el_extras
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Utils
|
5
|
+
describe SetupHelper do
|
6
|
+
let( :setup_helper ) { Beaker::Utils::SetupHelper.new( make_opts, hosts) }
|
7
|
+
let( :sync_cmd ) { Beaker::Utils::SetupHelper::ROOT_KEYS_SYNC_CMD }
|
8
|
+
let( :platform ) { @platform || 'unix' }
|
9
|
+
let( :ip ) { "ip.address.0.0" }
|
10
|
+
let( :stdout) { @stdout || ip }
|
11
|
+
let( :hosts ) { hosts = make_hosts( { :stdout => stdout, :platform => platform } )
|
12
|
+
hosts[0][:roles] = ['agent']
|
13
|
+
hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
|
14
|
+
hosts[2][:roles] = ['agent']
|
15
|
+
hosts }
|
16
|
+
|
17
|
+
context "add_master_entry" do
|
18
|
+
|
19
|
+
it "can configure /etc/hosts on a unix master" do
|
20
|
+
path = Beaker::Utils::SetupHelper::ETC_HOSTS_PATH
|
21
|
+
master = setup_helper.only_host_with_role(hosts, :master)
|
22
|
+
|
23
|
+
Command.should_receive( :new ).with( "ip a|awk '/g/{print$2}' | cut -d/ -f1 | head -1" ).once
|
24
|
+
Command.should_receive( :new ).with( "cp %s %s.old" % [path, path] ).once
|
25
|
+
Command.should_receive( :new ).with( "cp %s %s.new" % [path, path] ).once
|
26
|
+
Command.should_receive( :new ).with( "grep -v '#{ip} #{master}' %s > %s.new" % [path, path] ).once
|
27
|
+
Command.should_receive( :new ).with( "echo '#{ip} #{master}' >> %s.new" % path ).once
|
28
|
+
Command.should_receive( :new ).with( "mv %s.new %s" % [path, path] ).once
|
29
|
+
|
30
|
+
setup_helper.add_master_entry
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can configure /etc/hosts on a solaris master" do
|
34
|
+
@platform = 'solaris'
|
35
|
+
path = Beaker::Utils::SetupHelper::ETC_HOSTS_PATH_SOLARIS
|
36
|
+
master = setup_helper.only_host_with_role(hosts, :master)
|
37
|
+
|
38
|
+
Command.should_receive( :new ).with( "ifconfig -a inet| awk '/broadcast/ {print $2}' | cut -d/ -f1 | head -1" ).once
|
39
|
+
Command.should_receive( :new ).with( "cp %s %s.old" % [path, path] ).once
|
40
|
+
Command.should_receive( :new ).with( "cp %s %s.new" % [path, path] ).once
|
41
|
+
Command.should_receive( :new ).with( "grep -v '#{ip} #{master}' %s > %s.new" % [path, path] ).once
|
42
|
+
Command.should_receive( :new ).with( "echo '#{ip} #{master}' >> %s.new" % path ).once
|
43
|
+
Command.should_receive( :new ).with( "mv %s.new %s" % [path, path] ).once
|
44
|
+
|
45
|
+
setup_helper.add_master_entry
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does nothing on a vagrant master" do
|
49
|
+
master = setup_helper.only_host_with_role(hosts, :master)
|
50
|
+
master[:hypervisor] = 'vagrant'
|
51
|
+
|
52
|
+
Command.should_receive( :new ).never
|
53
|
+
|
54
|
+
setup_helper.add_master_entry
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "sync_root_keys" do
|
60
|
+
|
61
|
+
it "can sync keys on a solaris host" do
|
62
|
+
@platform = 'solaris'
|
63
|
+
|
64
|
+
Command.should_receive( :new ).with( sync_cmd % "bash" ).exactly( 3 ).times
|
65
|
+
|
66
|
+
setup_helper.sync_root_keys
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
it "can sync keys on a non-solaris host" do
|
71
|
+
|
72
|
+
Command.should_receive( :new ).with( sync_cmd % "env PATH=/usr/gnu/bin:$PATH bash" ).exactly( 3 ).times
|
73
|
+
|
74
|
+
setup_helper.sync_root_keys
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Utils
|
5
|
+
describe Validator do
|
6
|
+
let( :validator ) { Beaker::Utils::Validator }
|
7
|
+
let( :pkgs ) { Beaker::Utils::Validator::PACKAGES }
|
8
|
+
let( :unix_only_pkgs ) { Beaker::Utils::Validator::UNIX_PACKAGES }
|
9
|
+
let( :platform ) { @platform || 'unix' }
|
10
|
+
let( :hosts ) { hosts = make_hosts( { :platform => platform } )
|
11
|
+
hosts[0][:roles] = ['agent']
|
12
|
+
hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
|
13
|
+
hosts[2][:roles] = ['agent']
|
14
|
+
hosts }
|
15
|
+
|
16
|
+
context "can validate the SUTs" do
|
17
|
+
|
18
|
+
it "can validate unix hosts" do
|
19
|
+
|
20
|
+
hosts.each do |host|
|
21
|
+
pkgs.each do |pkg|
|
22
|
+
host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
|
23
|
+
host.should_receive( :install_package ).with( pkg ).once
|
24
|
+
end
|
25
|
+
unix_only_pkgs.each do |pkg|
|
26
|
+
host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
|
27
|
+
host.should_receive( :install_package ).with( pkg ).once
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
validator.validate(hosts, logger)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can validate windows hosts" do
|
37
|
+
@platform = 'windows'
|
38
|
+
|
39
|
+
hosts.each do |host|
|
40
|
+
pkgs.each do |pkg|
|
41
|
+
host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
|
42
|
+
host.should_receive( :install_package ).with( pkg ).once
|
43
|
+
end
|
44
|
+
unix_only_pkgs.each do |pkg|
|
45
|
+
host.should_receive( :check_for_package).with( pkg ).never
|
46
|
+
host.should_receive( :install_package ).with( pkg ).never
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
validator.validate(hosts, logger)
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|