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,11 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/data'
5
+ require 'puppet/indirector/instrumentation_data/rest'
6
+
7
+ describe Puppet::Indirector::InstrumentationData::Rest do
8
+ it "should be a subclass of Puppet::Indirector::REST" do
9
+ Puppet::Indirector::InstrumentationData::Rest.superclass.should equal(Puppet::Indirector::REST)
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/listener'
5
+ require 'puppet/indirector/instrumentation_listener/local'
6
+
7
+ describe Puppet::Indirector::InstrumentationListener::Local do
8
+ it "should be a subclass of the Code terminus" do
9
+ Puppet::Indirector::InstrumentationListener::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_listener)
14
+ Puppet::Indirector::InstrumentationListener::Local.indirection.should equal(indirection)
15
+ end
16
+
17
+ it "should have its name set to :local" do
18
+ Puppet::Indirector::InstrumentationListener::Local.name.should == :local
19
+ end
20
+ end
21
+
22
+ describe Puppet::Indirector::InstrumentationListener::Local do
23
+ before :each do
24
+ Puppet::Util::Instrumentation.stubs(:listener)
25
+ @listener = Puppet::Indirector::InstrumentationListener::Local.new
26
+ @name = "me"
27
+ @request = stub 'request', :key => @name
28
+ end
29
+
30
+ describe "when finding listeners" do
31
+ it "should return a Instrumentation Listener instance matching the key" do
32
+ Puppet::Util::Instrumentation.expects(:[]).with("me").returns(:instance)
33
+ @listener.find(@request).should == :instance
34
+ end
35
+ end
36
+
37
+ describe "when searching listeners" do
38
+ it "should return a list of all loaded Instrumentation Listenesrs irregardless of the given key" do
39
+ Puppet::Util::Instrumentation.expects(:listeners).returns([:instance1, :instance2])
40
+ @listener.search(@request).should == [:instance1, :instance2]
41
+ end
42
+ end
43
+
44
+ describe "when saving listeners" do
45
+ it "should set the new listener to the global listener list" do
46
+ newlistener = stub 'listener', :name => @name
47
+ @request.stubs(:instance).returns(newlistener)
48
+ Puppet::Util::Instrumentation.expects(:[]=).with("me", newlistener)
49
+ @listener.save(@request)
50
+ end
51
+ end
52
+
53
+ describe "when destroying listeners" do
54
+ it "should raise an error if listener wasn't subscribed" do
55
+ Puppet::Util::Instrumentation.expects(:[]).with("me").returns(nil)
56
+ lambda { @listener.destroy(@request) }.should raise_error
57
+ end
58
+
59
+ it "should unsubscribe the listener" do
60
+ Puppet::Util::Instrumentation.expects(:[]).with("me").returns(:instancce)
61
+ Puppet::Util::Instrumentation.expects(:unsubscribe).with(:instancce)
62
+ @listener.destroy(@request)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/listener'
5
+ require 'puppet/indirector/instrumentation_listener/rest'
6
+
7
+ describe Puppet::Indirector::InstrumentationListener::Rest do
8
+ it "should be a subclass of Puppet::Indirector::REST" do
9
+ Puppet::Indirector::InstrumentationListener::Rest.superclass.should equal(Puppet::Indirector::REST)
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/indirection_probe'
5
+ require 'puppet/indirector/instrumentation_probe/local'
6
+ require 'puppet/util/instrumentation/instrumentable'
7
+
8
+ describe Puppet::Indirector::InstrumentationProbe::Local do
9
+ it "should be a subclass of the Code terminus" do
10
+ Puppet::Indirector::InstrumentationProbe::Local.superclass.should equal(Puppet::Indirector::Code)
11
+ end
12
+
13
+ it "should be registered with the configuration store indirection" do
14
+ indirection = Puppet::Indirector::Indirection.instance(:instrumentation_probe)
15
+ Puppet::Indirector::InstrumentationProbe::Local.indirection.should equal(indirection)
16
+ end
17
+
18
+ it "should have its name set to :local" do
19
+ Puppet::Indirector::InstrumentationProbe::Local.name.should == :local
20
+ end
21
+ end
22
+
23
+ describe Puppet::Indirector::InstrumentationProbe::Local do
24
+ before :each do
25
+ Puppet::Util::Instrumentation.stubs(:listener)
26
+ @probe = Puppet::Indirector::InstrumentationProbe::Local.new
27
+ @name = "me"
28
+ @request = stub 'request', :key => @name
29
+ end
30
+
31
+ describe "when finding probes" do
32
+ it "should do nothing" do
33
+ @probe.find(@request).should be_nil
34
+ end
35
+ end
36
+
37
+ describe "when searching probes" do
38
+ it "should return a list of all loaded probes irregardless of the given key" do
39
+ instance1 = stub 'instance1', :method => "probe1", :klass => "Klass1"
40
+ instance2 = stub 'instance2', :method => "probe2", :klass => "Klass2"
41
+ Puppet::Util::Instrumentation::IndirectionProbe.expects(:new).with("Klass1.probe1").returns(:instance1)
42
+ Puppet::Util::Instrumentation::IndirectionProbe.expects(:new).with("Klass2.probe2").returns(:instance2)
43
+ Puppet::Util::Instrumentation::Instrumentable.expects(:each_probe).multiple_yields([instance1], [instance2])
44
+ @probe.search(@request).should == [ :instance1, :instance2 ]
45
+ end
46
+ end
47
+
48
+ describe "when saving probes" do
49
+ it "should enable probes" do
50
+ newprobe = stub 'probe', :name => @name
51
+ @request.stubs(:instance).returns(newprobe)
52
+ Puppet::Util::Instrumentation::Instrumentable.expects(:enable_probes)
53
+ @probe.save(@request)
54
+ end
55
+ end
56
+
57
+ describe "when destroying probes" do
58
+ it "should disable probes" do
59
+ newprobe = stub 'probe', :name => @name
60
+ @request.stubs(:instance).returns(newprobe)
61
+ Puppet::Util::Instrumentation::Instrumentable.expects(:disable_probes)
62
+ @probe.destroy(@request)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ require 'puppet/util/instrumentation/indirection_probe'
5
+ require 'puppet/indirector/instrumentation_probe/rest'
6
+
7
+ describe Puppet::Indirector::InstrumentationProbe::Rest do
8
+ it "should be a subclass of Puppet::Indirector::REST" do
9
+ Puppet::Indirector::InstrumentationProbe::Rest.superclass.should equal(Puppet::Indirector::REST)
10
+ end
11
+ end
@@ -89,83 +89,6 @@ describe Puppet::Module do
89
89
  lambda { mod.validate_puppet_version }.should raise_error(Puppet::Module::IncompatibleModule)
90
90
  end
91
91
 
92
- describe "when specifying required modules" do
93
- it "should support specifying a required module" do
94
- mod = Puppet::Module.new("mymod")
95
- mod.requires "foobar"
96
- end
97
-
98
- it "should support specifying multiple required modules" do
99
- mod = Puppet::Module.new("mymod")
100
- mod.requires "foobar"
101
- mod.requires "baz"
102
- end
103
-
104
- it "should support specifying a required module and version" do
105
- mod = Puppet::Module.new("mymod")
106
- mod.requires "foobar", 1.0
107
- end
108
-
109
- it "should fail when required modules are missing" do
110
- mod = Puppet::Module.new("mymod")
111
- mod.requires "foobar"
112
-
113
- mod.environment.expects(:module).with("foobar").returns nil
114
-
115
- lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::MissingModule)
116
- end
117
-
118
- it "should fail when required modules are present but of the wrong version" do
119
- mod = Puppet::Module.new("mymod")
120
- mod.requires "foobar", 1.0
121
-
122
- foobar = Puppet::Module.new("foobar")
123
- foobar.version = 2.0
124
-
125
- mod.environment.expects(:module).with("foobar").returns foobar
126
-
127
- lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::IncompatibleModule)
128
- end
129
-
130
- it "should have valid dependencies when no dependencies have been specified" do
131
- mod = Puppet::Module.new("mymod")
132
-
133
- lambda { mod.validate_dependencies }.should_not raise_error
134
- end
135
-
136
- it "should fail when some dependencies are present but others aren't" do
137
- mod = Puppet::Module.new("mymod")
138
- mod.requires "foobar"
139
- mod.requires "baz"
140
-
141
- mod.environment.expects(:module).with("foobar").returns Puppet::Module.new("foobar")
142
- mod.environment.expects(:module).with("baz").returns nil
143
-
144
- lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::MissingModule)
145
- end
146
-
147
- it "should have valid dependencies when all dependencies are met" do
148
- mod = Puppet::Module.new("mymod")
149
- mod.requires "foobar", 1.0
150
- mod.requires "baz"
151
-
152
- foobar = Puppet::Module.new("foobar")
153
- foobar.version = 1.0
154
-
155
- baz = Puppet::Module.new("baz")
156
-
157
- mod.environment.expects(:module).with("foobar").returns foobar
158
- mod.environment.expects(:module).with("baz").returns baz
159
-
160
- lambda { mod.validate_dependencies }.should_not raise_error
161
- end
162
-
163
- it "should validate its dependendencies on initialization" do
164
- Puppet::Module.any_instance.expects(:validate_dependencies)
165
- Puppet::Module.new("mymod")
166
- end
167
- end
168
-
169
92
  describe "when managing supported platforms" do
170
93
  it "should support specifying a supported platform" do
171
94
  mod = Puppet::Module.new("mymod")
@@ -251,11 +174,11 @@ describe Puppet::Module do
251
174
  end
252
175
 
253
176
  it "should convert an environment name into an Environment instance" do
254
- Puppet::Module.new("foo", "prod").environment.should be_instance_of(Puppet::Node::Environment)
177
+ Puppet::Module.new("foo", :environment => "prod").environment.should be_instance_of(Puppet::Node::Environment)
255
178
  end
256
179
 
257
180
  it "should accept an environment at initialization" do
258
- Puppet::Module.new("foo", :prod).environment.name.should == :prod
181
+ Puppet::Module.new("foo", :environment => :prod).environment.name.should == :prod
259
182
  end
260
183
 
261
184
  it "should use the default environment if none is provided" do
@@ -265,43 +188,53 @@ describe Puppet::Module do
265
188
 
266
189
  it "should use any provided Environment instance" do
267
190
  env = Puppet::Node::Environment.new
268
- Puppet::Module.new("foo", env).environment.should equal(env)
191
+ Puppet::Module.new("foo", :environment => env).environment.should equal(env)
269
192
  end
270
193
 
271
- it "should return the path to the first found instance in its environment's module paths as its path" do
272
- dir = tmpdir("deep_path")
273
- first = File.join(dir, "first")
274
- second = File.join(dir, "second")
194
+ describe ".path" do
195
+ before do
196
+ dir = tmpdir("deep_path")
275
197
 
276
- FileUtils.mkdir_p(first)
277
- FileUtils.mkdir_p(second)
278
- Puppet[:modulepath] = "#{first}#{File::PATH_SEPARATOR}#{second}"
198
+ @first = File.join(dir, "first")
199
+ @second = File.join(dir, "second")
200
+ Puppet[:modulepath] = "#{@first}#{File::PATH_SEPARATOR}#{@second}"
279
201
 
280
- modpath = File.join(first, "foo")
281
- FileUtils.mkdir_p(modpath)
202
+ FileUtils.mkdir_p(@first)
203
+ FileUtils.mkdir_p(@second)
204
+ end
282
205
 
283
- # Make a second one, which we shouldn't find
284
- FileUtils.mkdir_p(File.join(second, "foo"))
206
+ it "should return the path to the first found instance in its environment's module paths as its path" do
207
+ modpath = File.join(@first, "foo")
208
+ FileUtils.mkdir_p(modpath)
285
209
 
286
- mod = Puppet::Module.new("foo")
287
- mod.path.should == modpath
288
- end
210
+ # Make a second one, which we shouldn't find
211
+ FileUtils.mkdir_p(File.join(@second, "foo"))
212
+
213
+ mod = Puppet::Module.new("foo")
214
+ mod.path.should == modpath
215
+ end
289
216
 
290
- it "should be able to find itself in a directory other than the first directory in the module path" do
291
- dir = tmpdir("deep_path")
292
- first = File.join(dir, "first")
293
- second = File.join(dir, "second")
217
+ it "should be able to find itself in a directory other than the first directory in the module path" do
218
+ modpath = File.join(@second, "foo")
219
+ FileUtils.mkdir_p(modpath)
294
220
 
295
- FileUtils.mkdir_p(first)
296
- FileUtils.mkdir_p(second)
297
- Puppet[:modulepath] = "#{first}#{File::PATH_SEPARATOR}#{second}"
221
+ mod = Puppet::Module.new("foo")
222
+ mod.should be_exist
223
+ mod.path.should == modpath
224
+ end
298
225
 
299
- modpath = File.join(second, "foo")
300
- FileUtils.mkdir_p(modpath)
226
+ it "should be able to find itself in a directory other than the first directory in the module path even when it exists in the first" do
227
+ environment = Puppet::Node::Environment.new
301
228
 
302
- mod = Puppet::Module.new("foo")
303
- mod.should be_exist
304
- mod.path.should == modpath
229
+ first_modpath = File.join(@first, "foo")
230
+ FileUtils.mkdir_p(first_modpath)
231
+ second_modpath = File.join(@second, "foo")
232
+ FileUtils.mkdir_p(second_modpath)
233
+
234
+ mod = Puppet::Module.new("foo", :environment => environment, :path => second_modpath)
235
+ mod.path.should == File.join(@second, "foo")
236
+ mod.environment.should == environment
237
+ end
305
238
  end
306
239
 
307
240
  it "should be considered existent if it exists in at least one module path" do
@@ -403,24 +336,6 @@ describe Puppet::Module do
403
336
  end
404
337
  end
405
338
 
406
- describe Puppet::Module, " when building its search path" do
407
- it "should use the current environment's search path if no environment is specified" do
408
- env = mock 'env'
409
- env.expects(:modulepath).returns "eh"
410
- Puppet::Node::Environment.expects(:new).with(nil).returns env
411
-
412
- Puppet::Module.modulepath.should == "eh"
413
- end
414
-
415
- it "should use the specified environment's search path if an environment is specified" do
416
- env = mock 'env'
417
- env.expects(:modulepath).returns "eh"
418
- Puppet::Node::Environment.expects(:new).with("foo").returns env
419
-
420
- Puppet::Module.modulepath("foo").should == "eh"
421
- end
422
- end
423
-
424
339
  describe Puppet::Module, "when finding matching manifests" do
425
340
  before do
426
341
  @mod = Puppet::Module.new("mymod")
@@ -592,7 +507,6 @@ describe Puppet::Module do
592
507
  @module.puppetversion.should == @data[:puppetversion]
593
508
  end
594
509
 
595
-
596
510
  it "should fail if the discovered name is different than the metadata name"
597
511
  end
598
512
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'puppet/module_tool'
3
+ require 'tmpdir'
4
+
5
+ describe Puppet::Module::Tool::Applications::Uninstaller do
6
+ include PuppetSpec::Files
7
+
8
+ describe "instances" do
9
+ let(:tmp_module_path1) { tmpdir("uninstaller_module_path1") }
10
+ let(:tmp_module_path2) { tmpdir("uninstaller_module_path2") }
11
+ let(:options) do
12
+ { :target_directories => [ tmp_module_path1, tmp_module_path2 ] }
13
+ end
14
+
15
+ it "should return an empty list if the module is not installed" do
16
+ described_class.new('foo', options).run.should == []
17
+ end
18
+
19
+ it "should uninstall an installed module" do
20
+ foo_module_path = File.join(tmp_module_path1, 'foo')
21
+ Dir.mkdir(foo_module_path)
22
+ described_class.new('foo', options).run.should == [ foo_module_path ]
23
+ end
24
+
25
+ it "should only uninstall the requested module" do
26
+ foo_module_path = File.join(tmp_module_path1, 'foo')
27
+ bar_module_path = File.join(tmp_module_path1, 'bar')
28
+ Dir.mkdir(foo_module_path)
29
+ Dir.mkdir(bar_module_path)
30
+ described_class.new('foo', options).run.should == [ foo_module_path ]
31
+ end
32
+
33
+ it "should uninstall the module from all target directories" do
34
+ foo1_module_path = File.join(tmp_module_path1, 'foo')
35
+ foo2_module_path = File.join(tmp_module_path2, 'foo')
36
+ Dir.mkdir(foo1_module_path)
37
+ Dir.mkdir(foo2_module_path)
38
+ described_class.new('foo', options).run.should == [ foo1_module_path, foo2_module_path ]
39
+ end
40
+
41
+ #11803
42
+ it "should check for broken dependencies"
43
+ end
44
+ end
@@ -196,36 +196,18 @@ describe Puppet::Network::Server do
196
196
  end
197
197
 
198
198
  it "should do nothing if the pidfile is not present" do
199
- pidfile = mock 'pidfile', :locked? => false
199
+ pidfile = mock 'pidfile', :unlock => false
200
200
  Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
201
-
202
- Puppet.settings.stubs(:value).with(:name).returns "eh"
203
201
  Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
204
202
 
205
- pidfile.expects(:unlock).never
206
203
  @server.remove_pidfile
207
204
  end
208
205
 
209
206
  it "should unlock the pidfile using the Pidlock class" do
210
- pidfile = mock 'pidfile', :locked? => true
211
- Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
212
- pidfile.expects(:unlock).returns true
213
-
214
- Puppet.settings.stubs(:value).with(:name).returns "eh"
215
- Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
216
-
217
- @server.remove_pidfile
218
- end
219
-
220
- it "should warn if it cannot remove the pidfile" do
221
- pidfile = mock 'pidfile', :locked? => true
207
+ pidfile = mock 'pidfile', :unlock => true
222
208
  Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile
223
- pidfile.expects(:unlock).returns false
224
-
225
- Puppet.settings.stubs(:value).with(:name).returns "eh"
226
209
  Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file"
227
210
 
228
- Puppet.expects :err
229
211
  @server.remove_pidfile
230
212
  end
231
213
  end