beaker 2.39.0 → 2.40.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -551,6 +551,15 @@ describe ClassMixedWithDSLHelpers do
551
551
  })
552
552
  end
553
553
 
554
+ describe 'when the global option for :is_puppetserver is false' do
555
+ it 'checks the option for the host object' do
556
+ allow( subject ).to receive( :options) .and_return( {:is_puppetserver => false})
557
+ host[:is_puppetserver] = true
558
+ expect( subject ).to receive( :modify_tk_config)
559
+ subject.with_puppet_running_on(host, conf_opts)
560
+ end
561
+ end
562
+
554
563
  describe 'and command line args passed' do
555
564
  it 'modifies SUT trapperkeeper configuration w/ command line args' do
556
565
  host['puppetserver-confdir'] = '/etc/puppetserver/conf.d'
@@ -455,13 +455,15 @@ describe ClassMixedWithDSLInstallUtils do
455
455
  end
456
456
  end
457
457
  context 'on debian' do
458
- let(:platform) { Beaker::Platform.new('debian-7-amd64') }
459
- it 'installs latest if given no version info' do
460
- hosts.each do |host|
461
- expect(subject).to receive(:install_puppetlabs_release_repo).with(host)
458
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
459
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
460
+ it "installs latest on #{platform} if given no version info" do
461
+ hosts.each do |host|
462
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(host)
463
+ end
464
+ expect(hosts[0]).to receive(:install_package).with('puppet')
465
+ subject.install_puppet
462
466
  end
463
- expect(hosts[0]).to receive(:install_package).with('puppet')
464
- subject.install_puppet
465
467
  end
466
468
  it 'installs specific version of puppet when passed :version' do
467
469
  expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
@@ -531,17 +533,18 @@ describe ClassMixedWithDSLInstallUtils do
531
533
 
532
534
  describe 'configure_puppet_on' do
533
535
  context 'on debian' do
534
- let(:platform) { 'debian-7-amd64' }
535
- let(:host) { make_host('testbox.test.local', :platform => 'debian-7-amd64') }
536
-
537
- it 'it sets the puppet.conf file to the provided config' do
538
- config = { 'main' => {'server' => 'testbox.test.local'} }
539
- expected_config_string = "[main]\nserver=testbox.test.local\n\n"
540
-
541
- expect( subject ).to receive( :create_remote_file ).with(
542
- host, anything, expected_config_string
543
- )
544
- subject.configure_puppet_on(host, config)
536
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
537
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
538
+ let(:host) { make_host('testbox.test.local', :platform => "#{platform}") }
539
+ it "it sets the puppet.conf file to the provided config on #{platform}" do
540
+ config = { 'main' => {'server' => 'testbox.test.local'} }
541
+ expected_config_string = "[main]\nserver=testbox.test.local\n\n"
542
+
543
+ expect( subject ).to receive( :create_remote_file ).with(
544
+ host, anything, expected_config_string
545
+ )
546
+ subject.configure_puppet_on(host, config)
547
+ end
545
548
  end
546
549
  end
547
550
  context 'on windows' do
@@ -571,14 +574,15 @@ describe ClassMixedWithDSLInstallUtils do
571
574
  end
572
575
 
573
576
  context 'on debian' do
574
- let(:platform) { 'debian-7-amd64' }
575
-
576
- it 'calls configure_puppet_on correctly' do
577
- config = { 'main' => {'server' => 'testbox.test.local'} }
578
- expect( subject ).to receive( :configure_puppet_on ).with(
579
- anything, config
580
- ).exactly( hosts.length ).times
581
- subject.configure_puppet(config)
577
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
578
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
579
+ it "calls configure_puppet_on correctly on #{platform}" do
580
+ config = { 'main' => {'server' => 'testbox.test.local'} }
581
+ expect( subject ).to receive( :configure_puppet_on ).with(
582
+ anything, config
583
+ ).exactly( hosts.length ).times
584
+ subject.configure_puppet(config)
585
+ end
582
586
  end
583
587
  end
584
588
 
@@ -722,11 +726,13 @@ describe ClassMixedWithDSLInstallUtils do
722
726
  end
723
727
 
724
728
  describe "that are debian-like" do
725
- let( :platform ) { Beaker::Platform.new('debian-7-i386') }
726
- before { allow(subject).to receive(:link_exists?).and_return(true) }
729
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
730
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
731
+ before { allow(subject).to receive(:link_exists?).and_return(true) }
727
732
 
728
- include_examples "install-dev-repo"
733
+ include_examples "install-dev-repo"
729
734
 
735
+ end
730
736
  end
731
737
 
732
738
  describe "that are redhat-like" do
@@ -40,6 +40,17 @@ describe ClassMixedWithDSLInstallUtils do
40
40
  .exactly( times ).times
41
41
  end
42
42
 
43
+ def expect_version_log_called(times = hosts.length)
44
+ [
45
+ "\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\"",
46
+ "\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\"",
47
+ ].each do |path|
48
+ expect( Beaker::Command ).to receive( :new )
49
+ .with( "if exist #{path} type #{path}", [], {:cmdexe => true} )
50
+ .exactly( times ).times
51
+ end
52
+ end
53
+
43
54
  def expect_script_matches(hosts, contents)
44
55
  hosts.each do |host|
45
56
  expect( host )
@@ -60,6 +71,7 @@ describe ClassMixedWithDSLInstallUtils do
60
71
  it "will specify a PUPPET_AGENT_STARTUP_MODE of Manual (disabling the service) by default" do
61
72
  expect_install_called
62
73
  expect_status_called
74
+ expect_version_log_called
63
75
  expect( subject ).to receive( :create_install_msi_batch_on ).with(
64
76
  anything, anything,
65
77
  'PUPPET_AGENT_STARTUP_MODE' => 'Manual')
@@ -69,6 +81,7 @@ describe ClassMixedWithDSLInstallUtils do
69
81
  it "allows configuration of PUPPET_AGENT_STARTUP_MODE" do
70
82
  expect_install_called
71
83
  expect_status_called
84
+ expect_version_log_called
72
85
  value = 'Automatic'
73
86
  expect( subject ).to receive( :create_install_msi_batch_on ).with(
74
87
  anything, anything,
@@ -97,6 +110,7 @@ describe ClassMixedWithDSLInstallUtils do
97
110
  it "will generate a command to emit a log file with the :debug option set" do
98
111
  expect_install_called
99
112
  expect_status_called
113
+ expect_version_log_called
100
114
 
101
115
  expect( Beaker::Command ).to receive( :new ).with( /^type \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts.length ).times
102
116
  subject.install_msi_on(hosts, msi_path, {}, { :debug => true })
@@ -105,6 +119,7 @@ describe ClassMixedWithDSLInstallUtils do
105
119
  it 'will pass msi_path to #create_install_msi_batch_on as-is' do
106
120
  expect_install_called
107
121
  expect_status_called
122
+ expect_version_log_called
108
123
  test_path = 'test/path'
109
124
  expect( subject ).to receive( :create_install_msi_batch_on ).with(
110
125
  anything, test_path, anything)
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Beaker
4
+
4
5
  describe Unix::Exec do
5
6
  class UnixExecTest
6
7
  include Unix::Exec
@@ -70,6 +71,26 @@ module Beaker
70
71
  end
71
72
 
72
73
  describe '#ssh_permit_user_environment' do
74
+ context 'When called without error' do
75
+ let (:directory) {'/directory'}
76
+ let (:ssh_command) {"echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"}
77
+ let (:ssh_move) {"mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"}
78
+
79
+ platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS
80
+
81
+ platforms.each do |platform|
82
+ it "calls the correct commands for #{platform}" do
83
+ opts['platform'] = platform
84
+ expect(instance).to receive(:exec).twice
85
+ expect(instance).to receive(:create_tmpdir_on).and_return(directory)
86
+ expect(Beaker::Command).to receive(:new).with(ssh_move)
87
+ expect(Beaker::Command).to receive(:new).with(ssh_command)
88
+ expect(instance).to receive(:ssh_service_restart)
89
+ expect{instance.ssh_permit_user_environment}.to_not raise_error
90
+ end
91
+ end
92
+ end
93
+
73
94
  it 'raises an error on unsupported platforms' do
74
95
  opts['platform'] = 'notarealthing01-parts-arch'
75
96
  expect {
@@ -79,6 +100,33 @@ module Beaker
79
100
  end
80
101
 
81
102
  describe '#ssh_service_restart' do
103
+ PlatformHelpers::SYSTEMDPLATFORMS.each do |platform|
104
+ it "calls the correct command for #{platform}" do
105
+ opts['platform'] = platform
106
+ expect(instance).to receive(:exec)
107
+ expect(Beaker::Command).to receive(:new).with("systemctl restart sshd.service")
108
+ expect{instance.ssh_service_restart}.to_not raise_error
109
+ end
110
+ end
111
+
112
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
113
+ it "calls the correct command for #{platform}" do
114
+ opts['platform'] = platform
115
+ expect(instance).to receive(:exec)
116
+ expect(Beaker::Command).to receive(:new).with("service ssh restart")
117
+ expect{instance.ssh_service_restart}.to_not raise_error
118
+ end
119
+ end
120
+
121
+ PlatformHelpers::SYSTEMVPLATFORMS.each do |platform|
122
+ it "calls the correct command for #{platform}" do
123
+ opts['platform'] = "#{platform}-arch"
124
+ expect(instance).to receive(:exec)
125
+ expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart")
126
+ expect{instance.ssh_service_restart}.to_not raise_error
127
+ end
128
+ end
129
+
82
130
  it 'raises an error on unsupported platforms' do
83
131
  opts['platform'] = 'notarealthing02-parts-arch'
84
132
  expect {
@@ -41,6 +41,13 @@ module Beaker
41
41
  instance.deploy_package_repo(path,name,version)
42
42
  end
43
43
 
44
+ it 'calls #deploy_apt_repo for huaweios systems' do
45
+ @opts = {'platform' => 'huaweios-is-me'}
46
+ expect(instance).to receive(:deploy_apt_repo)
47
+ allow(File).to receive(:exists?).with(path).and_return(true)
48
+ instance.deploy_package_repo(path,name,version)
49
+ end
50
+
44
51
  it 'calls #deploy_apt_repo for debian systems' do
45
52
  @opts = {'platform' => 'ubuntu-is-me'}
46
53
  expect(instance).to receive(:deploy_apt_repo)
@@ -123,6 +130,13 @@ module Beaker
123
130
  expect( instance.check_for_package(pkg) ).to be === true
124
131
  end
125
132
 
133
+ it "checks correctly on huaweios" do
134
+ @opts = {'platform' => 'huaweios-is-me'}
135
+ pkg = 'debian_package'
136
+ expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
137
+ expect( instance ).to receive(:exec).with('', :accept_all_exit_codes => true).and_return(generate_result("hello", {:exit_code => 0}))
138
+ expect( instance.check_for_package(pkg) ).to be === true
139
+ end
126
140
  it "checks correctly on debian" do
127
141
  @opts = {'platform' => 'debian-is-me'}
128
142
  pkg = 'debian_package'
@@ -178,8 +192,28 @@ module Beaker
178
192
 
179
193
  end
180
194
 
195
+ describe '#update_apt_if_needed' do
196
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
197
+ it "calls update for #{platform}" do
198
+ @opts = {'platform' => platform}
199
+ instance.instance_variable_set("@apt_needs_update", true)
200
+ expect(instance).to receive('execute').with("apt-get update")
201
+ expect{instance.update_apt_if_needed}.to_not raise_error
202
+ end
203
+ end
204
+ end
181
205
  context "install_package" do
182
206
 
207
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
208
+ it "uses apt-get for #{platform}" do
209
+ @opts = {'platform' => platform}
210
+ pkg = 'pkg'
211
+ expect( Beaker::Command ).to receive(:new).with("apt-get install --force-yes -y #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
212
+ expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
213
+ expect( instance.install_package(pkg) ).to be == "hello"
214
+ end
215
+ end
216
+
183
217
  it "uses yum on fedora-20" do
184
218
  @opts = {'platform' => 'fedora-20-is-me'}
185
219
  pkg = 'fedora_package'
@@ -197,6 +231,27 @@ module Beaker
197
231
  end
198
232
  end
199
233
 
234
+ describe '#uninstall_package' do
235
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
236
+ it "calls pkg uninstall for #{platform}" do
237
+ @opts = {'platform' => platform}
238
+ expect( Beaker::Command ).to receive(:new).with("apt-get purge -y pkg", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
239
+ expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
240
+ expect(instance.uninstall_package('pkg')).to be == "hello"
241
+ end
242
+ end
243
+ end
244
+
245
+ describe '#upgrade_package' do
246
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
247
+ it "calls the correct apt-get incantation for #{platform}" do
248
+ @opts = {'platform' => platform}
249
+ expect( Beaker::Command ).to receive(:new).with("apt-get install -o Dpkg::Options::='--force-confold' -y --force-yes pkg", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
250
+ expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
251
+ expect(instance.upgrade_package('pkg')).to be == "hello"
252
+ end
253
+ end
254
+ end
200
255
  context "install_package_with_rpm" do
201
256
 
202
257
  it "accepts a package as a single argument" do
@@ -157,7 +157,7 @@ describe Beaker do
157
157
  it "can return the correct url for an el-7 host" do
158
158
  host = make_host( 'testhost', { :platform => Beaker::Platform.new('el-7-platform') } )
159
159
 
160
- expect( subject.epel_info_for( host, options )).to be === ["http://mirrors.kernel.org/fedora-epel/7", "x86_64", "epel-release-7-5.noarch.rpm"]
160
+ expect( subject.epel_info_for( host, options )).to be === ["http://mirrors.kernel.org/fedora-epel/7", "x86_64", "epel-release-7-6.noarch.rpm"]
161
161
  end
162
162
 
163
163
  it "can return the correct url for an el-6 host" do
@@ -293,7 +293,7 @@ module Beaker
293
293
  expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
294
294
  end
295
295
 
296
- it 'does not throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
296
+ it 'does throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
297
297
  result.exit_code = 7
298
298
  opts = {
299
299
  :acceptable_exit_codes => [0, 1],
@@ -301,11 +301,11 @@ module Beaker
301
301
  }
302
302
  allow( host.logger ).to receive( :warn )
303
303
 
304
- expect { host.exec(command, opts) }.to_not raise_error
304
+ expect { host.exec(command, opts) }.to raise_error
305
305
  end
306
306
 
307
307
  it 'sends a warning when both :acceptable_exit_codes & :accept_all_exit_codes are set' do
308
- result.exit_code = 7
308
+ result.exit_code = 1
309
309
  opts = {
310
310
  :acceptable_exit_codes => [0, 1],
311
311
  :accept_all_exit_codes => true
@@ -6,8 +6,8 @@ module Beaker
6
6
 
7
7
  let(:parser) {Beaker::Options::CommandLineParser.new}
8
8
  let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
9
- let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--no-color-host-output", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6", "--xml-time-order"]}
10
- let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :color_host_output=>false, :beaker_version_print=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>"normal", :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6", :xml_time_enabled => true}}
9
+ let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--pre-cleanup", "pre_cleanup.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--no-color-host-output", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6", "--xml-time-order"]}
10
+ let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :pre_cleanup => "pre_cleanup.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :color_host_output=>false, :beaker_version_print=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>"normal", :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6", :xml_time_enabled => true}}
11
11
  let(:validate_true) {["--validate"]}
12
12
  let(:validate_false) {["--no-validate"]}
13
13
  let(:configure_true) {['--configure']}
@@ -39,7 +39,7 @@ module Beaker
39
39
  end
40
40
 
41
41
  it "can produce a usage description" do
42
- expect{parser.usage}.to_not raise_error
42
+ expect{parser.usage}.to_not raise_error
43
43
  end
44
44
 
45
45
  context '--no-provision flag effects other options' do
@@ -111,3 +111,26 @@ module HostHelpers
111
111
  end
112
112
 
113
113
  end
114
+
115
+ module PlatformHelpers
116
+
117
+ DEBIANPLATFORMS = ['debian',
118
+ 'ubuntu',
119
+ 'cumulus',
120
+ 'huaweios']
121
+
122
+ SYSTEMDPLATFORMS = ['el-7',
123
+ 'centos-7',
124
+ 'redhat-7',
125
+ 'oracle-7',
126
+ 'scientific-7',
127
+ 'eos-7']
128
+
129
+ SYSTEMVPLATFORMS = ['el-',
130
+ 'centos',
131
+ 'fedora',
132
+ 'redhat',
133
+ 'oracle',
134
+ 'scientific',
135
+ 'eos']
136
+ end
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: 2.39.0
4
+ version: 2.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -353,6 +353,9 @@ dependencies:
353
353
  - - ~>
354
354
  - !ruby/object:Gem::Version
355
355
  version: '0.8'
356
+ - - <
357
+ - !ruby/object:Gem::Version
358
+ version: 0.9.5
356
359
  type: :runtime
357
360
  prerelease: false
358
361
  version_requirements: !ruby/object:Gem::Requirement
@@ -360,6 +363,9 @@ dependencies:
360
363
  - - ~>
361
364
  - !ruby/object:Gem::Version
362
365
  version: '0.8'
366
+ - - <
367
+ - !ruby/object:Gem::Version
368
+ version: 0.9.5
363
369
  - !ruby/object:Gem::Dependency
364
370
  name: aws-sdk
365
371
  requirement: !ruby/object:Gem::Requirement
@@ -604,6 +610,8 @@ files:
604
610
  - docs/hypervisors/README.md
605
611
  - docs/hypervisors/aws.md
606
612
  - docs/hypervisors/vagrant.md
613
+ - docs/meta/README.md
614
+ - docs/meta/ticket_process.md
607
615
  - docs/vSphere-Support.md
608
616
  - ext/completion/beaker-completion.bash
609
617
  - lib/beaker.rb