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,60 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+ require 'puppet/agent'
4
+ require 'puppet/agent/locker'
5
+
6
+ class LockerTester
7
+ include Puppet::Agent::Disabler
8
+ end
9
+
10
+ describe Puppet::Agent::Disabler do
11
+ before do
12
+ @locker = LockerTester.new
13
+ @locker.stubs(:lockfile_path).returns "/my/lock"
14
+ end
15
+
16
+ it "should use an AnonymousFilelock instance as its disable_lockfile" do
17
+ @locker.disable_lockfile.should be_instance_of(Puppet::Util::AnonymousFilelock)
18
+ end
19
+
20
+ it "should use 'lockfile_path' to determine its disable_lockfile path" do
21
+ @locker.expects(:lockfile_path).returns "/my/lock"
22
+ lock = Puppet::Util::AnonymousFilelock.new("/my/lock")
23
+ Puppet::Util::AnonymousFilelock.expects(:new).with("/my/lock.disabled").returns lock
24
+
25
+ @locker.disable_lockfile
26
+ end
27
+
28
+ it "should reuse the same lock file each time" do
29
+ @locker.disable_lockfile.should equal(@locker.disable_lockfile)
30
+ end
31
+
32
+ it "should lock the anonymous lock when disabled" do
33
+ @locker.disable_lockfile.expects(:lock)
34
+
35
+ @locker.disable
36
+ end
37
+
38
+ it "should disable with a message" do
39
+ @locker.disable_lockfile.expects(:lock).with("disabled because")
40
+
41
+ @locker.disable("disabled because")
42
+ end
43
+
44
+ it "should unlock the anonymous lock when enabled" do
45
+ @locker.disable_lockfile.expects(:unlock)
46
+
47
+ @locker.enable
48
+ end
49
+
50
+ it "should check the lock if it is disabled" do
51
+ @locker.disable_lockfile.expects(:locked?)
52
+
53
+ @locker.disabled?
54
+ end
55
+
56
+ it "should report the disable message when disabled" do
57
+ @locker.disable_lockfile.expects(:message).returns("message")
58
+ @locker.disable_message.should == "message"
59
+ end
60
+ end
@@ -29,18 +29,6 @@ describe Puppet::Agent::Locker do
29
29
  @locker.lockfile.should equal(@locker.lockfile)
30
30
  end
31
31
 
32
- it "should use the lock file to anonymously lock the process when disabled" do
33
- @locker.lockfile.expects(:lock).with(:anonymous => true)
34
-
35
- @locker.disable
36
- end
37
-
38
- it "should use the lock file to anonymously unlock the process when enabled" do
39
- @locker.lockfile.expects(:unlock).with(:anonymous => true)
40
-
41
- @locker.enable
42
- end
43
-
44
32
  it "should have a method that yields when a lock is attained" do
45
33
  @locker.lockfile.expects(:lock).returns true
46
34
 
@@ -24,6 +24,7 @@ describe Puppet::Agent do
24
24
 
25
25
  # So we don't actually try to hit the filesystem.
26
26
  @agent.stubs(:lock).yields
27
+ @agent.stubs(:disabled?).returns(false)
27
28
 
28
29
  # make Puppet::Application safe for stubbing; restore in an :after block; silence warnings for this.
29
30
  without_warnings { Puppet::Application = Class.new(Puppet::Application) }
@@ -76,6 +77,7 @@ describe Puppet::Agent do
76
77
 
77
78
  describe "when being run" do
78
79
  before do
80
+ AgentTestClient.stubs(:lockfile_path).returns "/my/lock"
79
81
  @agent.stubs(:running?).returns false
80
82
  end
81
83
 
@@ -92,6 +94,12 @@ describe Puppet::Agent do
92
94
  @agent.run
93
95
  end
94
96
 
97
+ it "should do nothing if disabled" do
98
+ @agent.expects(:disabled?).returns(true)
99
+ AgentTestClient.expects(:new).never
100
+ @agent.run
101
+ end
102
+
95
103
  it "should use Puppet::Application.controlled_run to manage process state behavior" do
96
104
  calls = sequence('calls')
97
105
  Puppet::Application.expects(:controlled_run).yields.in_sequence(calls)
@@ -91,7 +91,7 @@ describe Puppet::Application::Agent do
91
91
  @puppetd.command_line.stubs(:args).returns([])
92
92
  end
93
93
 
94
- [:centrallogging, :disable, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
94
+ [:centrallogging, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
95
95
  it "should declare handle_#{option} method" do
96
96
  @puppetd.should respond_to("handle_#{option}".to_sym)
97
97
  end
@@ -102,6 +102,24 @@ describe Puppet::Application::Agent do
102
102
  end
103
103
  end
104
104
 
105
+ describe "when handling --disable" do
106
+ it "should declare handle_disable method" do
107
+ @puppetd.should respond_to(:handle_disable)
108
+ end
109
+
110
+ it "should set disable to true" do
111
+ @puppetd.options.stubs(:[]=)
112
+ @puppetd.options.expects(:[]=).with(:disable, true)
113
+ @puppetd.handle_disable('')
114
+ end
115
+
116
+ it "should store disable message" do
117
+ @puppetd.options.stubs(:[]=)
118
+ @puppetd.options.expects(:[]=).with(:disable_message, "message")
119
+ @puppetd.handle_disable('message')
120
+ end
121
+ end
122
+
105
123
  it "should set an existing handler on server" do
106
124
  Puppet::Network::Handler.stubs(:handler).with("handler").returns(true)
107
125
 
@@ -349,6 +367,20 @@ describe Puppet::Application::Agent do
349
367
  end
350
368
  end
351
369
 
370
+ it "should pass the disable message when disabling" do
371
+ @puppetd.options.stubs(:[]).with(:disable).returns(true)
372
+ @puppetd.options.stubs(:[]).with(:disable_message).returns("message")
373
+ @agent.expects(:disable).with("message")
374
+ expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
375
+ end
376
+
377
+ it "should pass the default disable message when disabling without a message" do
378
+ @puppetd.options.stubs(:[]).with(:disable).returns(true)
379
+ @puppetd.options.stubs(:[]).with(:disable_message).returns(nil)
380
+ @agent.expects(:disable).with("reason not specified")
381
+ expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
382
+ end
383
+
352
384
  it "should finally exit" do
353
385
  expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
354
386
  end
@@ -523,6 +555,11 @@ describe Puppet::Application::Agent do
523
555
  expect { @puppetd.onetime }.to exit_with 0
524
556
  end
525
557
 
558
+ it "should stop the daemon" do
559
+ @daemon.expects(:stop).with(:exit => false)
560
+ expect { @puppetd.onetime }.to exit_with 0
561
+ end
562
+
526
563
  describe "and --detailed-exitcodes" do
527
564
  before :each do
528
565
  @puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
@@ -210,52 +210,12 @@ describe Puppet::Application::Apply do
210
210
  expect { @apply.main }.to exit_with 0
211
211
  end
212
212
 
213
- it "should set the facts name based on the node_name_fact" do
214
- @facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
215
- Puppet::Node::Facts.indirection.save(@facts)
216
-
217
- node = Puppet::Node.new('other_node_name')
218
- Puppet::Node.indirection.save(node)
219
-
220
- Puppet[:node_name_fact] = 'my_name_fact'
221
-
222
- expect { @apply.main }.to exit_with 0
223
-
224
- @facts.name.should == 'other_node_name'
225
- end
226
-
227
- it "should set the node_name_value based on the node_name_fact" do
228
- facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
229
- Puppet::Node::Facts.indirection.save(facts)
230
- node = Puppet::Node.new('other_node_name')
231
- Puppet::Node.indirection.save(node)
232
- Puppet[:node_name_fact] = 'my_name_fact'
233
-
234
- expect { @apply.main }.to exit_with 0
235
-
236
- Puppet[:node_name_value].should == 'other_node_name'
237
- end
238
-
239
- it "should raise an error if we can't find the facts" do
240
- Puppet::Node::Facts.indirection.expects(:find).returns(nil)
241
-
242
- lambda { @apply.main }.should raise_error
243
- end
244
-
245
213
  it "should raise an error if we can't find the node" do
246
214
  Puppet::Node.indirection.expects(:find).returns(nil)
247
215
 
248
216
  lambda { @apply.main }.should raise_error
249
217
  end
250
218
 
251
- it "should merge in our node the loaded facts" do
252
- @facts.values = {'key' => 'value'}
253
-
254
- expect { @apply.main }.to exit_with 0
255
-
256
- @node.parameters['key'].should == 'value'
257
- end
258
-
259
219
  it "should load custom classes if loadclasses" do
260
220
  @apply.options[:loadclasses] = true
261
221
  classfile = tmpfile('classfile')
@@ -308,6 +268,40 @@ describe Puppet::Application::Apply do
308
268
  expect { @apply.main }.to exit_with 0
309
269
  end
310
270
 
271
+ describe "when using node_name_fact" do
272
+ before :each do
273
+ @facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
274
+ Puppet::Node::Facts.indirection.save(@facts)
275
+ @node = Puppet::Node.new('other_node_name')
276
+ Puppet::Node.indirection.save(@node)
277
+ Puppet[:node_name_fact] = 'my_name_fact'
278
+ end
279
+
280
+ it "should set the facts name based on the node_name_fact" do
281
+ expect { @apply.main }.to exit_with 0
282
+ @facts.name.should == 'other_node_name'
283
+ end
284
+
285
+ it "should set the node_name_value based on the node_name_fact" do
286
+ expect { @apply.main }.to exit_with 0
287
+ Puppet[:node_name_value].should == 'other_node_name'
288
+ end
289
+
290
+ it "should merge in our node the loaded facts" do
291
+ @facts.values.merge!('key' => 'value')
292
+
293
+ expect { @apply.main }.to exit_with 0
294
+
295
+ @node.parameters['key'].should == 'value'
296
+ end
297
+
298
+ it "should raise an error if we can't find the facts" do
299
+ Puppet::Node::Facts.indirection.expects(:find).returns(nil)
300
+
301
+ lambda { @apply.main }.should raise_error
302
+ end
303
+ end
304
+
311
305
  describe "with detailed_exitcodes" do
312
306
  before :each do
313
307
  @apply.options[:detailed_exitcodes] = true
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
  require 'puppet/application/cert'
4
4
 
5
- describe Puppet::Application::Cert, :'fails_on_ruby_1.9.2' => true do
5
+ describe Puppet::Application::Cert => true do
6
6
  before :each do
7
7
  @cert_app = Puppet::Application[:cert]
8
8
  Puppet::Util::Log.stubs(:newdestination)
@@ -8,6 +8,7 @@ require 'getoptlong'
8
8
  describe Puppet::Application do
9
9
 
10
10
  before do
11
+ Puppet::Util::Instrumentation.stubs(:init)
11
12
  @app = Class.new(Puppet::Application).new
12
13
  @appclass = @app.class
13
14
 
@@ -117,6 +118,11 @@ describe Puppet::Application do
117
118
  @app.run_command
118
119
  end
119
120
 
121
+ it "should initialize the Puppet Instrumentation layer on creation" do
122
+ Puppet::Util::Instrumentation.expects(:init)
123
+ Class.new(Puppet::Application).new
124
+ end
125
+
120
126
  describe 'when invoking clear!' do
121
127
  before :each do
122
128
  Puppet::Application.run_status = :stop_requested
@@ -60,16 +60,35 @@ describe Puppet::Configurer::Downloader do
60
60
  @dler.file
61
61
  end
62
62
 
63
- it "should always set the owner to the current UID" do
64
- Process.expects(:uid).returns 51
65
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 51 }
66
- @dler.file
67
- end
68
-
69
- it "should always set the group to the current GID" do
70
- Process.expects(:gid).returns 61
71
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == 61 }
72
- @dler.file
63
+ describe "on POSIX" do
64
+ before :each do
65
+ Puppet.features.stubs(:microsoft_windows?).returns false
66
+ end
67
+
68
+ it "should always set the owner to the current UID" do
69
+ Process.expects(:uid).returns 51
70
+ Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 51 }
71
+ @dler.file
72
+ end
73
+
74
+ it "should always set the group to the current GID" do
75
+ Process.expects(:gid).returns 61
76
+ Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == 61 }
77
+ @dler.file
78
+ end
79
+ end
80
+
81
+ describe "on Windows", :if => Puppet.features.microsoft_windows? do
82
+ it "should always set the owner to the current user" do
83
+ Sys::Admin.expects(:get_login).returns 'foo'
84
+ Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 'foo' }
85
+ @dler.file
86
+ end
87
+
88
+ it "should always set the group to nobody" do
89
+ Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == 'S-1-0-0' }
90
+ @dler.file
91
+ end
73
92
  end
74
93
 
75
94
  it "should always force the download" do
@@ -78,12 +78,6 @@ describe Puppet::Configurer::FactHandler do
78
78
  Puppet[:node_name_value].should == 'other_node_name'
79
79
  end
80
80
 
81
- it "should reload Facter before finding facts" do
82
- @facthandler.expects(:reload_facter)
83
-
84
- @facthandler.find_facts
85
- end
86
-
87
81
  it "should fail if finding facts fails" do
88
82
  Puppet[:trace] = false
89
83
  Puppet[:certname] = "myhost"
@@ -93,6 +87,11 @@ describe Puppet::Configurer::FactHandler do
93
87
  end
94
88
  end
95
89
 
90
+ it "should only load fact plugins once" do
91
+ Puppet::Node::Facts.indirection.expects(:find).once
92
+ @facthandler.find_facts
93
+ end
94
+
96
95
  it "should warn about factsync deprecation when factsync is enabled" do
97
96
  Puppet::Configurer::Downloader.stubs(:new).returns mock("downloader", :evaluate => nil)
98
97
 
@@ -145,27 +144,4 @@ describe Puppet::Configurer::FactHandler do
145
144
 
146
145
  @facthandler.facts_for_uploading
147
146
  end
148
-
149
- describe "when reloading Facter" do
150
- before do
151
- Facter.stubs(:clear)
152
- Facter.stubs(:load)
153
- Facter.stubs(:loadfacts)
154
- end
155
-
156
- it "should clear Facter" do
157
- Facter.expects(:clear)
158
- @facthandler.reload_facter
159
- end
160
-
161
- it "should load all Facter facts" do
162
- Facter.expects(:loadfacts)
163
- @facthandler.reload_facter
164
- end
165
-
166
- it "should use the Facter terminus load all Puppet Fact plugins" do
167
- Puppet::Node::Facts::Facter.expects(:load_fact_plugins)
168
- @facthandler.reload_facter
169
- end
170
- end
171
147
  end
@@ -407,25 +407,26 @@ describe Puppet::Configurer do
407
407
  end
408
408
 
409
409
  describe "when saving the summary report file" do
410
+ include PuppetSpec::Files
411
+
410
412
  before do
411
413
  Puppet.settings.stubs(:use).returns(true)
412
414
  @configurer = Puppet::Configurer.new
413
415
 
414
- @report = stub 'report'
415
- @trans = stub 'transaction'
416
- @lastrunfd = stub 'lastrunfd'
417
- Puppet::Util::FileLocking.stubs(:writelock).yields(@lastrunfd)
416
+ @report = stub 'report', :raw_summary => {}
417
+
418
+ Puppet[:lastrunfile] = tmpfile('last_run_file')
418
419
  end
419
420
 
420
- it "should write the raw summary to the lastrunfile setting value" do
421
- Puppet::Util::FileLocking.expects(:writelock).with(Puppet[:lastrunfile], 0660)
421
+ it "should write the last run file" do
422
422
  @configurer.save_last_run_summary(@report)
423
+ FileTest.exists?(Puppet[:lastrunfile]).should be_true
423
424
  end
424
425
 
425
426
  it "should write the raw summary as yaml" do
426
427
  @report.expects(:raw_summary).returns("summary")
427
- @lastrunfd.expects(:print).with(YAML.dump("summary"))
428
428
  @configurer.save_last_run_summary(@report)
429
+ File.read(Puppet[:lastrunfile]).should == YAML.dump("summary")
429
430
  end
430
431
 
431
432
  it "should log but not fail if saving the last run summary fails" do
@@ -433,7 +434,6 @@ describe Puppet::Configurer do
433
434
  Puppet.expects(:err)
434
435
  lambda { @configurer.save_last_run_summary(@report) }.should_not raise_error
435
436
  end
436
-
437
437
  end
438
438
 
439
439
  describe "when retrieving a catalog" do
@@ -10,6 +10,8 @@ def without_warnings
10
10
  end
11
11
 
12
12
  describe Puppet::Daemon do
13
+ include PuppetSpec::Files
14
+
13
15
  before do
14
16
  @daemon = Puppet::Daemon.new
15
17
  end
@@ -141,9 +143,9 @@ describe Puppet::Daemon do
141
143
  pidfile = mock 'pidfile'
142
144
 
143
145
  Puppet.settings.stubs(:value).with(:name).returns "eh"
144
- Puppet.settings.expects(:value).with(:pidfile).returns "/my/file"
146
+ Puppet.settings.expects(:value).with(:pidfile).returns make_absolute("/my/file")
145
147
 
146
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
148
+ Puppet::Util::Pidlock.expects(:new).with(make_absolute("/my/file")).returns pidfile
147
149
 
148
150
  pidfile.expects(:lock).returns true
149
151
  @daemon.create_pidfile
@@ -153,9 +155,9 @@ describe Puppet::Daemon do
153
155
  pidfile = mock 'pidfile'
154
156
 
155
157
  Puppet.settings.stubs(:value).with(:name).returns "eh"
156
- Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
158
+ Puppet.settings.stubs(:value).with(:pidfile).returns make_absolute("/my/file")
157
159
 
158
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
160
+ Puppet::Util::Pidlock.expects(:new).with(make_absolute("/my/file")).returns pidfile
159
161
 
160
162
  pidfile.expects(:lock).returns false
161
163
 
@@ -173,36 +175,20 @@ describe Puppet::Daemon do
173
175
  end
174
176
 
175
177
  it "should do nothing if the pidfile is not present" do
176
- pidfile = mock 'pidfile', :locked? => false
177
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
178
+ pidfile = mock 'pidfile', :unlock => false
178
179
 
179
- Puppet.settings.stubs(:value).with(:name).returns "eh"
180
- Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
180
+ Puppet[:pidfile] = make_absolute("/my/file")
181
+ Puppet::Util::Pidlock.expects(:new).with(make_absolute("/my/file")).returns pidfile
181
182
 
182
- pidfile.expects(:unlock).never
183
183
  @daemon.remove_pidfile
184
184
  end
185
185
 
186
186
  it "should unlock the pidfile using the Pidlock class" do
187
- pidfile = mock 'pidfile', :locked? => true
188
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
189
- pidfile.expects(:unlock).returns true
187
+ pidfile = mock 'pidfile', :unlock => true
190
188
 
191
- Puppet.settings.stubs(:value).with(:name).returns "eh"
192
- Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
193
-
194
- @daemon.remove_pidfile
195
- end
196
-
197
- it "should warn if it cannot remove the pidfile" do
198
- pidfile = mock 'pidfile', :locked? => true
199
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
200
- pidfile.expects(:unlock).returns false
201
-
202
- Puppet.settings.stubs(:value).with(:name).returns "eh"
203
- Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
189
+ Puppet[:pidfile] = make_absolute("/my/file")
190
+ Puppet::Util::Pidlock.expects(:new).with(make_absolute("/my/file")).returns pidfile
204
191
 
205
- Puppet.expects :err
206
192
  @daemon.remove_pidfile
207
193
  end
208
194
  end