puppet 2.6.6 → 2.6.7
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 +107 -1
- data/README.queueing +1 -1
- data/Rakefile +1 -1
- data/conf/solaris/smf/svc-puppetd +0 -2
- data/conf/solaris/smf/svc-puppetmasterd +0 -2
- data/examples/etc/init.d/sleeper +0 -2
- data/examples/modules/sample-module/README.txt +2 -2
- data/ext/puppetstoredconfigclean.rb +1 -1
- data/install.rb +20 -25
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -2
- data/lib/puppet/application/apply.rb +2 -2
- data/lib/puppet/application/cert.rb +27 -11
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/queue.rb +2 -2
- data/lib/puppet/configurer/downloader.rb +1 -0
- data/lib/puppet/configurer/plugin_handler.rb +8 -1
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +18 -2
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +0 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +97 -0
- data/lib/puppet/indirector/facts/rest.rb +2 -0
- data/lib/puppet/indirector/facts/yaml.rb +75 -0
- data/lib/puppet/indirector/indirection.rb +1 -0
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/network/http/api/v1.rb +3 -4
- data/lib/puppet/network/http/compression.rb +4 -1
- data/lib/puppet/network/http/handler.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +1 -1
- data/lib/puppet/node/facts.rb +29 -0
- data/lib/puppet/parser/ast/collection.rb +5 -4
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +7 -14
- data/lib/puppet/parser/functions/split.rb +7 -7
- data/lib/puppet/parser/grammar.ra +2 -4
- data/lib/puppet/parser/lexer.rb +4 -1
- data/lib/puppet/parser/parser.rb +2062 -1976
- data/lib/puppet/parser/parser_support.rb +3 -3
- data/lib/puppet/provider/computer/computer.rb +1 -3
- data/lib/puppet/provider/mount.rb +12 -16
- data/lib/puppet/provider/mount/parsed.rb +67 -8
- data/lib/puppet/provider/parsedfile.rb +3 -1
- data/lib/puppet/provider/service/daemontools.rb +6 -6
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/launchd.rb +11 -8
- data/lib/puppet/provider/service/runit.rb +4 -4
- data/lib/puppet/provider/user/useradd.rb +6 -1
- data/lib/puppet/rails/database/004_add_inventory_service_tables.rb +36 -0
- data/lib/puppet/rails/database/schema.rb +17 -0
- data/lib/puppet/rails/fact_name.rb +0 -2
- data/lib/puppet/rails/fact_value.rb +0 -2
- data/lib/puppet/rails/inventory_fact.rb +5 -0
- data/lib/puppet/rails/inventory_node.rb +25 -0
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reports/store.rb +4 -1
- data/lib/puppet/resource.rb +39 -25
- data/lib/puppet/type.rb +5 -5
- data/lib/puppet/type/augeas.rb +4 -4
- data/lib/puppet/type/computer.rb +5 -1
- data/lib/puppet/type/exec.rb +3 -1
- data/lib/puppet/type/file.rb +3 -1
- data/lib/puppet/type/file/content.rb +13 -15
- data/lib/puppet/type/file/ensure.rb +11 -17
- data/lib/puppet/type/file/selcontext.rb +16 -0
- data/lib/puppet/type/file/target.rb +14 -1
- data/lib/puppet/type/k5login.rb +0 -2
- data/lib/puppet/type/macauthorization.rb +4 -1
- data/lib/puppet/type/mcx.rb +4 -1
- data/lib/puppet/type/mount.rb +37 -21
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/schedule.rb +20 -20
- data/lib/puppet/type/selmodule.rb +3 -1
- data/lib/puppet/type/ssh_authorized_key.rb +5 -1
- data/lib/puppet/type/user.rb +14 -1
- data/lib/puppet/type/zfs.rb +3 -1
- data/lib/puppet/type/zone.rb +3 -1
- data/lib/puppet/type/zpool.rb +7 -5
- data/lib/puppet/util.rb +5 -0
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/execution.rb +4 -5
- data/lib/puppet/util/execution_stub.rb +26 -0
- data/lib/puppet/util/monkey_patches.rb +21 -0
- data/lib/puppet/util/rdoc/code_objects.rb +39 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +18 -0
- data/lib/puppet/util/rdoc/parser.rb +5 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +7 -0
- data/spec/integration/provider/mount_spec.rb +151 -0
- data/spec/integration/type/file_spec.rb +32 -29
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/application/agent_spec.rb +3 -7
- data/spec/unit/application/apply_spec.rb +17 -2
- data/spec/unit/application/cert_spec.rb +54 -14
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/queue_spec.rb +1 -5
- data/spec/unit/configurer/downloader_spec.rb +22 -10
- data/spec/unit/daemon_spec.rb +1 -5
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +163 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +216 -2
- data/spec/unit/indirector/queue_spec.rb +3 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +1 -1
- data/spec/unit/network/http/api/v1_spec.rb +28 -0
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/handler_spec.rb +7 -4
- data/spec/unit/node/facts_spec.rb +24 -0
- data/spec/unit/parser/ast/collection_spec.rb +16 -12
- data/spec/unit/parser/lexer_spec.rb +16 -0
- data/spec/unit/parser/parser_spec.rb +35 -2
- data/spec/unit/provider/mount/parsed_spec.rb +199 -114
- data/spec/unit/provider/mount_spec.rb +54 -53
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -0
- data/spec/unit/provider/user/useradd_spec.rb +43 -3
- data/spec/unit/reports/store_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +39 -13
- data/spec/unit/type/file/content_spec.rb +38 -137
- data/spec/unit/type/file/selinux_spec.rb +5 -0
- data/spec/unit/type/mount_spec.rb +167 -122
- data/spec/unit/type/user_spec.rb +4 -0
- data/spec/unit/type_spec.rb +12 -1
- data/spec/unit/util/execution_spec.rb +49 -0
- data/spec/unit/util/execution_stub_spec.rb +35 -0
- data/spec/unit/util/rdoc/parser_spec.rb +15 -3
- data/spec/unit/util/settings_spec.rb +11 -2
- data/tasks/rake/git_workflow.rake +1 -1
- data/test/Rakefile +0 -2
- data/test/data/providers/mount/parsed/aix.mount +7 -0
- data/test/data/providers/mount/parsed/darwin.mount +6 -0
- data/test/data/providers/mount/parsed/hpux.mount +17 -0
- data/test/data/providers/mount/parsed/linux.mount +5 -0
- data/test/data/providers/mount/parsed/solaris.mount +6 -0
- data/test/data/types/mount/linux.fstab +1 -0
- data/test/data/types/mount/solaris.fstab +1 -0
- metadata +18 -4
@@ -173,7 +173,12 @@ describe Puppet::Type.type(:file) do
|
|
173
173
|
it "should be able to recurse over a nonexistent file" do
|
174
174
|
@path = tmpfile("file_integration_tests")
|
175
175
|
|
176
|
-
@file = Puppet::Type::File.new(
|
176
|
+
@file = Puppet::Type::File.new(
|
177
|
+
:name => @path,
|
178
|
+
:mode => 0644,
|
179
|
+
:recurse => true,
|
180
|
+
:backup => false
|
181
|
+
)
|
177
182
|
|
178
183
|
@catalog = Puppet::Resource::Catalog.new
|
179
184
|
@catalog.add_resource @file
|
@@ -186,7 +191,12 @@ describe Puppet::Type.type(:file) do
|
|
186
191
|
|
187
192
|
build_path(@path)
|
188
193
|
|
189
|
-
@file = Puppet::Type::File.new(
|
194
|
+
@file = Puppet::Type::File.new(
|
195
|
+
:name => @path,
|
196
|
+
:mode => 0644,
|
197
|
+
:recurse => true,
|
198
|
+
:backup => false
|
199
|
+
)
|
190
200
|
|
191
201
|
@catalog = Puppet::Resource::Catalog.new
|
192
202
|
@catalog.add_resource @file
|
@@ -393,10 +403,8 @@ describe Puppet::Type.type(:file) do
|
|
393
403
|
dest = tmpfile("files_with_content")
|
394
404
|
|
395
405
|
|
396
|
-
|
397
|
-
|
398
|
-
:name => dest,
|
399
|
-
|
406
|
+
file = Puppet::Type.type(:file).new(
|
407
|
+
:name => dest,
|
400
408
|
:content => "this is some content, yo"
|
401
409
|
)
|
402
410
|
|
@@ -411,11 +419,9 @@ describe Puppet::Type.type(:file) do
|
|
411
419
|
dest = tmpfile("files_with_content")
|
412
420
|
|
413
421
|
|
414
|
-
|
415
|
-
|
416
|
-
:
|
417
|
-
:ensure => "file",
|
418
|
-
|
422
|
+
file = Puppet::Type.type(:file).new(
|
423
|
+
:name => dest,
|
424
|
+
:ensure => "file",
|
419
425
|
:content => "this is some content, yo"
|
420
426
|
)
|
421
427
|
|
@@ -433,12 +439,10 @@ describe Puppet::Type.type(:file) do
|
|
433
439
|
File.open(dest, "w") { |f| f.puts "boo" }
|
434
440
|
|
435
441
|
|
436
|
-
|
437
|
-
|
438
|
-
:name => dest,
|
442
|
+
file = Puppet::Type.type(:file).new(
|
443
|
+
:name => dest,
|
439
444
|
:ensure => :absent,
|
440
445
|
:source => source,
|
441
|
-
|
442
446
|
:backup => false
|
443
447
|
)
|
444
448
|
|
@@ -465,24 +469,23 @@ describe Puppet::Type.type(:file) do
|
|
465
469
|
File.open(@purgee, "w") { |f| f.puts "footest" }
|
466
470
|
|
467
471
|
|
468
|
-
|
469
|
-
|
470
|
-
:
|
471
|
-
:path => @localfile,
|
472
|
+
@lfobj = Puppet::Type.newfile(
|
473
|
+
:title => "localfile",
|
474
|
+
:path => @localfile,
|
472
475
|
:content => "rahtest\n",
|
473
|
-
:ensure
|
474
|
-
|
475
|
-
:backup => false
|
476
|
+
:ensure => :file,
|
477
|
+
:backup => false
|
476
478
|
)
|
477
479
|
|
478
480
|
|
479
|
-
|
480
|
-
:title
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
481
|
+
@destobj = Puppet::Type.newfile(
|
482
|
+
:title => "destdir",
|
483
|
+
:path => @destdir,
|
484
|
+
:source => @sourcedir,
|
485
|
+
:backup => false,
|
486
|
+
:purge => true,
|
487
|
+
:recurse => true
|
488
|
+
)
|
486
489
|
|
487
490
|
@catalog = Puppet::Resource::Catalog.new
|
488
491
|
@catalog.add_resource @lfobj, @destobj
|
data/spec/spec_helper.rb
CHANGED
@@ -34,6 +34,7 @@ RSpec.configure do |config|
|
|
34
34
|
Puppet.settings.clear
|
35
35
|
Puppet::Node::Environment.clear
|
36
36
|
Puppet::Util::Storage.clear
|
37
|
+
Puppet::Util::ExecutionStub.reset
|
37
38
|
|
38
39
|
if defined?($tmpfiles)
|
39
40
|
$tmpfiles.each do |file|
|
@@ -64,6 +65,7 @@ RSpec.configure do |config|
|
|
64
65
|
# these globals are set by Application
|
65
66
|
$puppet_application_mode = nil
|
66
67
|
$puppet_application_name = nil
|
68
|
+
Signal.stubs(:trap)
|
67
69
|
|
68
70
|
# Set the confdir and vardir to gibberish so that tests
|
69
71
|
# have to be correctly mocked.
|
@@ -50,12 +50,8 @@ describe Puppet::Application::Agent do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "in preinit" do
|
53
|
-
before :each do
|
54
|
-
@puppetd.stubs(:trap)
|
55
|
-
end
|
56
|
-
|
57
53
|
it "should catch INT" do
|
58
|
-
|
54
|
+
Signal.expects(:trap).with { |arg,block| arg == :INT }
|
59
55
|
|
60
56
|
@puppetd.preinit
|
61
57
|
end
|
@@ -530,11 +526,11 @@ describe Puppet::Application::Agent do
|
|
530
526
|
@puppetd.onetime
|
531
527
|
end
|
532
528
|
|
533
|
-
it "should
|
529
|
+
it "should exit with the report's computer exit status, even if --noop is set." do
|
534
530
|
Puppet.stubs(:[]).with(:noop).returns(true)
|
535
531
|
report = stub 'report', :exit_status => 666
|
536
532
|
@agent.stubs(:run).returns(report)
|
537
|
-
@puppetd.expects(:exit).with(
|
533
|
+
@puppetd.expects(:exit).with(666)
|
538
534
|
|
539
535
|
@puppetd.onetime
|
540
536
|
end
|
@@ -52,7 +52,6 @@ describe Puppet::Application::Apply do
|
|
52
52
|
|
53
53
|
before :each do
|
54
54
|
Puppet::Log.stubs(:newdestination)
|
55
|
-
Puppet.stubs(:trap)
|
56
55
|
Puppet::Log.stubs(:level=)
|
57
56
|
Puppet.stubs(:parse_config)
|
58
57
|
Puppet::FileBucket::Dipper.stubs(:new)
|
@@ -78,7 +77,7 @@ describe Puppet::Application::Apply do
|
|
78
77
|
end
|
79
78
|
|
80
79
|
it "should set INT trap" do
|
81
|
-
|
80
|
+
Signal.expects(:trap).with(:INT)
|
82
81
|
|
83
82
|
@apply.setup
|
84
83
|
end
|
@@ -167,6 +166,13 @@ describe Puppet::Application::Apply do
|
|
167
166
|
@apply.expects(:exit).with(1)
|
168
167
|
@apply.parseonly
|
169
168
|
end
|
169
|
+
|
170
|
+
it "should exit with exit code 1 if error, even if --noop is set" do
|
171
|
+
Puppet[:noop] = true
|
172
|
+
@collection.stubs(:perform_initial_import).raises(Puppet::ParseError)
|
173
|
+
@apply.expects(:exit).with(1)
|
174
|
+
@apply.parseonly
|
175
|
+
end
|
170
176
|
end
|
171
177
|
|
172
178
|
describe "the main command" do
|
@@ -328,6 +334,15 @@ describe Puppet::Application::Apply do
|
|
328
334
|
@apply.main
|
329
335
|
end
|
330
336
|
|
337
|
+
it "should exit with report's computed exit status, even if --noop is set" do
|
338
|
+
Puppet.stubs(:[]).with(:noop).returns(true)
|
339
|
+
@apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
|
340
|
+
Puppet::Transaction::Report.any_instance.stubs(:exit_status).returns(666)
|
341
|
+
@apply.expects(:exit).with(666)
|
342
|
+
|
343
|
+
@apply.main
|
344
|
+
end
|
345
|
+
|
331
346
|
it "should always exit with 0 if option is disabled" do
|
332
347
|
Puppet.stubs(:[]).with(:noop).returns(false)
|
333
348
|
@apply.options.stubs(:[]).with(:detailed_exitcodes).returns(false)
|
@@ -51,7 +51,7 @@ describe Puppet::Application::Cert do
|
|
51
51
|
|
52
52
|
it "should set cert_mode to :destroy for --clean" do
|
53
53
|
@cert_app.handle_clean(0)
|
54
|
-
@cert_app.
|
54
|
+
@cert_app.subcommand.should == :destroy
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should set all to true for --all" do
|
@@ -68,7 +68,7 @@ describe Puppet::Application::Cert do
|
|
68
68
|
it "should set cert_mode to #{method} with option --#{method}" do
|
69
69
|
@cert_app.send("handle_#{method}".to_sym, nil)
|
70
70
|
|
71
|
-
@cert_app.
|
71
|
+
@cert_app.subcommand.should == method
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -114,19 +114,19 @@ describe Puppet::Application::Cert do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should set the ca_location to :local if the cert_mode is generate" do
|
117
|
-
@cert_app.
|
117
|
+
@cert_app.subcommand = 'generate'
|
118
118
|
Puppet::SSL::Host.expects(:ca_location=).with(:local)
|
119
119
|
@cert_app.setup
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should set the ca_location to :local if the cert_mode is destroy" do
|
123
|
-
@cert_app.
|
123
|
+
@cert_app.subcommand = 'destroy'
|
124
124
|
Puppet::SSL::Host.expects(:ca_location=).with(:local)
|
125
125
|
@cert_app.setup
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should set the ca_location to :only if the cert_mode is print" do
|
129
|
-
@cert_app.
|
129
|
+
@cert_app.subcommand = 'print'
|
130
130
|
Puppet::SSL::Host.expects(:ca_location=).with(:only)
|
131
131
|
@cert_app.setup
|
132
132
|
end
|
@@ -171,24 +171,64 @@ describe Puppet::Application::Cert do
|
|
171
171
|
@cert_app.main
|
172
172
|
end
|
173
173
|
|
174
|
-
it "should
|
175
|
-
@cert_app.
|
174
|
+
it "should revoke cert if cert_mode is clean" do
|
175
|
+
@cert_app.subcommand = :destroy
|
176
176
|
@cert_app.command_line.stubs(:args).returns(["host"])
|
177
177
|
|
178
|
-
@ca.expects(:apply).with { |cert_mode,to| cert_mode ==
|
178
|
+
@ca.expects(:apply).with { |cert_mode,to| cert_mode == :revoke }
|
179
|
+
@ca.expects(:apply).with { |cert_mode,to| cert_mode == :destroy }
|
179
180
|
|
180
181
|
@cert_app.main
|
181
182
|
end
|
183
|
+
end
|
182
184
|
|
183
|
-
|
184
|
-
|
185
|
-
@cert_app.
|
185
|
+
describe "when identifying subcommands" do
|
186
|
+
before :each do
|
187
|
+
@cert_app.all = false
|
188
|
+
@ca = stub_everything 'ca'
|
189
|
+
@cert_app.ca = @ca
|
190
|
+
end
|
186
191
|
|
187
|
-
|
188
|
-
|
192
|
+
it "should not fail when no command is given" do
|
193
|
+
# Make the help method silent for testing; this is a bit nasty, but we
|
194
|
+
# can't identify a cleaner method. Help welcome. --daniel 2011-02-22
|
195
|
+
Puppet.features.stubs(:usage?).returns(false)
|
196
|
+
@cert_app.stubs(:puts)
|
189
197
|
|
190
|
-
@cert_app.
|
198
|
+
@cert_app.command_line.stubs(:args).returns([])
|
199
|
+
expect { @cert_app.parse_options }.should raise_error SystemExit
|
191
200
|
end
|
192
201
|
|
202
|
+
%w{list revoke generate sign print verify fingerprint}.each do |cmd|
|
203
|
+
short = cmd[0,1]
|
204
|
+
[cmd, "--#{cmd}", "-#{short}"].each do |option|
|
205
|
+
# In our command line '-v' was eaten by 'verbose', so we can't consume
|
206
|
+
# it here; this is a special case from our otherwise standard
|
207
|
+
# processing. --daniel 2011-02-22
|
208
|
+
next if option == "-v"
|
209
|
+
|
210
|
+
it "should recognise '#{option}'" do
|
211
|
+
args = [option, "fun.example.com"]
|
212
|
+
|
213
|
+
@cert_app.command_line.stubs(:args).returns(args)
|
214
|
+
@cert_app.parse_options
|
215
|
+
@cert_app.subcommand.should == cmd.to_sym
|
216
|
+
|
217
|
+
args.should == ["fun.example.com"]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
%w{clean --clean -c}.each do |ugly|
|
223
|
+
it "should recognise the '#{ugly}' option as destroy" do
|
224
|
+
args = [ugly, "fun.example.com"]
|
225
|
+
|
226
|
+
@cert_app.command_line.stubs(:args).returns(args)
|
227
|
+
@cert_app.parse_options
|
228
|
+
@cert_app.subcommand.should == :destroy
|
229
|
+
|
230
|
+
args.should == ["fun.example.com"]
|
231
|
+
end
|
232
|
+
end
|
193
233
|
end
|
194
234
|
end
|
@@ -29,12 +29,8 @@ describe Puppet::Application::Queue do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "in preinit" do
|
32
|
-
before :each do
|
33
|
-
@queue.stubs(:trap)
|
34
|
-
end
|
35
|
-
|
36
32
|
it "should catch INT" do
|
37
|
-
|
33
|
+
Signal.expects(:trap).with { |arg,block| arg == :INT }
|
38
34
|
|
39
35
|
@queue.preinit
|
40
36
|
end
|
@@ -5,6 +5,8 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
5
|
require 'puppet/configurer/downloader'
|
6
6
|
|
7
7
|
describe Puppet::Configurer::Downloader do
|
8
|
+
require 'puppet_spec/files'
|
9
|
+
include PuppetSpec::Files
|
8
10
|
it "should require a name" do
|
9
11
|
lambda { Puppet::Configurer::Downloader.new }.should raise_error(ArgumentError)
|
10
12
|
end
|
@@ -96,25 +98,35 @@ describe Puppet::Configurer::Downloader do
|
|
96
98
|
|
97
99
|
describe "when creating the catalog to do the downloading" do
|
98
100
|
before do
|
99
|
-
@dler = Puppet::Configurer::Downloader.new("foo", "path", "source")
|
101
|
+
@dler = Puppet::Configurer::Downloader.new("foo", "/download/path", "source")
|
100
102
|
end
|
101
103
|
|
102
104
|
it "should create a catalog and add the file to it" do
|
103
|
-
|
104
|
-
catalog
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
Puppet::Resource::Catalog.expects(:new).returns catalog
|
109
|
-
catalog.expects(:add_resource).with(file)
|
105
|
+
catalog = @dler.catalog
|
106
|
+
catalog.resources.size.should == 1
|
107
|
+
catalog.resources.first.class.should == Puppet::Type::File
|
108
|
+
catalog.resources.first.name.should == "/download/path"
|
109
|
+
end
|
110
110
|
|
111
|
-
|
111
|
+
it "should specify that it is not managing a host catalog" do
|
112
|
+
@dler.catalog.host_config.should == false
|
112
113
|
end
|
114
|
+
|
113
115
|
end
|
114
116
|
|
115
117
|
describe "when downloading" do
|
116
118
|
before do
|
117
|
-
@
|
119
|
+
@dl_name = tmpfile("downloadpath")
|
120
|
+
source_name = tmpfile("source")
|
121
|
+
File.open(source_name, 'w') {|f| f.write('hola mundo') }
|
122
|
+
@dler = Puppet::Configurer::Downloader.new("foo", @dl_name, source_name)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should not skip downloaded resources when filtering on tags" do
|
126
|
+
Puppet[:tags] = 'maytag'
|
127
|
+
@dler.evaluate
|
128
|
+
|
129
|
+
File.exists?(@dl_name).should be_true
|
118
130
|
end
|
119
131
|
|
120
132
|
it "should log that it is downloading" do
|
data/spec/unit/daemon_spec.rb
CHANGED
@@ -29,13 +29,9 @@ describe Puppet::Daemon do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "when setting signal traps" do
|
32
|
-
before do
|
33
|
-
@daemon.stubs(:trap)
|
34
|
-
end
|
35
|
-
|
36
32
|
{:INT => :stop, :TERM => :stop, :HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}.each do |signal, method|
|
37
33
|
it "should log and call #{method} when it receives #{signal}" do
|
38
|
-
|
34
|
+
Signal.expects(:trap).with(signal).yields
|
39
35
|
|
40
36
|
Puppet.expects(:notice)
|
41
37
|
|
@@ -0,0 +1,163 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
|
+
require 'sqlite3' rescue nil
|
5
|
+
require 'tempfile'
|
6
|
+
require 'puppet/rails'
|
7
|
+
|
8
|
+
describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.rails? and defined? SQLite3) do
|
9
|
+
let(:terminus) { Puppet::Node::Facts::InventoryActiveRecord.new }
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
require 'puppet/indirector/facts/inventory_active_record'
|
13
|
+
@dbfile = Tempfile.new("testdb")
|
14
|
+
@dbfile.close
|
15
|
+
end
|
16
|
+
|
17
|
+
after :all do
|
18
|
+
Puppet::Node::Facts.indirection.reset_terminus_class
|
19
|
+
@dbfile.unlink
|
20
|
+
end
|
21
|
+
|
22
|
+
before :each do
|
23
|
+
Puppet::Node::Facts.terminus_class = :inventory_active_record
|
24
|
+
Puppet[:dbadapter] = 'sqlite3'
|
25
|
+
Puppet[:dblocation] = @dbfile.path
|
26
|
+
Puppet[:railslog] = "/dev/null"
|
27
|
+
Puppet::Rails.init
|
28
|
+
end
|
29
|
+
|
30
|
+
after :each do
|
31
|
+
Puppet::Rails.teardown
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#save" do
|
35
|
+
it "should use an existing node if possible" do
|
36
|
+
node = Puppet::Rails::InventoryNode.new(:name => "foo", :timestamp => Time.now)
|
37
|
+
node.save
|
38
|
+
Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
|
39
|
+
|
40
|
+
Puppet::Rails::InventoryNode.count.should == 1
|
41
|
+
Puppet::Rails::InventoryNode.first.should == node
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should create a new node if one can't be found" do
|
45
|
+
# This test isn't valid if there are nodes to begin with
|
46
|
+
Puppet::Rails::InventoryNode.count.should == 0
|
47
|
+
|
48
|
+
Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
|
49
|
+
|
50
|
+
Puppet::Rails::InventoryNode.count.should == 1
|
51
|
+
Puppet::Rails::InventoryNode.first.name.should == "foo"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should save the facts" do
|
55
|
+
Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
|
56
|
+
|
57
|
+
Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should =~ [["uptime_days","60"],["kernel","Darwin"]]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should remove the previous facts for an existing node" do
|
61
|
+
Puppet::Node::Facts.new("foo", "uptime_days" => "30", "kernel" => "Darwin").save
|
62
|
+
bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "35", "kernel" => "Linux")
|
63
|
+
foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "is_virtual" => "false")
|
64
|
+
bar_facts.save
|
65
|
+
foo_facts.save
|
66
|
+
|
67
|
+
Puppet::Node::Facts.find("bar").should == bar_facts
|
68
|
+
Puppet::Node::Facts.find("foo").should == foo_facts
|
69
|
+
Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should_not include(["uptime_days", "30"], ["kernel", "Darwin"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#find" do
|
74
|
+
before do
|
75
|
+
@foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
|
76
|
+
@bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "30", "kernel" => "Linux")
|
77
|
+
@foo_facts.save
|
78
|
+
@bar_facts.save
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should identify facts by node name" do
|
82
|
+
Puppet::Node::Facts.find("foo").should == @foo_facts
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return nil if no node instance can be found" do
|
86
|
+
Puppet::Node::Facts.find("non-existent node").should == nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#search" do
|
91
|
+
def search_request(conditions)
|
92
|
+
Puppet::Indirector::Request.new(:facts, :search, nil, conditions)
|
93
|
+
end
|
94
|
+
|
95
|
+
before :each do
|
96
|
+
@now = Time.now
|
97
|
+
@foo = Puppet::Node::Facts.new("foo", "fact1" => "value1", "fact2" => "value2", "uptime_days" => "30")
|
98
|
+
@bar = Puppet::Node::Facts.new("bar", "fact1" => "value1", "uptime_days" => "60")
|
99
|
+
@baz = Puppet::Node::Facts.new("baz", "fact1" => "value2", "fact2" => "value1", "uptime_days" => "90")
|
100
|
+
@bat = Puppet::Node::Facts.new("bat")
|
101
|
+
@foo.timestamp = @now - 3600*1
|
102
|
+
@bar.timestamp = @now - 3600*3
|
103
|
+
@baz.timestamp = @now - 3600*5
|
104
|
+
@bat.timestamp = @now - 3600*7
|
105
|
+
@foo.save
|
106
|
+
@bar.save
|
107
|
+
@baz.save
|
108
|
+
@bat.save
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return node names that match 'equal' constraints" do
|
112
|
+
request = search_request('facts.fact1.eq' => 'value1',
|
113
|
+
'facts.fact2.eq' => 'value2')
|
114
|
+
terminus.search(request).should == ["foo"]
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return node names that match 'not equal' constraints" do
|
118
|
+
request = search_request('facts.fact1.ne' => 'value2')
|
119
|
+
terminus.search(request).should == ["bar","foo"]
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should return node names that match strict inequality constraints" do
|
123
|
+
request = search_request('facts.uptime_days.gt' => '20',
|
124
|
+
'facts.uptime_days.lt' => '70')
|
125
|
+
terminus.search(request).should == ["bar","foo"]
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return node names that match non-strict inequality constraints" do
|
129
|
+
request = search_request('facts.uptime_days.ge' => '30',
|
130
|
+
'facts.uptime_days.le' => '60')
|
131
|
+
terminus.search(request).should == ["bar","foo"]
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should return node names whose facts are within a given timeframe" do
|
135
|
+
request = search_request('meta.timestamp.ge' => @now - 3600*5,
|
136
|
+
'meta.timestamp.le' => @now - 3600*1)
|
137
|
+
terminus.search(request).should == ["bar","baz","foo"]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should return node names whose facts are from a specific time" do
|
141
|
+
request = search_request('meta.timestamp.eq' => @now - 3600*3)
|
142
|
+
terminus.search(request).should == ["bar"]
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should return node names whose facts are not from a specific time" do
|
146
|
+
request = search_request('meta.timestamp.ne' => @now - 3600*1)
|
147
|
+
terminus.search(request).should == ["bar","bat","baz"]
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should perform strict searches on nodes by timestamp" do
|
151
|
+
request = search_request('meta.timestamp.gt' => @now - 3600*5,
|
152
|
+
'meta.timestamp.lt' => @now - 3600*1)
|
153
|
+
terminus.search(request).should == ["bar"]
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should search nodes based on both facts and timestamp values" do
|
157
|
+
request = search_request('facts.uptime_days.gt' => '45',
|
158
|
+
'meta.timestamp.lt' => @now - 3600*4)
|
159
|
+
terminus.search(request).should == ["baz"]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|