beaker-pe 1.11.0 → 1.12.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
- N2IyMTYxOWMzNzU2MzU0ZmRmNTM2NjQ2ODRiNTk1OWYyMzk0N2YzNA==
4
+ YTI4NjI0OGUyOGY5ZGMyZDljNTBhMjA1NDhhMzYxY2I5M2JjYmVkNQ==
5
5
  data.tar.gz: !binary |-
6
- ZjBiMWIwYjY3NjI5MTc0NTQ4NjFjN2EzMWU2N2I0ZDYwZTZiMWRkOA==
6
+ YWIyYThhODVhMmU0OGQ4ZjA2ZmM1NmQ3MzBhYjdiMTViMzhjZjgzMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDdhZDZlYjI1OTYzMzc3M2I3YjJmMmMzMDAyOTVkM2Q4NTQ3OTY0M2IwOTZk
10
- NmNlYTcxOWVkYjVjOGQ0ZjcyMGNiN2NjMjM1NWUxYjYzYjBmNGIwN2I1M2Uw
11
- MGE2NWUyNWZmMDM1MmMzOGI4ZGZlODQ0NzlmMmRjZWNiZmJjNWY=
9
+ MjkzODE5YmVlMzU1YjUzMTVkYzhiMTlhNjgyMTQ4MDkxOGMxMDcxMmU2ZjJj
10
+ NmI0MWE2MGJmNGFkNDExMDFlMzgzMmRiMDEyODJmNzI0MmZkMjc5Zjc2MmUz
11
+ OWIxYjIzYzRjMzFkMDJhZTE0MmFmZDFjZGFhMTFmZDU2Y2MxNjI=
12
12
  data.tar.gz: !binary |-
13
- MTEzMWRjMWM0ZTM1MDdiNTM2NTcwYjlhZDkxMGQwZmYwYWYzNjU3ZWNiOTYw
14
- NTg1ZGNjMTM5NzJmNjQzMjRhODNkYWNkMTFkNGRkYTBiZDJhYjJlY2U3YzQ0
15
- NDM2NzVmMTliMzNiNDM0YTZjZWQ2YmY4MGY2YTE3N2I0YTVjMDg=
13
+ YzdjYTQyOTI5ZDBmYmVjMzZiYjRmNmJmZmE1NmRmZTY5ZDY4OTA3ZGMyMzcx
14
+ YTAyMWM1ZmVjNTIzMzk2MDdmYzhmZTc1OWVmNDg3MWJjMjBjYWY2NDUwZDM1
15
+ NzZlYWRjMGJhNGJiMmMwNjU2YzJiY2JmN2E5NzVjMjZiNGQ2YzY=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # worker - History
2
2
  ## Tags
3
- * [LATEST - 23 Mar, 2017 (bce6add6)](#LATEST)
3
+ * [LATEST - 23 Mar, 2017 (dd68cfa4)](#LATEST)
4
+ * [1.11.0 - 23 Mar, 2017 (6c3b0067)](#1.11.0)
4
5
  * [1.10.0 - 20 Mar, 2017 (22e22ca8)](#1.10.0)
5
6
  * [1.9.1 - 22 Feb, 2017 (3b0bd457)](#1.9.1)
6
7
  * [1.9.0 - 7 Feb, 2017 (efae323b)](#1.9.0)
@@ -33,7 +34,55 @@
33
34
  * [0.1.0 - 29 Feb, 2016 (4fc88d8c)](#0.1.0)
34
35
 
35
36
  ## Details
36
- ### <a name = "LATEST">LATEST - 23 Mar, 2017 (bce6add6)
37
+ ### <a name = "LATEST">LATEST - 23 Mar, 2017 (dd68cfa4)
38
+
39
+ * (GEM) update beaker-pe version to 1.12.0 (dd68cfa4)
40
+
41
+ * Merge pull request #57 from nicklewis/improved-monolithic-install (07aa286e)
42
+
43
+
44
+ ```
45
+ Merge pull request #57 from nicklewis/improved-monolithic-install
46
+
47
+ (BKR-1058) Implement a simpler monolithic install method
48
+ ```
49
+ * (BKR-1058) Implement a simpler monolithic install method (691a101e)
50
+
51
+
52
+ ```
53
+ (BKR-1058) Implement a simpler monolithic install method
54
+
55
+ Currently, the `do_install` method is a mega-method responsible for
56
+ installing and upgrading every version, layout, and platform of PE. It
57
+ knows how to handle masterless installs, legacy agent installs, and
58
+ extremely old versions of PE. Because of that legacy, it has some
59
+ inefficiencies and is inflexible.
60
+
61
+ Since the most common case by far is a simple monolithic or split PE
62
+ install with a set of frictionless agents, we can dramatically simplify
63
+ and therefore speed up the basic case. This commit implements a
64
+ determine_install_type method that will detect whether the task being
65
+ asked of it is one of those simple cases. The `do_install` method now
66
+ branches based on the type of install, calling
67
+ `simple_monolithic_install` for a basic monolithic + agents install, or
68
+ `generic_install` for everything else. Simple split installs are
69
+ currently detected, but not handled specially (they still fall back to
70
+ the generic install).
71
+
72
+ Doing away with some of the legacy concerns allows this method to be
73
+ much simpler and more efficient. In particular, because the method has a
74
+ defined task (mono master + agents, rather than a generic list of
75
+ hosts), it can be optimized around that task. This is accomplished now
76
+ by first installing the master, and then installing all the agents in
77
+ parallel. This method also removes an extra agent run that hasn't been
78
+ necessary since PE 3.3.
79
+
80
+ For a monolithic master with four frictionless agents, this new method
81
+ takes ~6 min 30 sec, compared to ~11 minutes before.
82
+ ```
83
+ ### <a name = "1.11.0">1.11.0 - 23 Mar, 2017 (6c3b0067)
84
+
85
+ * (HISTORY) update beaker-pe history for gem release 1.11.0 (6c3b0067)
37
86
 
38
87
  * (GEM) update beaker-pe version to 1.11.0 (bce6add6)
39
88
 
@@ -378,6 +378,122 @@ module Beaker
378
378
  # @api private
379
379
  #
380
380
  def do_install hosts, opts = {}
381
+ # detect the kind of install we're doing
382
+ install_type = determine_install_type(hosts, opts)
383
+ case install_type
384
+ when :simple_monolithic
385
+ simple_monolithic_install(hosts.first, hosts.drop(1), opts)
386
+ when :simple_split
387
+ # This isn't implemented yet, so just do a generic install instead
388
+ #simple_split_install(hosts, opts)
389
+ generic_install(hosts, opts)
390
+ else
391
+ generic_install(hosts, opts)
392
+ end
393
+ end
394
+
395
+ def has_all_roles?(host, roles)
396
+ roles.all? {|role| host['roles'].include?(role)}
397
+ end
398
+
399
+ # Determine what kind of install is being performed
400
+ # @param [Array<Host>] hosts The sorted hosts to install or upgrade PE on
401
+ # @param [Hash{Symbol=>Symbol, String}] opts The options for how to install or upgrade PE
402
+ #
403
+ # @example
404
+ # determine_install_type(hosts, {:type => :install, :pe_ver => '2017.2.0'})
405
+ #
406
+ # @return [Symbol]
407
+ # One of :generic, :simple_monolithic, :simple_split
408
+ # :simple_monolithic
409
+ # returned when installing >=2016.4 with a monolithic master and
410
+ # any number of frictionless agents
411
+ # :simple_split
412
+ # returned when installing >=2016.4 with a split install and any
413
+ # number of frictionless agents
414
+ # :generic
415
+ # returned for any other install or upgrade
416
+ #
417
+ # @api private
418
+ def determine_install_type(hosts, opts)
419
+ # Do a generic install if this is masterless, not all the same PE version, an upgrade, or earlier than 2016.4
420
+ return :generic if opts[:masterless]
421
+ return :generic if hosts.map {|host| host['pe_ver']}.uniq.length > 1
422
+ return :generic if opts[:type] == :upgrade
423
+ return :generic if version_is_less(opts[:pe_ver] || hosts.first['pe_ver'], '2016.4')
424
+
425
+ mono_roles = ['master', 'database', 'dashboard']
426
+ if has_all_roles?(hosts.first, mono_roles) && hosts.drop(1).all? {|host| host['roles'].include?('frictionless')}
427
+ :simple_monolithic
428
+ elsif hosts[0]['roles'].include?('master') && hosts[1]['roles'].include?('database') && hosts[2]['roles'].include?('dashboard') && hosts.drop(3).all? {|host| host['roles'].include?('frictionless')}
429
+ :simple_split
430
+ else
431
+ :generic
432
+ end
433
+ end
434
+
435
+ # Install PE on a monolithic master and some number of frictionless agents.
436
+ # @param [Host] master The node to install the master on
437
+ # @param [Array<Host>] agents The nodes to install agents on
438
+ # @param [Hash{Symbol=>Symbol, String}] opts The options for how to install or upgrade PE
439
+ #
440
+ # @example
441
+ # simple_monolithic_install(master, agents, {:type => :install, :pe_ver => '2017.2.0'})
442
+ #
443
+ # @return nil
444
+ #
445
+ # @api private
446
+ def simple_monolithic_install(master, agents, opts={})
447
+ step "Performing a standard monolithic install with frictionless agents"
448
+ all_hosts = [master, *agents]
449
+ configure_type_defaults_on(all_hosts)
450
+
451
+ # Set PE distribution on the master, create working dir
452
+ prepare_hosts([master], opts)
453
+ fetch_pe([master], opts)
454
+ prepare_host_installer_options(master)
455
+ generate_installer_conf_file_for(master, [master], opts)
456
+ on master, installer_cmd(master, opts)
457
+
458
+ step "Setup frictionless installer on the master" do
459
+ agents.each do |agent|
460
+ # If We're *not* running the classic installer, we want
461
+ # to make sure the master has packages for us.
462
+ if agent['platform'] != master['platform'] # only need to do this if platform differs
463
+ deploy_frictionless_to_master(agent)
464
+ end
465
+ end
466
+ end
467
+
468
+ step "Install agents" do
469
+ agents.group_by {|agent| installer_cmd(agent, opts)}.each do |cmd, agents|
470
+ on agents, cmd, :run_in_parallel => true
471
+ end
472
+ end
473
+
474
+ step "Stop puppet agents to avoid interfering with tests" do
475
+ stop_agent_on(all_hosts, :run_in_parallel => true)
476
+ end
477
+
478
+ step "Sign agent certificates" do
479
+ # This will sign all cert requests
480
+ sign_certificate_for(agents)
481
+ end
482
+
483
+ step "Run puppet to setup mcollective and pxp-agent" do
484
+ on all_hosts, puppet_agent('-t'), :acceptable_exit_codes => [0,2], :run_in_parallel => true
485
+
486
+ #Workaround for windows frictionless install, see BKR-943 for the reason
487
+ agents.select {|agent| agent['platform'] =~ /windows/}.each do |agent|
488
+ client_datadir = agent.puppet['client_datadir']
489
+ on(agent, puppet("resource file \"#{client_datadir}\" ensure=absent force=true"))
490
+ end
491
+ end
492
+ end
493
+
494
+ def generic_install hosts, opts = {}
495
+ step "Installing PE on a generic set of hosts"
496
+
381
497
  masterless = opts[:masterless]
382
498
  opts[:type] = opts[:type] || :install
383
499
  unless masterless
@@ -3,7 +3,7 @@ module Beaker
3
3
  module PE
4
4
 
5
5
  module Version
6
- STRING = '1.11.0'
6
+ STRING = '1.12.0'
7
7
  end
8
8
 
9
9
  end
@@ -878,7 +878,64 @@ describe ClassMixedWithDSLInstallUtils do
878
878
  end
879
879
  end
880
880
 
881
+ describe "#determine_install_type" do
882
+ let(:monolithic) { make_host('monolithic', :pe_ver => '2016.4', :roles => [ 'master', 'database', 'dashboard' ]) }
883
+ let(:master) { make_host('master', :pe_ver => '2016.4', :roles => [ 'master' ]) }
884
+ let(:puppetdb) { make_host('puppetdb', :pe_ver => '2016.4', :roles => [ 'database' ]) }
885
+ let(:console) { make_host('console', :pe_ver => '2016.4', :roles => [ 'dashboard' ]) }
886
+ let(:agent) { make_host('agent', :pe_ver => '2016.4', :roles => ['frictionless']) }
887
+
888
+ it 'identifies a monolithic install with frictionless agents' do
889
+ hosts = [monolithic, agent, agent, agent]
890
+ expect(subject.determine_install_type(hosts, {})).to eq(:simple_monolithic)
891
+ end
892
+
893
+ it 'identifies a monolithic install without frictionless agents' do
894
+ expect(subject.determine_install_type([monolithic], {})).to eq(:simple_monolithic)
895
+ end
896
+
897
+ it 'identifies a split install with frictionless agents' do
898
+ hosts = [master, puppetdb, console, agent, agent, agent]
899
+ expect(subject.determine_install_type(hosts, {})).to eq(:simple_split)
900
+ end
901
+
902
+ it 'identifies a split install without frictionless agents' do
903
+ hosts = [master, puppetdb, console]
904
+ expect(subject.determine_install_type(hosts, {})).to eq(:simple_split)
905
+ end
906
+
907
+ it 'identifies an install with multiple agent versions as generic' do
908
+ new_agent = make_host('agent', :pe_ver => '2017.2', :roles => ['frictionless'])
909
+ hosts = [monolithic, agent, new_agent]
910
+ expect(subject.determine_install_type(hosts, {})).to eq(:generic)
911
+ end
912
+
913
+ it 'identifies an upgrade as generic' do
914
+ hosts = [monolithic, agent, agent, agent]
915
+ expect(subject.determine_install_type(hosts, {:type => :upgrade})).to eq(:generic)
916
+ end
917
+
918
+ it 'identifies a legacy PE version as generic' do
919
+ old_monolithic = make_host('monolithic', :pe_ver => '3.8', :roles => [ 'master', 'database', 'dashboard' ])
920
+ old_agent = make_host('agent', :pe_ver => '3.8', :roles => ['frictionless'])
921
+ hosts = [old_monolithic, old_agent, old_agent, old_agent]
922
+ expect(subject.determine_install_type(hosts, {})).to eq(:generic)
923
+ end
924
+
925
+ it 'identifies a non-standard install as generic' do
926
+ hosts = [monolithic, master, agent, agent, agent]
927
+ expect(subject.determine_install_type(hosts, {})).to eq(:generic)
928
+ end
929
+ end
930
+
881
931
  describe 'do_install' do
932
+ it 'chooses to do a simple monolithic install when appropriate' do
933
+ expect(subject).to receive(:simple_monolithic_install)
934
+ allow(subject).to receive(:determine_install_type).and_return(:simple_monolithic)
935
+
936
+ subject.do_install([])
937
+ end
938
+
882
939
  it 'can perform a simple installation' do
883
940
  allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
884
941
  allow( subject ).to receive( :fetch_pe ).and_return( true )
@@ -1186,6 +1243,78 @@ describe ClassMixedWithDSLInstallUtils do
1186
1243
 
1187
1244
  end
1188
1245
 
1246
+ describe 'simple_monolithic_install' do
1247
+ let(:monolithic) { make_host('monolithic', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => [ 'master', 'database', 'dashboard' ]) }
1248
+ let(:el_agent) { make_host('agent', :pe_ver => '2016.4', :platform => 'el-7-x86_64', :roles => ['frictionless']) }
1249
+ let(:deb_agent) { make_host('agent', :pe_ver => '2016.4', :platform => 'debian-7-x86_64', :roles => ['frictionless']) }
1250
+
1251
+ before :each do
1252
+ allow(subject).to receive(:on)
1253
+ allow(subject).to receive(:configure_type_defaults_on)
1254
+ allow(subject).to receive(:prepare_hosts)
1255
+ allow(subject).to receive(:fetch_pe)
1256
+ allow(subject).to receive(:prepare_host_installer_options)
1257
+ allow(subject).to receive(:generate_installer_conf_file_for)
1258
+ allow(subject).to receive(:deploy_frictionless_to_master)
1259
+
1260
+ allow(subject).to receive(:installer_cmd).with(monolithic, anything()).and_return("install master")
1261
+ allow(subject).to receive(:installer_cmd).with(el_agent, anything()).and_return("install el agent")
1262
+ allow(subject).to receive(:installer_cmd).with(deb_agent, anything()).and_return("install deb agent")
1263
+
1264
+ allow(subject).to receive(:stop_agent_on)
1265
+ allow(subject).to receive(:sign_certificate_for)
1266
+ end
1267
+
1268
+ describe 'configuring frictionless installer' do
1269
+ it "skips the master's platform" do
1270
+ expect(subject).not_to receive(:deploy_frictionless_to_master)
1271
+
1272
+ subject.simple_monolithic_install(monolithic, [el_agent, el_agent, el_agent])
1273
+ end
1274
+
1275
+ it "adds frictionless install classes for other platforms" do
1276
+ expect(subject).to receive(:deploy_frictionless_to_master).with(deb_agent)
1277
+
1278
+ subject.simple_monolithic_install(monolithic, [el_agent, deb_agent])
1279
+ end
1280
+ end
1281
+
1282
+ it 'installs on the master then on the agents' do
1283
+ expect(subject).to receive(:on).with(monolithic, "install master").ordered
1284
+ expect(subject).to receive(:on).with([el_agent, el_agent], "install el agent", anything()).ordered
1285
+
1286
+ subject.simple_monolithic_install(monolithic, [el_agent, el_agent])
1287
+ end
1288
+
1289
+ it 'installs agents in parallel if their install command is the same' do
1290
+ expect(subject).to receive(:on).with([el_agent, el_agent], "install el agent", :run_in_parallel => true)
1291
+ expect(subject).to receive(:on).with([deb_agent, deb_agent], "install deb agent", :run_in_parallel => true)
1292
+
1293
+ subject.simple_monolithic_install(monolithic, [el_agent, el_agent, deb_agent, deb_agent])
1294
+ end
1295
+
1296
+ it 'signs all certificates at once' do
1297
+ agents = [el_agent, el_agent, deb_agent, deb_agent]
1298
+ expect(subject).to receive(:sign_certificate_for).with(agents)
1299
+
1300
+ subject.simple_monolithic_install(monolithic, agents)
1301
+ end
1302
+
1303
+ it 'stops the agents in parallel to avoid interference with tests' do
1304
+ agents = [el_agent, el_agent, deb_agent, deb_agent]
1305
+ expect(subject).to receive(:stop_agent_on).with([monolithic, *agents], :run_in_parallel => true)
1306
+
1307
+ subject.simple_monolithic_install(monolithic, agents)
1308
+ end
1309
+
1310
+ it 'runs agents in parallel, only one time' do
1311
+ agents = [el_agent, el_agent, deb_agent, deb_agent]
1312
+ expect(subject).to receive(:on).with([monolithic, *agents], proc {|cmd| cmd.command == "puppet agent"}, hash_including(:run_in_parallel => true)).once
1313
+
1314
+ subject.simple_monolithic_install(monolithic, agents)
1315
+ end
1316
+ end
1317
+
1189
1318
  describe 'do_higgs_install' do
1190
1319
 
1191
1320
  before :each do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-pe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs