puppet 2.6.4 → 2.6.5
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 +147 -0
- data/LICENSE +2 -2
- data/Rakefile +3 -4
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application.rb +22 -5
- data/lib/puppet/application/apply.rb +2 -18
- data/lib/puppet/application/doc.rb +1 -4
- data/lib/puppet/application/inspect.rb +178 -0
- data/lib/puppet/configurer.rb +9 -11
- data/lib/puppet/configurer/plugin_handler.rb +0 -2
- data/lib/puppet/defaults.rb +12 -3
- data/lib/puppet/external/pson/pure/generator.rb +1 -22
- data/lib/puppet/file_bucket/dipper.rb +9 -3
- data/lib/puppet/file_bucket/file.rb +14 -94
- data/lib/puppet/indirector.rb +4 -0
- data/lib/puppet/indirector/catalog/active_record.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +64 -75
- data/lib/puppet/indirector/indirection.rb +18 -8
- data/lib/puppet/indirector/resource/ral.rb +7 -2
- data/lib/puppet/indirector/rest.rb +19 -2
- data/lib/puppet/network/http/api/v1.rb +3 -0
- data/lib/puppet/network/http/handler.rb +16 -1
- data/lib/puppet/network/http/rack/rest.rb +1 -3
- data/lib/puppet/network/rest_authconfig.rb +4 -12
- data/lib/puppet/network/rights.rb +28 -14
- data/lib/puppet/parser/ast.rb +4 -0
- data/lib/puppet/parser/compiler.rb +18 -3
- data/lib/puppet/parser/functions/defined.rb +28 -6
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -3
- data/lib/puppet/parser/templatewrapper.rb +1 -0
- data/lib/puppet/property.rb +16 -1
- data/lib/puppet/property/keyvalue.rb +0 -2
- data/lib/puppet/property/list.rb +0 -2
- data/lib/puppet/provider/file/posix.rb +1 -3
- data/lib/puppet/provider/file/win32.rb +1 -3
- data/lib/puppet/provider/maillist/mailman.rb +3 -5
- data/lib/puppet/provider/mount.rb +2 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/freebsd.rb +2 -2
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/reference/configuration.rb +2 -2
- data/lib/puppet/reference/function.rb +4 -0
- data/lib/puppet/relationship.rb +4 -0
- data/lib/puppet/reports/store.rb +1 -19
- data/lib/puppet/resource.rb +11 -2
- data/lib/puppet/resource/status.rb +24 -3
- data/lib/puppet/resource/type.rb +24 -16
- data/lib/puppet/resource/type_collection.rb +4 -1
- data/lib/puppet/simple_graph.rb +4 -0
- data/lib/puppet/transaction.rb +1 -28
- data/lib/puppet/transaction/event.rb +9 -4
- data/lib/puppet/transaction/report.rb +42 -22
- data/lib/puppet/transaction/resource_harness.rb +99 -71
- data/lib/puppet/type.rb +22 -9
- data/lib/puppet/type/cron.rb +1 -5
- data/lib/puppet/type/exec.rb +4 -34
- data/lib/puppet/type/file.rb +19 -26
- data/lib/puppet/type/file/checksum.rb +1 -1
- data/lib/puppet/type/file/content.rb +2 -1
- data/lib/puppet/type/file/ctime.rb +18 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +10 -44
- data/lib/puppet/type/file/mtime.rb +17 -0
- data/lib/puppet/type/file/owner.rb +1 -1
- data/lib/puppet/type/file/source.rb +0 -1
- data/lib/puppet/type/file/target.rb +1 -1
- data/lib/puppet/type/file/type.rb +5 -12
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/package.rb +0 -2
- data/lib/puppet/type/service.rb +11 -5
- data/lib/puppet/type/user.rb +7 -9
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zpool.rb +0 -4
- data/lib/puppet/util/checksums.rb +24 -1
- data/lib/puppet/util/command_line.rb +6 -2
- data/lib/puppet/util/command_line/puppet +5 -1
- data/lib/puppet/util/command_line/puppetca +2 -2
- data/lib/puppet/util/command_line/puppetd +11 -9
- data/lib/puppet/util/command_line/puppetdoc +2 -2
- data/lib/puppet/util/command_line/puppetmasterd +5 -0
- data/lib/puppet/util/log.rb +15 -8
- data/lib/puppet/util/log/destinations.rb +2 -0
- data/lib/puppet/util/log_paths.rb +1 -1
- data/lib/puppet/util/logging.rb +1 -1
- data/lib/puppet/util/metric.rb +1 -0
- data/lib/puppet/util/reference.rb +1 -10
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/zaml.rb +30 -31
- data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +7 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -4
- data/spec/integration/indirector/report/rest_spec.rb +13 -17
- data/spec/integration/network/formats_spec.rb +2 -5
- data/spec/integration/network/server/mongrel_spec.rb +1 -2
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -1
- data/spec/integration/provider/package_spec.rb +1 -3
- data/spec/integration/provider/service/init_spec.rb +3 -9
- data/spec/integration/reference/providers_spec.rb +2 -2
- data/spec/integration/resource/catalog_spec.rb +1 -2
- data/spec/integration/transaction/report_spec.rb +1 -1
- data/spec/monkey_patches/alias_should_to_must.rb +2 -0
- data/spec/shared_behaviours/file_server_terminus.rb +1 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/shared_behaviours/memory_terminus.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/unit/application/agent_spec.rb +1 -0
- data/spec/unit/application/apply_spec.rb +7 -7
- data/spec/unit/application/doc_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +278 -0
- data/spec/unit/application/kick_spec.rb +1 -3
- data/spec/unit/application/master_spec.rb +1 -3
- data/spec/unit/application/queue_spec.rb +1 -0
- data/spec/unit/application_spec.rb +63 -5
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -1
- data/spec/unit/configurer_spec.rb +33 -49
- data/spec/unit/file_bucket/dipper_spec.rb +69 -77
- data/spec/unit/file_bucket/file_spec.rb +12 -127
- data/spec/unit/file_serving/fileset_spec.rb +1 -0
- data/spec/unit/file_serving/metadata_spec.rb +4 -4
- data/spec/unit/indirector/active_record_spec.rb +1 -0
- data/spec/unit/indirector/catalog/active_record_spec.rb +29 -13
- data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
- data/spec/unit/indirector/facts/couch_spec.rb +1 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +202 -218
- data/spec/unit/indirector/file_server_spec.rb +6 -7
- data/spec/unit/indirector/indirection_spec.rb +71 -2
- data/spec/unit/indirector/ldap_spec.rb +2 -6
- data/spec/unit/indirector/node/active_record_spec.rb +1 -3
- data/spec/unit/indirector/queue_spec.rb +1 -3
- data/spec/unit/indirector/rest_spec.rb +37 -1
- data/spec/unit/indirector/ssl_file_spec.rb +5 -5
- data/spec/unit/indirector_spec.rb +6 -1
- data/spec/unit/module_spec.rb +1 -3
- data/spec/unit/network/formats_spec.rb +2 -5
- data/spec/unit/network/http/api/v1_spec.rb +4 -0
- data/spec/unit/network/http/compression_spec.rb +1 -3
- data/spec/unit/network/http/handler_spec.rb +39 -0
- data/spec/unit/network/http/mongrel/rest_spec.rb +1 -2
- data/spec/unit/network/http/mongrel_spec.rb +3 -9
- data/spec/unit/network/http/rack/rest_spec.rb +1 -3
- data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
- data/spec/unit/network/http/rack_spec.rb +2 -3
- data/spec/unit/network/http/webrick_spec.rb +1 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/network/rights_spec.rb +43 -23
- data/spec/unit/network/xmlrpc/client_spec.rb +1 -0
- data/spec/unit/parameter_spec.rb +1 -2
- data/spec/unit/parser/collector_spec.rb +3 -6
- data/spec/unit/parser/compiler_spec.rb +90 -5
- data/spec/unit/parser/lexer_spec.rb +3 -2
- data/spec/unit/parser/templatewrapper_spec.rb +1 -0
- data/spec/unit/property/keyvalue_spec.rb +5 -5
- data/spec/unit/property/list_spec.rb +7 -7
- data/spec/unit/provider/mount/parsed_spec.rb +1 -2
- data/spec/unit/provider/mount_spec.rb +8 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +38 -0
- data/spec/unit/provider/package/freebsd_spec.rb +55 -0
- data/spec/unit/provider/service/init_spec.rb +2 -0
- data/spec/unit/rails/host_spec.rb +1 -3
- data/spec/unit/rails/param_value_spec.rb +2 -3
- data/spec/unit/rails/resource_spec.rb +2 -3
- data/spec/unit/rails_spec.rb +5 -15
- data/spec/unit/relationship_spec.rb +2 -6
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/reports/store_spec.rb +31 -0
- data/spec/unit/reports/tagmail_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +2 -6
- data/spec/unit/resource/status_spec.rb +53 -3
- data/spec/unit/resource/type_collection_spec.rb +0 -8
- data/spec/unit/resource/type_spec.rb +50 -4
- data/spec/unit/resource_spec.rb +10 -6
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +1 -1
- data/spec/unit/transaction/event_spec.rb +21 -2
- data/spec/unit/transaction/report_spec.rb +91 -35
- data/spec/unit/transaction/resource_harness_spec.rb +289 -208
- data/spec/unit/transaction_spec.rb +1 -6
- data/spec/unit/type/augeas_spec.rb +1 -3
- data/spec/unit/type/file/content_spec.rb +63 -10
- data/spec/unit/type/file/ctime.rb +35 -0
- data/spec/unit/type/file/ensure_spec.rb +8 -7
- data/spec/unit/type/file/group_spec.rb +5 -5
- data/spec/unit/type/file/mtime.rb +35 -0
- data/spec/unit/type/file/owner_spec.rb +7 -7
- data/spec/unit/type/file/selinux_spec.rb +2 -2
- data/spec/unit/type/file/source_spec.rb +3 -3
- data/spec/unit/type/file/type.rb +20 -0
- data/spec/unit/type/file_spec.rb +131 -8
- data/spec/unit/type/mount_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +3 -3
- data/spec/unit/type/ssh_authorized_key_spec.rb +1 -1
- data/spec/unit/type/user_spec.rb +31 -3
- data/spec/unit/type/zpool_spec.rb +12 -12
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/checksums_spec.rb +9 -1
- data/spec/unit/util/command_line_spec.rb +29 -0
- data/spec/unit/util/log/destinations_spec.rb +13 -0
- data/spec/unit/util/log_spec.rb +24 -12
- data/spec/unit/util/logging_spec.rb +1 -1
- data/spec/unit/util/metric_spec.rb +7 -7
- data/spec/unit/util/pson_spec.rb +15 -0
- data/spec/unit/util/queue/stomp_spec.rb +2 -6
- data/spec/unit/util/settings/file_setting_spec.rb +1 -3
- data/spec/unit/util/zaml_spec.rb +51 -0
- data/test/language/snippets.rb +3 -0
- data/test/lib/puppettest/fileparsing.rb +2 -0
- data/test/lib/puppettest/reporttesting.rb +1 -1
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/network/server/mongrel_test.rb +0 -6
- data/test/other/report.rb +1 -1
- data/test/ral/providers/cron/crontab.rb +4 -1
- data/test/ral/type/file.rb +1 -1
- data/test/ral/type/filesources.rb +1 -4
- metadata +1119 -1113
- data/lib/puppet/transaction/change.rb +0 -87
- data/spec/Rakefile +0 -91
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -46
- data/spec/spec_specs/runnable_spec.rb +0 -95
- data/spec/unit/transaction/change_spec.rb +0 -193
@@ -426,14 +426,6 @@ describe Puppet::Resource::TypeCollection do
|
|
426
426
|
@parser.expects(:parse).raises ArgumentError
|
427
427
|
lambda { @code.perform_initial_import }.should raise_error(Puppet::Error)
|
428
428
|
end
|
429
|
-
|
430
|
-
it "should not do anything if the ignore_import settings is set" do
|
431
|
-
Puppet.settings[:ignoreimport] = true
|
432
|
-
@parser.expects(:string=).never
|
433
|
-
@parser.expects(:file=).never
|
434
|
-
@parser.expects(:parse).never
|
435
|
-
@code.perform_initial_import
|
436
|
-
end
|
437
429
|
end
|
438
430
|
|
439
431
|
describe "when determining the configuration version" do
|
@@ -261,6 +261,28 @@ describe Puppet::Resource::Type do
|
|
261
261
|
@type = Puppet::Resource::Type.new(:hostclass, "foo")
|
262
262
|
end
|
263
263
|
|
264
|
+
['module_name', 'name', 'title'].each do |variable|
|
265
|
+
it "should allow #{variable} to be evaluated as param default" do
|
266
|
+
@type.module_name = "bar"
|
267
|
+
var = Puppet::Parser::AST::Variable.new({'value' => variable})
|
268
|
+
@type.set_arguments :foo => var
|
269
|
+
@type.set_resource_parameters(@resource, @scope)
|
270
|
+
@scope.lookupvar('foo').should == 'bar'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# this test is to clarify a crazy edge case
|
275
|
+
# if you specify these special names as params, the resource
|
276
|
+
# will override the special variables
|
277
|
+
it "resource should override defaults" do
|
278
|
+
@type.set_arguments :name => nil
|
279
|
+
@resource[:name] = 'foobar'
|
280
|
+
var = Puppet::Parser::AST::Variable.new({'value' => 'name'})
|
281
|
+
@type.set_arguments :foo => var
|
282
|
+
@type.set_resource_parameters(@resource, @scope)
|
283
|
+
@scope.lookupvar('foo').should == 'foobar'
|
284
|
+
end
|
285
|
+
|
264
286
|
it "should set each of the resource's parameters as variables in the scope" do
|
265
287
|
@type.set_arguments :foo => nil, :boo => nil
|
266
288
|
@resource[:foo] = "bar"
|
@@ -496,7 +518,7 @@ describe Puppet::Resource::Type do
|
|
496
518
|
|
497
519
|
it "should evaluate the parent's resource" do
|
498
520
|
@type.parent_type(@scope)
|
499
|
-
|
521
|
+
|
500
522
|
@type.evaluate_code(@resource)
|
501
523
|
|
502
524
|
@scope.class_scope(@parent_type).should_not be_nil
|
@@ -504,7 +526,7 @@ describe Puppet::Resource::Type do
|
|
504
526
|
|
505
527
|
it "should not evaluate the parent's resource if it has already been evaluated" do
|
506
528
|
@parent_resource.evaluate
|
507
|
-
|
529
|
+
|
508
530
|
@type.parent_type(@scope)
|
509
531
|
|
510
532
|
@parent_resource.expects(:evaluate).never
|
@@ -545,7 +567,7 @@ describe Puppet::Resource::Type do
|
|
545
567
|
|
546
568
|
it "should not evaluate the parent's resource if it has already been evaluated" do
|
547
569
|
@parent_resource.evaluate
|
548
|
-
|
570
|
+
|
549
571
|
@type.parent_type(@scope)
|
550
572
|
|
551
573
|
@parent_resource.expects(:evaluate).never
|
@@ -575,7 +597,7 @@ describe Puppet::Resource::Type do
|
|
575
597
|
@code = Puppet::Resource::TypeCollection.new("env")
|
576
598
|
@code.add @top
|
577
599
|
@code.add @middle
|
578
|
-
|
600
|
+
|
579
601
|
@node.environment.stubs(:known_resource_types).returns(@code)
|
580
602
|
end
|
581
603
|
|
@@ -601,12 +623,36 @@ describe Puppet::Resource::Type do
|
|
601
623
|
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
602
624
|
end
|
603
625
|
|
626
|
+
it "should add specified parameters to the resource" do
|
627
|
+
@top.ensure_in_catalog(@scope, {'one'=>'1', 'two'=>'2'})
|
628
|
+
@compiler.catalog.resource(:class, "top")['one'].should == '1'
|
629
|
+
@compiler.catalog.resource(:class, "top")['two'].should == '2'
|
630
|
+
end
|
631
|
+
|
632
|
+
it "should not require params for a param class" do
|
633
|
+
@top.ensure_in_catalog(@scope, {})
|
634
|
+
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
635
|
+
end
|
636
|
+
|
604
637
|
it "should evaluate the parent class if one exists" do
|
605
638
|
@middle.ensure_in_catalog(@scope)
|
606
639
|
|
607
640
|
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
608
641
|
end
|
609
642
|
|
643
|
+
it "should evaluate the parent class if one exists" do
|
644
|
+
@middle.ensure_in_catalog(@scope, {})
|
645
|
+
|
646
|
+
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
647
|
+
end
|
648
|
+
|
649
|
+
it "should fail if you try to create duplicate class resources" do
|
650
|
+
othertop = Puppet::Parser::Resource.new(:class, 'top',:source => @source, :scope => @scope )
|
651
|
+
# add the same class resource to the catalog
|
652
|
+
@compiler.catalog.add_resource(othertop)
|
653
|
+
lambda { @top.ensure_in_catalog(@scope, {}) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError)
|
654
|
+
end
|
655
|
+
|
610
656
|
it "should fail to evaluate if a parent class is defined but cannot be found" do
|
611
657
|
othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay"
|
612
658
|
@code.add othertop
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -98,6 +98,14 @@ describe Puppet::Resource do
|
|
98
98
|
lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError)
|
99
99
|
end
|
100
100
|
|
101
|
+
it 'should fail if strict is set and type does not exist' do
|
102
|
+
lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo')
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should fail if strict is set and class does not exist' do
|
106
|
+
lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo')
|
107
|
+
end
|
108
|
+
|
101
109
|
it "should fail if the title is a hash and the type is not a valid resource reference string" do
|
102
110
|
lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError,
|
103
111
|
'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?'
|
@@ -585,9 +593,7 @@ describe Puppet::Resource do
|
|
585
593
|
end
|
586
594
|
end
|
587
595
|
|
588
|
-
describe "when converting to pson" do
|
589
|
-
confine "Missing 'pson' library" => Puppet.features.pson?
|
590
|
-
|
596
|
+
describe "when converting to pson", :if => Puppet.features.pson? do
|
591
597
|
def pson_output_should
|
592
598
|
@resource.class.expects(:pson_create).with { |hash| yield hash }
|
593
599
|
end
|
@@ -666,9 +672,7 @@ describe Puppet::Resource do
|
|
666
672
|
end
|
667
673
|
end
|
668
674
|
|
669
|
-
describe "when converting from pson" do
|
670
|
-
confine "Missing 'pson' library" => Puppet.features.pson?
|
671
|
-
|
675
|
+
describe "when converting from pson", :if => Puppet.features.pson? do
|
672
676
|
def pson_result_should
|
673
677
|
Puppet::Resource.expects(:new).with { |hash| yield hash }
|
674
678
|
end
|
@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
4
4
|
|
5
5
|
require 'puppet/ssl/certificate_authority'
|
6
6
|
|
7
|
-
|
7
|
+
shared_examples_for "a normal interface method" do
|
8
8
|
it "should call the method on the CA for each host specified if an array was provided" do
|
9
9
|
@ca.expects(@method).with("host1")
|
10
10
|
@ca.expects(@method).with("host2")
|
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
5
|
require 'puppet/transaction/event'
|
6
6
|
|
7
7
|
describe Puppet::Transaction::Event do
|
8
|
-
[:previous_value, :desired_value, :property, :resource, :name, :message, :
|
8
|
+
[:previous_value, :desired_value, :property, :resource, :name, :message, :file, :line, :tags, :audited].each do |attr|
|
9
9
|
it "should support #{attr}" do
|
10
10
|
event = Puppet::Transaction::Event.new
|
11
11
|
event.send(attr.to_s + "=", "foo")
|
@@ -46,6 +46,12 @@ describe Puppet::Transaction::Event do
|
|
46
46
|
Puppet::Transaction::Event.new.time.should be_instance_of(Time)
|
47
47
|
end
|
48
48
|
|
49
|
+
describe "audit property" do
|
50
|
+
it "should default to false" do
|
51
|
+
Puppet::Transaction::Event.new.audited.should == false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
49
55
|
describe "when sending logs" do
|
50
56
|
before do
|
51
57
|
Puppet::Util::Log.stubs(:new)
|
@@ -83,7 +89,7 @@ describe Puppet::Transaction::Event do
|
|
83
89
|
Puppet::Transaction::Event.new(:tags => %w{one two}).send_log
|
84
90
|
end
|
85
91
|
|
86
|
-
[:file, :line
|
92
|
+
[:file, :line].each do |attr|
|
87
93
|
it "should pass the #{attr}" do
|
88
94
|
Puppet::Util::Log.expects(:new).with { |args| args[attr] == "my val" }
|
89
95
|
Puppet::Transaction::Event.new(attr => "my val").send_log
|
@@ -105,4 +111,17 @@ describe Puppet::Transaction::Event do
|
|
105
111
|
Puppet::Transaction::Event.new(:resource => "Foo[bar]").send_log
|
106
112
|
end
|
107
113
|
end
|
114
|
+
|
115
|
+
describe "When converting to YAML" do
|
116
|
+
it "should include only documented attributes" do
|
117
|
+
resource = Puppet::Type.type(:file).new(:title => "/tmp/foo")
|
118
|
+
event = Puppet::Transaction::Event.new(:source_description => "/my/param", :resource => resource,
|
119
|
+
:file => "/foo.rb", :line => 27, :tags => %w{one two},
|
120
|
+
:desired_value => 7, :historical_value => 'Brazil',
|
121
|
+
:message => "Help I'm trapped in a spec test",
|
122
|
+
:name => :mode_changed, :previous_value => 6, :property => :mode,
|
123
|
+
:status => 'success')
|
124
|
+
event.to_yaml_properties.should == Puppet::Transaction::Event::YAML_ATTRIBUTES.sort
|
125
|
+
end
|
126
|
+
end
|
108
127
|
end
|
@@ -11,22 +11,36 @@ describe Puppet::Transaction::Report do
|
|
11
11
|
|
12
12
|
it "should set its host name to the certname" do
|
13
13
|
Puppet.settings.expects(:value).with(:certname).returns "myhost"
|
14
|
-
Puppet::Transaction::Report.new.host.should == "myhost"
|
14
|
+
Puppet::Transaction::Report.new("apply").host.should == "myhost"
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return its host name as its name" do
|
18
|
-
r = Puppet::Transaction::Report.new
|
18
|
+
r = Puppet::Transaction::Report.new("apply")
|
19
19
|
r.name.should == r.host
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should create an initialization timestamp" do
|
23
23
|
Time.expects(:now).returns "mytime"
|
24
|
-
Puppet::Transaction::Report.new.time.should == "mytime"
|
24
|
+
Puppet::Transaction::Report.new("apply").time.should == "mytime"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should take a 'kind' as an argument" do
|
28
|
+
Puppet::Transaction::Report.new("inspect").kind.should == "inspect"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should take a 'configuration_version' as an argument" do
|
32
|
+
Puppet::Transaction::Report.new("inspect", "some configuration version").configuration_version.should == "some configuration version"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to set configuration_version" do
|
36
|
+
report = Puppet::Transaction::Report.new("inspect")
|
37
|
+
report.configuration_version = "some version"
|
38
|
+
report.configuration_version.should == "some version"
|
25
39
|
end
|
26
40
|
|
27
41
|
describe "when accepting logs" do
|
28
42
|
before do
|
29
|
-
@report = Puppet::Transaction::Report.new
|
43
|
+
@report = Puppet::Transaction::Report.new("apply")
|
30
44
|
end
|
31
45
|
|
32
46
|
it "should add new logs to the log list" do
|
@@ -42,7 +56,7 @@ describe Puppet::Transaction::Report do
|
|
42
56
|
|
43
57
|
describe "when accepting resource statuses" do
|
44
58
|
before do
|
45
|
-
@report = Puppet::Transaction::Report.new
|
59
|
+
@report = Puppet::Transaction::Report.new("apply")
|
46
60
|
end
|
47
61
|
|
48
62
|
it "should add each status to its status list" do
|
@@ -64,7 +78,7 @@ describe Puppet::Transaction::Report do
|
|
64
78
|
Facter.stubs(:value).returns("eh")
|
65
79
|
@indirection = stub 'indirection', :name => :report
|
66
80
|
Puppet::Transaction::Report.stubs(:indirection).returns(@indirection)
|
67
|
-
report = Puppet::Transaction::Report.new
|
81
|
+
report = Puppet::Transaction::Report.new("apply")
|
68
82
|
@indirection.expects(:save)
|
69
83
|
report.save
|
70
84
|
end
|
@@ -74,7 +88,7 @@ describe Puppet::Transaction::Report do
|
|
74
88
|
end
|
75
89
|
|
76
90
|
it "should delegate its name attribute to its host method" do
|
77
|
-
report = Puppet::Transaction::Report.new
|
91
|
+
report = Puppet::Transaction::Report.new("apply")
|
78
92
|
report.expects(:host).returns "me"
|
79
93
|
report.name.should == "me"
|
80
94
|
end
|
@@ -86,30 +100,37 @@ describe Puppet::Transaction::Report do
|
|
86
100
|
|
87
101
|
describe "when computing exit status" do
|
88
102
|
it "should produce 2 if changes are present" do
|
89
|
-
report = Puppet::Transaction::Report.new
|
90
|
-
report.add_metric("changes", {
|
91
|
-
report.add_metric("resources", {
|
103
|
+
report = Puppet::Transaction::Report.new("apply")
|
104
|
+
report.add_metric("changes", {"total" => 1})
|
105
|
+
report.add_metric("resources", {"failed" => 0})
|
92
106
|
report.exit_status.should == 2
|
93
107
|
end
|
94
108
|
|
95
109
|
it "should produce 4 if failures are present" do
|
96
|
-
report = Puppet::Transaction::Report.new
|
97
|
-
report.add_metric("changes", {
|
98
|
-
report.add_metric("resources", {
|
110
|
+
report = Puppet::Transaction::Report.new("apply")
|
111
|
+
report.add_metric("changes", {"total" => 0})
|
112
|
+
report.add_metric("resources", {"failed" => 1})
|
99
113
|
report.exit_status.should == 4
|
100
114
|
end
|
101
115
|
|
102
116
|
it "should produce 6 if both changes and failures are present" do
|
103
|
-
report = Puppet::Transaction::Report.new
|
104
|
-
report.add_metric("changes", {
|
105
|
-
report.add_metric("resources", {
|
117
|
+
report = Puppet::Transaction::Report.new("apply")
|
118
|
+
report.add_metric("changes", {"total" => 1})
|
119
|
+
report.add_metric("resources", {"failed" => 1})
|
106
120
|
report.exit_status.should == 6
|
107
121
|
end
|
108
122
|
end
|
109
123
|
|
110
|
-
describe "
|
124
|
+
describe "before finalizing the report" do
|
125
|
+
it "should have a status of 'failed'" do
|
126
|
+
report = Puppet::Transaction::Report.new("apply")
|
127
|
+
report.status.should == 'failed'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "when finalizing the report" do
|
111
132
|
before do
|
112
|
-
@report = Puppet::Transaction::Report.new
|
133
|
+
@report = Puppet::Transaction::Report.new("apply")
|
113
134
|
end
|
114
135
|
|
115
136
|
def metric(name, value)
|
@@ -121,7 +142,7 @@ describe Puppet::Transaction::Report do
|
|
121
142
|
end
|
122
143
|
|
123
144
|
def add_statuses(count, type = :file)
|
124
|
-
|
145
|
+
count.times do |i|
|
125
146
|
status = Puppet::Resource::Status.new(Puppet::Type.type(type).new(:title => "/my/path#{i}"))
|
126
147
|
yield status if block_given?
|
127
148
|
@report.add_resource_status status
|
@@ -131,7 +152,7 @@ describe Puppet::Transaction::Report do
|
|
131
152
|
|
132
153
|
[:time, :resources, :changes, :events].each do |type|
|
133
154
|
it "should add #{type} metrics" do
|
134
|
-
@report.
|
155
|
+
@report.finalize_report
|
135
156
|
@report.metrics[type.to_s].should be_instance_of(Puppet::Transaction::Metric)
|
136
157
|
end
|
137
158
|
end
|
@@ -140,25 +161,38 @@ describe Puppet::Transaction::Report do
|
|
140
161
|
it "should provide the total number of resources" do
|
141
162
|
add_statuses(3)
|
142
163
|
|
143
|
-
@report.
|
144
|
-
metric(:resources,
|
164
|
+
@report.finalize_report
|
165
|
+
metric(:resources, "total").should == 3
|
145
166
|
end
|
146
167
|
|
147
168
|
Puppet::Resource::Status::STATES.each do |state|
|
148
169
|
it "should provide the number of #{state} resources as determined by the status objects" do
|
149
170
|
add_statuses(3) { |status| status.send(state.to_s + "=", true) }
|
150
171
|
|
151
|
-
@report.
|
152
|
-
metric(:resources, state).should == 3
|
172
|
+
@report.finalize_report
|
173
|
+
metric(:resources, state.to_s).should == 3
|
153
174
|
end
|
154
175
|
end
|
176
|
+
|
177
|
+
it "should mark the report as 'failed' if there are failing resources" do
|
178
|
+
add_statuses(1) { |status| status.failed = true }
|
179
|
+
@report.finalize_report
|
180
|
+
@report.status.should == 'failed'
|
181
|
+
end
|
155
182
|
end
|
156
183
|
|
157
184
|
describe "for changes" do
|
158
|
-
it "should provide the number of changes from the resource statuses" do
|
159
|
-
add_statuses(3) { |status| status.
|
160
|
-
@report.
|
161
|
-
metric(:changes,
|
185
|
+
it "should provide the number of changes from the resource statuses and mark the report as 'changed'" do
|
186
|
+
add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new(:status => 'success') } }
|
187
|
+
@report.finalize_report
|
188
|
+
metric(:changes, "total").should == 9
|
189
|
+
@report.status.should == 'changed'
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should provide a total even if there are no changes, and mark the report as 'unchanged'" do
|
193
|
+
@report.finalize_report
|
194
|
+
metric(:changes, "total").should == 0
|
195
|
+
@report.status.should == 'unchanged'
|
162
196
|
end
|
163
197
|
end
|
164
198
|
|
@@ -174,7 +208,7 @@ describe Puppet::Transaction::Report do
|
|
174
208
|
status.evaluation_time = 3
|
175
209
|
end
|
176
210
|
|
177
|
-
@report.
|
211
|
+
@report.finalize_report
|
178
212
|
|
179
213
|
metric(:time, "file").should == 3
|
180
214
|
metric(:time, "exec").should == 6
|
@@ -183,18 +217,32 @@ describe Puppet::Transaction::Report do
|
|
183
217
|
|
184
218
|
it "should add any provided times from external sources" do
|
185
219
|
@report.add_times :foobar, 50
|
186
|
-
@report.
|
220
|
+
@report.finalize_report
|
187
221
|
metric(:time, "foobar").should == 50
|
188
222
|
end
|
223
|
+
|
224
|
+
it "should have a total time" do
|
225
|
+
add_statuses(3, :file) do |status|
|
226
|
+
status.evaluation_time = 1.25
|
227
|
+
end
|
228
|
+
@report.add_times :config_retrieval, 0.5
|
229
|
+
@report.finalize_report
|
230
|
+
metric(:time, "total").should == 4.25
|
231
|
+
end
|
189
232
|
end
|
190
233
|
|
191
234
|
describe "for events" do
|
192
235
|
it "should provide the total number of events" do
|
193
236
|
add_statuses(3) do |status|
|
194
|
-
3.times { |i| status.add_event(Puppet::Transaction::Event.new) }
|
237
|
+
3.times { |i| status.add_event(Puppet::Transaction::Event.new :status => 'success') }
|
195
238
|
end
|
196
|
-
@report.
|
197
|
-
metric(:events,
|
239
|
+
@report.finalize_report
|
240
|
+
metric(:events, "total").should == 9
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should provide the total even if there are no events" do
|
244
|
+
@report.finalize_report
|
245
|
+
metric(:events, "total").should == 0
|
198
246
|
end
|
199
247
|
|
200
248
|
Puppet::Transaction::Event::EVENT_STATUSES.each do |status_name|
|
@@ -207,7 +255,7 @@ describe Puppet::Transaction::Report do
|
|
207
255
|
end
|
208
256
|
end
|
209
257
|
|
210
|
-
@report.
|
258
|
+
@report.finalize_report
|
211
259
|
metric(:events, status_name).should == 9
|
212
260
|
end
|
213
261
|
end
|
@@ -222,7 +270,7 @@ describe Puppet::Transaction::Report do
|
|
222
270
|
trans = catalog.apply
|
223
271
|
|
224
272
|
@report = trans.report
|
225
|
-
@report.
|
273
|
+
@report.finalize_report
|
226
274
|
end
|
227
275
|
|
228
276
|
%w{Changes Total Resources}.each do |main|
|
@@ -231,4 +279,12 @@ describe Puppet::Transaction::Report do
|
|
231
279
|
end
|
232
280
|
end
|
233
281
|
end
|
282
|
+
|
283
|
+
describe "when outputting yaml" do
|
284
|
+
it "should not include @external_times" do
|
285
|
+
report = Puppet::Transaction::Report.new('apply')
|
286
|
+
report.add_times('config_retrieval', 1.0)
|
287
|
+
report.to_yaml_properties.should_not include('@external_times')
|
288
|
+
end
|
289
|
+
end
|
234
290
|
end
|