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
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'puppet/transaction'
|
2
|
-
require 'puppet/transaction/event'
|
3
|
-
|
4
|
-
# Handle all of the work around performing an actual change,
|
5
|
-
# including calling 'sync' on the properties and producing events.
|
6
|
-
class Puppet::Transaction::Change
|
7
|
-
attr_accessor :is, :should, :property, :proxy, :auditing
|
8
|
-
|
9
|
-
def auditing?
|
10
|
-
auditing
|
11
|
-
end
|
12
|
-
|
13
|
-
# Create our event object.
|
14
|
-
def event
|
15
|
-
result = property.event
|
16
|
-
result.previous_value = is
|
17
|
-
result.desired_value = should
|
18
|
-
result
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(property, currentvalue)
|
22
|
-
@property = property
|
23
|
-
@is = currentvalue
|
24
|
-
|
25
|
-
@should = property.should
|
26
|
-
|
27
|
-
@changed = false
|
28
|
-
end
|
29
|
-
|
30
|
-
def apply
|
31
|
-
return audit_event if auditing?
|
32
|
-
return noop_event if noop?
|
33
|
-
|
34
|
-
property.sync
|
35
|
-
|
36
|
-
result = event
|
37
|
-
result.message = property.change_to_s(is, should)
|
38
|
-
result.status = "success"
|
39
|
-
result.send_log
|
40
|
-
result
|
41
|
-
rescue => detail
|
42
|
-
puts detail.backtrace if Puppet[:trace]
|
43
|
-
result = event
|
44
|
-
result.status = "failure"
|
45
|
-
|
46
|
-
result.message = "change from #{property.is_to_s(is)} to #{property.should_to_s(should)} failed: #{detail}"
|
47
|
-
result.send_log
|
48
|
-
result
|
49
|
-
end
|
50
|
-
|
51
|
-
# Is our property noop? This is used for generating special events.
|
52
|
-
def noop?
|
53
|
-
@property.noop
|
54
|
-
end
|
55
|
-
|
56
|
-
# The resource that generated this change. This is used for handling events,
|
57
|
-
# and the proxy resource is used for generated resources, since we can't
|
58
|
-
# send an event to a resource we don't have a direct relationship with. If we
|
59
|
-
# have a proxy resource, then the events will be considered to be from
|
60
|
-
# that resource, rather than us, so the graph resolution will still work.
|
61
|
-
def resource
|
62
|
-
self.proxy || @property.resource
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_s
|
66
|
-
"change #{@property.change_to_s(@is, @should)}"
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def audit_event
|
72
|
-
# This needs to store the appropriate value, and then produce a new event
|
73
|
-
result = event
|
74
|
-
result.message = "audit change: previously recorded value #{property.should_to_s(should)} has been changed to #{property.is_to_s(is)}"
|
75
|
-
result.status = "audit"
|
76
|
-
result.send_log
|
77
|
-
result
|
78
|
-
end
|
79
|
-
|
80
|
-
def noop_event
|
81
|
-
result = event
|
82
|
-
result.message = "is #{property.is_to_s(is)}, should be #{property.should_to_s(should)} (noop)"
|
83
|
-
result.status = "noop"
|
84
|
-
result.send_log
|
85
|
-
result
|
86
|
-
end
|
87
|
-
end
|
data/spec/Rakefile
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
2
|
-
require 'rake'
|
3
|
-
require 'spec/rake/spectask'
|
4
|
-
|
5
|
-
basedir = File.dirname(__FILE__)
|
6
|
-
puppetlibdir = File.join(basedir, "../lib")
|
7
|
-
puppettestlibdir = File.join(basedir, "../test/lib")
|
8
|
-
speclibdir = File.join(basedir, "lib")
|
9
|
-
|
10
|
-
require 'find'
|
11
|
-
|
12
|
-
include Find
|
13
|
-
include FileTest
|
14
|
-
|
15
|
-
$exclusions = %W(lib)
|
16
|
-
|
17
|
-
filemap = Hash.new { |hash, key| hash[key] = [] }
|
18
|
-
|
19
|
-
allfiles = []
|
20
|
-
|
21
|
-
# First collect the entire file list.
|
22
|
-
find(".") do |f|
|
23
|
-
# Get rid of the leading ./
|
24
|
-
f = f.sub(/^\.\//, '')
|
25
|
-
|
26
|
-
file = File.basename(f)
|
27
|
-
dir = File.dirname(f)
|
28
|
-
|
29
|
-
# Prune . directories and excluded dirs
|
30
|
-
if (file =~ /^\./ and f != ".") or $exclusions.include?(File.basename(file))
|
31
|
-
prune
|
32
|
-
next
|
33
|
-
end
|
34
|
-
next if f == "."
|
35
|
-
next if dir == "."
|
36
|
-
|
37
|
-
# If we're a ruby script, then add it to the list of files for that dir
|
38
|
-
if file =~ /\.rb$/
|
39
|
-
allfiles << f
|
40
|
-
# Add it to all of the parent dirs, not just our own
|
41
|
-
parts = File.split(dir)
|
42
|
-
if parts[0] == "."
|
43
|
-
parts.shift
|
44
|
-
end
|
45
|
-
parts.each_with_index { |part, i|
|
46
|
-
path = File.join(parts[0..i])
|
47
|
-
filemap[path] << f
|
48
|
-
}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
libs = [puppetlibdir, puppettestlibdir, speclibdir]
|
54
|
-
desc "Run all specs"
|
55
|
-
Spec::Rake::SpecTask.new('all') do |t|
|
56
|
-
t.spec_files = FileList['integration/**/*.rb', 'unit/**/*.rb']
|
57
|
-
t.libs = libs
|
58
|
-
t.spec_opts = ['--options', 'spec.opts']
|
59
|
-
end
|
60
|
-
|
61
|
-
task :default => [:all]
|
62
|
-
|
63
|
-
# Now create a task for every directory
|
64
|
-
filemap.each do |dir, files|
|
65
|
-
ns = dir.gsub "/", ":"
|
66
|
-
|
67
|
-
# First create a separate task for each file in the namespace.
|
68
|
-
namespace ns do
|
69
|
-
files.each do |file|
|
70
|
-
Spec::Rake::SpecTask.new(File.basename(file, '.rb').to_sym) do |t|
|
71
|
-
t.spec_files = [ file ]
|
72
|
-
t.libs = libs
|
73
|
-
t.spec_opts = ['--options', 'spec.opts']
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Then create a task that matches the directory itself.
|
79
|
-
Spec::Rake::SpecTask.new(dir) do |t|
|
80
|
-
if ENV["TESTFILES"]
|
81
|
-
t.spec_files = ENV["TESTFILES"].split(/\s+/)
|
82
|
-
else
|
83
|
-
t.spec_files = files.sort
|
84
|
-
end
|
85
|
-
t.libs = libs
|
86
|
-
t.spec_opts = ['--options', 'spec.opts']
|
87
|
-
end
|
88
|
-
|
89
|
-
# And alias it with a slash on the end
|
90
|
-
task(dir + "/" => dir)
|
91
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
dir = File.expand_path(File.dirname(__FILE__))
|
2
|
-
[ "#{dir}/../../lib", "#{dir}/../../test/lib"].each do |dir|
|
3
|
-
fulldir = File.expand_path(dir)
|
4
|
-
$LOAD_PATH.unshift(fulldir) unless $LOAD_PATH.include?(fulldir)
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'spec'
|
8
|
-
require 'puppettest/runnable_test'
|
9
|
-
|
10
|
-
module Spec
|
11
|
-
module Runner
|
12
|
-
class ExampleGroupRunner
|
13
|
-
def run
|
14
|
-
prepare
|
15
|
-
success = true
|
16
|
-
example_groups.each do |example_group|
|
17
|
-
unless example_group.runnable?
|
18
|
-
warn "Skipping unsuitable example group #{example_group.description}: #{example_group.messages.join(", ")}"
|
19
|
-
next
|
20
|
-
end
|
21
|
-
success = success & example_group.run(@options)
|
22
|
-
Puppet.settings.clear
|
23
|
-
end
|
24
|
-
return success
|
25
|
-
ensure
|
26
|
-
finish
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module Spec
|
33
|
-
module Example
|
34
|
-
class ExampleGroup
|
35
|
-
extend PuppetTest::RunnableTest
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
module Test
|
41
|
-
module Unit
|
42
|
-
class TestCase
|
43
|
-
extend PuppetTest::RunnableTest
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe PuppetTest::RunnableTest do
|
4
|
-
before do
|
5
|
-
@runnable_test = Class.new.extend(PuppetTest::RunnableTest)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#confine" do
|
9
|
-
subject { @runnable_test }
|
10
|
-
|
11
|
-
it "should accept a hash" do
|
12
|
-
subject.confine({}).should_not raise_error(ArgumentError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should accept a message and a block" do
|
16
|
-
subject.confine(""){}.should_not raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#runnable?" do
|
22
|
-
describe "when the superclass is not runnable" do
|
23
|
-
before { @runnable_test.stubs(:superclass).returns(stub("unrunnable superclass", :runnable? => false)) }
|
24
|
-
subject { @runnable_test.runnable? }
|
25
|
-
|
26
|
-
it { should be_false }
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "when a confine is false" do
|
30
|
-
before { @runnable_test.confine(:message => false) }
|
31
|
-
subject { @runnable_test.runnable? }
|
32
|
-
|
33
|
-
it { should be_false }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "when a confine has a block that returns false" do
|
37
|
-
before { @runnable_test.confine(:message){ false } }
|
38
|
-
subject { @runnable_test.runnable? }
|
39
|
-
|
40
|
-
it { should be_false }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "when a confine is true and no false confines" do
|
44
|
-
before { @runnable_test.confine(:message => true) }
|
45
|
-
subject { @runnable_test.runnable? }
|
46
|
-
|
47
|
-
it { should be_true }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "when a confine has block that returns true and no false confines" do
|
51
|
-
before { @runnable_test.confine(:message){ true } }
|
52
|
-
subject { @runnable_test.runnable? }
|
53
|
-
|
54
|
-
it { should be_true }
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#messages" do
|
60
|
-
describe "before runnable? is called" do
|
61
|
-
subject { @runnable_test.messages }
|
62
|
-
|
63
|
-
it { should == [] }
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "when runnable? is called and returns false" do
|
67
|
-
before do
|
68
|
-
@runnable_test.confine(:message => false)
|
69
|
-
@runnable_test.runnable?
|
70
|
-
end
|
71
|
-
|
72
|
-
subject { @runnable_test.messages }
|
73
|
-
|
74
|
-
it "should include the failed confine's message" do
|
75
|
-
should include(:message)
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "when runnable? is called whose block returns false" do
|
81
|
-
before do
|
82
|
-
@runnable_test.confine(:message){ false }
|
83
|
-
@runnable_test.runnable?
|
84
|
-
end
|
85
|
-
|
86
|
-
subject { @runnable_test.messages }
|
87
|
-
|
88
|
-
it "should include the failed confine's message" do
|
89
|
-
should include(:message)
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
end
|
@@ -1,193 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
|
-
|
5
|
-
require 'puppet/transaction/change'
|
6
|
-
|
7
|
-
describe Puppet::Transaction::Change do
|
8
|
-
Change = Puppet::Transaction::Change
|
9
|
-
|
10
|
-
describe "when initializing" do
|
11
|
-
before do
|
12
|
-
@property = stub 'property', :path => "/property/path", :should => "shouldval"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should require the property and current value" do
|
16
|
-
lambda { Change.new }.should raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should set its property to the provided property" do
|
20
|
-
Change.new(@property, "value").property.should == :property
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set its 'is' value to the provided value" do
|
24
|
-
Change.new(@property, "value").is.should == "value"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should retrieve the 'should' value from the property" do
|
28
|
-
# Yay rspec :)
|
29
|
-
Change.new(@property, "value").should.should == @property.should
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "when an instance" do
|
34
|
-
before do
|
35
|
-
@property = stub 'property', :path => "/property/path", :should => "shouldval"
|
36
|
-
@change = Change.new(@property, "value")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should be noop if the property is noop" do
|
40
|
-
@property.expects(:noop).returns true
|
41
|
-
@change.noop?.should be_true
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should be auditing if set so" do
|
45
|
-
@change.auditing = true
|
46
|
-
@change.must be_auditing
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should set its resource to the proxy if it has one" do
|
50
|
-
@change.proxy = :myresource
|
51
|
-
@change.resource.should == :myresource
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should set its resource to the property's resource if no proxy is set" do
|
55
|
-
@property.expects(:resource).returns :myresource
|
56
|
-
@change.resource.should == :myresource
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "and creating an event" do
|
60
|
-
before do
|
61
|
-
@resource = stub 'resource', :ref => "My[resource]"
|
62
|
-
@event = stub 'event', :previous_value= => nil, :desired_value= => nil
|
63
|
-
@property.stubs(:event).returns @event
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should use the property to create the event" do
|
67
|
-
@property.expects(:event).returns @event
|
68
|
-
@change.event.should equal(@event)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should set 'previous_value' from the change's 'is'" do
|
72
|
-
@event.expects(:previous_value=).with(@change.is)
|
73
|
-
@change.event
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should set 'desired_value' from the change's 'should'" do
|
77
|
-
@event.expects(:desired_value=).with(@change.should)
|
78
|
-
@change.event
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "and executing" do
|
83
|
-
before do
|
84
|
-
@event = Puppet::Transaction::Event.new(:myevent)
|
85
|
-
@event.stubs(:send_log)
|
86
|
-
@change.stubs(:noop?).returns false
|
87
|
-
@property.stubs(:event).returns @event
|
88
|
-
|
89
|
-
@property.stub_everything
|
90
|
-
@property.stubs(:resource).returns "myresource"
|
91
|
-
@property.stubs(:name).returns :myprop
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "in noop mode" do
|
95
|
-
before { @change.stubs(:noop?).returns true }
|
96
|
-
|
97
|
-
it "should log that it is in noop" do
|
98
|
-
@property.expects(:is_to_s)
|
99
|
-
@property.expects(:should_to_s)
|
100
|
-
|
101
|
-
@event.expects(:message=).with { |msg| msg.include?("should be") }
|
102
|
-
|
103
|
-
@change.apply
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should produce a :noop event and return" do
|
107
|
-
@property.stub_everything
|
108
|
-
|
109
|
-
@event.expects(:status=).with("noop")
|
110
|
-
|
111
|
-
@change.apply.should == @event
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "in audit mode" do
|
116
|
-
before { @change.auditing = true }
|
117
|
-
|
118
|
-
it "should log that it is in audit mode" do
|
119
|
-
@property.expects(:is_to_s)
|
120
|
-
@property.expects(:should_to_s)
|
121
|
-
|
122
|
-
@event.expects(:message=).with { |msg| msg.include?("audit") }
|
123
|
-
|
124
|
-
@change.apply
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should produce a :audit event and return" do
|
128
|
-
@property.stub_everything
|
129
|
-
|
130
|
-
@event.expects(:status=).with("audit")
|
131
|
-
|
132
|
-
@change.apply.should == @event
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should sync the property" do
|
137
|
-
@property.expects(:sync)
|
138
|
-
|
139
|
-
@change.apply
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should return the default event if syncing the property returns nil" do
|
143
|
-
@property.stubs(:sync).returns nil
|
144
|
-
|
145
|
-
@change.expects(:event).with(nil).returns @event
|
146
|
-
|
147
|
-
@change.apply.should == @event
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should return the default event if syncing the property returns an empty array" do
|
151
|
-
@property.stubs(:sync).returns []
|
152
|
-
|
153
|
-
@change.expects(:event).with(nil).returns @event
|
154
|
-
|
155
|
-
@change.apply.should == @event
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should log the change" do
|
159
|
-
@property.expects(:sync).returns [:one]
|
160
|
-
|
161
|
-
@event.expects(:send_log)
|
162
|
-
|
163
|
-
@change.apply
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should set the event's message to the change log" do
|
167
|
-
@property.expects(:change_to_s).returns "my change"
|
168
|
-
@change.apply.message.should == "my change"
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should set the event's status to 'success'" do
|
172
|
-
@change.apply.status.should == "success"
|
173
|
-
end
|
174
|
-
|
175
|
-
describe "and the change fails" do
|
176
|
-
before { @property.expects(:sync).raises "an exception" }
|
177
|
-
|
178
|
-
it "should catch the exception and log the err" do
|
179
|
-
@event.expects(:send_log)
|
180
|
-
lambda { @change.apply }.should_not raise_error
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should mark the event status as 'failure'" do
|
184
|
-
@change.apply.status.should == "failure"
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should set the event log to a failure log" do
|
188
|
-
@change.apply.message.should be_include("failed")
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|