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
@@ -4,9 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
4
4
|
|
5
5
|
require 'puppet/application/kick'
|
6
6
|
|
7
|
-
describe Puppet::Application::Kick do
|
8
|
-
|
9
|
-
confine "Kick's eventloops can only start on POSIX" => Puppet.features.posix?
|
7
|
+
describe Puppet::Application::Kick, :if => Puppet.features.posix? do
|
10
8
|
|
11
9
|
before :each do
|
12
10
|
require 'puppet/util/ldap/connection'
|
@@ -412,9 +412,7 @@ describe Puppet::Application::Master do
|
|
412
412
|
@master.main
|
413
413
|
end
|
414
414
|
|
415
|
-
describe "with --rack" do
|
416
|
-
confine "Rack is not available" => Puppet.features.rack?
|
417
|
-
|
415
|
+
describe "with --rack", :if => Puppet.features.rack? do
|
418
416
|
before do
|
419
417
|
require 'puppet/network/http/rack'
|
420
418
|
Puppet::Network::HTTP::Rack.stubs(:new).returns(@app)
|
@@ -16,6 +16,25 @@ describe Puppet::Application do
|
|
16
16
|
Puppet.settings.stubs(:parse)
|
17
17
|
end
|
18
18
|
|
19
|
+
describe "finding" do
|
20
|
+
before do
|
21
|
+
@klass = Puppet::Application
|
22
|
+
@klass.stubs(:puts)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should find classes in the namespace" do
|
26
|
+
@klass.find("Agent").should == @klass::Agent
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not find classes outside the namespace" do
|
30
|
+
lambda { @klass.find("String") }.should raise_error(SystemExit)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should exit if it can't find a class" do
|
34
|
+
lambda { @klass.find("ThisShallNeverEverEverExistAsdf") }.should raise_error(SystemExit)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
19
38
|
describe ".run_mode" do
|
20
39
|
it "should default to user" do
|
21
40
|
@appclass.run_mode.name.should == :user
|
@@ -27,6 +46,48 @@ describe Puppet::Application do
|
|
27
46
|
end
|
28
47
|
end
|
29
48
|
|
49
|
+
it "should sadly and frighteningly allow run_mode to change at runtime" do
|
50
|
+
class TestApp < Puppet::Application
|
51
|
+
run_mode :master
|
52
|
+
def run_command
|
53
|
+
# This is equivalent to calling these methods externally to the
|
54
|
+
# instance, but since this is what "real world" code is likely to do
|
55
|
+
# (and we need the class anyway) we may as well test that. --daniel 2011-02-03
|
56
|
+
set_run_mode self.class.run_mode "agent"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Puppet[:run_mode].should == "user"
|
61
|
+
|
62
|
+
expect {
|
63
|
+
app = TestApp.new
|
64
|
+
|
65
|
+
Puppet[:run_mode].should == "master"
|
66
|
+
|
67
|
+
app.run
|
68
|
+
|
69
|
+
app.class.run_mode.name.should == :agent
|
70
|
+
$puppet_application_mode.name.should == :agent
|
71
|
+
}.should_not raise_error
|
72
|
+
|
73
|
+
Puppet[:run_mode].should == "agent"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "it should not allow run mode to be set multiple times" do
|
77
|
+
pending "great floods of tears, you can do this right now" # --daniel 2011-02-03
|
78
|
+
app = Puppet::Application.new
|
79
|
+
expect {
|
80
|
+
app.set_run_mode app.class.run_mode "master"
|
81
|
+
$puppet_application_mode.name.should == :master
|
82
|
+
app.set_run_mode app.class.run_mode "agent"
|
83
|
+
$puppet_application_mode.name.should == :agent
|
84
|
+
}.should raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should explode when an invalid run mode is set at runtime, for great victory"
|
88
|
+
# ...but you can, and while it will explode, that only happens too late for
|
89
|
+
# us to easily test. --daniel 2011-02-03
|
90
|
+
|
30
91
|
it "should have a run entry-point" do
|
31
92
|
@app.should respond_to(:run)
|
32
93
|
end
|
@@ -160,9 +221,7 @@ describe Puppet::Application do
|
|
160
221
|
end
|
161
222
|
end
|
162
223
|
|
163
|
-
describe 'on POSIX systems' do
|
164
|
-
confine "HUP works only on POSIX systems" => Puppet.features.posix?
|
165
|
-
|
224
|
+
describe 'on POSIX systems', :if => Puppet.features.posix? do
|
166
225
|
it 'should signal process with HUP after block if restart requested during block execution' do
|
167
226
|
Puppet::Application.run_status = nil
|
168
227
|
target = mock 'target'
|
@@ -224,8 +283,7 @@ describe Puppet::Application do
|
|
224
283
|
@app.parse_options
|
225
284
|
end
|
226
285
|
|
227
|
-
describe "when using --help" do
|
228
|
-
confine "rdoc" => Puppet.features.usage?
|
286
|
+
describe "when using --help", :if => Puppet.features.usage? do
|
229
287
|
|
230
288
|
it "should call RDoc::usage and exit" do
|
231
289
|
@app.expects(:exit)
|
@@ -11,6 +11,10 @@ end
|
|
11
11
|
describe Puppet::Configurer::PluginHandler do
|
12
12
|
before do
|
13
13
|
@pluginhandler = PluginHandlerTester.new
|
14
|
+
|
15
|
+
# PluginHandler#load_plugin has an extra-strong rescue clause
|
16
|
+
# this mock is to make sure that we don't silently ignore errors
|
17
|
+
Puppet.expects(:err).never
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should have a method for downloading plugins" do
|
@@ -80,7 +84,7 @@ describe Puppet::Configurer::PluginHandler do
|
|
80
84
|
end
|
81
85
|
|
82
86
|
it "should not try to load files that don't exist" do
|
83
|
-
FileTest.expects(:exist?).with("foo").returns
|
87
|
+
FileTest.expects(:exist?).with("foo").returns false
|
84
88
|
@pluginhandler.expects(:load).never
|
85
89
|
|
86
90
|
@pluginhandler.load_plugin("foo")
|
@@ -72,14 +72,6 @@ describe Puppet::Configurer do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe Puppet::Configurer, "when initializing a report" do
|
76
|
-
it "should return an instance of a transaction report" do
|
77
|
-
Puppet.settings.stubs(:use).returns(true)
|
78
|
-
@agent = Puppet::Configurer.new
|
79
|
-
@agent.initialize_report.should be_instance_of(Puppet::Transaction::Report)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
75
|
describe Puppet::Configurer, "when executing a catalog run" do
|
84
76
|
before do
|
85
77
|
Puppet.settings.stubs(:use).returns(true)
|
@@ -101,31 +93,31 @@ describe Puppet::Configurer, "when executing a catalog run" do
|
|
101
93
|
end
|
102
94
|
|
103
95
|
it "should initialize a transaction report if one is not provided" do
|
104
|
-
report =
|
105
|
-
|
96
|
+
report = Puppet::Transaction::Report.new("apply")
|
97
|
+
Puppet::Transaction::Report.expects(:new).returns report
|
106
98
|
|
107
99
|
@agent.run
|
108
100
|
end
|
109
101
|
|
110
102
|
it "should pass the new report to the catalog" do
|
111
|
-
report =
|
112
|
-
|
103
|
+
report = Puppet::Transaction::Report.new("apply")
|
104
|
+
Puppet::Transaction::Report.stubs(:new).returns report
|
113
105
|
@catalog.expects(:apply).with{|options| options[:report] == report}
|
114
106
|
|
115
107
|
@agent.run
|
116
108
|
end
|
117
109
|
|
118
110
|
it "should use the provided report if it was passed one" do
|
119
|
-
report =
|
120
|
-
|
111
|
+
report = Puppet::Transaction::Report.new("apply")
|
112
|
+
Puppet::Transaction::Report.expects(:new).never
|
121
113
|
@catalog.expects(:apply).with{|options| options[:report] == report}
|
122
114
|
|
123
115
|
@agent.run(:report => report)
|
124
116
|
end
|
125
117
|
|
126
118
|
it "should set the report as a log destination" do
|
127
|
-
report =
|
128
|
-
|
119
|
+
report = Puppet::Transaction::Report.new("apply")
|
120
|
+
Puppet::Transaction::Report.expects(:new).returns report
|
129
121
|
|
130
122
|
Puppet::Util::Log.expects(:newdestination).with(report)
|
131
123
|
|
@@ -176,16 +168,16 @@ describe Puppet::Configurer, "when executing a catalog run" do
|
|
176
168
|
end
|
177
169
|
|
178
170
|
it "should send the report" do
|
179
|
-
report =
|
180
|
-
|
171
|
+
report = Puppet::Transaction::Report.new("apply")
|
172
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
181
173
|
@agent.expects(:send_report).with { |r, trans| r == report }
|
182
174
|
|
183
175
|
@agent.run
|
184
176
|
end
|
185
177
|
|
186
178
|
it "should send the transaction report with a reference to the transaction if a run was actually made" do
|
187
|
-
report =
|
188
|
-
|
179
|
+
report = Puppet::Transaction::Report.new("apply")
|
180
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
189
181
|
|
190
182
|
trans = stub 'transaction'
|
191
183
|
@catalog.expects(:apply).returns trans
|
@@ -198,8 +190,8 @@ describe Puppet::Configurer, "when executing a catalog run" do
|
|
198
190
|
it "should send the transaction report even if the catalog could not be retrieved" do
|
199
191
|
@agent.expects(:retrieve_catalog).returns nil
|
200
192
|
|
201
|
-
report =
|
202
|
-
|
193
|
+
report = Puppet::Transaction::Report.new("apply")
|
194
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
203
195
|
@agent.expects(:send_report)
|
204
196
|
|
205
197
|
@agent.run
|
@@ -208,16 +200,16 @@ describe Puppet::Configurer, "when executing a catalog run" do
|
|
208
200
|
it "should send the transaction report even if there is a failure" do
|
209
201
|
@agent.expects(:retrieve_catalog).raises "whatever"
|
210
202
|
|
211
|
-
report =
|
212
|
-
|
203
|
+
report = Puppet::Transaction::Report.new("apply")
|
204
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
213
205
|
@agent.expects(:send_report)
|
214
206
|
|
215
207
|
lambda { @agent.run }.should raise_error
|
216
208
|
end
|
217
209
|
|
218
210
|
it "should remove the report as a log destination when the run is finished" do
|
219
|
-
report =
|
220
|
-
|
211
|
+
report = Puppet::Transaction::Report.new("apply")
|
212
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
221
213
|
|
222
214
|
Puppet::Util::Log.expects(:close).with(report)
|
223
215
|
|
@@ -225,8 +217,8 @@ describe Puppet::Configurer, "when executing a catalog run" do
|
|
225
217
|
end
|
226
218
|
|
227
219
|
it "should return the report as the result of the run" do
|
228
|
-
report =
|
229
|
-
|
220
|
+
report = Puppet::Transaction::Report.new("apply")
|
221
|
+
Puppet::Transaction::Report.expects(:new).returns(report)
|
230
222
|
|
231
223
|
@agent.run.should equal(report)
|
232
224
|
end
|
@@ -237,20 +229,12 @@ describe Puppet::Configurer, "when sending a report" do
|
|
237
229
|
Puppet.settings.stubs(:use).returns(true)
|
238
230
|
@configurer = Puppet::Configurer.new
|
239
231
|
|
240
|
-
@report =
|
232
|
+
@report = Puppet::Transaction::Report.new("apply")
|
241
233
|
@trans = stub 'transaction'
|
242
234
|
end
|
243
235
|
|
244
|
-
it "should
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should allow specification of a transaction" do
|
249
|
-
lambda { @configurer.send_report(@report, @trans) }.should_not raise_error(ArgumentError)
|
250
|
-
end
|
251
|
-
|
252
|
-
it "should use any provided transaction to add metrics to the report" do
|
253
|
-
@trans.expects(:generate_report)
|
236
|
+
it "should finalize the report" do
|
237
|
+
@report.expects(:finalize_report)
|
254
238
|
@configurer.send_report(@report, @trans)
|
255
239
|
end
|
256
240
|
|
@@ -260,28 +244,28 @@ describe Puppet::Configurer, "when sending a report" do
|
|
260
244
|
@report.expects(:summary).returns "stuff"
|
261
245
|
|
262
246
|
@configurer.expects(:puts).with("stuff")
|
263
|
-
@configurer.send_report(@report)
|
247
|
+
@configurer.send_report(@report, nil)
|
264
248
|
end
|
265
249
|
|
266
250
|
it "should not print a report summary if not configured to do so" do
|
267
251
|
Puppet.settings[:summarize] = false
|
268
252
|
|
269
253
|
@configurer.expects(:puts).never
|
270
|
-
@configurer.send_report(@report)
|
254
|
+
@configurer.send_report(@report, nil)
|
271
255
|
end
|
272
256
|
|
273
257
|
it "should save the report if reporting is enabled" do
|
274
258
|
Puppet.settings[:report] = true
|
275
259
|
|
276
260
|
@report.expects(:save)
|
277
|
-
@configurer.send_report(@report)
|
261
|
+
@configurer.send_report(@report, nil)
|
278
262
|
end
|
279
263
|
|
280
264
|
it "should not save the report if reporting is disabled" do
|
281
265
|
Puppet.settings[:report] = false
|
282
266
|
|
283
267
|
@report.expects(:save).never
|
284
|
-
@configurer.send_report(@report)
|
268
|
+
@configurer.send_report(@report, nil)
|
285
269
|
end
|
286
270
|
|
287
271
|
it "should log but not fail if saving the report fails" do
|
@@ -290,7 +274,7 @@ describe Puppet::Configurer, "when sending a report" do
|
|
290
274
|
@report.expects(:save).raises "whatever"
|
291
275
|
|
292
276
|
Puppet.expects(:err)
|
293
|
-
lambda { @configurer.send_report(@report) }.should_not raise_error
|
277
|
+
lambda { @configurer.send_report(@report, nil) }.should_not raise_error
|
294
278
|
end
|
295
279
|
end
|
296
280
|
|
@@ -418,7 +402,7 @@ describe Puppet::Configurer, "when retrieving a catalog" do
|
|
418
402
|
end
|
419
403
|
|
420
404
|
it "should return nil if there is an error while retrieving the catalog" do
|
421
|
-
Puppet::Resource::Catalog.expects(:find).raises "eh"
|
405
|
+
Puppet::Resource::Catalog.expects(:find).at_least_once.raises "eh"
|
422
406
|
|
423
407
|
@agent.retrieve_catalog.should be_nil
|
424
408
|
end
|
@@ -472,23 +456,23 @@ describe Puppet::Configurer, "when preparing for a run" do
|
|
472
456
|
it "should initialize the metadata store" do
|
473
457
|
@agent.class.stubs(:facts).returns(@facts)
|
474
458
|
@agent.expects(:dostorage)
|
475
|
-
@agent.prepare
|
459
|
+
@agent.prepare({})
|
476
460
|
end
|
477
461
|
|
478
462
|
it "should download fact plugins" do
|
479
463
|
@agent.expects(:download_fact_plugins)
|
480
464
|
|
481
|
-
@agent.prepare
|
465
|
+
@agent.prepare({})
|
482
466
|
end
|
483
467
|
|
484
468
|
it "should download plugins" do
|
485
469
|
@agent.expects(:download_plugins)
|
486
470
|
|
487
|
-
@agent.prepare
|
471
|
+
@agent.prepare({})
|
488
472
|
end
|
489
473
|
|
490
474
|
it "should perform the pre-run commands" do
|
491
475
|
@agent.expects(:execute_prerun_command)
|
492
|
-
@agent.prepare
|
476
|
+
@agent.prepare({})
|
493
477
|
end
|
494
478
|
end
|
@@ -2,121 +2,113 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
4
|
|
5
|
+
require 'pathname'
|
6
|
+
|
5
7
|
require 'puppet/file_bucket/dipper'
|
8
|
+
require 'puppet/indirector/file_bucket_file/rest'
|
9
|
+
|
6
10
|
describe Puppet::FileBucket::Dipper do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
include PuppetSpec::Files
|
12
|
+
|
13
|
+
def make_tmp_file(contents)
|
14
|
+
file = tmpfile("file_bucket_file")
|
15
|
+
File.open(file, 'w') { |f| f.write(contents) }
|
16
|
+
file
|
11
17
|
end
|
12
18
|
|
13
|
-
it "should fail in an informative way when there are failures
|
14
|
-
|
15
|
-
|
19
|
+
it "should fail in an informative way when there are failures checking for the file on the server" do
|
20
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
|
21
|
+
|
22
|
+
file = make_tmp_file('contents')
|
23
|
+
Puppet::FileBucket::File.expects(:head).raises ArgumentError
|
16
24
|
|
25
|
+
lambda { @dipper.backup(file) }.should raise_error(Puppet::Error)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should fail in an informative way when there are failures backing up to the server" do
|
17
29
|
@dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
|
18
30
|
|
19
|
-
|
20
|
-
Puppet::FileBucket::File.
|
21
|
-
|
22
|
-
filemock.expects(:save).raises ArgumentError
|
31
|
+
file = make_tmp_file('contents')
|
32
|
+
Puppet::FileBucket::File.expects(:head).returns false
|
33
|
+
Puppet::FileBucket::File.any_instance.expects(:save).raises ArgumentError
|
23
34
|
|
24
|
-
lambda { @dipper.backup(
|
35
|
+
lambda { @dipper.backup(file) }.should raise_error(Puppet::Error)
|
25
36
|
end
|
26
37
|
|
27
38
|
it "should backup files to a local bucket" do
|
28
|
-
|
29
|
-
|
30
|
-
)
|
39
|
+
Puppet[:bucketdir] = "/non/existent/directory"
|
40
|
+
file_bucket = tmpdir("bucket")
|
31
41
|
|
32
|
-
|
33
|
-
File.stubs(:read).with("/my/file").returns "my contents"
|
42
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Path => file_bucket)
|
34
43
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
bucketfile.expects(:save).with('md5/DIGEST123')
|
44
|
+
file = make_tmp_file('my contents')
|
45
|
+
checksum = "2975f560750e71c478b8e3b39a956adb"
|
46
|
+
Digest::MD5.hexdigest('my contents').should == checksum
|
39
47
|
|
48
|
+
@dipper.backup(file).should == checksum
|
49
|
+
File.exists?("#{file_bucket}/2/9/7/5/f/5/6/0/2975f560750e71c478b8e3b39a956adb/contents").should == true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should not backup a file that is already in the bucket" do
|
53
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
|
40
54
|
|
41
|
-
|
42
|
-
|
43
|
-
"my contents",
|
44
|
-
:bucket_path => '/my/bucket',
|
45
|
-
|
46
|
-
:path => '/my/file'
|
47
|
-
).returns(bucketfile)
|
55
|
+
file = make_tmp_file('my contents')
|
56
|
+
checksum = Digest::MD5.hexdigest('my contents')
|
48
57
|
|
49
|
-
|
58
|
+
Puppet::FileBucket::File.expects(:head).returns true
|
59
|
+
Puppet::FileBucket::File.any_instance.expects(:save).never
|
60
|
+
@dipper.backup(file).should == checksum
|
50
61
|
end
|
51
62
|
|
52
63
|
it "should retrieve files from a local bucket" do
|
53
|
-
@dipper = Puppet::FileBucket::Dipper.new(
|
54
|
-
|
55
|
-
)
|
64
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
|
65
|
+
|
66
|
+
checksum = Digest::MD5.hexdigest('my contents')
|
56
67
|
|
57
|
-
|
58
|
-
File.stubs(:read).with("/my/file").returns "my contents"
|
68
|
+
request = nil
|
59
69
|
|
60
|
-
|
61
|
-
bucketfile.stubs(:to_s).returns "Content"
|
70
|
+
Puppet::FileBucketFile::File.any_instance.expects(:find).with{ |r| request = r }.once.returns(Puppet::FileBucket::File.new('my contents'))
|
62
71
|
|
63
|
-
|
64
|
-
x == 'md5/DIGEST123'
|
65
|
-
}.returns(bucketfile)
|
72
|
+
@dipper.getfile(checksum).should == 'my contents'
|
66
73
|
|
67
|
-
|
74
|
+
request.key.should == "md5/#{checksum}"
|
68
75
|
end
|
69
76
|
|
70
77
|
it "should backup files to a remote server" do
|
78
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337")
|
71
79
|
|
72
|
-
|
73
|
-
|
74
|
-
:Server => "puppetmaster",
|
75
|
-
|
76
|
-
:Port => "31337"
|
77
|
-
)
|
80
|
+
file = make_tmp_file('my contents')
|
81
|
+
checksum = Digest::MD5.hexdigest('my contents')
|
78
82
|
|
79
|
-
|
80
|
-
File.stubs(:read).with("/my/file").returns "my contents"
|
83
|
+
real_path = Pathname.new(file).realpath
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
bucketfile.stubs(:checksum_data).returns("DIGEST123")
|
85
|
-
bucketfile.expects(:save).with('https://puppetmaster:31337/production/file_bucket_file/md5/DIGEST123')
|
85
|
+
request1 = nil
|
86
|
+
request2 = nil
|
86
87
|
|
88
|
+
Puppet::FileBucketFile::Rest.any_instance.expects(:head).with { |r| request1 = r }.once.returns(nil)
|
89
|
+
Puppet::FileBucketFile::Rest.any_instance.expects(:save).with { |r| request2 = r }.once
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
).returns(bucketfile)
|
95
|
-
|
96
|
-
@dipper.backup("/my/file").should == "DIGEST123"
|
91
|
+
@dipper.backup(file).should == checksum
|
92
|
+
[request1, request2].each do |r|
|
93
|
+
r.server.should == 'puppetmaster'
|
94
|
+
r.port.should == 31337
|
95
|
+
r.key.should == "md5/#{checksum}#{real_path}"
|
96
|
+
end
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should retrieve files from a remote server" do
|
100
|
+
@dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337")
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
:Server => "puppetmaster",
|
104
|
-
|
105
|
-
:Port => "31337"
|
106
|
-
)
|
102
|
+
checksum = Digest::MD5.hexdigest('my contents')
|
107
103
|
|
108
|
-
|
109
|
-
File.stubs(:read).with("/my/file").returns "my contents"
|
104
|
+
request = nil
|
110
105
|
|
111
|
-
|
112
|
-
bucketfile.stubs(:to_s).returns "Content"
|
106
|
+
Puppet::FileBucketFile::Rest.any_instance.expects(:find).with { |r| request = r }.returns(Puppet::FileBucket::File.new('my contents'))
|
113
107
|
|
114
|
-
|
115
|
-
x == 'https://puppetmaster:31337/production/file_bucket_file/md5/DIGEST123'
|
116
|
-
}.returns(bucketfile)
|
108
|
+
@dipper.getfile(checksum).should == "my contents"
|
117
109
|
|
118
|
-
|
110
|
+
request.server.should == 'puppetmaster'
|
111
|
+
request.port.should == 31337
|
112
|
+
request.key.should == "md5/#{checksum}"
|
119
113
|
end
|
120
|
-
|
121
|
-
|
122
114
|
end
|