puppet 3.0.2 → 3.1.0.rc1
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.
- data/Gemfile +13 -11
- data/README.md +9 -7
- data/README_DEVELOPER.md +21 -30
- data/bin/extlookup2hiera +0 -0
- data/conf/auth.conf +42 -26
- data/conf/fileserver.conf +41 -0
- data/conf/tagmail.conf +16 -0
- data/examples/hiera/modules/data/manifests/common.pp +2 -1
- data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
- data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
- data/examples/hiera/modules/users/manifests/common.pp +2 -1
- data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
- data/examples/hiera/modules/users/manifests/development.pp +2 -1
- data/examples/hiera/site.pp +1 -1
- data/ext/debian/fileserver.conf +39 -15
- data/ext/envpuppet +2 -0
- data/ext/gentoo/puppet/fileserver.conf +41 -12
- data/ext/ips/puppet-agent +1 -6
- data/ext/ips/puppetagent.xml +0 -4
- data/ext/osx/postflight.erb +109 -0
- data/ext/project_data.yaml +2 -2
- data/ext/redhat/fileserver.conf +41 -12
- data/ext/redhat/puppet.spec.erb +8 -13
- data/install.rb +2 -5
- data/lib/puppet.rb +30 -13
- data/lib/puppet/application.rb +34 -16
- data/lib/puppet/application/agent.rb +4 -4
- data/lib/puppet/application/master.rb +25 -5
- data/lib/puppet/defaults.rb +11 -7
- data/lib/puppet/dsl.rb +7 -3
- data/lib/puppet/dsl/actions.rb +283 -0
- data/lib/puppet/dsl/blank_slate.rb +55 -0
- data/lib/puppet/dsl/context.rb +393 -0
- data/lib/puppet/dsl/parser.rb +57 -0
- data/lib/puppet/dsl/resource_decorator.rb +56 -0
- data/lib/puppet/dsl/resource_reference.rb +95 -0
- data/lib/puppet/dsl/type_reference.rb +102 -0
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/face/help.rb +2 -4
- data/lib/puppet/face/man.rb +8 -2
- data/lib/puppet/feature/pson.rb +1 -3
- data/lib/puppet/indirector/catalog/active_record.rb +3 -0
- data/lib/puppet/indirector/catalog/compiler.rb +1 -2
- data/lib/puppet/indirector/catalog/queue.rb +4 -0
- data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
- data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_status/file.rb +4 -0
- data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
- data/lib/puppet/indirector/facts/active_record.rb +3 -0
- data/lib/puppet/indirector/facts/couch.rb +3 -0
- data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
- data/lib/puppet/indirector/facts/store_configs.rb +3 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
- data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
- data/lib/puppet/indirector/node/active_record.rb +3 -0
- data/lib/puppet/indirector/node/rest.rb +2 -2
- data/lib/puppet/indirector/node/store_configs.rb +3 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
- data/lib/puppet/indirector/queue.rb +0 -1
- data/lib/puppet/indirector/request.rb +1 -2
- data/lib/puppet/indirector/resource/active_record.rb +4 -0
- data/lib/puppet/indirector/resource/ral.rb +3 -0
- data/lib/puppet/indirector/resource/rest.rb +3 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/run/local.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +16 -14
- data/lib/puppet/indirector/status/local.rb +3 -0
- data/lib/puppet/indirector/status/rest.rb +4 -0
- data/lib/puppet/interface.rb +78 -3
- data/lib/puppet/interface/action.rb +39 -3
- data/lib/puppet/interface/action_builder.rb +74 -1
- data/lib/puppet/interface/action_manager.rb +33 -3
- data/lib/puppet/interface/documentation.rb +116 -5
- data/lib/puppet/interface/face_collection.rb +6 -7
- data/lib/puppet/interface/option.rb +10 -1
- data/lib/puppet/interface/option_builder.rb +29 -1
- data/lib/puppet/interface/option_manager.rb +21 -6
- data/lib/puppet/metatype/manager.rb +47 -9
- data/lib/puppet/module_tool.rb +0 -1
- data/lib/puppet/network/formats.rb +0 -2
- data/lib/puppet/node.rb +2 -3
- data/lib/puppet/node/environment.rb +14 -1
- data/lib/puppet/parameter.rb +309 -44
- data/lib/puppet/parameter/package_options.rb +5 -0
- data/lib/puppet/parameter/path.rb +26 -3
- data/lib/puppet/parameter/value.rb +30 -6
- data/lib/puppet/parameter/value_collection.rb +82 -20
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/parser/ast/definition.rb +2 -5
- data/lib/puppet/parser/ast/hostclass.rb +2 -3
- data/lib/puppet/parser/ast/node.rb +2 -5
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +10 -0
- data/lib/puppet/parser/functions.rb +111 -7
- data/lib/puppet/parser/functions/create_resources.rb +23 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +2 -1
- data/lib/puppet/parser/functions/fail.rb +1 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/functions/hiera.rb +1 -1
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/md5.rb +1 -1
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +54 -57
- data/lib/puppet/parser/functions/require.rb +1 -0
- data/lib/puppet/parser/functions/search.rb +1 -1
- data/lib/puppet/parser/functions/sha1.rb +1 -1
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +7 -10
- data/lib/puppet/parser/functions/tag.rb +1 -1
- data/lib/puppet/parser/functions/tagged.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +1 -1
- data/lib/puppet/parser/functions/versioncmp.rb +1 -5
- data/lib/puppet/parser/parser_support.rb +11 -27
- data/lib/puppet/parser/scope.rb +48 -4
- data/lib/puppet/parser/type_loader.rb +31 -7
- data/lib/puppet/property.rb +304 -70
- data/lib/puppet/property/ensure.rb +14 -1
- data/lib/puppet/property/keyvalue.rb +17 -8
- data/lib/puppet/property/list.rb +3 -0
- data/lib/puppet/property/ordered_list.rb +7 -0
- data/lib/puppet/provider.rb +275 -53
- data/lib/puppet/provider/augeas/augeas.rb +17 -3
- data/lib/puppet/provider/confiner.rb +30 -1
- data/lib/puppet/provider/group/pw.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkgin.rb +2 -0
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +10 -6
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/service.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +2 -3
- data/lib/puppet/reference/configuration.rb +6 -0
- data/lib/puppet/reports.rb +44 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +38 -25
- data/lib/puppet/resource/type.rb +14 -6
- data/lib/puppet/settings.rb +66 -142
- data/lib/puppet/settings/config_file.rb +99 -0
- data/lib/puppet/settings/file_setting.rb +92 -24
- data/lib/puppet/settings/value_translator.rb +15 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/test/test_helper.rb +8 -3
- data/lib/puppet/transaction.rb +1 -2
- data/lib/puppet/transaction/report.rb +122 -13
- data/lib/puppet/type.rb +763 -150
- data/lib/puppet/type/augeas.rb +4 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/group.rb +1 -1
- data/lib/puppet/type/file/mode.rb +2 -0
- data/lib/puppet/type/file/selcontext.rb +1 -0
- data/lib/puppet/type/group.rb +12 -0
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/router.rb +1 -1
- data/lib/puppet/type/service.rb +1 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type/user.rb +8 -1
- data/lib/puppet/util.rb +8 -0
- data/lib/puppet/util/autoload.rb +7 -10
- data/lib/puppet/util/classgen.rb +58 -33
- data/lib/puppet/util/command_line.rb +120 -77
- data/lib/puppet/util/constant_inflector.rb +2 -0
- data/lib/puppet/util/execution.rb +63 -33
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
- data/lib/puppet/util/methodhelper.rb +19 -0
- data/lib/puppet/util/monkey_patches.rb +46 -0
- data/lib/puppet/util/plugins.rb +2 -2
- data/lib/puppet/util/provider_features.rb +24 -8
- data/lib/puppet/util/rubygems.rb +8 -1
- data/lib/puppet/util/zaml.rb +1 -1
- data/lib/puppet/version.rb +74 -3
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/dsl/classes_spec.rb +191 -0
- data/spec/integration/dsl/defaults_spec.rb +38 -0
- data/spec/integration/dsl/definitions_spec.rb +73 -0
- data/spec/integration/dsl/functions_spec.rb +95 -0
- data/spec/integration/dsl/nodes_spec.rb +96 -0
- data/spec/integration/dsl/params_spec.rb +146 -0
- data/spec/integration/dsl/relationships_spec.rb +46 -0
- data/spec/integration/dsl/resources_spec.rb +202 -0
- data/spec/integration/dsl/type_loading_spec.rb +64 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/network/formats_spec.rb +32 -45
- data/spec/integration/parser/collector_spec.rb +105 -25
- data/spec/integration/parser/scope_spec.rb +64 -1
- data/spec/integration/resource/catalog_spec.rb +2 -4
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/matchers/catalog.rb +50 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -0
- data/spec/lib/puppet_spec/dsl.rb +29 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +11 -4
- data/spec/unit/application/indirection_base_spec.rb +4 -8
- data/spec/unit/application/kick_spec.rb +5 -2
- data/spec/unit/application/master_spec.rb +0 -6
- data/spec/unit/application_spec.rb +38 -14
- data/spec/unit/dsl/actions_spec.rb +402 -0
- data/spec/unit/dsl/blank_slate_spec.rb +27 -0
- data/spec/unit/dsl/context_spec.rb +678 -0
- data/spec/unit/dsl/parser_spec.rb +56 -0
- data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
- data/spec/unit/dsl/resource_reference_spec.rb +150 -0
- data/spec/unit/dsl/type_reference_spec.rb +164 -0
- data/spec/unit/face/help_spec.rb +5 -7
- data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
- data/spec/unit/indirector/hiera_spec.rb +3 -1
- data/spec/unit/indirector/queue_spec.rb +1 -7
- data/spec/unit/indirector/ssl_file_spec.rb +66 -39
- data/spec/unit/module_spec.rb +1 -1
- data/spec/unit/network/authstore_spec.rb +22 -1
- data/spec/unit/network/formats_spec.rb +1 -1
- data/spec/unit/node/environment_spec.rb +13 -0
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +26 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
- data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +4 -4
- data/spec/unit/parser/functions/split_spec.rb +4 -4
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
- data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
- data/spec/unit/parser/functions_spec.rb +51 -1
- data/spec/unit/parser/parser_spec.rb +0 -14
- data/spec/unit/parser/type_loader_spec.rb +15 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
- data/spec/unit/provider/package/apt_spec.rb +0 -2
- data/spec/unit/provider/package/pip_spec.rb +12 -2
- data/spec/unit/provider/service/freebsd_spec.rb +8 -0
- data/spec/unit/provider/service/gentoo_spec.rb +20 -20
- data/spec/unit/provider/service/openrc_spec.rb +20 -20
- data/spec/unit/provider/service/src_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_spec.rb +0 -8
- data/spec/unit/provider/service/windows_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +2 -9
- data/spec/unit/relationship_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource/type_spec.rb +49 -25
- data/spec/unit/resource_spec.rb +34 -2
- data/spec/unit/settings/config_file_spec.rb +100 -0
- data/spec/unit/settings/file_setting_spec.rb +87 -84
- data/spec/unit/settings/value_translator_spec.rb +77 -0
- data/spec/unit/settings_spec.rb +96 -29
- data/spec/unit/type/file/ensure_spec.rb +75 -36
- data/spec/unit/type/file_spec.rb +0 -68
- data/spec/unit/type/group_spec.rb +10 -0
- data/spec/unit/util/autoload_spec.rb +6 -0
- data/spec/unit/util/command_line_spec.rb +54 -62
- data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
- data/spec/unit/util/metric_spec.rb +0 -9
- data/spec/unit/util/posix_spec.rb +0 -4
- data/spec/unit/util/rdoc_spec.rb +0 -12
- data/spec/unit/util/zaml_spec.rb +188 -130
- data/spec/unit/version_spec.rb +42 -0
- metadata +123 -90
- data/README_HIERA.md +0 -148
- data/conf/epm.list +0 -8
- data/conf/namespaceauth.conf +0 -20
- data/conf/puppet-queue.conf +0 -10
- data/examples/allatonce +0 -13
- data/examples/assignments +0 -11
- data/examples/components +0 -73
- data/examples/etc/init.d/sleeper +0 -70
- data/examples/etc/otherfile +0 -0
- data/examples/etc/puppet/fileserver.conf +0 -13
- data/examples/etc/puppet/namespaceauth.conf +0 -20
- data/examples/etc/puppet/puppet.conf +0 -10
- data/examples/etc/puppet/tagmail.conf +0 -1
- data/examples/execs +0 -16
- data/examples/file.bl +0 -11
- data/examples/filedefaults +0 -10
- data/examples/fileparsing +0 -116
- data/examples/filerecursion +0 -15
- data/examples/functions +0 -3
- data/examples/groups +0 -7
- data/examples/head +0 -30
- data/examples/importing +0 -8
- data/examples/mac_dscl.pp +0 -28
- data/examples/mac_dscl_revert.pp +0 -26
- data/examples/mac_pkgdmg.pp +0 -7
- data/examples/modules/sample_module.pp +0 -10
- data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
- data/examples/modules/sample_module/manifests/init.pp +0 -12
- data/examples/modules/sample_module/templates/sample.erb +0 -5
- data/examples/nodes +0 -20
- data/examples/one +0 -8
- data/examples/relationships +0 -34
- data/examples/selectors +0 -28
- data/examples/simpletests +0 -11
- data/examples/svncommit +0 -13
- data/lib/puppet/dsl/resource_api.rb +0 -120
- data/lib/puppet/dsl/resource_type_api.rb +0 -34
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
- data/spec/unit/dsl/resource_api_spec.rb +0 -180
- data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
require 'puppet/resource/catalog'
|
5
5
|
|
6
|
-
describe "Puppet::Resource::Catalog::Queue"
|
6
|
+
describe "Puppet::Resource::Catalog::Queue" do
|
7
7
|
before do
|
8
8
|
Puppet::Resource::Catalog.indirection.terminus(:queue)
|
9
9
|
@catalog = Puppet::Resource::Catalog.new
|
@@ -45,60 +45,47 @@ describe Puppet::Network::FormatHandler.format(:s) do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe Puppet::Network::FormatHandler.format(:pson) do
|
48
|
-
|
49
|
-
|
50
|
-
before do
|
51
|
-
@pson = Puppet::Network::FormatHandler.format(:pson)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should not be suitable" do
|
55
|
-
@pson.should_not be_suitable
|
56
|
-
end
|
48
|
+
before do
|
49
|
+
@pson = Puppet::Network::FormatHandler.format(:pson)
|
57
50
|
end
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
it "should be able to render an instance to pson" do
|
65
|
-
instance = PsonIntTest.new("foo")
|
66
|
-
PsonIntTest.canonical_order(@pson.render(instance)).should == PsonIntTest.canonical_order('{"type":"PsonIntTest","data":["foo"]}' )
|
67
|
-
end
|
52
|
+
it "should be able to render an instance to pson" do
|
53
|
+
instance = PsonIntTest.new("foo")
|
54
|
+
PsonIntTest.canonical_order(@pson.render(instance)).should == PsonIntTest.canonical_order('{"type":"PsonIntTest","data":["foo"]}' )
|
55
|
+
end
|
68
56
|
|
69
|
-
|
70
|
-
|
71
|
-
|
57
|
+
it "should be able to render arrays to pson" do
|
58
|
+
@pson.render([1,2]).should == '[1,2]'
|
59
|
+
end
|
72
60
|
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
it "should be able to render arrays containing hashes to pson" do
|
62
|
+
@pson.render([{"one"=>1},{"two"=>2}]).should == '[{"one":1},{"two":2}]'
|
63
|
+
end
|
76
64
|
|
77
|
-
|
78
|
-
|
79
|
-
|
65
|
+
it "should be able to render multiple instances to pson" do
|
66
|
+
one = PsonIntTest.new("one")
|
67
|
+
two = PsonIntTest.new("two")
|
80
68
|
|
81
|
-
|
82
|
-
|
69
|
+
PsonIntTest.canonical_order(@pson.render([one,two])).should == PsonIntTest.canonical_order('[{"type":"PsonIntTest","data":["one"]},{"type":"PsonIntTest","data":["two"]}]')
|
70
|
+
end
|
83
71
|
|
84
|
-
|
85
|
-
|
86
|
-
|
72
|
+
it "should be able to intern pson into an instance" do
|
73
|
+
@pson.intern(PsonIntTest, '{"type":"PsonIntTest","data":["foo"]}').should == PsonIntTest.new("foo")
|
74
|
+
end
|
87
75
|
|
88
|
-
|
89
|
-
|
90
|
-
|
76
|
+
it "should be able to intern pson with no class information into an instance" do
|
77
|
+
@pson.intern(PsonIntTest, '["foo"]').should == PsonIntTest.new("foo")
|
78
|
+
end
|
91
79
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
80
|
+
it "should be able to intern multiple instances from pson" do
|
81
|
+
@pson.intern_multiple(PsonIntTest, '[{"type": "PsonIntTest", "data": ["one"]},{"type": "PsonIntTest", "data": ["two"]}]').should == [
|
82
|
+
PsonIntTest.new("one"), PsonIntTest.new("two")
|
83
|
+
]
|
84
|
+
end
|
97
85
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
86
|
+
it "should be able to intern multiple instances from pson with no class information" do
|
87
|
+
@pson.intern_multiple(PsonIntTest, '[["one"],["two"]]').should == [
|
88
|
+
PsonIntTest.new("one"), PsonIntTest.new("two")
|
89
|
+
]
|
103
90
|
end
|
104
91
|
end
|
@@ -1,37 +1,117 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
|
+
require 'puppet_spec/compiler'
|
3
4
|
|
4
5
|
require 'puppet/parser/collector'
|
5
6
|
|
6
7
|
describe Puppet::Parser::Collector do
|
7
|
-
|
8
|
-
@scope = Puppet::Parser::Scope.new(Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")))
|
8
|
+
include PuppetSpec::Compiler
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def expect_the_message_to_be(expected_messages, code, node = Puppet::Node.new('the node'))
|
11
|
+
catalog = compile_to_catalog(code, node)
|
12
|
+
messages = catalog.resources.find_all { |resource| resource.type == 'Notify' }.
|
13
|
+
collect { |notify| notify[:message] }
|
14
|
+
messages.should include(*expected_messages)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "matches on title" do
|
18
|
+
expect_the_message_to_be(["the message"], <<-MANIFEST)
|
19
|
+
@notify { "testing": message => "the message" }
|
20
|
+
|
21
|
+
Notify <| title == "testing" |>
|
22
|
+
MANIFEST
|
14
23
|
end
|
15
24
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
it "matches on other parameters" do
|
26
|
+
expect_the_message_to_be(["the message"], <<-MANIFEST)
|
27
|
+
@notify { "testing": message => "the message" }
|
28
|
+
@notify { "other testing": message => "the wrong message" }
|
29
|
+
|
30
|
+
Notify <| message == "the message" |>
|
31
|
+
MANIFEST
|
32
|
+
end
|
33
|
+
|
34
|
+
it "allows criteria to be combined with 'and'" do
|
35
|
+
expect_the_message_to_be(["the message"], <<-MANIFEST)
|
36
|
+
@notify { "testing": message => "the message" }
|
37
|
+
@notify { "other": message => "the message" }
|
38
|
+
|
39
|
+
Notify <| title == "testing" and message == "the message" |>
|
40
|
+
MANIFEST
|
41
|
+
end
|
42
|
+
|
43
|
+
it "allows criteria to be combined with 'or'" do
|
44
|
+
expect_the_message_to_be(["the message", "other message"], <<-MANIFEST)
|
45
|
+
@notify { "testing": message => "the message" }
|
46
|
+
@notify { "other": message => "other message" }
|
47
|
+
@notify { "yet another": message => "different message" }
|
48
|
+
|
49
|
+
Notify <| title == "testing" or message == "other message" |>
|
50
|
+
MANIFEST
|
51
|
+
end
|
52
|
+
|
53
|
+
it "allows criteria to be combined with 'or'" do
|
54
|
+
expect_the_message_to_be(["the message", "other message"], <<-MANIFEST)
|
55
|
+
@notify { "testing": message => "the message" }
|
56
|
+
@notify { "other": message => "other message" }
|
57
|
+
@notify { "yet another": message => "different message" }
|
58
|
+
|
59
|
+
Notify <| title == "testing" or message == "other message" |>
|
60
|
+
MANIFEST
|
61
|
+
end
|
62
|
+
|
63
|
+
it "allows criteria to be grouped with parens" do
|
64
|
+
expect_the_message_to_be(["the message", "different message"], <<-MANIFEST)
|
65
|
+
@notify { "testing": message => "different message", withpath => true }
|
66
|
+
@notify { "other": message => "the message" }
|
67
|
+
@notify { "yet another": message => "the message", withpath => true }
|
68
|
+
|
69
|
+
Notify <| (title == "testing" or message == "the message") and withpath == true |>
|
70
|
+
MANIFEST
|
71
|
+
end
|
72
|
+
|
73
|
+
it "does not do anything if nothing matches" do
|
74
|
+
expect_the_message_to_be([], <<-MANIFEST)
|
75
|
+
@notify { "testing": message => "different message" }
|
76
|
+
|
77
|
+
Notify <| title == "does not exist" |>
|
78
|
+
MANIFEST
|
79
|
+
end
|
80
|
+
|
81
|
+
it "excludes items with inequalities" do
|
82
|
+
expect_the_message_to_be(["good message"], <<-MANIFEST)
|
83
|
+
@notify { "testing": message => "good message" }
|
84
|
+
@notify { "the wrong one": message => "bad message" }
|
85
|
+
|
86
|
+
Notify <| title != "the wrong one" |>
|
87
|
+
MANIFEST
|
88
|
+
end
|
89
|
+
|
90
|
+
context "issue #10963" do
|
91
|
+
it "collects with override when inside a class" do
|
92
|
+
expect_the_message_to_be(["overridden message"], <<-MANIFEST)
|
93
|
+
@notify { "testing": message => "original message" }
|
94
|
+
|
95
|
+
include collector_test
|
96
|
+
class collector_test {
|
97
|
+
Notify <| |> {
|
98
|
+
message => "overridden message"
|
99
|
+
}
|
100
|
+
}
|
101
|
+
MANIFEST
|
102
|
+
end
|
103
|
+
|
104
|
+
it "collects with override when inside a define" do
|
105
|
+
expect_the_message_to_be(["overridden message"], <<-MANIFEST)
|
106
|
+
@notify { "testing": message => "original message" }
|
107
|
+
|
108
|
+
collector_test { testing: }
|
109
|
+
define collector_test() {
|
110
|
+
Notify <| |> {
|
111
|
+
message => "overridden message"
|
112
|
+
}
|
113
|
+
}
|
114
|
+
MANIFEST
|
35
115
|
end
|
36
116
|
end
|
37
117
|
end
|
@@ -4,7 +4,7 @@ require 'puppet_spec/compiler'
|
|
4
4
|
describe "Two step scoping for variables" do
|
5
5
|
include PuppetSpec::Compiler
|
6
6
|
|
7
|
-
def expect_the_message_to_be(message, node = Puppet::Node.new('the node'))
|
7
|
+
def expect_the_message_to_be(message, node = Puppet::Node.new('the node'))
|
8
8
|
catalog = compile_to_catalog(yield, node)
|
9
9
|
catalog.resource('Notify', 'something')[:message].should == message
|
10
10
|
end
|
@@ -13,6 +13,69 @@ describe "Two step scoping for variables" do
|
|
13
13
|
Puppet.expects(:deprecation_warning).never
|
14
14
|
end
|
15
15
|
|
16
|
+
describe "fully qualified variable names" do
|
17
|
+
it "keeps nodescope separate from topscope" do
|
18
|
+
expect_the_message_to_be('topscope') do <<-MANIFEST
|
19
|
+
$c = "topscope"
|
20
|
+
node default {
|
21
|
+
$c = "nodescope"
|
22
|
+
notify { 'something': message => $::c }
|
23
|
+
}
|
24
|
+
MANIFEST
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "when colliding class and variable names" do
|
30
|
+
it "finds a topscope variable with the same name as a class" do
|
31
|
+
expect_the_message_to_be('topscope') do <<-MANIFEST
|
32
|
+
$c = "topscope"
|
33
|
+
class c { }
|
34
|
+
node default {
|
35
|
+
include c
|
36
|
+
notify { 'something': message => $c }
|
37
|
+
}
|
38
|
+
MANIFEST
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "finds a node scope variable with the same name as a class" do
|
43
|
+
expect_the_message_to_be('nodescope') do <<-MANIFEST
|
44
|
+
class c { }
|
45
|
+
node default {
|
46
|
+
$c = "nodescope"
|
47
|
+
include c
|
48
|
+
notify { 'something': message => $c }
|
49
|
+
}
|
50
|
+
MANIFEST
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "finds a class variable when the class collides with a nodescope variable" do
|
55
|
+
expect_the_message_to_be('class') do <<-MANIFEST
|
56
|
+
class c { $b = "class" }
|
57
|
+
node default {
|
58
|
+
$c = "nodescope"
|
59
|
+
include c
|
60
|
+
notify { 'something': message => $c::b }
|
61
|
+
}
|
62
|
+
MANIFEST
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "finds a class variable when the class collides with a topscope variable" do
|
67
|
+
expect_the_message_to_be('class') do <<-MANIFEST
|
68
|
+
$c = "topscope"
|
69
|
+
class c { $b = "class" }
|
70
|
+
node default {
|
71
|
+
include c
|
72
|
+
notify { 'something': message => $::c::b }
|
73
|
+
}
|
74
|
+
MANIFEST
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
16
79
|
describe "when using shadowing and inheritance" do
|
17
80
|
it "finds value define in the inherited node" do
|
18
81
|
expect_the_message_to_be('parent_msg') do <<-MANIFEST
|
@@ -2,10 +2,8 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Puppet::Resource::Catalog do
|
5
|
-
|
6
|
-
|
7
|
-
Puppet::Resource::Catalog.supported_formats.should be_include(:pson)
|
8
|
-
end
|
5
|
+
it "should support pson" do
|
6
|
+
Puppet::Resource::Catalog.supported_formats.should be_include(:pson)
|
9
7
|
end
|
10
8
|
|
11
9
|
describe "when using the indirector" do
|
@@ -11,7 +11,7 @@ describe Puppet::Type.type(:package), "when choosing a default package provider"
|
|
11
11
|
if Facter.value(:operatingsystem) == 'Solaris' && Puppet::Util::Package.versioncmp(Facter.value(:kernelrelease), '5.11') >= 0
|
12
12
|
:pkg
|
13
13
|
else
|
14
|
-
{"Ubuntu" => :apt, "Debian" => :apt, "Darwin" => :pkgdmg, "RedHat" => :up2date, "Fedora" => :yum, "FreeBSD" => :ports, "OpenBSD" => :openbsd, "Solaris" => :sun}[os]
|
14
|
+
{"Ubuntu" => :apt, "Debian" => :apt, "Darwin" => :pkgdmg, "RedHat" => :up2date, "Fedora" => :yum, "FreeBSD" => :ports, "OpenBSD" => :openbsd, "Solaris" => :sun, "DragonFly" => :pkgin}[os]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
RSpec::Matchers.define :be_equivalent_to_catalog do |expected|
|
2
|
+
diffable
|
3
|
+
|
4
|
+
match do |actual|
|
5
|
+
actual.is_a? Puppet::Resource::Catalog and
|
6
|
+
expected.is_a? Puppet::Resource::Catalog and
|
7
|
+
compare_catalogs(actual, expected)
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should do |actual|
|
11
|
+
"expected catalog #{actual.inspect} would be equivalent to catalog #{expected.inspect}"
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message_for_should_not do |actual|
|
15
|
+
"expected catalog #{actual.inspect} would not be equivalent to catalog #{expected.inspect}"
|
16
|
+
end
|
17
|
+
|
18
|
+
description do
|
19
|
+
"be equivalent to catalog #{expected.inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def compare_catalogs(actual, expected)
|
23
|
+
compare_attributes([:name, :environment, :tags, :classes], actual, expected) and
|
24
|
+
compare_resources(actual, expected) and
|
25
|
+
compare_relationships(actual, expected)
|
26
|
+
end
|
27
|
+
|
28
|
+
def compare_attributes(attributes, actual, expected)
|
29
|
+
attributes.all? do |attribute|
|
30
|
+
actual.send(attribute) == expected.send(attribute)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def compare_relationships(actual, expected)
|
35
|
+
actual = actual.edges.sort_by { |r| r.to_s }
|
36
|
+
expected = expected.edges.sort_by { |r| r.to_s }
|
37
|
+
|
38
|
+
[:source, :target, :event, :callback].all? do |attribute|
|
39
|
+
actual.map(&attribute) == expected.map(&attribute)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def compare_resources(actual, expected)
|
44
|
+
actual = actual.resources.sort_by { |r| r.name }
|
45
|
+
expected = expected.resources.sort_by { |r| r.name }
|
46
|
+
|
47
|
+
actual == expected
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -3,4 +3,15 @@ module PuppetSpec::Compiler
|
|
3
3
|
Puppet[:code] = string
|
4
4
|
Puppet::Parser::Compiler.compile(node)
|
5
5
|
end
|
6
|
+
|
7
|
+
def compile_ruby_to_catalog(string = nil, node = Puppet::Node.new('foonode'))
|
8
|
+
File.stubs(:read).returns(string)
|
9
|
+
Puppet::Parser::Compiler.compile(node)
|
10
|
+
end
|
11
|
+
|
12
|
+
def prepare_compiler
|
13
|
+
let(:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) }
|
14
|
+
let(:scope) { Puppet::Parser::Scope.new compiler }
|
15
|
+
end
|
16
|
+
|
6
17
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PuppetSpec
|
2
|
+
module DSL
|
3
|
+
|
4
|
+
def prepare_compiler_and_scope_for_evaluation
|
5
|
+
let(:compiler) { Puppet::Parser::Compiler.new Puppet::Node.new("test") }
|
6
|
+
let(:scope) { Puppet::Parser::Scope.new compiler, :source => "test" }
|
7
|
+
end
|
8
|
+
|
9
|
+
def evaluate_in_context(options = {}, &block)
|
10
|
+
eval_scope = options.fetch :scope, scope
|
11
|
+
Puppet::DSL::Context.new(block, options).evaluate eval_scope, eval_scope.known_resource_types
|
12
|
+
end
|
13
|
+
|
14
|
+
def known_resource_types
|
15
|
+
compiler.known_resource_types
|
16
|
+
end
|
17
|
+
|
18
|
+
def evaluate_in_scope(options = {})
|
19
|
+
eval_scope = options.fetch :scope, scope
|
20
|
+
Puppet::DSL::Parser.add_scope eval_scope
|
21
|
+
Puppet::DSL::Parser.known_resource_types = eval_scope.known_resource_types
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
Puppet::DSL::Parser.known_resource_types = nil
|
25
|
+
Puppet::DSL::Parser.remove_scope
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
# NOTE: a lot of the stuff in this file is duplicated in the
|
2
|
-
#
|
3
|
-
#
|
1
|
+
# NOTE: a lot of the stuff in this file is duplicated in the
|
2
|
+
# "puppet_spec_helper" in the project puppetlabs_spec_helper. We should
|
3
|
+
# probably eat our own dog food and get rid of most of this from here, and
|
4
|
+
# have the puppet core itself use puppetlabs_spec_helper
|
4
5
|
|
5
6
|
dir = File.expand_path(File.dirname(__FILE__))
|
6
7
|
$LOAD_PATH.unshift File.join(dir, 'lib')
|
@@ -47,6 +48,17 @@ end
|
|
47
48
|
RSpec.configure do |config|
|
48
49
|
include PuppetSpec::Fixtures
|
49
50
|
|
51
|
+
# Examples or groups can selectively tag themselves as broken.
|
52
|
+
# For example;
|
53
|
+
#
|
54
|
+
# rbv = "#{RUBY_VERSION}-p#{RbConfig::CONFIG['PATCHLEVEL']}"
|
55
|
+
# describe "mostly working", :broken => false unless rbv == "1.9.3-p327" do
|
56
|
+
# it "parses a valid IP" do
|
57
|
+
# IPAddr.new("::2:3:4:5:6:7:8")
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
config.filter_run_excluding :broken => true
|
61
|
+
|
50
62
|
config.mock_with :mocha
|
51
63
|
|
52
64
|
tmpdir = Dir.mktmpdir("rspecrun")
|
@@ -59,6 +71,8 @@ RSpec.configure do |config|
|
|
59
71
|
config.formatters.each { |f| f.instance_variable_set(:@output, $stdout) }
|
60
72
|
end
|
61
73
|
|
74
|
+
Puppet::Test::TestHelper.initialize
|
75
|
+
|
62
76
|
config.before :all do
|
63
77
|
Puppet::Test::TestHelper.before_all_tests()
|
64
78
|
end
|