puppet 2.7.11 → 2.7.12
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 +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -5,6 +5,7 @@ require 'tmpdir'
|
|
5
5
|
|
6
6
|
require 'puppet/node/environment'
|
7
7
|
require 'puppet/util/execution'
|
8
|
+
require 'puppet_spec/modules'
|
8
9
|
|
9
10
|
describe Puppet::Node::Environment do
|
10
11
|
let(:env) { Puppet::Node::Environment.new("testing") }
|
@@ -124,8 +125,10 @@ describe Puppet::Node::Environment do
|
|
124
125
|
|
125
126
|
describe "when validating modulepath or manifestdir directories" do
|
126
127
|
before :each do
|
127
|
-
@path_one =
|
128
|
-
@path_two =
|
128
|
+
@path_one = tmpdir("path_one")
|
129
|
+
@path_two = tmpdir("path_one")
|
130
|
+
sep = File::PATH_SEPARATOR
|
131
|
+
Puppet[:modulepath] = "#{@path_one}#{sep}#{@path_two}"
|
129
132
|
end
|
130
133
|
|
131
134
|
it "should not return non-directories" do
|
@@ -167,15 +170,13 @@ describe Puppet::Node::Environment do
|
|
167
170
|
end
|
168
171
|
|
169
172
|
it "should return nil if asked for a module that does not exist in its path" do
|
170
|
-
|
171
|
-
|
172
|
-
Puppet::Module.expects(:new).with("one", :environment => env).returns mod
|
173
|
-
mod.expects(:exist?).returns false
|
173
|
+
modpath = tmpdir('modpath')
|
174
|
+
env.modulepath = [modpath]
|
174
175
|
|
175
176
|
env.module("one").should be_nil
|
176
177
|
end
|
177
178
|
|
178
|
-
describe "
|
179
|
+
describe "module data" do
|
179
180
|
before do
|
180
181
|
dir = tmpdir("deep_path")
|
181
182
|
|
@@ -187,75 +188,167 @@ describe Puppet::Node::Environment do
|
|
187
188
|
FileUtils.mkdir_p(@second)
|
188
189
|
end
|
189
190
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
describe ".modules" do
|
211
|
-
it "should return an empty list if there are no modules" do
|
212
|
-
env.modulepath = %w{/a /b}
|
213
|
-
Dir.expects(:entries).with("/a").returns []
|
214
|
-
Dir.expects(:entries).with("/b").returns []
|
215
|
-
|
216
|
-
env.modules.should == []
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should return a module named for every directory in each module path" do
|
220
|
-
env.modulepath = %w{/a /b}
|
221
|
-
Dir.expects(:entries).with("/a").returns %w{foo bar}
|
222
|
-
Dir.expects(:entries).with("/b").returns %w{bee baz}
|
223
|
-
|
224
|
-
env.modules.collect{|mod| mod.name}.sort.should == %w{foo bar bee baz}.sort
|
191
|
+
describe "#modules_by_path" do
|
192
|
+
it "should return an empty list if there are no modules" do
|
193
|
+
env.modules_by_path.should == {
|
194
|
+
@first => [],
|
195
|
+
@second => []
|
196
|
+
}
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should include modules even if they exist in multiple dirs in the modulepath" do
|
200
|
+
modpath1 = File.join(@first, "foo")
|
201
|
+
FileUtils.mkdir_p(modpath1)
|
202
|
+
modpath2 = File.join(@second, "foo")
|
203
|
+
FileUtils.mkdir_p(modpath2)
|
204
|
+
|
205
|
+
env.modules_by_path.should == {
|
206
|
+
@first => [Puppet::Module.new('foo', :environment => env, :path => modpath1)],
|
207
|
+
@second => [Puppet::Module.new('foo', :environment => env, :path => modpath2)]
|
208
|
+
}
|
209
|
+
end
|
225
210
|
end
|
226
211
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
212
|
+
describe "#module_requirements" do
|
213
|
+
it "should return a list of what modules depend on other modules" do
|
214
|
+
PuppetSpec::Modules.create(
|
215
|
+
'foo',
|
216
|
+
@first,
|
217
|
+
:metadata => {
|
218
|
+
:author => 'puppetlabs',
|
219
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => ">= 1.0.0" }]
|
220
|
+
}
|
221
|
+
)
|
222
|
+
PuppetSpec::Modules.create(
|
223
|
+
'bar',
|
224
|
+
@second,
|
225
|
+
:metadata => {
|
226
|
+
:author => 'puppetlabs',
|
227
|
+
:dependencies => [{ 'name' => 'puppetlabs/foo', "version_requirement" => "<= 2.0.0" }]
|
228
|
+
}
|
229
|
+
)
|
230
|
+
PuppetSpec::Modules.create(
|
231
|
+
'baz',
|
232
|
+
@first,
|
233
|
+
:metadata => {
|
234
|
+
:author => 'puppetlabs',
|
235
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "3.0.0" }]
|
236
|
+
}
|
237
|
+
)
|
238
|
+
PuppetSpec::Modules.create(
|
239
|
+
'alpha',
|
240
|
+
@first,
|
241
|
+
:metadata => {
|
242
|
+
:author => 'puppetlabs',
|
243
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "~3.0.0" }]
|
244
|
+
}
|
245
|
+
)
|
246
|
+
|
247
|
+
env.module_requirements.should == {
|
248
|
+
'puppetlabs/alpha' => [],
|
249
|
+
'puppetlabs/foo' => [
|
250
|
+
{
|
251
|
+
"name" => "puppetlabs/bar",
|
252
|
+
"version" => "9.9.9",
|
253
|
+
"version_requirement" => "<= 2.0.0"
|
254
|
+
}
|
255
|
+
],
|
256
|
+
'puppetlabs/bar' => [
|
257
|
+
{
|
258
|
+
"name" => "puppetlabs/alpha",
|
259
|
+
"version" => "9.9.9",
|
260
|
+
"version_requirement" => "~3.0.0"
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"name" => "puppetlabs/baz",
|
264
|
+
"version" => "9.9.9",
|
265
|
+
"version_requirement" => "3.0.0"
|
266
|
+
},
|
267
|
+
{
|
268
|
+
"name" => "puppetlabs/foo",
|
269
|
+
"version" => "9.9.9",
|
270
|
+
"version_requirement" => ">= 1.0.0"
|
271
|
+
}
|
272
|
+
],
|
273
|
+
'puppetlabs/baz' => []
|
274
|
+
}
|
275
|
+
end
|
233
276
|
end
|
234
277
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
278
|
+
describe ".module_by_forge_name" do
|
279
|
+
it "should find modules by forge_name" do
|
280
|
+
mod = PuppetSpec::Modules.create(
|
281
|
+
'baz',
|
282
|
+
@first,
|
283
|
+
:metadata => {:author => 'puppetlabs'},
|
284
|
+
:environment => env
|
285
|
+
)
|
286
|
+
env.module_by_forge_name('puppetlabs/baz').should == mod
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should not find modules with same name by the wrong author" do
|
290
|
+
mod = PuppetSpec::Modules.create(
|
291
|
+
'baz',
|
292
|
+
@first,
|
293
|
+
:metadata => {:author => 'sneakylabs'},
|
294
|
+
:environment => env
|
295
|
+
)
|
296
|
+
env.module_by_forge_name('puppetlabs/baz').should == nil
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should return nil when the module can't be found" do
|
300
|
+
env.module_by_forge_name('ima/nothere').should be_nil
|
301
|
+
end
|
243
302
|
end
|
244
303
|
|
245
|
-
|
246
|
-
|
247
|
-
|
304
|
+
describe ".modules" do
|
305
|
+
it "should return an empty list if there are no modules" do
|
306
|
+
env.modules.should == []
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should return a module named for every directory in each module path" do
|
310
|
+
%w{foo bar}.each do |mod_name|
|
311
|
+
FileUtils.mkdir_p(File.join(@first, mod_name))
|
312
|
+
end
|
313
|
+
%w{bee baz}.each do |mod_name|
|
314
|
+
FileUtils.mkdir_p(File.join(@second, mod_name))
|
315
|
+
end
|
316
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo bar bee baz}.sort
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should remove duplicates" do
|
320
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
321
|
+
FileUtils.mkdir_p(File.join(@second, 'foo'))
|
322
|
+
|
323
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo}
|
324
|
+
end
|
325
|
+
|
326
|
+
it "should ignore modules with invalid names" do
|
327
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
328
|
+
FileUtils.mkdir_p(File.join(@first, 'foo2'))
|
329
|
+
FileUtils.mkdir_p(File.join(@first, 'foo-bar'))
|
330
|
+
FileUtils.mkdir_p(File.join(@first, 'foo_bar'))
|
331
|
+
FileUtils.mkdir_p(File.join(@first, 'foo=bar'))
|
332
|
+
FileUtils.mkdir_p(File.join(@first, 'foo bar'))
|
333
|
+
|
334
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo foo-bar foo2 foo_bar}
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should create modules with the correct environment" do
|
338
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
339
|
+
|
340
|
+
env.modules.each {|mod| mod.environment.should == env }
|
341
|
+
end
|
248
342
|
|
249
|
-
env.modules.each {|mod| mod.environment.should == env }
|
250
343
|
end
|
344
|
+
end
|
251
345
|
|
252
|
-
|
253
|
-
|
254
|
-
|
346
|
+
it "should cache the module list" do
|
347
|
+
env.modulepath = %w{/a}
|
348
|
+
Dir.expects(:entries).once.with("/a").returns %w{foo}
|
255
349
|
|
256
|
-
|
257
|
-
|
258
|
-
end
|
350
|
+
env.modules
|
351
|
+
env.modules
|
259
352
|
end
|
260
353
|
end
|
261
354
|
|
@@ -287,21 +287,16 @@ describe Puppet::Parser::Collector, "when collecting exported resources", :if =>
|
|
287
287
|
|
288
288
|
context "with storeconfigs enabled" do
|
289
289
|
before :each do
|
290
|
-
ActiveRecord::Base.remove_connection
|
291
|
-
|
292
290
|
dir = Pathname(tmpdir('puppet-var'))
|
293
291
|
Puppet[:vardir] = dir.to_s
|
294
292
|
Puppet[:dbadapter] = 'sqlite3'
|
295
293
|
Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
|
296
294
|
Puppet[:storeconfigs] = true
|
297
295
|
Puppet[:environment] = "production"
|
296
|
+
Puppet[:storeconfigs_backend] = "active_record"
|
298
297
|
Puppet::Rails.init
|
299
298
|
end
|
300
299
|
|
301
|
-
after :each do
|
302
|
-
ActiveRecord::Base.remove_connection
|
303
|
-
end
|
304
|
-
|
305
300
|
it "should return all matching resources from the current compile and mark them non-virtual and non-exported" do
|
306
301
|
one = Puppet::Parser::Resource.new('notify', 'one',
|
307
302
|
:virtual => true,
|
@@ -336,7 +331,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources", :if =>
|
|
336
331
|
one.should_not be_virtual
|
337
332
|
end
|
338
333
|
|
339
|
-
it "should convert all found resources into parser resources" do
|
334
|
+
it "should convert all found resources into parser resources if necessary" do
|
340
335
|
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
341
336
|
Puppet::Rails::Resource.
|
342
337
|
create!(:host => host,
|
@@ -350,6 +345,19 @@ describe Puppet::Parser::Collector, "when collecting exported resources", :if =>
|
|
350
345
|
result.first.title.should == 'whammo'
|
351
346
|
end
|
352
347
|
|
348
|
+
it "should leave parser resources alone" do
|
349
|
+
resource = Puppet::Parser::Resource.new(:file, "/tmp/foo", :scope => @scope)
|
350
|
+
resource2 = Puppet::Parser::Resource.new(:file, "/tmp/bar", :scope => @scope)
|
351
|
+
resource.expects(:to_resource).never
|
352
|
+
resource2.expects(:to_resource).never
|
353
|
+
|
354
|
+
resources = [resource, resource2]
|
355
|
+
|
356
|
+
Puppet::Resource.indirection.stubs(:search).returns resources
|
357
|
+
|
358
|
+
@collector.evaluate.should == resources
|
359
|
+
end
|
360
|
+
|
353
361
|
it "should override all exported collected resources if collector has an override" do
|
354
362
|
host = Puppet::Rails::Host.create!(:name => 'one.local')
|
355
363
|
Puppet::Rails::Resource.
|
@@ -408,7 +416,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources", :if =>
|
|
408
416
|
@compiler.add_resource(@scope, local)
|
409
417
|
|
410
418
|
expect { @collector.evaluate }.
|
411
|
-
to raise_error Puppet::ParseError, /
|
419
|
+
to raise_error Puppet::ParseError, /exists with the type and title/
|
412
420
|
end
|
413
421
|
|
414
422
|
it "should ignore exported resources that match already-collected resources" do
|
@@ -6,38 +6,80 @@ describe "the generate function" do
|
|
6
6
|
Puppet::Parser::Functions.autoloader.loadall
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
@scope = Puppet::Parser::Scope.new
|
11
|
-
end
|
9
|
+
let(:scope) { Puppet::Parser::Scope.new }
|
12
10
|
|
13
11
|
it "should exist" do
|
14
12
|
Puppet::Parser::Functions.function("generate").should == "function_generate"
|
15
13
|
end
|
16
14
|
|
17
|
-
it "
|
18
|
-
command = File
|
19
|
-
|
20
|
-
|
15
|
+
it " accept a fully-qualified path as a command" do
|
16
|
+
command = File.expand_path('/command/foo')
|
17
|
+
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
18
|
+
scope.function_generate([command]).should == "yay"
|
21
19
|
end
|
22
20
|
|
23
21
|
it "should not accept a relative path as a command" do
|
24
|
-
|
25
|
-
|
22
|
+
lambda { scope.function_generate(["command"]) }.should raise_error(Puppet::ParseError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not accept a command containing illegal characters" do
|
26
|
+
lambda { scope.function_generate([File.expand_path('/##/command')]) }.should raise_error(Puppet::ParseError)
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
it "should not accept a command containing spaces" do
|
30
|
+
lambda { scope.function_generate([File.expand_path('/com mand')]) }.should raise_error(Puppet::ParseError)
|
31
|
+
end
|
31
32
|
|
32
33
|
it "should not accept a command containing '..'" do
|
33
|
-
command = File
|
34
|
-
lambda {
|
34
|
+
command = File.expand_path("/command/../")
|
35
|
+
lambda { scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
|
35
36
|
end
|
36
37
|
|
37
38
|
it "should execute the generate script with the correct working directory" do
|
38
|
-
command = File
|
39
|
-
Dir.expects(:chdir).with(File.dirname(command)).
|
40
|
-
|
41
|
-
|
39
|
+
command = File.expand_path("/command")
|
40
|
+
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
41
|
+
scope.function_generate([command]).should == 'yay'
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "on Windows" do
|
45
|
+
before :each do
|
46
|
+
Puppet.features.stubs(:microsoft_windows?).returns(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should accept lower-case drive letters" do
|
50
|
+
command = 'd:/command/foo'
|
51
|
+
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
52
|
+
scope.function_generate([command]).should == 'yay'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should accept upper-case drive letters" do
|
56
|
+
command = 'D:/command/foo'
|
57
|
+
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
58
|
+
scope.function_generate([command]).should == 'yay'
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should accept forward and backslashes in the path" do
|
62
|
+
command = 'D:\command/foo\bar'
|
63
|
+
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
64
|
+
scope.function_generate([command]).should == 'yay'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should reject colons when not part of the drive letter" do
|
68
|
+
lambda { scope.function_generate(['C:/com:mand']) }.should raise_error(Puppet::ParseError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should reject root drives" do
|
72
|
+
lambda { scope.function_generate(['C:/']) }.should raise_error(Puppet::ParseError)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "on non-Windows" do
|
77
|
+
before :each do
|
78
|
+
Puppet.features.stubs(:microsoft_windows?).returns(false)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should reject backslashes" do
|
82
|
+
lambda { scope.function_generate(['/com\\mand']) }.should raise_error(Puppet::ParseError)
|
83
|
+
end
|
42
84
|
end
|
43
85
|
end
|
@@ -200,6 +200,50 @@ describe Puppet::Parser::Resource do
|
|
200
200
|
@compiler.catalog.should be_edge(foo_stage, resource)
|
201
201
|
end
|
202
202
|
|
203
|
+
it "should allow edges to propagate multiple levels down the scope hierarchy" do
|
204
|
+
Puppet[:code] = <<-MANIFEST
|
205
|
+
stage { before: before => Stage[main] }
|
206
|
+
|
207
|
+
class alpha {
|
208
|
+
include beta
|
209
|
+
}
|
210
|
+
class beta {
|
211
|
+
include gamma
|
212
|
+
}
|
213
|
+
class gamma { }
|
214
|
+
class { alpha: stage => before }
|
215
|
+
MANIFEST
|
216
|
+
|
217
|
+
catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new 'anyone')
|
218
|
+
|
219
|
+
# Stringify them to make for easier lookup
|
220
|
+
edges = catalog.edges.map {|e| [e.source.ref, e.target.ref]}
|
221
|
+
|
222
|
+
edges.should include(["Stage[before]", "Class[Alpha]"])
|
223
|
+
edges.should include(["Stage[before]", "Class[Beta]"])
|
224
|
+
edges.should include(["Stage[before]", "Class[Gamma]"])
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should use the specified stage even if the parent scope specifies one" do
|
228
|
+
Puppet[:code] = <<-MANIFEST
|
229
|
+
stage { before: before => Stage[main], }
|
230
|
+
stage { after: require => Stage[main], }
|
231
|
+
|
232
|
+
class alpha {
|
233
|
+
class { beta: stage => after }
|
234
|
+
}
|
235
|
+
class beta { }
|
236
|
+
class { alpha: stage => before }
|
237
|
+
MANIFEST
|
238
|
+
|
239
|
+
catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new 'anyone')
|
240
|
+
|
241
|
+
edges = catalog.edges.map {|e| [e.source.ref, e.target.ref]}
|
242
|
+
|
243
|
+
edges.should include(["Stage[before]", "Class[Alpha]"])
|
244
|
+
edges.should include(["Stage[after]", "Class[Beta]"])
|
245
|
+
end
|
246
|
+
|
203
247
|
it "should add edges from top-level class resources to the main stage if no stage is specified", :'fails_on_ruby_1.9.2' => true do
|
204
248
|
main = @compiler.catalog.resource(:stage, :main)
|
205
249
|
@compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "foo", '')
|