puppet 2.7.3 → 2.7.4
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/CHANGELOG +166 -0
- data/install.rb +27 -7
- data/lib/puppet/application/agent.rb +29 -29
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/inspect.rb +9 -1
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/application/queue.rb +1 -1
- data/lib/puppet/application/resource.rb +3 -0
- data/lib/puppet/application.rb +4 -5
- data/lib/puppet/configurer.rb +1 -4
- data/lib/puppet/defaults.rb +45 -15
- data/lib/puppet/feature/base.rb +28 -17
- data/lib/puppet/feature/rails.rb +0 -3
- data/lib/puppet/feature/rubygems.rb +0 -3
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_bucket/file.rb +3 -3
- data/lib/puppet/file_serving/base.rb +4 -5
- data/lib/puppet/file_serving/configuration.rb +7 -13
- data/lib/puppet/file_serving/content.rb +0 -4
- data/lib/puppet/file_serving/fileset.rb +7 -6
- data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
- data/lib/puppet/file_serving/metadata.rb +0 -4
- data/lib/puppet/file_serving/mount/file.rb +9 -12
- data/lib/puppet/file_serving/mount.rb +0 -5
- data/lib/puppet/file_serving/terminus_helper.rb +0 -4
- data/lib/puppet/file_serving.rb +0 -4
- data/lib/puppet/indirector/catalog/compiler.rb +0 -18
- data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
- data/lib/puppet/indirector/direct_file_server.rb +0 -4
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/store_configs.rb +5 -0
- data/lib/puppet/indirector/file_content/file.rb +0 -4
- data/lib/puppet/indirector/file_content/file_server.rb +0 -4
- data/lib/puppet/indirector/file_content/rest.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
- data/lib/puppet/indirector/file_server.rb +1 -5
- data/lib/puppet/indirector/indirection.rb +3 -5
- data/lib/puppet/indirector/node/store_configs.rb +5 -0
- data/lib/puppet/indirector/request.rb +3 -1
- data/lib/puppet/indirector/resource/active_record.rb +97 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +5 -1
- data/lib/puppet/indirector/store_configs.rb +30 -0
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/indirector.rb +7 -0
- data/lib/puppet/network/client.rb +0 -5
- data/lib/puppet/network/http_pool.rb +0 -56
- data/lib/puppet/node/environment.rb +9 -11
- data/lib/puppet/parameter/path.rb +1 -5
- data/lib/puppet/parameter.rb +1 -7
- data/lib/puppet/parser/ast/collection.rb +2 -2
- data/lib/puppet/parser/ast/collexpr.rb +10 -39
- data/lib/puppet/parser/collector.rb +41 -90
- data/lib/puppet/parser/compiler.rb +0 -3
- data/lib/puppet/parser/functions/create_resources.rb +22 -10
- data/lib/puppet/parser/functions/versioncmp.rb +9 -6
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +2 -1
- data/lib/puppet/provider/augeas/augeas.rb +5 -3
- data/lib/puppet/provider/cron/crontab.rb +2 -2
- data/lib/puppet/provider/exec/posix.rb +23 -96
- data/lib/puppet/provider/exec/shell.rb +11 -2
- data/lib/puppet/provider/exec/windows.rb +35 -0
- data/lib/puppet/provider/exec.rb +79 -0
- data/lib/puppet/provider/group/windows_adsi.rb +48 -0
- data/lib/puppet/provider/host/parsed.rb +3 -0
- data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
- data/lib/puppet/provider/mount.rb +0 -3
- data/lib/puppet/provider/naginator.rb +0 -3
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +3 -7
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/aptrpm.rb +0 -1
- data/lib/puppet/provider/package/blastwave.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +5 -6
- data/lib/puppet/provider/package/fink.rb +3 -4
- data/lib/puppet/provider/package/freebsd.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +0 -1
- data/lib/puppet/provider/package/hpux.rb +3 -3
- data/lib/puppet/provider/package/macports.rb +0 -1
- data/lib/puppet/provider/package/msi.rb +82 -0
- data/lib/puppet/provider/package/openbsd.rb +18 -19
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +0 -1
- data/lib/puppet/provider/package/pkgdmg.rb +9 -7
- data/lib/puppet/provider/package/pkgutil.rb +0 -1
- data/lib/puppet/provider/package/ports.rb +0 -1
- data/lib/puppet/provider/package/portupgrade.rb +183 -193
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +0 -1
- data/lib/puppet/provider/package/sunfreeware.rb +0 -2
- data/lib/puppet/provider/package/up2date.rb +0 -1
- data/lib/puppet/provider/package/urpmi.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package.rb +4 -3
- data/lib/puppet/provider/service/systemd.rb +64 -0
- data/lib/puppet/provider/service/windows.rb +110 -0
- data/lib/puppet/provider/user/windows_adsi.rb +71 -0
- data/lib/puppet/rails/resource.rb +1 -1
- data/lib/puppet/relationship.rb +0 -3
- data/lib/puppet/reports/tagmail.rb +15 -11
- data/lib/puppet/resource/catalog.rb +17 -24
- data/lib/puppet/ssl/certificate_authority.rb +7 -5
- data/lib/puppet/ssl/host.rb +6 -10
- data/lib/puppet/type/augeas.rb +19 -13
- data/lib/puppet/type/cron.rb +13 -12
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file/content.rb +7 -3
- data/lib/puppet/type/file/source.rb +14 -9
- data/lib/puppet/type/file.rb +44 -23
- data/lib/puppet/type/filebucket.rb +13 -5
- data/lib/puppet/type/package.rb +14 -1
- data/lib/puppet/type/service.rb +11 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type.rb +8 -17
- data/lib/puppet/util/adsi.rb +278 -0
- data/lib/puppet/util/autoload.rb +0 -2
- data/lib/puppet/util/cacher.rb +15 -67
- data/lib/puppet/util/feature.rb +0 -3
- data/lib/puppet/util/graph.rb +0 -3
- data/lib/puppet/util/ldap/connection.rb +0 -3
- data/lib/puppet/util/ldap/generator.rb +0 -3
- data/lib/puppet/util/ldap.rb +0 -3
- data/lib/puppet/util/log_paths.rb +0 -3
- data/lib/puppet/util/network_device/cisco/device.rb +2 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/pidlock.rb +5 -1
- data/lib/puppet/util/rdoc/parser.rb +3 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/settings/file_setting.rb +3 -2
- data/lib/puppet/util/settings.rb +4 -6
- data/lib/puppet/util/suidmanager.rb +62 -15
- data/lib/puppet/util.rb +113 -131
- data/lib/puppet.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +22 -17
- data/spec/integration/file_serving/content_spec.rb +0 -6
- data/spec/integration/file_serving/metadata_spec.rb +0 -6
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
- data/spec/integration/network/server/webrick_spec.rb +6 -9
- data/spec/integration/node/facts_spec.rb +0 -6
- data/spec/integration/node_spec.rb +3 -4
- data/spec/integration/parser/compiler_spec.rb +2 -1
- data/spec/integration/parser/parser_spec.rb +2 -4
- data/spec/integration/provider/mount_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +13 -3
- data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
- data/spec/integration/reports_spec.rb +0 -4
- data/spec/integration/resource/catalog_spec.rb +0 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
- data/spec/integration/ssl/certificate_request_spec.rb +10 -17
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
- data/spec/integration/ssl/host_spec.rb +8 -14
- data/spec/integration/transaction/report_spec.rb +0 -5
- data/spec/integration/transaction_spec.rb +11 -13
- data/spec/integration/type/file_spec.rb +16 -16
- data/spec/integration/type/tidy_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +2 -2
- data/spec/integration/util_spec.rb +13 -0
- data/spec/lib/puppet_spec/files.rb +18 -10
- data/spec/shared_behaviours/file_server_terminus.rb +1 -5
- data/spec/shared_behaviours/file_serving.rb +0 -4
- data/spec/shared_behaviours/memory_terminus.rb +0 -4
- data/spec/shared_behaviours/path_parameters.rb +20 -18
- data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/unit/agent_spec.rb +0 -4
- data/spec/unit/application/apply_spec.rb +8 -2
- data/spec/unit/application/certificate_spec.rb +2 -0
- data/spec/unit/application/device_spec.rb +8 -6
- data/spec/unit/application/inspect_spec.rb +2 -1
- data/spec/unit/application/master_spec.rb +7 -2
- data/spec/unit/application/queue_spec.rb +3 -4
- data/spec/unit/application/resource_spec.rb +26 -0
- data/spec/unit/application/secret_agent_spec.rb +3 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/configurer/downloader_spec.rb +4 -3
- data/spec/unit/configurer_spec.rb +11 -4
- data/spec/unit/daemon_spec.rb +3 -1
- data/spec/unit/face/ca_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +5 -1
- data/spec/unit/face/secret_agent_spec.rb +3 -1
- data/spec/unit/file_bucket/dipper_spec.rb +4 -4
- data/spec/unit/file_bucket/file_spec.rb +9 -3
- data/spec/unit/file_serving/configuration_spec.rb +26 -37
- data/spec/unit/file_serving/fileset_spec.rb +71 -55
- data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
- data/spec/unit/file_serving/mount/file_spec.rb +163 -169
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
- data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
- data/spec/unit/indirector/facts/facter_spec.rb +0 -4
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_content/file_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
- data/spec/unit/indirector/file_server_spec.rb +1 -5
- data/spec/unit/indirector/indirection_spec.rb +0 -4
- data/spec/unit/indirector/key/ca_spec.rb +0 -4
- data/spec/unit/indirector/key/file_spec.rb +0 -4
- data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -4
- data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
- data/spec/unit/indirector/ssl_file_spec.rb +25 -6
- data/spec/unit/indirector/store_configs_spec.rb +8 -0
- data/spec/unit/indirector/yaml_spec.rb +14 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +5 -5
- data/spec/unit/network/http/mongrel_spec.rb +0 -4
- data/spec/unit/network/http/webrick_spec.rb +5 -9
- data/spec/unit/network/http_pool_spec.rb +4 -75
- data/spec/unit/network/http_spec.rb +0 -4
- data/spec/unit/network/server_spec.rb +0 -4
- data/spec/unit/node/environment_spec.rb +18 -31
- data/spec/unit/node/facts_spec.rb +0 -4
- data/spec/unit/node_spec.rb +1 -8
- data/spec/unit/other/selinux_spec.rb +3 -1
- data/spec/unit/parameter_spec.rb +0 -10
- data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
- data/spec/unit/parser/collector_spec.rb +147 -263
- data/spec/unit/parser/compiler_spec.rb +3 -1
- data/spec/unit/parser/files_spec.rb +7 -4
- data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
- data/spec/unit/parser/type_loader_spec.rb +7 -7
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
- data/spec/unit/provider/exec/posix_spec.rb +102 -106
- data/spec/unit/provider/exec/shell_spec.rb +1 -1
- data/spec/unit/provider/exec/windows_spec.rb +119 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
- data/spec/unit/provider/ldap_spec.rb +0 -4
- data/spec/unit/provider/macauthorization_spec.rb +5 -0
- data/spec/unit/provider/mount/parsed_spec.rb +1 -5
- data/spec/unit/provider/package/msi_spec.rb +170 -0
- data/spec/unit/provider/service/redhat_spec.rb +2 -0
- data/spec/unit/provider/service/smf_spec.rb +3 -0
- data/spec/unit/provider/service/systemd_spec.rb +25 -0
- data/spec/unit/provider/service/windows_spec.rb +166 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/ldap_spec.rb +0 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
- data/spec/unit/relationship_spec.rb +0 -4
- data/spec/unit/resource/catalog_spec.rb +37 -25
- data/spec/unit/resource/status_spec.rb +4 -2
- data/spec/unit/resource_spec.rb +5 -5
- data/spec/unit/simple_graph_spec.rb +0 -4
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
- data/spec/unit/ssl/host_spec.rb +12 -13
- data/spec/unit/ssl/inventory_spec.rb +2 -2
- data/spec/unit/sslcertificates/ca_spec.rb +6 -10
- data/spec/unit/transaction/event_manager_spec.rb +4 -2
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/report_spec.rb +2 -6
- data/spec/unit/transaction/resource_harness_spec.rb +9 -5
- data/spec/unit/transaction_spec.rb +3 -1
- data/spec/unit/type/cron_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +80 -47
- data/spec/unit/type/file/checksum_spec.rb +9 -8
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/file/selinux_spec.rb +10 -8
- data/spec/unit/type/file/source_spec.rb +18 -36
- data/spec/unit/type/file_spec.rb +170 -217
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/noop_metaparam_spec.rb +3 -1
- data/spec/unit/type/package_spec.rb +15 -3
- data/spec/unit/type/resources_spec.rb +2 -2
- data/spec/unit/type/service_spec.rb +19 -4
- data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
- data/spec/unit/type/tidy_spec.rb +3 -1
- data/spec/unit/type/user_spec.rb +1 -1
- data/spec/unit/type_spec.rb +29 -34
- data/spec/unit/util/adsi_spec.rb +202 -0
- data/spec/unit/util/autoload_spec.rb +23 -19
- data/spec/unit/util/backups_spec.rb +16 -13
- data/spec/unit/util/cacher_spec.rb +64 -141
- data/spec/unit/util/checksums_spec.rb +0 -4
- data/spec/unit/util/constant_inflector_spec.rb +0 -4
- data/spec/unit/util/execution_stub_spec.rb +1 -1
- data/spec/unit/util/ldap/connection_spec.rb +0 -4
- data/spec/unit/util/ldap/generator_spec.rb +0 -4
- data/spec/unit/util/ldap/manager_spec.rb +0 -4
- data/spec/unit/util/log_spec.rb +4 -2
- data/spec/unit/util/logging_spec.rb +2 -2
- data/spec/unit/util/nagios_maker_spec.rb +0 -4
- data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
- data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
- data/spec/unit/util/network_device/config_spec.rb +5 -3
- data/spec/unit/util/rdoc/parser_spec.rb +7 -1
- data/spec/unit/util/run_mode_spec.rb +6 -2
- data/spec/unit/util/settings/file_setting_spec.rb +29 -2
- data/spec/unit/util/settings_spec.rb +28 -15
- data/spec/unit/util/storage_spec.rb +1 -1
- data/spec/unit/util/suidmanager_spec.rb +310 -0
- data/spec/unit/util/tagging_spec.rb +0 -4
- data/spec/unit/util_spec.rb +335 -0
- data/test/language/ast/variable.rb +0 -4
- data/test/lib/puppettest/support/resources.rb +0 -4
- data/test/lib/puppettest/testcase.rb +0 -4
- data/test/lib/puppettest.rb +0 -1
- data/test/network/handler/master.rb +0 -5
- data/test/network/server/webrick.rb +5 -22
- data/test/ral/manager/attributes.rb +0 -4
- data/test/ral/manager/instances.rb +0 -4
- data/test/ral/manager/manager.rb +0 -4
- data/test/ral/providers/cron/crontab.rb +1 -0
- data/test/ral/providers/service/base.rb +0 -4
- data/test/ral/type/filesources.rb +0 -1
- data/test/ral/type/resources.rb +0 -4
- data/test/util/utiltest.rb +0 -13
- metadata +36 -9
- data/spec/unit/network/client_spec.rb +0 -45
- data/test/puppet/tc_suidmanager.rb +0 -120
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
require 'tmpdir'
|
5
|
+
|
4
6
|
require 'puppet/node/environment'
|
5
7
|
require 'puppet/util/execution'
|
6
8
|
|
@@ -10,10 +12,6 @@ describe Puppet::Node::Environment do
|
|
10
12
|
Puppet::Node::Environment.clear
|
11
13
|
end
|
12
14
|
|
13
|
-
it "should include the Cacher module" do
|
14
|
-
Puppet::Node::Environment.ancestors.should be_include(Puppet::Util::Cacher)
|
15
|
-
end
|
16
|
-
|
17
15
|
it "should use the filetimeout for the ttl for the modulepath" do
|
18
16
|
Puppet::Node::Environment.attr_ttl(:modulepath).should == Integer(Puppet[:filetimeout])
|
19
17
|
end
|
@@ -22,10 +20,6 @@ describe Puppet::Node::Environment do
|
|
22
20
|
Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
|
23
21
|
end
|
24
22
|
|
25
|
-
it "should use the filetimeout for the ttl for the manifestdir" do
|
26
|
-
Puppet::Node::Environment.attr_ttl(:manifestdir).should == Integer(Puppet[:filetimeout])
|
27
|
-
end
|
28
|
-
|
29
23
|
it "should use the default environment if no name is provided while initializing an environment" do
|
30
24
|
Puppet.settings.expects(:value).with(:environment).returns("one")
|
31
25
|
Puppet::Node::Environment.new.name.should == :one
|
@@ -109,27 +103,15 @@ describe Puppet::Node::Environment do
|
|
109
103
|
end
|
110
104
|
end
|
111
105
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
env = Puppet::Node::Environment.new("testing")
|
117
|
-
env.stubs(:[]).with(setting).returns path
|
118
|
-
|
119
|
-
env.expects(:validate_dirs).with(%w{/one /two})
|
120
|
-
|
121
|
-
env.send(setting)
|
122
|
-
end
|
106
|
+
it "should validate the modulepath directories" do
|
107
|
+
real_file = tmpdir('moduledir')
|
108
|
+
path = %W[/one /two #{real_file}].join(File::PATH_SEPARATOR)
|
123
109
|
|
124
|
-
|
125
|
-
path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
110
|
+
Puppet[:modulepath] = path
|
126
111
|
|
127
|
-
|
128
|
-
env.stubs(:[]).with(setting).returns path
|
129
|
-
env.stubs(:validate_dirs).returns %w{/one /two}
|
112
|
+
env = Puppet::Node::Environment.new("testing")
|
130
113
|
|
131
|
-
|
132
|
-
end
|
114
|
+
env.modulepath.should == [real_file]
|
133
115
|
end
|
134
116
|
|
135
117
|
it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
|
@@ -144,21 +126,26 @@ describe Puppet::Node::Environment do
|
|
144
126
|
end
|
145
127
|
|
146
128
|
describe "when validating modulepath or manifestdir directories" do
|
129
|
+
before :each do
|
130
|
+
@path_one = make_absolute('/one')
|
131
|
+
@path_two = make_absolute('/two')
|
132
|
+
end
|
133
|
+
|
147
134
|
it "should not return non-directories" do
|
148
135
|
env = Puppet::Node::Environment.new("testing")
|
149
136
|
|
150
|
-
FileTest.expects(:directory?).with(
|
151
|
-
FileTest.expects(:directory?).with(
|
137
|
+
FileTest.expects(:directory?).with(@path_one).returns true
|
138
|
+
FileTest.expects(:directory?).with(@path_two).returns false
|
152
139
|
|
153
|
-
env.validate_dirs(
|
140
|
+
env.validate_dirs([@path_one, @path_two]).should == [@path_one]
|
154
141
|
end
|
155
142
|
|
156
143
|
it "should use the current working directory to fully-qualify unqualified paths" do
|
157
144
|
FileTest.stubs(:directory?).returns true
|
158
145
|
env = Puppet::Node::Environment.new("testing")
|
159
146
|
|
160
|
-
two = File.join(Dir.getwd, "two")
|
161
|
-
env.validate_dirs(
|
147
|
+
two = File.expand_path(File.join(Dir.getwd, "two"))
|
148
|
+
env.validate_dirs([@path_one, 'two']).should == [@path_one, two]
|
162
149
|
end
|
163
150
|
end
|
164
151
|
|
@@ -68,10 +68,6 @@ describe Puppet::Node::Facts, "when indirecting" do
|
|
68
68
|
before do
|
69
69
|
@indirection = stub 'indirection', :request => mock('request'), :name => :facts
|
70
70
|
|
71
|
-
# We have to clear the cache so that the facts ask for our indirection stub,
|
72
|
-
# instead of anything that might be cached.
|
73
|
-
Puppet::Util::Cacher.expire
|
74
|
-
|
75
71
|
@facts = Puppet::Node::Facts.new("me", "one" => "two")
|
76
72
|
end
|
77
73
|
|
data/spec/unit/node_spec.rb
CHANGED
@@ -130,15 +130,8 @@ end
|
|
130
130
|
describe Puppet::Node, "when indirecting" do
|
131
131
|
it "should default to the 'plain' node terminus" do
|
132
132
|
Puppet::Node.indirection.reset_terminus_class
|
133
|
-
Puppet::Node.indirection.terminus_class.should == :plain
|
134
|
-
end
|
135
133
|
|
136
|
-
|
137
|
-
Puppet::Node.indirection.cache_class.should be_nil
|
138
|
-
end
|
139
|
-
|
140
|
-
after do
|
141
|
-
Puppet::Util::Cacher.expire
|
134
|
+
Puppet::Node.indirection.terminus_class.should == :plain
|
142
135
|
end
|
143
136
|
end
|
144
137
|
|
@@ -5,11 +5,13 @@ require 'puppet/type/selboolean'
|
|
5
5
|
require 'puppet/type/selmodule'
|
6
6
|
|
7
7
|
describe Puppet::Type.type(:file), " when manipulating file contexts" do
|
8
|
+
include PuppetSpec::Files
|
9
|
+
|
8
10
|
before :each do
|
9
11
|
|
10
12
|
@file = Puppet::Type::File.new(
|
11
13
|
|
12
|
-
:name => "/tmp/foo",
|
14
|
+
:name => make_absolute("/tmp/foo"),
|
13
15
|
:ensure => "file",
|
14
16
|
:seluser => "user_u",
|
15
17
|
:selrole => "role_r",
|
data/spec/unit/parameter_spec.rb
CHANGED
@@ -25,16 +25,6 @@ describe Puppet::Parameter do
|
|
25
25
|
@parameter.to_s.should == @parameter.name.to_s
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should be able to use cached attributes" do
|
29
|
-
Puppet::Parameter.ancestors.should be_include(Puppet::Util::Cacher)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should use the resource catalog for expiration" do
|
33
|
-
catalog = mock 'catalog'
|
34
|
-
@resource.stubs(:catalog).returns catalog
|
35
|
-
@parameter.expirer.should equal(catalog)
|
36
|
-
end
|
37
|
-
|
38
28
|
[:line, :file, :version].each do |data|
|
39
29
|
it "should return its resource's #{data} as its #{data}" do
|
40
30
|
@resource.expects(data).returns "foo"
|
@@ -18,14 +18,14 @@ describe Puppet::Parser::AST::CollExpr do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should evaluate both" do
|
21
|
-
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=>"==")
|
21
|
+
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper => "==")
|
22
22
|
collexpr.evaluate(@scope)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should produce a
|
26
|
-
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=>"==")
|
25
|
+
it "should produce a data and code representation of the expression" do
|
26
|
+
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper => "==")
|
27
27
|
result = collexpr.evaluate(@scope)
|
28
|
-
result[0].should == "
|
28
|
+
result[0].should == ["test1", "==", "test2"]
|
29
29
|
result[1].should be_an_instance_of(Proc)
|
30
30
|
end
|
31
31
|
|
@@ -59,16 +59,20 @@ describe Puppet::Parser::AST::CollExpr do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
it "should
|
63
|
-
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
|
64
|
-
|
65
|
-
collexpr.evaluate(@scope)
|
62
|
+
it "should work if this is an exported collection containing parenthesis" do
|
63
|
+
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
|
64
|
+
:oper => "==", :parens => true, :form => :exported)
|
65
|
+
match, code = collexpr.evaluate(@scope)
|
66
|
+
match.should == ["test1", "==", "test2"]
|
67
|
+
@logs.should be_empty # no warnings emitted
|
66
68
|
end
|
67
69
|
|
68
70
|
%w{and or}.each do |op|
|
69
|
-
it "should
|
70
|
-
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
|
71
|
-
|
71
|
+
it "should parse / eval if this is an exported collection with #{op} operator" do
|
72
|
+
collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
|
73
|
+
:oper => op, :form => :exported)
|
74
|
+
match, code = collexpr.evaluate(@scope)
|
75
|
+
match.should == ["test1", op, "test2"]
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
@@ -82,10 +86,10 @@ describe Puppet::Parser::AST::CollExpr do
|
|
82
86
|
@resource.stubs(:tagged?).with("value").returns(true)
|
83
87
|
end
|
84
88
|
|
85
|
-
it "should produce a
|
89
|
+
it "should produce a data representation of the expression" do
|
86
90
|
collexpr = ast::CollExpr.new(:test1 => @tag, :test2 => @value, :oper=>"==")
|
87
91
|
result = collexpr.evaluate(@scope)
|
88
|
-
result[0].should == "
|
92
|
+
result[0].should == ["tag", "==", "value"]
|
89
93
|
end
|
90
94
|
|
91
95
|
it "should inspect resource tags if the query term is on tags" do
|
@@ -1,6 +1,11 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
begin
|
5
|
+
require 'sqlite3'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
4
9
|
require 'puppet/rails'
|
5
10
|
require 'puppet/parser/collector'
|
6
11
|
|
@@ -262,294 +267,173 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
|
|
262
267
|
end
|
263
268
|
end
|
264
269
|
|
265
|
-
describe Puppet::Parser::Collector, "when collecting exported resources", :if => Puppet.features.rails? do
|
270
|
+
describe Puppet::Parser::Collector, "when collecting exported resources", :if => (Puppet.features.rails? and defined? SQLite3) do
|
271
|
+
include PuppetSpec::Files
|
272
|
+
|
266
273
|
before do
|
267
274
|
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
|
268
275
|
@scope = Puppet::Parser::Scope.new :compiler => @compiler
|
269
|
-
@resource_type = "
|
270
|
-
@equery = "
|
276
|
+
@resource_type = "notify"
|
277
|
+
@equery = ["title", "!=", ""]
|
271
278
|
@vquery = proc { |r| true }
|
272
|
-
|
273
|
-
|
274
|
-
res.stubs(:type).returns @resource_type
|
275
|
-
Puppet::Resource.stubs(:new).returns res
|
276
|
-
|
277
|
-
Puppet.settings.stubs(:value).with(:storeconfigs).returns true
|
278
|
-
Puppet.settings.stubs(:value).with(:environment).returns "production"
|
279
|
-
|
280
|
-
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
|
281
|
-
end
|
282
|
-
|
283
|
-
# Stub most of our interface to Rails.
|
284
|
-
def stub_rails(everything = false)
|
285
|
-
ActiveRecord::Base.stubs(:connected?).returns(false)
|
286
|
-
Puppet::Rails.stubs(:init)
|
287
|
-
if everything
|
288
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
289
|
-
Puppet::Rails::Resource.stubs(:find).returns([])
|
290
|
-
end
|
279
|
+
@collector = Puppet::Parser::Collector.new(@scope, @resource_type,
|
280
|
+
@equery, @vquery, :exported)
|
291
281
|
end
|
292
282
|
|
293
283
|
it "should just return false if :storeconfigs is not enabled" do
|
294
|
-
Puppet
|
284
|
+
Puppet[:storeconfigs] = false
|
295
285
|
@collector.evaluate.should be_false
|
296
286
|
end
|
297
287
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
Puppet::Rails.expects(:init)
|
302
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
303
|
-
Puppet::Rails::Resource.stubs(:find).returns([])
|
304
|
-
|
305
|
-
@collector.evaluate
|
306
|
-
end
|
307
|
-
|
308
|
-
it "should return all matching resources from the current compile and mark them non-virtual and non-exported" do
|
309
|
-
stub_rails(true)
|
310
|
-
|
311
|
-
one = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "one"
|
312
|
-
two = stub 'two', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "two"
|
313
|
-
|
314
|
-
one.stubs(:exported=)
|
315
|
-
one.stubs(:virtual=)
|
316
|
-
two.stubs(:exported=)
|
317
|
-
two.stubs(:virtual=)
|
318
|
-
|
319
|
-
@compiler.expects(:resources).returns([one, two])
|
320
|
-
|
321
|
-
@collector.evaluate.should == [one, two]
|
322
|
-
end
|
323
|
-
|
324
|
-
it "should mark all returned resources as not virtual" do
|
325
|
-
stub_rails(true)
|
326
|
-
|
327
|
-
one = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "one"
|
328
|
-
|
329
|
-
one.stubs(:exported=)
|
330
|
-
one.expects(:virtual=).with(false)
|
331
|
-
|
332
|
-
@compiler.expects(:resources).returns([one])
|
333
|
-
|
334
|
-
@collector.evaluate.should == [one]
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should convert all found resources into parser resources" do
|
338
|
-
stub_rails
|
339
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
340
|
-
|
341
|
-
one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
|
342
|
-
Puppet::Rails::Resource.stubs(:find).returns([one])
|
343
|
-
|
344
|
-
resource = mock 'resource'
|
345
|
-
one.expects(:to_resource).with(@scope).returns(resource)
|
346
|
-
resource.stubs(:exported=)
|
347
|
-
resource.stubs(:virtual=)
|
348
|
-
resource.stubs(:ref)
|
349
|
-
|
350
|
-
@compiler.stubs(:resources).returns([])
|
351
|
-
@scope.stubs(:findresource).returns(nil)
|
352
|
-
|
353
|
-
@compiler.stubs(:add_resource)
|
354
|
-
|
355
|
-
@collector.evaluate.should == [resource]
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should override all exported collected resources if collector has an override" do
|
359
|
-
stub_rails
|
360
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
361
|
-
|
362
|
-
one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
|
363
|
-
Puppet::Rails::Resource.stubs(:find).returns([one])
|
364
|
-
|
365
|
-
resource = mock 'resource', :type => "Mytype"
|
366
|
-
one.expects(:to_resource).with(@scope).returns(resource)
|
367
|
-
resource.stubs(:exported=)
|
368
|
-
resource.stubs(:virtual=)
|
369
|
-
resource.stubs(:ref)
|
370
|
-
resource.stubs(:title)
|
371
|
-
|
372
|
-
@compiler.stubs(:resources).returns([])
|
373
|
-
@scope.stubs(:findresource).returns(nil)
|
374
|
-
|
375
|
-
param = stub 'param'
|
376
|
-
@compiler.stubs(:add_override)
|
377
|
-
@compiler.stubs(:add_resource)
|
378
|
-
|
379
|
-
@collector.add_override(:parameters => param )
|
380
|
-
Puppet::Parser::Resource.expects(:new).once.with { |type, title, h|
|
381
|
-
h[:parameters] == param
|
382
|
-
}
|
383
|
-
|
384
|
-
@collector.evaluate
|
385
|
-
end
|
386
|
-
|
387
|
-
it "should store converted resources in the compile's resource list" do
|
388
|
-
stub_rails
|
389
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
390
|
-
|
391
|
-
one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
|
392
|
-
Puppet::Rails::Resource.stubs(:find).returns([one])
|
393
|
-
|
394
|
-
resource = mock 'resource'
|
395
|
-
one.expects(:to_resource).with(@scope).returns(resource)
|
396
|
-
resource.stubs(:exported=)
|
397
|
-
resource.stubs(:virtual=)
|
398
|
-
resource.stubs(:ref)
|
399
|
-
|
400
|
-
@compiler.stubs(:resources).returns([])
|
401
|
-
@scope.stubs(:findresource).returns(nil)
|
402
|
-
|
403
|
-
@compiler.expects(:add_resource).with(@scope, resource)
|
404
|
-
|
405
|
-
@collector.evaluate.should == [resource]
|
406
|
-
end
|
407
|
-
|
408
|
-
# This way one host doesn't store another host's resources as exported.
|
409
|
-
it "should mark resources collected from the database as not exported" do
|
410
|
-
stub_rails
|
411
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
412
|
-
|
413
|
-
one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
|
414
|
-
Puppet::Rails::Resource.stubs(:find).returns([one])
|
415
|
-
|
416
|
-
resource = mock 'resource'
|
417
|
-
one.expects(:to_resource).with(@scope).returns(resource)
|
418
|
-
resource.expects(:exported=).with(false)
|
419
|
-
resource.stubs(:virtual=)
|
420
|
-
resource.stubs(:ref)
|
421
|
-
|
422
|
-
@compiler.stubs(:resources).returns([])
|
423
|
-
@scope.stubs(:findresource).returns(nil)
|
424
|
-
|
425
|
-
@compiler.stubs(:add_resource)
|
426
|
-
|
427
|
-
@collector.evaluate
|
428
|
-
end
|
429
|
-
|
430
|
-
it "should fail if an equivalent resource already exists in the compile" do
|
431
|
-
stub_rails
|
432
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
433
|
-
|
434
|
-
rails = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :id => 1, :ref => "yay"
|
435
|
-
inmemory = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :rails_id => 2
|
436
|
-
|
437
|
-
Puppet::Rails::Resource.stubs(:find).returns([rails])
|
438
|
-
|
439
|
-
resource = mock 'resource'
|
440
|
-
|
441
|
-
@compiler.stubs(:resources).returns([])
|
442
|
-
@scope.stubs(:findresource).returns(inmemory)
|
443
|
-
|
444
|
-
@compiler.stubs(:add_resource)
|
445
|
-
|
446
|
-
proc { @collector.evaluate }.should raise_error(Puppet::ParseError)
|
447
|
-
end
|
448
|
-
|
449
|
-
it "should ignore exported resources that match already-collected resources" do
|
450
|
-
stub_rails
|
451
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
288
|
+
context "with storeconfigs enabled" do
|
289
|
+
before :each do
|
290
|
+
ActiveRecord::Base.remove_connection
|
452
291
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
@scope.stubs(:findresource).returns(inmemory)
|
462
|
-
|
463
|
-
@compiler.stubs(:add_resource)
|
464
|
-
|
465
|
-
proc { @collector.evaluate }.should_not raise_error(Puppet::ParseError)
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources", :if => Puppet.features.rails? do
|
470
|
-
before do
|
471
|
-
@scope = stub 'scope', :host => "myhost", :debug => nil
|
472
|
-
@compiler = mock 'compile'
|
473
|
-
@scope.stubs(:compiler).returns(@compiler)
|
474
|
-
@resource_type = "Mytype"
|
475
|
-
@equery = nil
|
476
|
-
@vquery = proc { |r| true }
|
477
|
-
|
478
|
-
@resource = stub_everything 'collected'
|
479
|
-
|
480
|
-
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
|
481
|
-
@collector.stubs(:exported_resource).with(@resource).returns(@resource)
|
482
|
-
@compiler.stubs(:resources).returns([])
|
483
|
-
|
484
|
-
ActiveRecord::Base.stubs(:connected?).returns(false)
|
485
|
-
|
486
|
-
Puppet::Rails.stubs(:init)
|
487
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
488
|
-
Puppet::Rails::Resource.stubs(:find).returns([])
|
292
|
+
dir = Pathname(tmpdir('puppet-var'))
|
293
|
+
Puppet[:vardir] = dir.to_s
|
294
|
+
Puppet[:dbadapter] = 'sqlite3'
|
295
|
+
Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
|
296
|
+
Puppet[:storeconfigs] = true
|
297
|
+
Puppet[:environment] = "production"
|
298
|
+
Puppet::Rails.init
|
299
|
+
end
|
489
300
|
|
490
|
-
|
491
|
-
|
301
|
+
after :each do
|
302
|
+
ActiveRecord::Base.remove_connection
|
303
|
+
end
|
492
304
|
|
493
|
-
|
494
|
-
|
495
|
-
|
305
|
+
it "should return all matching resources from the current compile and mark them non-virtual and non-exported" do
|
306
|
+
one = Puppet::Parser::Resource.new('notify', 'one',
|
307
|
+
:virtual => true,
|
308
|
+
:exported => true,
|
309
|
+
:scope => @scope)
|
310
|
+
two = Puppet::Parser::Resource.new('notify', 'two',
|
311
|
+
:virtual => true,
|
312
|
+
:exported => true,
|
313
|
+
:scope => @scope)
|
314
|
+
|
315
|
+
@compiler.resources << one
|
316
|
+
@compiler.resources << two
|
317
|
+
|
318
|
+
@collector.evaluate.should == [one, two]
|
319
|
+
one.should_not be_virtual
|
320
|
+
two.should_not be_virtual
|
321
|
+
|
322
|
+
# REVISIT: Apparently we never actually marked local resources as
|
323
|
+
# non-exported. So, this is what the previous test asserted, and checking
|
324
|
+
# what it claims to do causes test failures. --daniel 2011-08-23
|
325
|
+
end
|
496
326
|
|
497
|
-
|
327
|
+
it "should mark all returned resources as not virtual" do
|
328
|
+
one = Puppet::Parser::Resource.new('notify', 'one',
|
329
|
+
:virtual => true,
|
330
|
+
:exported => true,
|
331
|
+
:scope => @scope)
|
498
332
|
|
499
|
-
|
500
|
-
options = arguments[1]
|
501
|
-
options[:conditions][0] =~ /^host_id != \?/ and options[:conditions][1] == 5
|
502
|
-
}.returns([@resource])
|
333
|
+
@compiler.resources << one
|
503
334
|
|
504
|
-
|
505
|
-
|
335
|
+
@collector.evaluate.should == [one]
|
336
|
+
one.should_not be_virtual
|
337
|
+
end
|
506
338
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
339
|
+
it "should convert all found resources into parser resources" do
|
340
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
341
|
+
Puppet::Rails::Resource.
|
342
|
+
create!(:host => host,
|
343
|
+
:restype => 'notify', :title => 'whammo',
|
344
|
+
:exported => true)
|
345
|
+
|
346
|
+
result = @collector.evaluate
|
347
|
+
result.length.should == 1
|
348
|
+
result.first.should be_an_instance_of Puppet::Parser::Resource
|
349
|
+
result.first.type.should == 'Notify'
|
350
|
+
result.first.title.should == 'whammo'
|
351
|
+
end
|
513
352
|
|
514
|
-
|
515
|
-
|
353
|
+
it "should override all exported collected resources if collector has an override" do
|
354
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
355
|
+
Puppet::Rails::Resource.
|
356
|
+
create!(:host => host,
|
357
|
+
:restype => 'notify', :title => 'whammo',
|
358
|
+
:exported => true)
|
516
359
|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
options = arguments[1]
|
521
|
-
options[:joins] == {:resource_tags => :puppet_tag}
|
522
|
-
}.returns([@resource])
|
360
|
+
param = Puppet::Parser::Resource::Param.
|
361
|
+
new(:name => 'message', :value => 'howdy')
|
362
|
+
@collector.add_override(:parameters => [param], :scope => @scope)
|
523
363
|
|
524
|
-
|
525
|
-
|
364
|
+
got = @collector.evaluate
|
365
|
+
got.first[:message].should == param.value
|
366
|
+
end
|
526
367
|
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
368
|
+
it "should store converted resources in the compile's resource list" do
|
369
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
370
|
+
Puppet::Rails::Resource.
|
371
|
+
create!(:host => host,
|
372
|
+
:restype => 'notify', :title => 'whammo',
|
373
|
+
:exported => true)
|
374
|
+
|
375
|
+
@compiler.expects(:add_resource).with do |scope, resource|
|
376
|
+
scope.should be_an_instance_of Puppet::Parser::Scope
|
377
|
+
resource.type.should == 'Notify'
|
378
|
+
resource.title.should == 'whammo'
|
379
|
+
true
|
380
|
+
end
|
381
|
+
|
382
|
+
@collector.evaluate
|
383
|
+
end
|
533
384
|
|
534
|
-
|
535
|
-
|
385
|
+
# This way one host doesn't store another host's resources as exported.
|
386
|
+
it "should mark resources collected from the database as not exported" do
|
387
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
388
|
+
Puppet::Rails::Resource.
|
389
|
+
create!(:host => host,
|
390
|
+
:restype => 'notify', :title => 'whammo',
|
391
|
+
:exported => true)
|
392
|
+
|
393
|
+
got = @collector.evaluate
|
394
|
+
got.length.should == 1
|
395
|
+
got.first.type.should == "Notify"
|
396
|
+
got.first.title.should == "whammo"
|
397
|
+
got.first.should_not be_exported
|
398
|
+
end
|
536
399
|
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
400
|
+
it "should fail if an equivalent resource already exists in the compile" do
|
401
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
402
|
+
Puppet::Rails::Resource.
|
403
|
+
create!(:host => host,
|
404
|
+
:restype => 'notify', :title => 'whammo',
|
405
|
+
:exported => true)
|
542
406
|
|
543
|
-
|
544
|
-
|
407
|
+
local = Puppet::Parser::Resource.new('notify', 'whammo', :scope => @scope)
|
408
|
+
@compiler.add_resource(@scope, local)
|
545
409
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
options = arguments[1]
|
550
|
-
options[:conditions][0].include?("test = true")
|
551
|
-
}.returns([@resource])
|
410
|
+
expect { @collector.evaluate }.
|
411
|
+
to raise_error Puppet::ParseError, /cannot override local resource/
|
412
|
+
end
|
552
413
|
|
553
|
-
|
414
|
+
it "should ignore exported resources that match already-collected resources" do
|
415
|
+
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
416
|
+
# One that we already collected...
|
417
|
+
db = Puppet::Rails::Resource.
|
418
|
+
create!(:host => host,
|
419
|
+
:restype => 'notify', :title => 'whammo',
|
420
|
+
:exported => true)
|
421
|
+
# ...and one we didn't.
|
422
|
+
Puppet::Rails::Resource.
|
423
|
+
create!(:host => host,
|
424
|
+
:restype => 'notify', :title => 'boingy-boingy',
|
425
|
+
:exported => true)
|
426
|
+
|
427
|
+
local = Puppet::Parser::Resource.new('notify', 'whammo',
|
428
|
+
:scope => @scope,
|
429
|
+
:collector_id => db.id)
|
430
|
+
@compiler.add_resource(@scope, local)
|
431
|
+
|
432
|
+
got = nil
|
433
|
+
expect { got = @collector.evaluate }.not_to raise_error(Puppet::ParseError)
|
434
|
+
got.length.should == 1
|
435
|
+
got.first.type.should == "Notify"
|
436
|
+
got.first.title.should == "boingy-boingy"
|
437
|
+
end
|
554
438
|
end
|
555
439
|
end
|