puppet 2.7.9 → 2.7.11

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.

Files changed (187) hide show
  1. data/CHANGELOG +413 -0
  2. data/README_DEVELOPER.md +28 -0
  3. data/conf/redhat/puppet.spec +10 -1
  4. data/conf/solaris/pkginfo +1 -1
  5. data/conf/suse/puppet.spec +7 -4
  6. data/ext/envpuppet.bat +13 -0
  7. data/ext/rack/files/apache2.conf +4 -0
  8. data/install.rb +4 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/agent.rb +7 -0
  11. data/lib/puppet/agent/disabler.rb +27 -0
  12. data/lib/puppet/agent/locker.rb +0 -10
  13. data/lib/puppet/application.rb +3 -0
  14. data/lib/puppet/application/agent.rb +13 -3
  15. data/lib/puppet/application/apply.rb +6 -6
  16. data/lib/puppet/application/cert.rb +5 -5
  17. data/lib/puppet/application/instrumentation_data.rb +4 -0
  18. data/lib/puppet/application/instrumentation_listener.rb +4 -0
  19. data/lib/puppet/application/instrumentation_probe.rb +4 -0
  20. data/lib/puppet/configurer.rb +3 -1
  21. data/lib/puppet/configurer/downloader.rb +4 -2
  22. data/lib/puppet/configurer/fact_handler.rb +0 -21
  23. data/lib/puppet/daemon.rb +3 -4
  24. data/lib/puppet/defaults.rb +2 -2
  25. data/lib/puppet/face/instrumentation_data.rb +28 -0
  26. data/lib/puppet/face/instrumentation_listener.rb +96 -0
  27. data/lib/puppet/face/instrumentation_probe.rb +77 -0
  28. data/lib/puppet/face/module/list.rb +64 -0
  29. data/lib/puppet/face/module/uninstall.rb +50 -0
  30. data/lib/puppet/face/node/clean.rb +1 -4
  31. data/lib/puppet/feature/base.rb +1 -0
  32. data/lib/puppet/file_serving/content.rb +1 -1
  33. data/lib/puppet/indirector/facts/facter.rb +20 -7
  34. data/lib/puppet/indirector/facts/inventory_active_record.rb +14 -11
  35. data/lib/puppet/indirector/indirection.rb +7 -0
  36. data/lib/puppet/indirector/instrumentation_data.rb +3 -0
  37. data/lib/puppet/indirector/instrumentation_data/local.rb +19 -0
  38. data/lib/puppet/indirector/instrumentation_data/rest.rb +5 -0
  39. data/lib/puppet/indirector/instrumentation_listener.rb +3 -0
  40. data/lib/puppet/indirector/instrumentation_listener/local.rb +23 -0
  41. data/lib/puppet/indirector/instrumentation_listener/rest.rb +5 -0
  42. data/lib/puppet/indirector/instrumentation_probe.rb +3 -0
  43. data/lib/puppet/indirector/instrumentation_probe/local.rb +24 -0
  44. data/lib/puppet/indirector/instrumentation_probe/rest.rb +5 -0
  45. data/lib/puppet/indirector/rest.rb +1 -1
  46. data/lib/puppet/module.rb +13 -17
  47. data/lib/puppet/module_tool/applications.rb +1 -0
  48. data/lib/puppet/module_tool/applications/uninstaller.rb +33 -0
  49. data/lib/puppet/module_tool/contents_description.rb +1 -1
  50. data/lib/puppet/network/server.rb +2 -3
  51. data/lib/puppet/node/environment.rb +16 -3
  52. data/lib/puppet/parser/ast/leaf.rb +1 -1
  53. data/lib/puppet/parser/functions/create_resources.rb +1 -1
  54. data/lib/puppet/parser/type_loader.rb +1 -1
  55. data/lib/puppet/property.rb +46 -14
  56. data/lib/puppet/provider.rb +13 -4
  57. data/lib/puppet/provider/augeas/augeas.rb +6 -4
  58. data/lib/puppet/provider/group/pw.rb +24 -10
  59. data/lib/puppet/provider/nameservice/directoryservice.rb +146 -37
  60. data/lib/puppet/provider/package/pip.rb +1 -1
  61. data/lib/puppet/provider/package/yum.rb +1 -2
  62. data/lib/puppet/provider/service/debian.rb +14 -0
  63. data/lib/puppet/provider/service/launchd.rb +1 -1
  64. data/lib/puppet/provider/service/smf.rb +2 -2
  65. data/lib/puppet/provider/user/pw.rb +56 -2
  66. data/lib/puppet/provider/user/user_role_add.rb +32 -22
  67. data/lib/puppet/provider/user/windows_adsi.rb +1 -0
  68. data/lib/puppet/rails/benchmark.rb +1 -1
  69. data/lib/puppet/reports/store.rb +8 -1
  70. data/lib/puppet/resource/catalog.rb +5 -1
  71. data/lib/puppet/simple_graph.rb +11 -14
  72. data/lib/puppet/transaction.rb +10 -4
  73. data/lib/puppet/transaction/report.rb +9 -3
  74. data/lib/puppet/type.rb +19 -7
  75. data/lib/puppet/type/exec.rb +1 -1
  76. data/lib/puppet/type/file.rb +4 -1
  77. data/lib/puppet/type/file/ensure.rb +5 -1
  78. data/lib/puppet/type/file/mode.rb +45 -10
  79. data/lib/puppet/type/file/source.rb +4 -0
  80. data/lib/puppet/type/host.rb +17 -3
  81. data/lib/puppet/type/k5login.rb +3 -2
  82. data/lib/puppet/type/schedule.rb +3 -2
  83. data/lib/puppet/util.rb +83 -27
  84. data/lib/puppet/util/anonymous_filelock.rb +36 -0
  85. data/lib/puppet/util/docs.rb +18 -2
  86. data/lib/puppet/util/instrumentation.rb +173 -0
  87. data/lib/puppet/util/instrumentation/data.rb +34 -0
  88. data/lib/puppet/util/instrumentation/indirection_probe.rb +29 -0
  89. data/lib/puppet/util/instrumentation/instrumentable.rb +143 -0
  90. data/lib/puppet/util/instrumentation/listener.rb +60 -0
  91. data/lib/puppet/util/instrumentation/listeners/log.rb +29 -0
  92. data/lib/puppet/util/instrumentation/listeners/performance.rb +30 -0
  93. data/lib/puppet/util/monkey_patches.rb +8 -0
  94. data/lib/puppet/util/pidlock.rb +21 -25
  95. data/lib/puppet/util/rdoc/parser.rb +2 -2
  96. data/lib/puppet/util/reference.rb +8 -23
  97. data/lib/puppet/util/retryaction.rb +48 -0
  98. data/lib/puppet/util/suidmanager.rb +70 -39
  99. data/lib/puppet/util/symbolic_file_mode.rb +140 -0
  100. data/spec/integration/configurer_spec.rb +5 -0
  101. data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
  102. data/spec/integration/indirector/file_content/file_server_spec.rb +7 -7
  103. data/spec/integration/provider/package_spec.rb +7 -0
  104. data/spec/unit/agent/disabler_spec.rb +60 -0
  105. data/spec/unit/agent/locker_spec.rb +0 -12
  106. data/spec/unit/agent_spec.rb +8 -0
  107. data/spec/unit/application/agent_spec.rb +38 -1
  108. data/spec/unit/application/apply_spec.rb +34 -40
  109. data/spec/unit/application/cert_spec.rb +1 -1
  110. data/spec/unit/application_spec.rb +6 -0
  111. data/spec/unit/configurer/downloader_spec.rb +29 -10
  112. data/spec/unit/configurer/fact_handler_spec.rb +5 -29
  113. data/spec/unit/configurer_spec.rb +8 -8
  114. data/spec/unit/daemon_spec.rb +12 -26
  115. data/spec/unit/face/instrumentation_data.rb +7 -0
  116. data/spec/unit/face/instrumentation_listener.rb +38 -0
  117. data/spec/unit/face/instrumentation_probe.rb +21 -0
  118. data/spec/unit/face/node_spec.rb +111 -111
  119. data/spec/unit/file_serving/content_spec.rb +2 -2
  120. data/spec/unit/indirector/facts/facter_spec.rb +25 -3
  121. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +14 -4
  122. data/spec/unit/indirector/instrumentation_data/local_spec.rb +52 -0
  123. data/spec/unit/indirector/instrumentation_data/rest_spec.rb +11 -0
  124. data/spec/unit/indirector/instrumentation_listener/local_spec.rb +65 -0
  125. data/spec/unit/indirector/instrumentation_listener/rest_spec.rb +11 -0
  126. data/spec/unit/indirector/instrumentation_probe/local_spec.rb +65 -0
  127. data/spec/unit/indirector/instrumentation_probe/rest_spec.rb +11 -0
  128. data/spec/unit/module_spec.rb +39 -125
  129. data/spec/unit/module_tool/uninstaller_spec.rb +44 -0
  130. data/spec/unit/network/server_spec.rb +2 -20
  131. data/spec/unit/node/environment_spec.rb +76 -58
  132. data/spec/unit/parser/ast/asthash_spec.rb +1 -2
  133. data/spec/unit/parser/ast/leaf_spec.rb +16 -0
  134. data/spec/unit/property/keyvalue_spec.rb +5 -2
  135. data/spec/unit/property_spec.rb +260 -159
  136. data/spec/unit/provider/augeas/augeas_spec.rb +2 -2
  137. data/spec/unit/provider/group/pw_spec.rb +81 -0
  138. data/spec/unit/provider/nameservice/directoryservice_spec.rb +102 -0
  139. data/spec/unit/provider/package/pip_spec.rb +7 -0
  140. data/spec/unit/provider/package/yum_spec.rb +45 -1
  141. data/spec/unit/provider/service/debian_spec.rb +15 -0
  142. data/spec/unit/provider/service/launchd_spec.rb +48 -43
  143. data/spec/unit/provider/service/smf_spec.rb +3 -3
  144. data/spec/unit/provider/user/pw_spec.rb +183 -0
  145. data/spec/unit/provider/user/user_role_add_spec.rb +46 -39
  146. data/spec/unit/provider/user/windows_adsi_spec.rb +1 -0
  147. data/spec/unit/provider_spec.rb +32 -0
  148. data/spec/unit/reports/store_spec.rb +19 -1
  149. data/spec/unit/simple_graph_spec.rb +34 -19
  150. data/spec/unit/ssl/certificate_factory_spec.rb +3 -3
  151. data/spec/unit/transaction/report_spec.rb +29 -1
  152. data/spec/unit/transaction_spec.rb +32 -46
  153. data/spec/unit/type/file/mode_spec.rb +1 -1
  154. data/spec/unit/type/file/source_spec.rb +28 -3
  155. data/spec/unit/type/file_spec.rb +17 -16
  156. data/spec/unit/type/host_spec.rb +527 -0
  157. data/spec/unit/type/k5login_spec.rb +115 -0
  158. data/spec/unit/type/schedule_spec.rb +6 -6
  159. data/spec/unit/type_spec.rb +51 -0
  160. data/spec/unit/util/anonymous_filelock_spec.rb +78 -0
  161. data/spec/unit/util/execution_stub_spec.rb +2 -1
  162. data/spec/unit/util/instrumentation/data_spec.rb +44 -0
  163. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +19 -0
  164. data/spec/unit/util/instrumentation/instrumentable_spec.rb +186 -0
  165. data/spec/unit/util/instrumentation/listener_spec.rb +100 -0
  166. data/spec/unit/util/instrumentation/listeners/log_spec.rb +34 -0
  167. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +36 -0
  168. data/spec/unit/util/instrumentation_spec.rb +181 -0
  169. data/spec/unit/util/pidlock_spec.rb +208 -0
  170. data/spec/unit/util/rdoc/parser_spec.rb +1 -1
  171. data/spec/unit/util/reference_spec.rb +16 -6
  172. data/spec/unit/util/retryaction_spec.rb +62 -0
  173. data/spec/unit/util/suidmanager_spec.rb +101 -83
  174. data/spec/unit/util/symbolic_file_mode_spec.rb +182 -0
  175. data/spec/unit/util_spec.rb +126 -0
  176. data/tasks/rake/apple.rake +176 -0
  177. data/tasks/rake/templates/prototype.plist.erb +38 -0
  178. metadata +61 -13
  179. data/lib/puppet/application/module.rb +0 -3
  180. data/lib/puppet/face/module.rb +0 -12
  181. data/spec/unit/face/module/build_spec.rb +0 -30
  182. data/spec/unit/face/module/changes_spec.rb +0 -30
  183. data/spec/unit/face/module/clean_spec.rb +0 -30
  184. data/spec/unit/face/module/generate_spec.rb +0 -30
  185. data/spec/unit/face/module/install_spec.rb +0 -75
  186. data/spec/unit/face/module/search_spec.rb +0 -40
  187. data/test/util/pidlock.rb +0 -126
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+ require 'puppet/face'
4
+
5
+ describe Puppet::Face[:instrumentation_data, '0.0.1'] do
6
+ it_should_behave_like "an indirector face"
7
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+ require 'puppet/face'
4
+
5
+ describe Puppet::Face[:instrumentation_listener, '0.0.1'] do
6
+ it_should_behave_like "an indirector face"
7
+
8
+ [:enable, :disable].each do |m|
9
+ describe "when running ##{m}" do
10
+ before(:each) do
11
+ @listener = stub_everything 'listener'
12
+ Puppet::Face[:instrumentation_listener, '0.0.1'].stubs(:find).returns(@listener)
13
+ Puppet::Face[:instrumentation_listener, '0.0.1'].stubs(:save)
14
+ Puppet::Util::Instrumentation::Listener.indirection.stubs(:terminus_class=)
15
+ end
16
+
17
+ it "should force the REST terminus" do
18
+ Puppet::Util::Instrumentation::Listener.indirection.expects(:terminus_class=).with(:rest)
19
+ subject.send(m, "dummy")
20
+ end
21
+
22
+ it "should find the named listener" do
23
+ Puppet::Face[:instrumentation_listener, '0.0.1'].expects(:find).with("dummy").returns(@listener)
24
+ subject.send(m, "dummy")
25
+ end
26
+
27
+ it "should #{m} the named listener" do
28
+ @listener.expects(:enabled=).with( m == :enable )
29
+ subject.send(m, "dummy")
30
+ end
31
+
32
+ it "should save finally the listener" do
33
+ Puppet::Face[:instrumentation_listener, '0.0.1'].expects(:save).with(@listener)
34
+ subject.send(m, "dummy")
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+ require 'puppet/face'
4
+
5
+ describe Puppet::Face[:instrumentation_probe, '0.0.1'] do
6
+ it_should_behave_like "an indirector face"
7
+
8
+ describe 'when running #enable' do
9
+ it 'should invoke #save' do
10
+ subject.expects(:save).with(nil)
11
+ subject.enable('hostname')
12
+ end
13
+ end
14
+
15
+ describe 'when running #disable' do
16
+ it 'should invoke #destroy' do
17
+ subject.expects(:destroy).with(nil)
18
+ subject.disable('hostname')
19
+ end
20
+ end
21
+ end
@@ -14,9 +14,7 @@ describe Puppet::Face[:node, '0.0.1'] do
14
14
  "cached_facts" => ['hostname'],
15
15
  "cached_node" => ['hostname'],
16
16
  "reports" => ['hostname'],
17
-
18
- # Support for cleaning storeconfigs has been temporarily suspended.
19
- # "storeconfigs" => ['hostname', :unexport]
17
+ "storeconfigs" => ['hostname', :unexport]
20
18
  }.each { |k, v| subject.expects("clean_#{k}".to_sym).with(*v) }
21
19
  subject.cleanup('hostname', :unexport)
22
20
  end
@@ -158,114 +156,116 @@ describe Puppet::Face[:node, '0.0.1'] do
158
156
  end
159
157
  end
160
158
 
161
- # describe "when cleaning storeconfigs entries for host", :if => Puppet.features.rails? do
162
- # before :each do
163
- # # Stub this so we don't need access to the DB
164
- # require 'puppet/rails/host'
165
- #
166
- # Puppet.stubs(:[]).with(:storeconfigs).returns(true)
167
- #
168
- # Puppet::Rails.stubs(:connect)
169
- # @rails_node = stub_everything 'rails_node'
170
- # Puppet::Rails::Host.stubs(:find_by_name).returns(@rails_node)
171
- # end
172
- #
173
- # it "should connect to the database" do
174
- # Puppet::Rails.expects(:connect)
175
- # subject.clean_storeconfigs(@host, false)
176
- # end
177
- #
178
- # it "should find the right host entry" do
179
- # Puppet::Rails::Host.expects(:find_by_name).with(@host).returns(@rails_node)
180
- # subject.clean_storeconfigs(@host, false)
181
- # end
182
- #
183
- # describe "without unexport" do
184
- # it "should remove the host and it's content" do
185
- # @rails_node.expects(:destroy)
186
- # subject.clean_storeconfigs(@host, false)
187
- # end
188
- # end
189
- #
190
- # describe "with unexport" do
191
- # before :each do
192
- # @rails_node.stubs(:id).returns(1234)
193
- #
194
- # @type = stub_everything 'type'
195
- # @type.stubs(:validattr?).with(:ensure).returns(true)
196
- #
197
- # @ensure_name = stub_everything 'ensure_name', :id => 23453
198
- # Puppet::Rails::ParamName.stubs(:find_or_create_by_name).returns(@ensure_name)
199
- #
200
- # @param_values = stub_everything 'param_values'
201
- # @resource = stub_everything 'resource', :param_values => @param_values, :restype => "File"
202
- # Puppet::Rails::Resource.stubs(:find).returns([@resource])
203
- # end
204
- #
205
- # it "should find all resources" do
206
- # Puppet::Rails::Resource.expects(:find).with(:all, {:include => {:param_values => :param_name}, :conditions => ["exported=? AND host_id=?", true, 1234]}).returns([])
207
- #
208
- # subject.clean_storeconfigs(@host, true)
209
- # end
210
- #
211
- # describe "with an exported native type" do
212
- # before :each do
213
- # Puppet::Type.stubs(:type).returns(@type)
214
- # @type.expects(:validattr?).with(:ensure).returns(true)
215
- # end
216
- #
217
- # it "should test a native type for ensure as an attribute" do
218
- # subject.clean_storeconfigs(@host, true)
219
- # end
220
- #
221
- # it "should delete the old ensure parameter" do
222
- # ensure_param = stub 'ensure_param', :id => 12345, :line => 12
223
- # @param_values.stubs(:find).returns(ensure_param)
224
- # Puppet::Rails::ParamValue.expects(:delete).with(12345);
225
- # subject.clean_storeconfigs(@host, true)
226
- # end
227
- #
228
- # it "should add an ensure => absent parameter" do
229
- # @param_values.expects(:create).with(:value => "absent",
230
- # :line => 0,
231
- # :param_name => @ensure_name)
232
- # subject.clean_storeconfigs(@host, true)
233
- # end
234
- # end
235
- #
236
- # describe "with an exported definition" do
237
- # it "should try to lookup a definition and test it for the ensure argument" do
238
- # Puppet::Type.stubs(:type).returns(nil)
239
- # definition = stub_everything 'definition', :arguments => { 'ensure' => 'present' }
240
- # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition)
241
- # subject.clean_storeconfigs(@host, true)
242
- # end
243
- # end
244
- #
245
- # it "should not unexport the resource of an unknown type" do
246
- # Puppet::Type.stubs(:type).returns(nil)
247
- # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil)
248
- # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
249
- # subject.clean_storeconfigs(@host)
250
- # end
251
- #
252
- # it "should not unexport the resource of a not ensurable native type" do
253
- # Puppet::Type.stubs(:type).returns(@type)
254
- # @type.expects(:validattr?).with(:ensure).returns(false)
255
- # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil)
256
- # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
257
- # subject.clean_storeconfigs(@host, true)
258
- # end
259
- #
260
- # it "should not unexport the resource of a not ensurable definition" do
261
- # Puppet::Type.stubs(:type).returns(nil)
262
- # definition = stub_everything 'definition', :arguments => { 'foobar' => 'someValue' }
263
- # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition)
264
- # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
265
- # subject.clean_storeconfigs(@host, true)
266
- # end
267
- # end
268
- # end
159
+ describe "when cleaning storeconfigs entries for host", :if => Puppet.features.rails? do
160
+ before :each do
161
+ # Stub this so we don't need access to the DB
162
+ require 'puppet/rails/host'
163
+
164
+ Puppet.stubs(:[]).with(:storeconfigs).returns(true)
165
+
166
+ Puppet::Rails.stubs(:connect)
167
+ @rails_node = stub_everything 'rails_node'
168
+ Puppet::Rails::Host.stubs(:find_by_name).returns(@rails_node)
169
+ end
170
+
171
+ it "should connect to the database" do
172
+ Puppet::Rails.expects(:connect)
173
+ subject.clean_storeconfigs(@host, false)
174
+ end
175
+
176
+ it "should find the right host entry" do
177
+ Puppet::Rails::Host.expects(:find_by_name).with(@host).returns(@rails_node)
178
+
179
+ subject.clean_storeconfigs(@host, false)
180
+ end
181
+
182
+ describe "without unexport" do
183
+ it "should remove the host and it's content" do
184
+ @rails_node.expects(:destroy)
185
+
186
+ subject.clean_storeconfigs(@host, false)
187
+ end
188
+ end
189
+
190
+ describe "with unexport" do
191
+ before :each do
192
+ @rails_node.stubs(:id).returns(1234)
193
+
194
+ @type = stub_everything 'type'
195
+ @type.stubs(:validattr?).with(:ensure).returns(true)
196
+
197
+ @ensure_name = stub_everything 'ensure_name', :id => 23453
198
+ Puppet::Rails::ParamName.stubs(:find_or_create_by_name).returns(@ensure_name)
199
+
200
+ @param_values = stub_everything 'param_values'
201
+ @resource = stub_everything 'resource', :param_values => @param_values, :restype => "File"
202
+ Puppet::Rails::Resource.stubs(:find).returns([@resource])
203
+ end
204
+
205
+ it "should find all resources" do
206
+ Puppet::Rails::Resource.expects(:find).with(:all, {:include => {:param_values => :param_name}, :conditions => ["exported=? AND host_id=?", true, 1234]}).returns([])
207
+
208
+ subject.clean_storeconfigs(@host, true)
209
+ end
210
+
211
+ describe "with an exported native type" do
212
+ before :each do
213
+ Puppet::Type.stubs(:type).returns(@type)
214
+ @type.expects(:validattr?).with(:ensure).returns(true)
215
+ end
216
+
217
+ it "should test a native type for ensure as an attribute" do
218
+ subject.clean_storeconfigs(@host, true)
219
+ end
220
+
221
+ it "should delete the old ensure parameter" do
222
+ ensure_param = stub 'ensure_param', :id => 12345, :line => 12
223
+ @param_values.stubs(:find).returns(ensure_param)
224
+ Puppet::Rails::ParamValue.expects(:delete).with(12345);
225
+ subject.clean_storeconfigs(@host, true)
226
+ end
227
+
228
+ it "should add an ensure => absent parameter" do
229
+ @param_values.expects(:create).with(:value => "absent",
230
+ :line => 0,
231
+ :param_name => @ensure_name)
232
+ subject.clean_storeconfigs(@host, true)
233
+ end
234
+ end
235
+
236
+ describe "with an exported definition" do
237
+ it "should try to lookup a definition and test it for the ensure argument" do
238
+ Puppet::Type.stubs(:type).returns(nil)
239
+ definition = stub_everything 'definition', :arguments => { 'ensure' => 'present' }
240
+ Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition)
241
+ subject.clean_storeconfigs(@host, true)
242
+ end
243
+ end
244
+
245
+ it "should not unexport the resource of an unkown type" do
246
+ Puppet::Type.stubs(:type).returns(nil)
247
+ Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil)
248
+ Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
249
+ subject.clean_storeconfigs(@host, true)
250
+ end
251
+
252
+ it "should not unexport the resource of a not ensurable native type" do
253
+ Puppet::Type.stubs(:type).returns(@type)
254
+ @type.expects(:validattr?).with(:ensure).returns(false)
255
+ Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil)
256
+ Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
257
+ subject.clean_storeconfigs(@host, true)
258
+ end
259
+
260
+ it "should not unexport the resource of a not ensurable definition" do
261
+ Puppet::Type.stubs(:type).returns(nil)
262
+ definition = stub_everything 'definition', :arguments => { 'foobar' => 'someValue' }
263
+ Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition)
264
+ Puppet::Rails::ParamName.expects(:find_or_create_by_name).never
265
+ subject.clean_storeconfigs(@host, true)
266
+ end
267
+ end
268
+ end
269
269
  end
270
270
  end
271
271
  end
@@ -102,13 +102,13 @@ describe Puppet::FileServing::Content, "when returning the contents" do
102
102
 
103
103
  it "should return the contents of the path if the file exists" do
104
104
  File.expects(:stat).with(@path).returns stub("stat", :ftype => "file")
105
- File.expects(:read).with(@path).returns(:mycontent)
105
+ Puppet::Util.expects(:binread).with(@path).returns(:mycontent)
106
106
  @content.content.should == :mycontent
107
107
  end
108
108
 
109
109
  it "should cache the returned contents" do
110
110
  File.expects(:stat).with(@path).returns stub("stat", :ftype => "file")
111
- File.expects(:read).with(@path).returns(:mycontent)
111
+ Puppet::Util.expects(:binread).with(@path).returns(:mycontent)
112
112
  @content.content
113
113
 
114
114
  # The second run would throw a failure if the content weren't being cached.
@@ -21,14 +21,29 @@ describe Puppet::Node::Facts::Facter do
21
21
  Puppet::Node::Facts::Facter.name.should == :facter
22
22
  end
23
23
 
24
- it "should load facts on initialization" do
25
- Puppet::Node::Facts::Facter.expects(:load_fact_plugins)
26
- Puppet::Node::Facts::Facter.new
24
+ describe "when reloading Facter" do
25
+ before do
26
+ @facter_class = Puppet::Node::Facts::Facter
27
+ Facter.stubs(:clear)
28
+ Facter.stubs(:load)
29
+ Facter.stubs(:loadfacts)
30
+ end
31
+
32
+ it "should clear Facter" do
33
+ Facter.expects(:clear)
34
+ @facter_class.reload_facter
35
+ end
36
+
37
+ it "should load all Facter facts" do
38
+ Facter.expects(:loadfacts)
39
+ @facter_class.reload_facter
40
+ end
27
41
  end
28
42
  end
29
43
 
30
44
  describe Puppet::Node::Facts::Facter do
31
45
  before :each do
46
+ Puppet::Node::Facts::Facter.stubs(:reload_facter)
32
47
  @facter = Puppet::Node::Facts::Facter.new
33
48
  Facter.stubs(:to_hash).returns({})
34
49
  @name = "me"
@@ -36,6 +51,13 @@ describe Puppet::Node::Facts::Facter do
36
51
  end
37
52
 
38
53
  describe Puppet::Node::Facts::Facter, " when finding facts" do
54
+ it "should reset and load facts" do
55
+ clear = sequence 'clear'
56
+ Puppet::Node::Facts::Facter.expects(:reload_facter).in_sequence(clear)
57
+ Puppet::Node::Facts::Facter.expects(:load_fact_plugins).in_sequence(clear)
58
+ @facter.find(@request)
59
+ end
60
+
39
61
  it "should return a Facts instance" do
40
62
  @facter.find(@request).should be_instance_of(Puppet::Node::Facts)
41
63
  end
@@ -38,10 +38,22 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
38
38
  end
39
39
 
40
40
  describe "#save" do
41
+ let(:node) {
42
+ Puppet::Rails::InventoryNode.new(:name => "foo", :timestamp => Time.now)
43
+ }
44
+
45
+ let(:facts) {
46
+ Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
47
+ }
48
+
49
+ it "should retry on ActiveRecord error" do
50
+ Puppet::Rails::InventoryNode.expects(:create).twice.raises(ActiveRecord::StatementInvalid).returns node
51
+
52
+ Puppet::Node::Facts.indirection.save(facts)
53
+ end
54
+
41
55
  it "should use an existing node if possible" do
42
- node = Puppet::Rails::InventoryNode.new(:name => "foo", :timestamp => Time.now)
43
56
  node.save
44
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
45
57
  Puppet::Node::Facts.indirection.save(facts)
46
58
 
47
59
  Puppet::Rails::InventoryNode.count.should == 1
@@ -52,7 +64,6 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
52
64
  # This test isn't valid if there are nodes to begin with
53
65
  Puppet::Rails::InventoryNode.count.should == 0
54
66
 
55
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
56
67
  Puppet::Node::Facts.indirection.save(facts)
57
68
 
58
69
  Puppet::Rails::InventoryNode.count.should == 1
@@ -60,7 +71,6 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
60
71
  end
61
72
 
62
73
  it "should save the facts" do
63
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
64
74
  Puppet::Node::Facts.indirection.save(facts)
65
75
 
66
76
  Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should =~ [["uptime_days","60"],["kernel","Darwin"]]
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/listener'
5
+ require 'puppet/indirector/instrumentation_data/local'
6
+
7
+ describe Puppet::Indirector::InstrumentationData::Local do
8
+ it "should be a subclass of the Code terminus" do
9
+ Puppet::Indirector::InstrumentationData::Local.superclass.should equal(Puppet::Indirector::Code)
10
+ end
11
+
12
+ it "should be registered with the configuration store indirection" do
13
+ indirection = Puppet::Indirector::Indirection.instance(:instrumentation_data)
14
+ Puppet::Indirector::InstrumentationData::Local.indirection.should equal(indirection)
15
+ end
16
+
17
+ it "should have its name set to :local" do
18
+ Puppet::Indirector::InstrumentationData::Local.name.should == :local
19
+ end
20
+ end
21
+
22
+ describe Puppet::Indirector::InstrumentationData::Local do
23
+ before :each do
24
+ Puppet::Util::Instrumentation.stubs(:listener)
25
+ @data = Puppet::Indirector::InstrumentationData::Local.new
26
+ @name = "me"
27
+ @request = stub 'request', :key => @name
28
+ end
29
+
30
+ describe "when finding instrumentation data" do
31
+ it "should return a Instrumentation Data instance matching the key" do
32
+ end
33
+ end
34
+
35
+ describe "when searching listeners" do
36
+ it "should raise an error" do
37
+ lambda { @data.search(@request) }.should raise_error(Puppet::DevError)
38
+ end
39
+ end
40
+
41
+ describe "when saving listeners" do
42
+ it "should raise an error" do
43
+ lambda { @data.save(@request) }.should raise_error(Puppet::DevError)
44
+ end
45
+ end
46
+
47
+ describe "when destroying listeners" do
48
+ it "should raise an error" do
49
+ lambda { @data.destroy(@reques) }.should raise_error(Puppet::DevError)
50
+ end
51
+ end
52
+ end