beaker-pe 0.2.0 → 0.3.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDZkZGU0MTNmZTVjNjQ5NGM3YTk5OGFhNTNhM2IyMDFjYmQ3MmEyNg==
4
+ Yzg3NzgwODgwMmQ4ZTM5YTgxZWUxZjM0MGJhOTViZTA2NjBkYmYyYw==
5
5
  data.tar.gz: !binary |-
6
- ODE5N2ZmYTdiYzkwOGM2MTIzY2Q0MjIwMGJlNGQ5MjIxYTk5YzEzMQ==
6
+ NDlhMTNiZDZjYzZhNGQ5NDEwNzE1ODYyMmFiZjg4M2ViZDZmYjc1OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjZhMjJjZWI4ZTE4ZmRhYjExZjNmODdmM2Q5YzAzYTZmZGE5ZWQzMjM4ZTA3
10
- NzNiMGQwYzZhZGRiZjc4ZjViMWViYTI3NWMwZmJjOTA5ZTlkMTIyZjVkMDIy
11
- ZDA3NzUzMzkxZDE3NGYxMGI0ZWRhNDM1OWNhOTFiZjg2Y2UxYTA=
9
+ ZWM3YWJlNDlmMzY0YzM0MTYzZmY3ZGJiN2E0ZmMwMmY2YjQ1MTg3MjAyNWNj
10
+ NjUzNmMwMTQwZWYzYmQ0ZTA1OTg5ZjIzY2VlYTQ5YTkxM2M3YzAyNzdmMTFk
11
+ MzRjMDgyNDgzOWY5MTVlODZkMmFjMzNjYWZjZmUyMzAzMzZlZDE=
12
12
  data.tar.gz: !binary |-
13
- NWI4NWFmYzA1YTdiMmQyNjIwNzY0ZjA0N2UwOTAzZGQxNjBhODFlZWI2OTFk
14
- Y2I5MzY2ZWE3NDc3MTYzZTY2M2M4MGY4YzVlYjg4NmU5M2RjMzNjOTRjYTY2
15
- M2UzNTE0MmM3MzdiY2I1OGI4OWQ4MjdjZTgyMGI1ZDdmMDg0YTI=
13
+ NWFjMDEzODdlNjU3ZGJmMmQwZmZkOTY2NTBiYmM2MjE5ODFjNTM1NDcwMTcz
14
+ M2QxY2YxNDRlMzc5OGMyOGYzODI2MjljNTczOGNlN2NiNDY1NGEwMGNmYjY0
15
+ ZTcxYWQzYWYxMGQ1N2Q0NGY1YzExM2U5OWUzZTNhMjlkODg4Nzc=
data/HISTORY.md CHANGED
@@ -1,12 +1,174 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 18 May, 2016 (d9a052a4)](#LATEST)
3
+ * [LATEST - 26 May, 2016 (d58ed99e)](#LATEST)
4
+ * [0.2.0 - 18 May, 2016 (a65f2083)](#0.2.0)
4
5
  * [0.1.2 - 4 Apr, 2016 (a6fd7bef)](#0.1.2)
5
6
  * [0.1.1 - 4 Apr, 2016 (8203d928)](#0.1.1)
6
7
  * [0.1.0 - 29 Feb, 2016 (4fc88d8c)](#0.1.0)
7
8
 
8
9
  ## Details
9
- ### <a name = "LATEST">LATEST - 18 May, 2016 (d9a052a4)
10
+ ### <a name = "LATEST">LATEST - 26 May, 2016 (d58ed99e)
11
+
12
+ * (GEM) update beaker-pe version to 0.3.0 (d58ed99e)
13
+
14
+ * Merge pull request #5 from jpartlow/issue/master/pe-14271-wire-for-meep (55aa098f)
15
+
16
+
17
+ ```
18
+ Merge pull request #5 from jpartlow/issue/master/pe-14271-wire-for-meep
19
+
20
+ (PE-14271) Wire beaker-pe for meep
21
+ ```
22
+ * (maint) Add some logging context for sign and agent shutdown (398882f4)
23
+
24
+
25
+ ```
26
+ (maint) Add some logging context for sign and agent shutdown
27
+
28
+ ...steps.
29
+ ```
30
+ * (PE-14271) Do not try to sign certificate for meep core hosts (e485c423)
31
+
32
+
33
+ ```
34
+ (PE-14271) Do not try to sign certificate for meep core hosts
35
+
36
+ Certificate is generated by meep. Step is redundant and produces failed
37
+ puppet agent run and puppet cert sign in log.
38
+ ```
39
+ * (PE-15259) Inform BeakerAnswers if we need legacy database defaults (7ef0347d)
40
+
41
+
42
+ ```
43
+ (PE-15259) Inform BeakerAnswers if we need legacy database defaults
44
+
45
+ Based on this setting, BeakerAnswers can provide legacy bash default
46
+ values for database user parameters in the meep hiera config. This is
47
+ necessary if we are upgrading from an older pe that beaker just
48
+ installed using the legacy script/answer defaults.
49
+
50
+ Also logs the actual answers/pe.conf file that was generated so we can
51
+ see what is going on.
52
+ ```
53
+ * (maint) Remove unused variables from spec (61134529)
54
+
55
+
56
+ ```
57
+ (maint) Remove unused variables from spec
58
+
59
+ Marked by static analysis; specs continue to pass after removal.
60
+ ```
61
+ * (PE-14271) Have mock hosts return a hostname (53e90212)
62
+
63
+
64
+ ```
65
+ (PE-14271) Have mock hosts return a hostname
66
+
67
+ Because BeakerAnswers sets hiera host parameters from Host#hostname, so
68
+ the method needs to exist in our mocks.
69
+ ```
70
+ * (maint) Make the previous_pe_ver available on upgrade (0f72aaab)
71
+
72
+
73
+ ```
74
+ (maint) Make the previous_pe_ver available on upgrade
75
+
76
+ Sometimes during PE upgrades we need to be able to determine what
77
+ version we upgraded from, to know what behavior we expect from the
78
+ upgrade. Prior to this change, that could only be determined by probing
79
+ into the original host.cfg yaml. This patch just sets it explicitly in
80
+ each host prior to overwriting the pe_ver with pe_upgrade_ver.
81
+ ```
82
+ * (PE-14271) Adjust higgs commands to provide correct answer (f7cc8d9a)
83
+
84
+
85
+ ```
86
+ (PE-14271) Adjust higgs commands to provide correct answer
87
+
88
+ ...for both legacy and meep installers. The former prompts to continue
89
+ expecting 'Y' and the later prompts with options where '1' is intended
90
+ to kick off Higgs.
91
+
92
+ Also added spec coverage for these methods.
93
+ ```
94
+ * (PE-14271) Adjust BeakerAnswers call for meep (6bc392ff)
95
+
96
+
97
+ ```
98
+ (PE-14271) Adjust BeakerAnswers call for meep
99
+
100
+ Based on changes pending in puppetlabs/beaker-answers#16, change the
101
+ generate_installer_conf_file_for() method to submit the expected :format
102
+ option temporarily. This will go away when we cutover to meep and no
103
+ longer have to have both installer scripts operational in the same
104
+ build.
105
+
106
+ Fleshes out the specs that verify the method returns expected answer or
107
+ pe.conf data from BeakerAnswers, as written out via scp.
108
+ ```
109
+ * (PE-14271) Prepare host installer options based on version/env (616612a6)
110
+
111
+
112
+ ```
113
+ (PE-14271) Prepare host installer options based on version/env
114
+
115
+ The addition of a use_meep? query allows setting host options for either
116
+ legacy or meep installer. This enables installer_cmd to invoke the
117
+ correct installer.
118
+ ```
119
+ * (maint) Remove remaining version_is_less mocks (7ea8fbcf)
120
+
121
+
122
+ ```
123
+ (maint) Remove remaining version_is_less mocks
124
+
125
+ For consistency, removed the rest of the version_is_less mocks.
126
+
127
+ In the three cases where this had an impact on the specs, replaced
128
+ them with a concrete version setting on the test host object.
129
+ ```
130
+ * (maint) Stop mocking version_is_less in do_install tests (d3e09cc1)
131
+
132
+
133
+ ```
134
+ (maint) Stop mocking version_is_less in do_install tests
135
+
136
+ Each change to do_install and supporting methods involving a
137
+ version_is_less call was requiring additional mocking simulating
138
+ version_is_less's behavior. This is unnecessary given that hosts are
139
+ being set with a version, and actually masks behavior of the class.
140
+ Removing these specifically because it was causing churn when
141
+ introducing meep functionality.
142
+ ```
143
+ * (PE-14271) Extract installer configuration methods (3071c5e9)
144
+
145
+
146
+ ```
147
+ (PE-14271) Extract installer configuration methods
148
+
149
+ ...from the existing code to generate answers and expand it to
150
+ generalize the installer settings and configuration file. Passes
151
+ existing specs. Will be further specialized to handle legacy/meep
152
+ cases.
153
+ ```
154
+ * (PE-14934) Fix specs to cover changes from PE-14934 (b22c3790)
155
+
156
+
157
+ ```
158
+ (PE-14934) Fix specs to cover changes from PE-14934
159
+
160
+ Introduced chagnes to the do_install method, but specs were failing
161
+ because of the tight coupling between expectations and counts of command
162
+ execution.
163
+
164
+ The need to initialize metadata comes from the fact that the previous
165
+ PR #3 added step() calls, which reference the TestCase metadata attr.
166
+ Since we aren't using an actual TestCase instance, this had to be
167
+ initalized separately.
168
+ ```
169
+ ### <a name = "0.2.0">0.2.0 - 18 May, 2016 (a65f2083)
170
+
171
+ * (HISTORY) update beaker-pe history for gem release 0.2.0 (a65f2083)
10
172
 
11
173
  * (GEM) update beaker-pe version to 0.2.0 (d9a052a4)
12
174
 
@@ -22,6 +22,9 @@ module Beaker
22
22
  include PuppetUtils
23
23
  include WindowsUtils
24
24
 
25
+ # Version of PE when we switched from legacy installer to MEEP.
26
+ MEEP_CUTOVER_VERSION = '2016.2.0'
27
+
25
28
  # @!macro [new] common_opts
26
29
  # @param [Hash{Symbol=>String}] opts Options to alter execution.
27
30
  # @option opts [Boolean] :silent (false) Do not produce log output
@@ -106,7 +109,7 @@ module Beaker
106
109
  host.install_from_file("puppet-enterprise-#{version}-#{host['platform']}.swix")
107
110
  else
108
111
  pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -D' : ''
109
- "cd #{host['working_dir']}/#{host['dist']} && ./#{host['pe_installer']}#{pe_debug} -a #{host['working_dir']}/answers"
112
+ "cd #{host['working_dir']}/#{host['dist']} && ./#{host['pe_installer']}#{pe_debug} #{host['pe_installer_conf_setting']}"
110
113
  end
111
114
  end
112
115
 
@@ -433,16 +436,27 @@ module Beaker
433
436
  acceptable_codes = host['platform'] =~ /osx/ ? [1] : [0, 1]
434
437
  setup_defaults_and_config_helper_on(host, master, acceptable_codes)
435
438
  else
436
- answers = BeakerAnswers::Answers.create(opts[:pe_ver] || host['pe_ver'], hosts, opts)
437
- create_remote_file host, "#{host['working_dir']}/answers", answers.answer_string(host)
439
+ prepare_host_installer_options(host)
440
+ generate_installer_conf_file_for(host, hosts, opts)
438
441
  on host, installer_cmd(host, opts)
439
442
  configure_type_defaults_on(host)
440
443
  end
441
444
  end
442
445
 
443
- # On each agent, we ensure the certificate is signed then shut down the agent
444
- sign_certificate_for(host) unless masterless
445
- stop_agent_on(host)
446
+ # On each agent, we ensure the certificate is signed
447
+ if !masterless
448
+ if [master, database, dashboard].include?(host) && use_meep?(host['pe_ver'])
449
+ # This step is not necessary for the core pe nodes when using meep
450
+ else
451
+ step "Sign certificate for #{host}" do
452
+ sign_certificate_for(host)
453
+ end
454
+ end
455
+ end
456
+ # then shut down the agent
457
+ step "Shutting down agent for #{host}" do
458
+ stop_agent_on(host)
459
+ end
446
460
  end
447
461
 
448
462
  unless masterless
@@ -497,6 +511,92 @@ module Beaker
497
511
  end
498
512
  end
499
513
 
514
+ # True if version is greater than or equal to 2016.2.0 and the
515
+ # INSTALLER_TYPE environment variable is 'meep'.
516
+ #
517
+ # This will be switched to be true if >= 2016.2.0 and INSTALLER_TYPE !=
518
+ # 'legacy' once meep is default.
519
+ #
520
+ # And then to just >= 2016.2.0 for cutover.
521
+ def use_meep?(version)
522
+ !version_is_less(version, MEEP_CUTOVER_VERSION) && ENV['INSTALLER_TYPE'] == 'meep'
523
+ end
524
+
525
+ # Set installer options on the passed *host* according to current
526
+ # version and external INSTALLER_TYPE setting.
527
+ #
528
+ # Sets:
529
+ # * 'pe_installer_conf_file'
530
+ # * 'pe_installer_conf_setting'
531
+ # * 'pe_installer_type'
532
+ #
533
+ # @param [Beaker::Host] host The host object to configure
534
+ # @return [Beaker::Host] The same host object passed in
535
+ def prepare_host_installer_options(host)
536
+ if use_meep?(host['pe_ver'])
537
+ conf_file = "#{host['working_dir']}/pe.conf"
538
+ host['pe_installer_conf_file'] = conf_file
539
+ host['pe_installer_conf_setting'] = "-c #{conf_file}"
540
+ host['pe_installer_type'] = 'meep'
541
+ else
542
+ conf_file = "#{host['working_dir']}/answers"
543
+ host['pe_installer_conf_file'] = conf_file
544
+ host['pe_installer_conf_setting'] = "-a #{conf_file}"
545
+ host['pe_installer_type'] = 'legacy'
546
+ end
547
+ host
548
+ end
549
+
550
+ # Adds in settings needed by BeakerAnswers:
551
+ #
552
+ # * :format => :bash or :hiera depending on which legacy or meep format we need
553
+ # * :include_legacy_database_defaults => true or false. True
554
+ # indicates that we are upgrading from a legacy version and
555
+ # BeakerAnswers should include the database defaults for user
556
+ # which were set for the legacy install.
557
+ #
558
+ # @param [Beaker::Host] host that we are generating answers for
559
+ # @param [Hash] opts The Beaker options hash
560
+ # @return [Hash] a dup of the opts hash with additional settings for BeakerAnswers
561
+ def setup_beaker_answers_opts(host, opts)
562
+ beaker_answers_opts = host['pe_installer_type'] == 'meep' ?
563
+ { :format => :hiera } :
564
+ { :format => :bash }
565
+
566
+ beaker_answers_opts[:include_legacy_database_defaults] =
567
+ opts[:type] == :upgrade && !use_meep?(host['previous_pe_ver'])
568
+
569
+ opts.merge(beaker_answers_opts)
570
+ end
571
+
572
+ # Generates a Beaker Answers object for the passed *host* and creates
573
+ # the answer or pe.conf configuration file on the *host* needed for
574
+ # installation.
575
+ #
576
+ # Expects the host['pe_installer_conf_file'] to have been set, which is
577
+ # where the configuration will be written to, and expects
578
+ # host['pe_installer_type'] to have been set to either 'legacy' or
579
+ # 'meep'.
580
+ #
581
+ # @param [Beaker::Host] host The host to create a configuration file on
582
+ # @param [Array<Beaker::Host]> hosts All of the hosts to be configured
583
+ # @param [Hash] opts The Beaker options hash
584
+ # @return [BeakerAnswers::Answers] the generated answers object
585
+ def generate_installer_conf_file_for(host, hosts, opts)
586
+ beaker_answers_opts = setup_beaker_answers_opts(host, opts)
587
+ answers = BeakerAnswers::Answers.create(
588
+ opts[:pe_ver] || host['pe_ver'], hosts, beaker_answers_opts
589
+ )
590
+ configuration = answers.installer_configuration_string(host)
591
+
592
+ step "Generate the #{host['pe_installer_conf_file']} on #{host}" do
593
+ logger.debug(configuration)
594
+ create_remote_file(host, host['pe_installer_conf_file'], configuration)
595
+ end
596
+
597
+ answers
598
+ end
599
+
500
600
  # Builds the agent_only and not_agent_only arrays needed for installation.
501
601
  #
502
602
  # @param [Array<Host>] hosts hosts to split up into the arrays
@@ -657,6 +757,7 @@ module Beaker
657
757
  # prep_host_for_upgrade(master, {}, "http://neptune.puppetlabs.lan/3.0/ci-ready/")
658
758
  def prep_host_for_upgrade(host, opts={}, path='')
659
759
  host['pe_dir'] = host['pe_upgrade_dir'] || path
760
+ host['previous_pe_ver'] = host['pe_ver']
660
761
  if host['platform'] =~ /windows/
661
762
  host['pe_ver'] = host['pe_upgrade_ver'] || opts['pe_upgrade_ver'] ||
662
763
  Options::PEVersionScraper.load_pe_version(host['pe_dir'], opts[:pe_version_file_win])
@@ -675,9 +776,8 @@ module Beaker
675
776
  # The host object must have the 'working_dir', 'dist' and 'pe_installer' field set correctly.
676
777
  # @api private
677
778
  def higgs_installer_cmd host
678
-
679
- "cd #{host['working_dir']}/#{host['dist']} ; nohup ./#{host['pe_installer']} <<<Y > #{host['higgs_file']} 2>&1 &"
680
-
779
+ higgs_answer = host['pe_installer_type'] == 'meep' ? '1' : 'Y'
780
+ "cd #{host['working_dir']}/#{host['dist']} ; nohup ./#{host['pe_installer']} <<<#{higgs_answer} > #{host['higgs_file']} 2>&1 &"
681
781
  end
682
782
 
683
783
  #Perform a Puppet Enterprise Higgs install up until web browser interaction is required, runs on linux hosts only.
@@ -710,6 +810,8 @@ module Beaker
710
810
  fetch_pe([host], opts)
711
811
 
712
812
  host['higgs_file'] = "higgs_#{File.basename(host['working_dir'])}.log"
813
+
814
+ prepare_host_installer_options(host)
713
815
  on host, higgs_installer_cmd(host), opts
714
816
 
715
817
  #wait for output to host['higgs_file']
@@ -3,7 +3,7 @@ module Beaker
3
3
  module PE
4
4
 
5
5
  module Version
6
- STRING = '0.2.0'
6
+ STRING = '0.3.0'
7
7
  end
8
8
 
9
9
  end
@@ -10,7 +10,11 @@ class ClassMixedWithDSLInstallUtils
10
10
  include Beaker::DSL::Patterns
11
11
  include Beaker::DSL::PE
12
12
 
13
- attr_accessor :hosts
13
+ attr_accessor :hosts, :metadata
14
+
15
+ def initialize
16
+ @metadata = {}
17
+ end
14
18
 
15
19
  # Because some the methods now actually call out to the `step` method, we need to
16
20
  # mock out `metadata` that is initialized in a test case.
@@ -46,7 +50,7 @@ describe ClassMixedWithDSLInstallUtils do
46
50
  :working_dir => '/tmp' } ) }
47
51
  let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
48
52
  :pe_ver => '3.0',
49
- :type => 'pe',
53
+ :type => 'pe',
50
54
  :working_dir => '/tmp',
51
55
  :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
52
56
  let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
@@ -188,26 +192,27 @@ describe ClassMixedWithDSLInstallUtils do
188
192
  it 'generates a unix PE install command for a unix host' do
189
193
  the_host = unixhost.dup
190
194
  the_host['pe_installer'] = 'puppet-enterprise-installer'
195
+ the_host['pe_installer_conf_setting'] = '-a /tmp/answers'
191
196
  expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -a /tmp/answers"
192
197
  end
193
198
 
194
199
  it 'generates a unix PE frictionless install command for a unix host with role "frictionless"' do
195
- allow( subject ).to receive( :version_is_less ).and_return( false )
196
200
  allow( subject ).to receive( :master ).and_return( 'testmaster' )
197
201
  the_host = unixhost.dup
202
+ the_host['pe_ver'] = '3.8.0'
198
203
  the_host['pe_installer'] = 'puppet-enterprise-installer'
199
204
  the_host['roles'] = ['frictionless']
200
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash"
205
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.8.0/install.bash && bash install.bash"
201
206
  end
202
207
 
203
208
  it 'generates a unix PE frictionless install command for a unix host with role "frictionless" and "frictionless_options"' do
204
- allow( subject ).to receive( :version_is_less ).and_return( false )
205
209
  allow( subject ).to receive( :master ).and_return( 'testmaster' )
206
210
  the_host = unixhost.dup
211
+ the_host['pe_ver'] = '3.8.0'
207
212
  the_host['pe_installer'] = 'puppet-enterprise-installer'
208
213
  the_host['roles'] = ['frictionless']
209
214
  the_host['frictionless_options'] = { 'main' => { 'dns_alt_names' => 'puppet' } }
210
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash main:dns_alt_names=puppet"
215
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.8.0/install.bash && bash install.bash main:dns_alt_names=puppet"
211
216
  end
212
217
 
213
218
  it 'generates a osx PE install command for a osx host' do
@@ -225,6 +230,7 @@ describe ClassMixedWithDSLInstallUtils do
225
230
  it 'generates a unix PE install command in verbose for a unix host when pe_debug is enabled' do
226
231
  the_host = unixhost.dup
227
232
  the_host['pe_installer'] = 'puppet-enterprise-installer'
233
+ the_host['pe_installer_conf_setting'] = '-a /tmp/answers'
228
234
  the_host[:pe_debug] = true
229
235
  expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -D -a /tmp/answers"
230
236
  end
@@ -237,17 +243,241 @@ describe ClassMixedWithDSLInstallUtils do
237
243
  end
238
244
 
239
245
  it 'generates a unix PE frictionless install command in verbose for a unix host with role "frictionless" and pe_debug is enabled' do
240
- allow( subject ).to receive( :version_is_less ).and_return( false )
241
246
  allow( subject ).to receive( :master ).and_return( 'testmaster' )
242
247
  the_host = unixhost.dup
248
+ the_host['pe_ver'] = '3.8.0'
243
249
  the_host['pe_installer'] = 'puppet-enterprise-installer'
244
250
  the_host['roles'] = ['frictionless']
245
251
  the_host[:pe_debug] = true
246
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash -x install.bash"
252
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.8.0/install.bash && bash -x install.bash"
253
+ end
254
+
255
+ end
256
+
257
+ describe 'higgs installer' do
258
+ let(:host) { unixhost }
259
+ let(:higgs_regex) { %r{cd .* ; nohup \./puppet-enterprise-installer <<<#{higgs_answer} .*} }
260
+ before(:each) do
261
+ host['pe_installer'] = 'puppet-enterprise-installer'
262
+ end
263
+
264
+ def prep_host(host)
265
+ allow(subject).to receive(:sleep)
266
+ allow(host).to receive(:tmpdir).and_return('/tmp')
267
+ allow(subject).to receive(:fetch_pe)
268
+ expect(subject).to receive(:on).with(host, higgs_regex, opts).once
269
+ result = double(Beaker::Result, :stdout => 'Please go to https://somewhere in your browser to continue installation')
270
+ expect(subject).to receive(:on).with(host, %r{cd .* && cat .*}, anything)
271
+ .and_return(result)
272
+ end
273
+
274
+ context 'for legacy installer' do
275
+ let(:higgs_answer) { 'Y' }
276
+
277
+ context 'the higgs_installer_cmd' do
278
+ it 'returns correct command to invoke Higgs' do
279
+ expect(subject.higgs_installer_cmd(host)).to match(higgs_regex)
280
+ end
281
+ end
282
+
283
+ context 'the do_higgs_install' do
284
+ it 'submits the correct installer cmd to invoke Higgs' do
285
+ prep_host(host)
286
+ subject.do_higgs_install(host, opts)
287
+ end
288
+ end
289
+ end
290
+
291
+ context 'for meep installer' do
292
+ let(:higgs_answer) { '1' }
293
+
294
+ before(:each) do
295
+ ENV['INSTALLER_TYPE'] = 'meep'
296
+ host['pe_ver'] = '2016.2.0'
297
+ end
298
+
299
+ after(:each) do
300
+ ENV.delete('INSTALLER_TYPE')
301
+ end
302
+
303
+ context 'the higgs_installer_cmd' do
304
+ it 'submits correct command to invoke Higgs' do
305
+ subject.prepare_host_installer_options(host)
306
+ expect(subject.higgs_installer_cmd(host)).to match(higgs_regex)
307
+ end
308
+ end
309
+
310
+ context 'the do_higgs_install' do
311
+ it 'submits the correct installer cmd to invoke Higgs' do
312
+ prep_host(host)
313
+ subject.do_higgs_install(host, opts)
314
+ end
315
+ end
316
+ end
317
+ end
318
+
319
+ describe 'prepare_host_installer_options' do
320
+ let(:legacy_settings) do
321
+ {
322
+ :pe_installer_conf_file => '/tmp/answers',
323
+ :pe_installer_conf_setting => '-a /tmp/answers',
324
+ :pe_installer_type => 'legacy',
325
+ }
326
+ end
327
+ let(:meep_settings) do
328
+ {
329
+ :pe_installer_conf_file => '/tmp/pe.conf',
330
+ :pe_installer_conf_setting => '-c /tmp/pe.conf',
331
+ :pe_installer_type => 'meep',
332
+ }
333
+ end
334
+ let(:installer_type) { nil }
335
+ let(:host) { unixhost }
336
+
337
+ before(:each) do
338
+ ENV['INSTALLER_TYPE'] = installer_type
339
+ host['pe_ver'] = pe_ver
340
+ subject.prepare_host_installer_options(host)
341
+ end
342
+
343
+ after(:each) do
344
+ ENV.delete('INSTALLER_TYPE')
345
+ end
346
+
347
+ def slice_installer_options(host)
348
+ host.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting, :pe_installer_type].include?(k) }
349
+ end
350
+
351
+ context 'when version < 2016.2.0' do
352
+ let(:pe_ver) { '3.8.5' }
353
+
354
+ it 'sets legacy settings' do
355
+ expect(slice_installer_options(host)).to eq(legacy_settings)
356
+ end
357
+
358
+ context 'and ENV["INSTALLER"]=="meep"' do
359
+ let(:installer_type) { 'meep' }
360
+
361
+ it 'still sets legacy settings' do
362
+ expect(slice_installer_options(host)).to eq(legacy_settings)
363
+ end
364
+ end
247
365
  end
248
366
 
367
+ context 'when version >= 2016.2.0' do
368
+ let (:pe_ver) { '2016.2.0' }
369
+
370
+ context 'and ENV["INSTALLER_TYPE"]=="legacy"' do
371
+ let(:installer_type) { 'legacy' }
372
+
373
+ it 'sets legacy settings' do
374
+ expect(slice_installer_options(host)).to eq(legacy_settings)
375
+ end
376
+ end
377
+
378
+ context 'and ENV["INSTALLER_TYPE"]=="meep"' do
379
+ let(:installer_type) { 'meep' }
380
+
381
+ it 'sets meep settings' do
382
+ expect(slice_installer_options(host)).to eq(meep_settings)
383
+ end
384
+ end
385
+ end
249
386
  end
250
387
 
388
+ describe 'generate_installer_conf_file_for' do
389
+ let(:master) { hosts.first }
390
+
391
+ it 'generates a legacy answer file if host["pe_installer_type"]=="legacy"' do
392
+ master['pe_installer_conf_file'] = '/tmp/answers'
393
+ master['pe_installer_type'] = 'legacy'
394
+ expect(subject).to receive(:create_remote_file).with(
395
+ master,
396
+ '/tmp/answers',
397
+ %r{q_install=y.*q_puppetmaster_certname=#{master}}m
398
+ )
399
+ subject.generate_installer_conf_file_for(master, hosts, opts)
400
+ end
401
+
402
+ it 'generates a meep config file if host["pe_installer_type"]=="meep"' do
403
+ master['pe_installer_conf_file'] = '/tmp/pe.conf'
404
+ master['pe_installer_type'] = 'meep'
405
+ master['pe_ver'] = '2016.2.0'
406
+ expect(subject).to receive(:create_remote_file).with(
407
+ master,
408
+ '/tmp/pe.conf',
409
+ %r{\{.*"puppet_enterprise::puppet_master_host": "#{master.hostname}"}m
410
+ )
411
+ subject.generate_installer_conf_file_for(master, hosts, opts)
412
+ end
413
+ end
414
+
415
+ describe 'setup_beaker_answers_opts' do
416
+ let(:opts) { {} }
417
+ let(:host) { hosts.first }
418
+
419
+ context 'for legacy installer' do
420
+ it 'adds option for bash format' do
421
+ host['pe_installer_type'] = 'legacy'
422
+ expect(subject.setup_beaker_answers_opts(host, opts)).to eq(
423
+ opts.merge(
424
+ :format => :bash,
425
+ :include_legacy_database_defaults => false,
426
+ )
427
+ )
428
+ end
429
+ end
430
+
431
+ context 'for meep installer' do
432
+ before(:each) do
433
+ ENV['INSTALLER_TYPE'] = 'meep'
434
+ host['pe_ver'] = '2016.2.0'
435
+ host['pe_installer_type'] = 'meep'
436
+ end
437
+
438
+ after(:each) do
439
+ ENV.delete('INSTALLER_TYPE')
440
+ end
441
+
442
+ it 'adds option for hiera format' do
443
+ expect(subject.setup_beaker_answers_opts(host, opts)).to eq(
444
+ opts.merge(
445
+ :format => :hiera,
446
+ :include_legacy_database_defaults => false,
447
+ )
448
+ )
449
+ end
450
+
451
+ context 'when upgrading' do
452
+ let(:opts) { { :type => :upgrade } }
453
+
454
+ context 'from meep' do
455
+ it 'sets legacy password defaults false' do
456
+ host['pe_ver'] = '2016.2.1'
457
+ host['previous_pe_ver'] = '2016.2.0'
458
+ expect(subject.setup_beaker_answers_opts(host, opts)).to eq(
459
+ opts.merge(
460
+ :format => :hiera,
461
+ :include_legacy_database_defaults => false,
462
+ )
463
+ )
464
+ end
465
+ end
466
+
467
+ context 'from legacy' do
468
+ it 'sets legacy password defaults to true' do
469
+ host['previous_pe_ver'] = '3.8.5'
470
+ expect(subject.setup_beaker_answers_opts(host, opts)).to eq(
471
+ opts.merge(
472
+ :format => :hiera,
473
+ :include_legacy_database_defaults => true,
474
+ )
475
+ )
476
+ end
477
+ end
478
+ end
479
+ end
480
+ end
251
481
 
252
482
  describe 'fetch_pe' do
253
483
 
@@ -295,7 +525,6 @@ describe ClassMixedWithDSLInstallUtils do
295
525
  end
296
526
  allow( subject ).to receive( :on ).and_return( true )
297
527
 
298
- path = unixhost['pe_dir']
299
528
  filename = "#{ unixhost['dist'] }"
300
529
  extension = '.tar'
301
530
  expect( subject ).to receive( :fetch_and_push_pe ).with( unixhost, anything, filename, extension ).once
@@ -320,7 +549,6 @@ describe ClassMixedWithDSLInstallUtils do
320
549
  allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
321
550
  allow( subject ).to receive( :on ).and_return( true )
322
551
 
323
- path = unixhost['pe_dir']
324
552
  filename = "#{ unixhost['dist'] }"
325
553
  extension = '.tar.gz'
326
554
  expect( subject ).to receive( :fetch_and_push_pe ).with( unixhost, anything, filename, extension ).once
@@ -380,7 +608,6 @@ describe ClassMixedWithDSLInstallUtils do
380
608
 
381
609
  expect( subject).to_not receive(:scp_to)
382
610
  expect( subject).to_not receive(:on)
383
- allow( subject ).to receive(:version_is_less).with('3.2.0', '3.2.0').and_return(false)
384
611
  subject.fetch_pe( [unixhost], {} )
385
612
  end
386
613
  end
@@ -394,13 +621,6 @@ describe ClassMixedWithDSLInstallUtils do
394
621
  allow( subject ).to receive( :stop_agent_on ).and_return( true )
395
622
  allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
396
623
  allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('3.0')
397
- allow( subject ).to receive( :version_is_less ).with('3.0', '4.0').and_return( true )
398
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
399
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
400
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.99').and_return( true )
401
- allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
402
- allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
403
- allow( subject ).to receive( :version_is_less ).with('3.0', '2016.1.0').and_return( false )
404
624
  allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
405
625
  allow( subject ).to receive( :puppet_agent ) do |arg|
406
626
  "puppet agent #{arg}"
@@ -438,7 +658,7 @@ describe ClassMixedWithDSLInstallUtils do
438
658
  expect( subject ).to receive( :stop_agent_on ).with( hosts[3] ).once
439
659
  # We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
440
660
  expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times
441
- # Each puppet agent runs twice, once for the initial run, and once to configure mcollective
661
+ #run each puppet agent (also captures the final run below)
442
662
  expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
443
663
  expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
444
664
  expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
@@ -446,6 +666,9 @@ describe ClassMixedWithDSLInstallUtils do
446
666
  #run rake task on dashboard
447
667
 
448
668
  expect( subject ).to receive( :on ).with( hosts[0], /\/opt\/puppet\/bin\/rake -sf \/opt\/puppet\/share\/puppet-dashboard\/Rakefile .* RAILS_ENV=production/ ).once
669
+ #wait for all hosts to appear in the dashboard
670
+ #run puppet agent now that installation is complete
671
+ # This is captured above (run each puppet agent)
449
672
 
450
673
  hosts.each do |host|
451
674
  allow( host ).to receive( :tmpdir )
@@ -468,9 +691,6 @@ describe ClassMixedWithDSLInstallUtils do
468
691
  allow( subject ).to receive( :create_remote_file ).and_return( true )
469
692
  allow( subject ).to receive( :stop_agent_on ).and_return( true )
470
693
  allow( subject ).to receive( :max_version ).with(['3.0'], '3.8').and_return('3.0')
471
- allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
472
- allow( subject ).to receive( :version_is_less ).with(anything, '3.2.0').exactly(hosts.length + 1).times.and_return( false )
473
- allow( subject ).to receive( :version_is_less ).with(anything, '4.0').exactly(hosts.length + 1).times.and_return( true )
474
694
 
475
695
  expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
476
696
  expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
@@ -506,14 +726,6 @@ describe ClassMixedWithDSLInstallUtils do
506
726
  allow( subject ).to receive( :stop_agent_on ).and_return( true )
507
727
  allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
508
728
  allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
509
- allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
510
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
511
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
512
- allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
513
- # pe_ver is only set on the hosts for this test, not the opt
514
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
515
- allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
516
- allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
517
729
  allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
518
730
  allow( subject ).to receive( :puppet_agent ) do |arg|
519
731
  "puppet agent #{arg}"
@@ -540,6 +752,9 @@ describe ClassMixedWithDSLInstallUtils do
540
752
  end
541
753
  # We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
542
754
  expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times
755
+ #wait for all hosts to appear in the dashboard
756
+ #run puppet agent now that installation is complete
757
+ # tested above in the hosts loop ^^
543
758
 
544
759
  hosts.each do |host|
545
760
  allow( host ).to receive( :tmpdir )
@@ -568,15 +783,6 @@ describe ClassMixedWithDSLInstallUtils do
568
783
  allow( subject ).to receive( :stop_agent_on ).and_return( true )
569
784
  allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
570
785
  allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
571
- allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
572
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
573
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
574
- allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
575
- allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
576
- # pe_ver is only set on the hosts for this test, not the opt
577
- allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
578
- allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
579
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
580
786
  allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
581
787
  allow( subject ).to receive( :puppet_agent ) do |arg|
582
788
  "puppet agent #{arg}"
@@ -602,6 +808,9 @@ describe ClassMixedWithDSLInstallUtils do
602
808
  end
603
809
  # We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
604
810
  expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times
811
+ #wait for all hosts to appear in the dashboard
812
+ #run puppet agent now that installation is complete
813
+ # tested above in the hosts loop ^^
605
814
 
606
815
  hosts.each do |host|
607
816
  allow( host ).to receive( :tmpdir )
@@ -613,6 +822,7 @@ describe ClassMixedWithDSLInstallUtils do
613
822
 
614
823
  it 'sets puppet-agent acceptable_exit_codes correctly for config helper on upgrade' do
615
824
  hosts = make_hosts({
825
+ :previous_pe_ver => '3.0',
616
826
  :pe_ver => '4.0',
617
827
  :roles => ['agent'],
618
828
  }, 2)
@@ -628,15 +838,6 @@ describe ClassMixedWithDSLInstallUtils do
628
838
  allow( subject ).to receive( :stop_agent_on ).and_return( true )
629
839
  allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
630
840
  allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
631
- allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
632
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
633
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
634
- allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
635
- allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
636
- # pe_ver is only set on the hosts for this test, not the opt
637
- allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
638
- allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
639
- allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
640
841
  allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
641
842
  allow( subject ).to receive( :puppet_agent ) do |arg|
642
843
  "puppet agent #{arg}"
@@ -783,9 +984,6 @@ describe ClassMixedWithDSLInstallUtils do
783
984
  the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
784
985
  allow( subject ).to receive( :hosts ).and_return( the_hosts )
785
986
  allow( subject ).to receive( :options ).and_return( {} )
786
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
787
- allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
788
- version = version_win = '2.8'
789
987
  path = "/path/to/upgradepkg"
790
988
  expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
791
989
  subject.upgrade_pe( path )
@@ -800,9 +998,6 @@ describe ClassMixedWithDSLInstallUtils do
800
998
  the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
801
999
  allow( subject ).to receive( :hosts ).and_return( the_hosts )
802
1000
  allow( subject ).to receive( :options ).and_return( {} )
803
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
804
- allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
805
- version = version_win = '3.1'
806
1001
  path = "/path/to/upgradepkg"
807
1002
  expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
808
1003
  subject.upgrade_pe( path )
@@ -817,9 +1012,6 @@ describe ClassMixedWithDSLInstallUtils do
817
1012
  the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
818
1013
  allow( subject ).to receive( :hosts ).and_return( the_hosts )
819
1014
  allow( subject ).to receive( :options ).and_return( {} )
820
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
821
- allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
822
- version = version_win = '2.8'
823
1015
  path = "/path/to/upgradepkg"
824
1016
  expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
825
1017
  subject.upgrade_pe( path )
@@ -832,15 +1024,22 @@ describe ClassMixedWithDSLInstallUtils do
832
1024
  allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '3.1' )
833
1025
  allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '3.1' )
834
1026
  allow( subject ).to receive( :hosts ).and_return( hosts )
835
- allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
836
- allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
837
1027
  allow( subject ).to receive( :sorted_hosts ).and_return( [hosts[0]] )
838
- version = version_win = '3.1'
839
1028
  path = "/path/to/upgradepkg"
840
1029
  expect( subject ).to receive( :do_install ).with( [hosts[0]], {:type=>:upgrade, :set_console_password=>true} )
841
1030
  subject.upgrade_pe_on(hosts[0], {}, path)
842
1031
  end
843
1032
 
1033
+ it 'sets previous_pe_ver' do
1034
+ subject.hosts = hosts
1035
+ host = hosts[0]
1036
+ host['pe_ver'] = '3.8.5'
1037
+ host['pe_upgrade_ver'] = '2016.2.0'
1038
+ expect(subject).to receive(:do_install).with([host], Hash)
1039
+ subject.upgrade_pe_on([host], {})
1040
+ expect(host['pe_ver']).to eq('2016.2.0')
1041
+ expect(host['previous_pe_ver']).to eq('3.8.5')
1042
+ end
844
1043
  end
845
1044
 
846
1045
  describe 'fetch_and_push_pe' do
data/spec/helpers.rb CHANGED
@@ -83,6 +83,7 @@ module HostHelpers
83
83
  host = make_opts.merge(host_hash)
84
84
 
85
85
  allow(host).to receive( :name ).and_return( name )
86
+ allow(host).to receive( :hostname ).and_return( "#{name}.test" )
86
87
  allow(host).to receive( :to_s ).and_return( name )
87
88
  allow(host).to receive( :exec ).and_return( generate_result( name, host_hash ) )
88
89
  host
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-pe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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-05-18 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec