puppet 7.0.0-x64-mingw32 → 7.5.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CODEOWNERS +2 -16
- data/Gemfile +2 -3
- data/Gemfile.lock +45 -33
- data/ext/build_defaults.yaml +0 -1
- data/ext/project_data.yaml +1 -0
- data/lib/puppet/application.rb +10 -6
- data/lib/puppet/application/agent.rb +1 -0
- data/lib/puppet/application/apply.rb +3 -2
- data/lib/puppet/application/device.rb +1 -0
- data/lib/puppet/application/script.rb +1 -0
- data/lib/puppet/application/ssl.rb +11 -0
- data/lib/puppet/application_support.rb +7 -0
- data/lib/puppet/configurer.rb +16 -3
- data/lib/puppet/defaults.rb +14 -41
- data/lib/puppet/environments.rb +54 -55
- data/lib/puppet/face/facts.rb +26 -2
- data/lib/puppet/face/node/clean.rb +8 -0
- data/lib/puppet/ffi/posix.rb +10 -0
- data/lib/puppet/ffi/posix/constants.rb +14 -0
- data/lib/puppet/ffi/posix/functions.rb +24 -0
- data/lib/puppet/ffi/windows/api_types.rb +1 -1
- data/lib/puppet/ffi/windows/constants.rb +1 -1
- data/lib/puppet/file_serving/configuration/parser.rb +5 -2
- data/lib/puppet/file_system/memory_file.rb +8 -1
- data/lib/puppet/file_system/windows.rb +2 -0
- data/lib/puppet/http/factory.rb +4 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -0
- data/lib/puppet/module_tool/applications/installer.rb +48 -2
- data/lib/puppet/module_tool/errors/shared.rb +17 -2
- data/lib/puppet/network/formats.rb +67 -0
- data/lib/puppet/network/http.rb +5 -2
- data/lib/puppet/network/http/api.rb +10 -6
- data/lib/puppet/network/http/api/master.rb +3 -2
- data/lib/puppet/network/http/api/master/v3.rb +2 -25
- data/lib/puppet/network/http/api/master/v3/environments.rb +2 -33
- data/lib/puppet/network/http/api/server.rb +10 -0
- data/lib/puppet/network/http/api/server/v3.rb +39 -0
- data/lib/puppet/network/http/api/server/v3/environments.rb +48 -0
- data/lib/puppet/parser/ast/leaf.rb +3 -2
- data/lib/puppet/parser/templatewrapper.rb +1 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/pops/parser/lexer2.rb +0 -4
- data/lib/puppet/pops/validation/checker4_0.rb +0 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/group/groupadd.rb +13 -8
- data/lib/puppet/provider/package/apt.rb +34 -2
- data/lib/puppet/provider/package/aptitude.rb +6 -0
- data/lib/puppet/provider/service/debian.rb +2 -0
- data/lib/puppet/provider/user/aix.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +62 -8
- data/lib/puppet/reference/configuration.rb +6 -5
- data/lib/puppet/settings.rb +33 -28
- data/lib/puppet/settings/alias_setting.rb +37 -0
- data/lib/puppet/settings/environment_conf.rb +1 -0
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/type/user.rb +1 -1
- data/lib/puppet/util/autoload.rb +1 -8
- data/lib/puppet/util/monkey_patches.rb +7 -0
- data/lib/puppet/util/posix.rb +54 -5
- data/lib/puppet/util/windows/adsi.rb +46 -0
- data/lib/puppet/util/windows/principal.rb +9 -2
- data/lib/puppet/util/windows/sid.rb +4 -2
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +166 -146
- data/man/man5/puppet.conf.5 +14 -6
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +2 -2
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +8 -2
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +2 -2
- data/man/man8/puppet-ssl.8 +5 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
- data/spec/integration/application/agent_spec.rb +160 -3
- data/spec/integration/application/apply_spec.rb +19 -0
- data/spec/integration/application/plugin_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +0 -7
- data/spec/integration/http/client_spec.rb +12 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
- data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
- data/spec/integration/parser/collection_spec.rb +10 -0
- data/spec/integration/resource/type_collection_spec.rb +2 -6
- data/spec/integration/transaction_spec.rb +4 -9
- data/spec/integration/util/windows/adsi_spec.rb +21 -1
- data/spec/integration/util/windows/principal_spec.rb +21 -0
- data/spec/integration/util/windows/registry_spec.rb +6 -10
- data/spec/spec_helper.rb +1 -4
- data/spec/unit/agent_spec.rb +8 -6
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/facts_spec.rb +58 -7
- data/spec/unit/application/filebucket_spec.rb +0 -2
- data/spec/unit/application/ssl_spec.rb +23 -0
- data/spec/unit/application_spec.rb +51 -9
- data/spec/unit/confine/feature_spec.rb +1 -1
- data/spec/unit/confine_spec.rb +8 -2
- data/spec/unit/defaults_spec.rb +1 -56
- data/spec/unit/environments_spec.rb +221 -68
- data/spec/unit/face/node_spec.rb +14 -13
- data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
- data/spec/unit/file_serving/metadata_spec.rb +3 -3
- data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
- data/spec/unit/file_system_spec.rb +9 -0
- data/spec/unit/forge/module_release_spec.rb +2 -7
- data/spec/unit/http/factory_spec.rb +19 -0
- data/spec/unit/indirector/face_spec.rb +0 -1
- data/spec/unit/indirector/facts/facter_spec.rb +20 -5
- data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
- data/spec/unit/indirector/indirection_spec.rb +8 -12
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
- data/spec/unit/network/formats_spec.rb +41 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
- data/spec/unit/network/http/api/master_spec.rb +38 -0
- data/spec/unit/network/http/api/{master → server}/v3/environments_spec.rb +2 -2
- data/spec/unit/network/http/api/{master → server}/v3_spec.rb +19 -19
- data/spec/unit/network/http/api_spec.rb +11 -11
- data/spec/unit/parser/compiler_spec.rb +3 -19
- data/spec/unit/parser/resource_spec.rb +14 -8
- data/spec/unit/parser/templatewrapper_spec.rb +4 -3
- data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +0 -4
- data/spec/unit/pops/validator/validator_spec.rb +20 -43
- data/spec/unit/property_spec.rb +1 -0
- data/spec/unit/provider/group/groupadd_spec.rb +5 -2
- data/spec/unit/provider/nameservice_spec.rb +66 -65
- data/spec/unit/provider/package/apt_spec.rb +28 -23
- data/spec/unit/provider/package/aptitude_spec.rb +1 -1
- data/spec/unit/provider/package/base_spec.rb +6 -5
- data/spec/unit/provider/package/pacman_spec.rb +18 -12
- data/spec/unit/provider/package/pip_spec.rb +6 -11
- data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
- data/spec/unit/provider/user/aix_spec.rb +5 -0
- data/spec/unit/provider/user/hpux_spec.rb +1 -1
- data/spec/unit/provider/user/pw_spec.rb +2 -0
- data/spec/unit/provider/user/useradd_spec.rb +56 -3
- data/spec/unit/provider_spec.rb +6 -8
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +11 -10
- data/spec/unit/settings_spec.rb +13 -6
- data/spec/unit/ssl/base_spec.rb +0 -1
- data/spec/unit/ssl/certificate_request_spec.rb +4 -10
- data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
- data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
- data/spec/unit/transaction/event_manager_spec.rb +14 -11
- data/spec/unit/transaction_spec.rb +13 -4
- data/spec/unit/type/file/content_spec.rb +0 -1
- data/spec/unit/type/file/selinux_spec.rb +0 -2
- data/spec/unit/type/file_spec.rb +0 -6
- data/spec/unit/type/group_spec.rb +13 -6
- data/spec/unit/type/resources_spec.rb +7 -7
- data/spec/unit/type/service_spec.rb +1 -1
- data/spec/unit/type/tidy_spec.rb +0 -1
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/at_fork_spec.rb +2 -2
- data/spec/unit/util/autoload_spec.rb +5 -1
- data/spec/unit/util/backups_spec.rb +1 -2
- data/spec/unit/util/execution_spec.rb +15 -11
- data/spec/unit/util/inifile_spec.rb +6 -14
- data/spec/unit/util/log_spec.rb +8 -7
- data/spec/unit/util/logging_spec.rb +3 -3
- data/spec/unit/util/posix_spec.rb +363 -15
- data/spec/unit/util/selinux_spec.rb +76 -52
- data/spec/unit/util/storage_spec.rb +3 -1
- data/spec/unit/util/suidmanager_spec.rb +44 -41
- data/spec/unit/util/windows/sid_spec.rb +6 -0
- data/spec/unit/util_spec.rb +13 -6
- metadata +33 -16
- data/spec/lib/matchers/include.rb +0 -27
- data/spec/lib/matchers/include_spec.rb +0 -32
- data/spec/unit/pops/parser/parse_application_spec.rb +0 -13
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +0 -23
- data/spec/unit/pops/parser/parse_site_spec.rb +0 -43
@@ -1,13 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet/environments'
|
3
3
|
require 'puppet/file_system'
|
4
|
-
require 'matchers/include'
|
5
|
-
require 'matchers/include_in_order'
|
6
4
|
|
7
|
-
module PuppetEnvironments
|
8
5
|
describe Puppet::Environments do
|
9
|
-
include Matchers::Include
|
10
|
-
|
11
6
|
FS = Puppet::FileSystem
|
12
7
|
|
13
8
|
before(:each) do
|
@@ -49,7 +44,7 @@ describe Puppet::Environments do
|
|
49
44
|
loader_from(:filesystem => [directory_tree, global_path_1, global_path_2],
|
50
45
|
:directory => directory_tree.children.first,
|
51
46
|
:modulepath => [global_path_1_location, global_path_2_location]) do |loader|
|
52
|
-
expect(loader.list).to
|
47
|
+
expect(loader.list).to contain_exactly(
|
53
48
|
environment(:an_environment).
|
54
49
|
with_manifest("#{FS.path_string(directory_tree)}/envdir/an_environment/manifests").
|
55
50
|
with_modulepath(["#{FS.path_string(directory_tree)}/envdir/an_environment/modules",
|
@@ -87,7 +82,7 @@ describe Puppet::Environments do
|
|
87
82
|
|
88
83
|
loader_from(:filesystem => [envdir],
|
89
84
|
:directory => envdir) do |loader|
|
90
|
-
expect(loader.list).to
|
85
|
+
expect(loader.list).to contain_exactly(environment(:env1), environment(:env2))
|
91
86
|
end
|
92
87
|
end
|
93
88
|
|
@@ -406,33 +401,29 @@ config_version=$vardir/random/scripts
|
|
406
401
|
]),
|
407
402
|
])
|
408
403
|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
EOF
|
422
|
-
]),
|
423
|
-
])
|
404
|
+
cached_loader_from(:filesystem => [original_envdir], :directory => original_envdir) do |loader|
|
405
|
+
original_env = loader.get("env3") # force the environment.conf to be read
|
406
|
+
|
407
|
+
changed_envdir = FS::MemoryFile.a_directory(base_dir, [
|
408
|
+
FS::MemoryFile.a_directory("env3", [
|
409
|
+
FS::MemoryFile.a_regular_file_containing("environment.conf", <<-EOF)
|
410
|
+
manifest=/manifest_changed
|
411
|
+
modulepath=/modules_changed
|
412
|
+
environment_timeout=0
|
413
|
+
EOF
|
414
|
+
]),
|
415
|
+
])
|
424
416
|
|
425
|
-
|
426
|
-
|
417
|
+
FS.overlay(changed_envdir) do
|
418
|
+
changed_env = loader.get("env3")
|
427
419
|
|
428
|
-
|
429
|
-
|
430
|
-
|
420
|
+
expect(original_env).to environment(:env3).
|
421
|
+
with_manifest(File.expand_path("/manifest_orig")).
|
422
|
+
with_full_modulepath([File.expand_path("/modules_orig")])
|
431
423
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
end
|
424
|
+
expect(changed_env).to environment(:env3).
|
425
|
+
with_manifest(File.expand_path("/manifest_changed")).
|
426
|
+
with_full_modulepath([File.expand_path("/modules_changed")])
|
436
427
|
end
|
437
428
|
end
|
438
429
|
end
|
@@ -558,24 +549,49 @@ config_version=$vardir/random/scripts
|
|
558
549
|
|
559
550
|
describe "cached loaders" do
|
560
551
|
it "lists environments" do
|
561
|
-
|
562
|
-
expect(
|
552
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
553
|
+
expect(loader.list).to contain_exactly(
|
563
554
|
environment(:an_environment),
|
564
555
|
environment(:another_environment),
|
565
556
|
environment(:symlinked_environment))
|
566
557
|
end
|
567
558
|
end
|
568
559
|
|
560
|
+
it "returns the same cached environment object for list and get methods" do
|
561
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
562
|
+
env = loader.list.find { |e| e.name == :an_environment }
|
563
|
+
|
564
|
+
expect(env).to equal(loader.get(:an_environment)) # same object
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
it "returns the same cached environment object for multiple list calls" do
|
569
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
570
|
+
expect(loader.list.first).to equal(loader.list.first) # same object
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
it "expires environments and returns a new environment object with the same value" do
|
575
|
+
Puppet[:environment_timeout] = "0"
|
576
|
+
|
577
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
578
|
+
a = loader.list.first
|
579
|
+
b = loader.list.first
|
580
|
+
expect(a).to eq(b) # same value
|
581
|
+
expect(a).to_not equal(b) # not same object
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
569
585
|
it "has search_paths" do
|
570
|
-
|
571
|
-
expect(
|
586
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
587
|
+
expect(loader.search_paths).to eq(["file://#{directory_tree.children.first}"])
|
572
588
|
end
|
573
589
|
end
|
574
590
|
|
575
591
|
context "#get" do
|
576
592
|
it "gets an environment" do
|
577
|
-
|
578
|
-
expect(
|
593
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
594
|
+
expect(loader.get(:an_environment)).to environment(:an_environment)
|
579
595
|
end
|
580
596
|
end
|
581
597
|
|
@@ -592,16 +608,16 @@ config_version=$vardir/random/scripts
|
|
592
608
|
end
|
593
609
|
|
594
610
|
it "returns nil if env not found" do
|
595
|
-
|
596
|
-
expect(
|
611
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
612
|
+
expect(loader.get(:doesnotexist)).to be_nil
|
597
613
|
end
|
598
614
|
end
|
599
615
|
end
|
600
616
|
|
601
617
|
context "#get!" do
|
602
618
|
it "gets an environment" do
|
603
|
-
|
604
|
-
expect(
|
619
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
620
|
+
expect(loader.get!(:an_environment)).to environment(:an_environment)
|
605
621
|
end
|
606
622
|
end
|
607
623
|
|
@@ -618,29 +634,43 @@ config_version=$vardir/random/scripts
|
|
618
634
|
end
|
619
635
|
|
620
636
|
it "raises error if environment is not found" do
|
621
|
-
|
637
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
622
638
|
expect do
|
623
|
-
|
639
|
+
loader.get!(:doesnotexist)
|
624
640
|
end.to raise_error(Puppet::Environments::EnvironmentNotFound)
|
625
641
|
end
|
626
642
|
end
|
627
643
|
end
|
628
644
|
|
629
|
-
context "
|
630
|
-
|
645
|
+
context "#get_conf" do
|
646
|
+
it "loads environment.conf" do
|
647
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
648
|
+
expect(loader.get_conf(:an_environment)).to match_environment_conf(:an_environment).
|
649
|
+
with_env_path(directory_tree.children.first).
|
650
|
+
with_global_module_path([])
|
651
|
+
end
|
652
|
+
end
|
631
653
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
using_expiration_service(service) do
|
637
|
-
cached = Puppet::Environments::Cached.new(loader)
|
638
|
-
cached.get!(:an_environment)
|
654
|
+
it "always reloads environment.conf" do
|
655
|
+
env = Puppet::Node::Environment.create(:cached, [])
|
656
|
+
mocked_loader = double('loader')
|
657
|
+
expect(mocked_loader).to receive(:get_conf).with(:cached).and_return(Puppet::Settings::EnvironmentConf.static_for(env, 20)).twice
|
639
658
|
|
640
|
-
|
641
|
-
|
659
|
+
cached = Puppet::Environments::Cached.new(mocked_loader)
|
660
|
+
|
661
|
+
cached.get_conf(:cached)
|
662
|
+
cached.get_conf(:cached)
|
663
|
+
end
|
664
|
+
|
665
|
+
it "returns nil if environment is not found" do
|
666
|
+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
667
|
+
expect(loader.get_conf(:doesnotexist)).to be_nil
|
642
668
|
end
|
643
669
|
end
|
670
|
+
end
|
671
|
+
|
672
|
+
context "expiration policies" do
|
673
|
+
let(:service) { ReplayExpirationService.new }
|
644
674
|
|
645
675
|
it "notifies when the environment is first created" do
|
646
676
|
with_environment_loaded(service)
|
@@ -660,12 +690,7 @@ config_version=$vardir/random/scripts
|
|
660
690
|
end
|
661
691
|
|
662
692
|
it "evicts an expired environment" do
|
663
|
-
service
|
664
|
-
|
665
|
-
# The `Cached#clear_all_expired` method tries to optimize the case where
|
666
|
-
# no entries are expired. But if `Time.now < @next_expiration` and there is
|
667
|
-
# an expired entry, then the `service#expired?` method is called twice.
|
668
|
-
expect(service).to receive(:expired?).twice.and_return(true)
|
693
|
+
expect(service).to receive(:expired?).and_return(true)
|
669
694
|
|
670
695
|
with_environment_loaded(service) do |cached|
|
671
696
|
cached.get!(:an_environment)
|
@@ -706,8 +731,7 @@ config_version=$vardir/random/scripts
|
|
706
731
|
it "evicts a recently touched environment" do
|
707
732
|
Puppet[:environment_timeout] = 60
|
708
733
|
|
709
|
-
|
710
|
-
expect(service).to receive(:expired?).twice.and_return(true)
|
734
|
+
expect(service).to receive(:expired?).and_return(true)
|
711
735
|
|
712
736
|
with_environment_loaded(service) do |cached|
|
713
737
|
# even though the environment was recently touched, it's been expired
|
@@ -717,13 +741,116 @@ config_version=$vardir/random/scripts
|
|
717
741
|
expect(service.created_envs).to eq([:an_environment, :an_environment])
|
718
742
|
expect(service.evicted_envs).to eq([:an_environment])
|
719
743
|
end
|
744
|
+
|
745
|
+
it "evicts expired environments when listing" do
|
746
|
+
expect(service).to receive(:expired?).with(:an_environment).and_return(true)
|
747
|
+
|
748
|
+
with_environment_loaded(service) do |cached|
|
749
|
+
cached.list
|
750
|
+
end
|
751
|
+
|
752
|
+
expect(service.evicted_envs).to eq([:an_environment])
|
753
|
+
end
|
720
754
|
end
|
721
755
|
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
756
|
+
context '#clear' do
|
757
|
+
let(:service) { ReplayExpirationService.new }
|
758
|
+
|
759
|
+
it "evicts an environment" do
|
760
|
+
with_environment_loaded(service) do |cached|
|
761
|
+
cached.clear(:an_environment)
|
762
|
+
end
|
763
|
+
|
764
|
+
expect(service.evicted_envs).to eq([:an_environment])
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
context '#clear_all' do
|
769
|
+
let(:service) { ReplayExpirationService.new }
|
770
|
+
let(:envdir) { File.expand_path("envdir") }
|
771
|
+
let(:default_dir) { File.join(envdir, "cached_env", "modules") }
|
772
|
+
let(:expected_dir) { File.join(envdir, "cached_env", "site") }
|
773
|
+
|
774
|
+
let(:base_dir) do
|
775
|
+
FS::MemoryFile.a_directory(envdir, [
|
776
|
+
FS::MemoryFile.a_directory("cached_env", [
|
777
|
+
FS::MemoryFile.a_missing_file("environment.conf")
|
778
|
+
])
|
779
|
+
])
|
780
|
+
end
|
781
|
+
|
782
|
+
let(:updated_dir) do
|
783
|
+
FS::MemoryFile.a_directory(envdir, [
|
784
|
+
FS::MemoryFile.a_directory("cached_env", [
|
785
|
+
FS::MemoryFile.a_directory("site"),
|
786
|
+
FS::MemoryFile.a_missing_directory("modules"),
|
787
|
+
FS::MemoryFile.a_regular_file_containing("environment.conf", <<-EOF)
|
788
|
+
modulepath=site
|
789
|
+
environment_timeout=unlimited
|
790
|
+
EOF
|
791
|
+
])
|
792
|
+
])
|
793
|
+
end
|
794
|
+
|
795
|
+
it 'evicts all environments' do
|
796
|
+
with_environment_loaded(service) do |cached|
|
797
|
+
cached.get(:an_environment)
|
798
|
+
cached.get(:another_environment)
|
799
|
+
cached.clear_all
|
800
|
+
|
801
|
+
expect(service.evicted_envs).to match([:an_environment, :another_environment])
|
802
|
+
end
|
803
|
+
end
|
804
|
+
|
805
|
+
it "recomputes modulepath if 'get' is called before 'clear_all'" do
|
806
|
+
cached_loader_from(:filesystem => [base_dir], :directory => base_dir) do |loader|
|
807
|
+
loader.get(:cached_env)
|
808
|
+
|
809
|
+
expect(Puppet.settings.value(:modulepath, :cached_env)).to eq(default_dir)
|
810
|
+
|
811
|
+
FS.overlay(updated_dir) do
|
812
|
+
loader.clear_all
|
813
|
+
|
814
|
+
expect(loader.get(:cached_env).modulepath).to contain_exactly(expected_dir)
|
815
|
+
end
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
819
|
+
it "recomputes modulepath if 'list' is called before 'clear_all'" do
|
820
|
+
cached_loader_from(:filesystem => [base_dir], :directory => base_dir) do |loader|
|
821
|
+
loader.list
|
822
|
+
|
823
|
+
expect(Puppet.settings.value(:modulepath, :cached_env)).to eq(default_dir)
|
824
|
+
|
825
|
+
FS.overlay(updated_dir) do
|
826
|
+
loader.clear_all
|
827
|
+
|
828
|
+
expect(loader.get(:cached_env).modulepath).to contain_exactly(expected_dir)
|
829
|
+
end
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
833
|
+
it "recomputes modulepath if 'get_conf' is called before 'clear_all'" do
|
834
|
+
cached_loader_from(:filesystem => [base_dir], :directory => base_dir) do |loader|
|
835
|
+
loader.get_conf(:cached_env)
|
836
|
+
|
837
|
+
expect(Puppet.settings.value(:modulepath, :cached_env)).to eq(default_dir)
|
838
|
+
|
839
|
+
FS.overlay(updated_dir) do
|
840
|
+
loader.clear_all
|
841
|
+
|
842
|
+
expect(loader.get(:cached_env).modulepath).to contain_exactly(expected_dir)
|
843
|
+
end
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
847
|
+
it 'deletes environment text domains' do
|
848
|
+
with_environment_loaded(service) do |cached|
|
849
|
+
cached.get(:an_environment)
|
850
|
+
cached.clear_all
|
851
|
+
|
852
|
+
expect(FastGettext.text_domain).to eq(Puppet::GettextConfig::DEFAULT_TEXT_DOMAIN)
|
853
|
+
end
|
727
854
|
end
|
728
855
|
end
|
729
856
|
end
|
@@ -798,6 +925,20 @@ config_version=$vardir/random/scripts
|
|
798
925
|
end
|
799
926
|
end
|
800
927
|
|
928
|
+
def cached_loader_from(options, &block)
|
929
|
+
FS.overlay(*options[:filesystem]) do
|
930
|
+
environments = Puppet::Environments::Cached.new(
|
931
|
+
Puppet::Environments::Directories.new(
|
932
|
+
options[:directory],
|
933
|
+
options[:modulepath] || []
|
934
|
+
)
|
935
|
+
)
|
936
|
+
Puppet.override(:environments => environments) do
|
937
|
+
yield environments
|
938
|
+
end
|
939
|
+
end
|
940
|
+
end
|
941
|
+
|
801
942
|
def loader_from(options, &block)
|
802
943
|
FS.overlay(*options[:filesystem]) do
|
803
944
|
environments = Puppet::Environments::Directories.new(
|
@@ -820,6 +961,19 @@ config_version=$vardir/random/scripts
|
|
820
961
|
end
|
821
962
|
end
|
822
963
|
|
964
|
+
# The environment named `:an_environment` will already be loaded when the
|
965
|
+
# block is yielded to
|
966
|
+
def with_environment_loaded(service, &block)
|
967
|
+
loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
|
968
|
+
using_expiration_service(service) do
|
969
|
+
cached = Puppet::Environments::Cached.new(loader)
|
970
|
+
cached.get!(:an_environment)
|
971
|
+
|
972
|
+
yield cached if block_given?
|
973
|
+
end
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
823
977
|
class ReplayExpirationService < Puppet::Environments::Cached::DefaultCacheExpirationService
|
824
978
|
attr_reader :created_envs, :evicted_envs
|
825
979
|
|
@@ -837,4 +991,3 @@ config_version=$vardir/random/scripts
|
|
837
991
|
end
|
838
992
|
end
|
839
993
|
end
|
840
|
-
end
|
data/spec/unit/face/node_spec.rb
CHANGED
@@ -15,13 +15,6 @@ describe Puppet::Face[:node, '0.0.1'] do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'when running #clean' do
|
18
|
-
before :each do
|
19
|
-
allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
|
20
|
-
allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
|
21
|
-
allow(Puppet::Node).to receive(:terminus_class=)
|
22
|
-
allow(Puppet::Node).to receive(:cache_class=)
|
23
|
-
end
|
24
|
-
|
25
18
|
it 'should invoke #cleanup' do
|
26
19
|
expect(subject).to receive(:cleanup).with('hostname')
|
27
20
|
subject.clean('hostname')
|
@@ -30,10 +23,6 @@ describe Puppet::Face[:node, '0.0.1'] do
|
|
30
23
|
|
31
24
|
describe "clean action" do
|
32
25
|
before :each do
|
33
|
-
allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
|
34
|
-
allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
|
35
|
-
allow(Puppet::Node).to receive(:terminus_class=)
|
36
|
-
allow(Puppet::Node).to receive(:cache_class=)
|
37
26
|
allow(subject).to receive(:cleanup)
|
38
27
|
end
|
39
28
|
|
@@ -89,8 +78,20 @@ describe Puppet::Face[:node, '0.0.1'] do
|
|
89
78
|
|
90
79
|
describe "when cleaning certificate", :if => Puppet.features.puppetserver_ca? do
|
91
80
|
it "should call the CA CLI gem's clean action" do
|
92
|
-
expect_any_instance_of(Puppetserver::Ca::Action::Clean).
|
93
|
-
|
81
|
+
expect_any_instance_of(Puppetserver::Ca::Action::Clean).
|
82
|
+
to receive(:clean_certs).
|
83
|
+
with(['hostname'], anything).
|
84
|
+
and_return(:success)
|
85
|
+
|
86
|
+
if Puppet[:cadir].start_with?(Puppet[:ssldir])
|
87
|
+
expect_any_instance_of(LoggerIO).
|
88
|
+
to receive(:warn).
|
89
|
+
with(/cadir is currently configured to be inside/)
|
90
|
+
end
|
91
|
+
|
92
|
+
expect(Puppet).not_to receive(:warning)
|
93
|
+
result = subject.clean_cert('hostname')
|
94
|
+
expect(result).to eq(0)
|
94
95
|
end
|
95
96
|
|
96
97
|
it "should not call the CA CLI gem's clean action if the gem is missing" do
|