puppet 2.7.11 → 2.7.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
data/spec/unit/type/exec_spec.rb
CHANGED
@@ -632,6 +632,13 @@ describe Puppet::Type.type(:exec) do
|
|
632
632
|
@test.check_all_attributes.should == false
|
633
633
|
end
|
634
634
|
end
|
635
|
+
|
636
|
+
it "should emit output to debug" do
|
637
|
+
Puppet::Util::Log.level = :debug
|
638
|
+
@test[param] = @fail
|
639
|
+
@test.check_all_attributes.should == true
|
640
|
+
@logs.shift.message.should == "test output"
|
641
|
+
end
|
635
642
|
end
|
636
643
|
end
|
637
644
|
end
|
@@ -314,7 +314,7 @@ describe content do
|
|
314
314
|
|
315
315
|
it "should copy content from the source to the file" do
|
316
316
|
@resource.write(@source)
|
317
|
-
|
317
|
+
IO.binread(@filename).should == @source_content
|
318
318
|
end
|
319
319
|
|
320
320
|
it "should return the checksum computed" do
|
@@ -343,7 +343,7 @@ describe content do
|
|
343
343
|
|
344
344
|
it "should write the contents to the file" do
|
345
345
|
@resource.write(@source)
|
346
|
-
|
346
|
+
IO.binread(@filename).should == @source_content
|
347
347
|
end
|
348
348
|
|
349
349
|
it "should not write anything if source is not found" do
|
data/spec/unit/type/file_spec.rb
CHANGED
@@ -749,11 +749,13 @@ describe Puppet::Type.type(:file) do
|
|
749
749
|
end
|
750
750
|
|
751
751
|
describe "#recurse_remote" do
|
752
|
+
let(:my) { File.expand_path('/my') }
|
753
|
+
|
752
754
|
before do
|
753
755
|
file[:source] = "puppet://foo/bar"
|
754
756
|
|
755
|
-
@first = Puppet::FileServing::Metadata.new(
|
756
|
-
@second = Puppet::FileServing::Metadata.new(
|
757
|
+
@first = Puppet::FileServing::Metadata.new(my, :relative_path => "first")
|
758
|
+
@second = Puppet::FileServing::Metadata.new(my, :relative_path => "second")
|
757
759
|
@first.stubs(:ftype).returns "directory"
|
758
760
|
@second.stubs(:ftype).returns "directory"
|
759
761
|
|
@@ -762,14 +764,14 @@ describe Puppet::Type.type(:file) do
|
|
762
764
|
end
|
763
765
|
|
764
766
|
it "should pass its source to the :perform_recursion method" do
|
765
|
-
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar")
|
767
|
+
data = Puppet::FileServing::Metadata.new(File.expand_path("/whatever"), :relative_path => "foobar")
|
766
768
|
file.expects(:perform_recursion).with("puppet://foo/bar").returns [data]
|
767
769
|
file.stubs(:newchild).returns @resource
|
768
770
|
file.recurse_remote({})
|
769
771
|
end
|
770
772
|
|
771
773
|
it "should not recurse when the remote file is not a directory" do
|
772
|
-
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => ".")
|
774
|
+
data = Puppet::FileServing::Metadata.new(File.expand_path("/whatever"), :relative_path => ".")
|
773
775
|
data.stubs(:ftype).returns "file"
|
774
776
|
file.expects(:perform_recursion).with("puppet://foo/bar").returns [data]
|
775
777
|
file.expects(:newchild).never
|
@@ -850,7 +852,7 @@ describe Puppet::Type.type(:file) do
|
|
850
852
|
|
851
853
|
describe "and :sourceselect is set to :first" do
|
852
854
|
it "should create file instances for the results for the first source to return any values" do
|
853
|
-
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar")
|
855
|
+
data = Puppet::FileServing::Metadata.new(File.expand_path("/whatever"), :relative_path => "foobar")
|
854
856
|
file[:source] = sources.keys.sort.map { |key| File.expand_path(key) }
|
855
857
|
file.expects(:perform_recursion).with(sources['/a']).returns nil
|
856
858
|
file.expects(:perform_recursion).with(sources['/b']).returns []
|
@@ -868,18 +870,19 @@ describe Puppet::Type.type(:file) do
|
|
868
870
|
|
869
871
|
it "should return every found file that is not in a previous source" do
|
870
872
|
klass = Puppet::FileServing::Metadata
|
871
|
-
|
873
|
+
|
874
|
+
file[:source] = abs_path = %w{/a /b /c /d}.map {|f| File.expand_path(f) }
|
872
875
|
file.stubs(:newchild).returns @resource
|
873
876
|
|
874
|
-
one = [klass.new(
|
877
|
+
one = [klass.new(abs_path[0], :relative_path => "a")]
|
875
878
|
file.expects(:perform_recursion).with(sources['/a']).returns one
|
876
879
|
file.expects(:newchild).with("a").returns @resource
|
877
880
|
|
878
|
-
two = [klass.new(
|
881
|
+
two = [klass.new(abs_path[1], :relative_path => "a"), klass.new(abs_path[1], :relative_path => "b")]
|
879
882
|
file.expects(:perform_recursion).with(sources['/b']).returns two
|
880
883
|
file.expects(:newchild).with("b").returns @resource
|
881
884
|
|
882
|
-
three = [klass.new(
|
885
|
+
three = [klass.new(abs_path[2], :relative_path => "a"), klass.new(abs_path[2], :relative_path => "c")]
|
883
886
|
file.expects(:perform_recursion).with(sources['/c']).returns three
|
884
887
|
file.expects(:newchild).with("c").returns @resource
|
885
888
|
|
@@ -230,6 +230,7 @@ describe Puppet::Type.type(:package) do
|
|
230
230
|
[:purged, :absent].each do |state|
|
231
231
|
it "should install if it is #{state.to_s}" do
|
232
232
|
@provider.stubs(:properties).returns(:ensure => state)
|
233
|
+
@package.property(:ensure).insync?(state).should be_false
|
233
234
|
@provider.expects(:install)
|
234
235
|
@catalog.apply
|
235
236
|
end
|
@@ -237,15 +238,39 @@ describe Puppet::Type.type(:package) do
|
|
237
238
|
|
238
239
|
it "should do nothing if the current version is equal to the desired version" do
|
239
240
|
@provider.stubs(:properties).returns(:ensure => "1.0")
|
241
|
+
@package.property(:ensure).insync?('1.0').should be_true
|
240
242
|
@provider.expects(:install).never
|
241
243
|
@catalog.apply
|
242
244
|
end
|
243
245
|
|
244
246
|
it "should install if the current version is not equal to the specified version" do
|
245
247
|
@provider.stubs(:properties).returns(:ensure => "2.0")
|
248
|
+
@package.property(:ensure).insync?('2.0').should be_false
|
246
249
|
@provider.expects(:install)
|
247
250
|
@catalog.apply
|
248
251
|
end
|
252
|
+
|
253
|
+
describe "when current value is an array" do
|
254
|
+
let(:installed_versions) { ["1.0", "2.0", "3.0"] }
|
255
|
+
|
256
|
+
before (:each) do
|
257
|
+
@provider.stubs(:properties).returns(:ensure => installed_versions)
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should install if value not in the array" do
|
261
|
+
@package[:ensure] = "1.5"
|
262
|
+
@package.property(:ensure).insync?(installed_versions).should be_false
|
263
|
+
@provider.expects(:install)
|
264
|
+
@catalog.apply
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should not install if value is in the array" do
|
268
|
+
@package[:ensure] = "2.0"
|
269
|
+
@package.property(:ensure).insync?(installed_versions).should be_true
|
270
|
+
@provider.expects(:install).never
|
271
|
+
@catalog.apply
|
272
|
+
end
|
273
|
+
end
|
249
274
|
end
|
250
275
|
end
|
251
276
|
end
|
@@ -33,24 +33,24 @@ describe Puppet::Type.type(:schedule) do
|
|
33
33
|
include ScheduleTesting
|
34
34
|
|
35
35
|
it "should apply to device" do
|
36
|
-
@schedule.
|
36
|
+
@schedule.must be_appliable_to_device
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should apply to host" do
|
40
|
-
@schedule.
|
40
|
+
@schedule.must be_appliable_to_host
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should default to :distance for period-matching" do
|
44
|
-
@schedule[:periodmatch].
|
44
|
+
@schedule[:periodmatch].must == :distance
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should default to a :repeat of 1" do
|
48
|
-
@schedule[:repeat].
|
48
|
+
@schedule[:repeat].must == 1
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should never match when the period is :never" do
|
52
52
|
@schedule[:period] = :never
|
53
|
-
@schedule.
|
53
|
+
@schedule.must_not be_match
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -61,7 +61,7 @@ describe Puppet::Type.type(:schedule) do
|
|
61
61
|
period = period.to_sym
|
62
62
|
it "should produce a #{period} schedule with the period set appropriately" do
|
63
63
|
schedules = Puppet::Type.type(:schedule).mkdefaultschedules
|
64
|
-
schedules.find { |s| s[:name] == period.to_s and s[:period] == period }.
|
64
|
+
schedules.find { |s| s[:name] == period.to_s and s[:period] == period }.must be_instance_of(Puppet::Type.type(:schedule))
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -69,7 +69,7 @@ describe Puppet::Type.type(:schedule) do
|
|
69
69
|
schedules = Puppet::Type.type(:schedule).mkdefaultschedules
|
70
70
|
schedules.find { |s|
|
71
71
|
s[:name] == "puppet" and s[:period] == :hourly and s[:repeat] == 2
|
72
|
-
}.
|
72
|
+
}.must be_instance_of(Puppet::Type.type(:schedule))
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -98,7 +98,7 @@ describe Puppet::Type.type(:schedule) do
|
|
98
98
|
it "should throw an error if the upper limit is less than the lower limit" do
|
99
99
|
pending "bug #7639"
|
100
100
|
@schedule[:range] = "01:02:03 - 01:00:00"
|
101
|
-
@schedule.
|
101
|
+
@schedule.must_throw Puppet::Error
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should not match the current time fails between an array of ranges" do
|
@@ -128,15 +128,15 @@ describe Puppet::Type.type(:schedule) do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should match when the previous time was an hour ago" do
|
131
|
-
@schedule.
|
131
|
+
@schedule.must be_match(hour("-", 1))
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should not match when the previous time was now" do
|
135
|
-
@schedule.
|
135
|
+
@schedule.must_not be_match(Time.now)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should not match when the previous time was 59 minutes ago" do
|
139
|
-
@schedule.
|
139
|
+
@schedule.must_not be_match(min("-", 59))
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -151,15 +151,15 @@ describe Puppet::Type.type(:schedule) do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should match when the previous time was one day ago" do
|
154
|
-
@schedule.
|
154
|
+
@schedule.must be_match(day("-", 1))
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should not match when the previous time is now" do
|
158
|
-
@schedule.
|
158
|
+
@schedule.must_not be_match(Time.now)
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should not match when the previous time was 23 hours ago" do
|
162
|
-
@schedule.
|
162
|
+
@schedule.must_not be_match(hour("-", 23))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -174,15 +174,15 @@ describe Puppet::Type.type(:schedule) do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should match when the previous time was seven days ago" do
|
177
|
-
@schedule.
|
177
|
+
@schedule.must be_match(day("-", 7))
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should not match when the previous time was now" do
|
181
|
-
@schedule.
|
181
|
+
@schedule.must_not be_match(Time.now)
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should not match when the previous time was six days ago" do
|
185
|
-
@schedule.
|
185
|
+
@schedule.must_not be_match(day("-", 6))
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
@@ -197,15 +197,15 @@ describe Puppet::Type.type(:schedule) do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should match when the previous time was 32 days ago" do
|
200
|
-
@schedule.
|
200
|
+
@schedule.must be_match(day("-", 32))
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should not match when the previous time was now" do
|
204
|
-
@schedule.
|
204
|
+
@schedule.must_not be_match(Time.now)
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should not match when the previous time was 27 days ago" do
|
208
|
-
@schedule.
|
208
|
+
@schedule.must_not be_match(day("-", 27))
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
@@ -222,7 +222,7 @@ describe Puppet::Type.type(:schedule) do
|
|
222
222
|
previous = Time.utc(2007, 12, 31, 23, 59, 0)
|
223
223
|
|
224
224
|
Time.stubs(:now).returns(current)
|
225
|
-
@schedule.
|
225
|
+
@schedule.must be_match(previous)
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should not match if the times are 59 minutes apart and the current minute is 59" do
|
@@ -230,7 +230,7 @@ describe Puppet::Type.type(:schedule) do
|
|
230
230
|
previous = Time.utc(2009, 2, 1, 12, 0, 0)
|
231
231
|
|
232
232
|
Time.stubs(:now).returns(current)
|
233
|
-
@schedule.
|
233
|
+
@schedule.must_not be_match(previous)
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
@@ -249,7 +249,7 @@ describe Puppet::Type.type(:schedule) do
|
|
249
249
|
previous = current - 60
|
250
250
|
|
251
251
|
Time.stubs(:now).returns(current)
|
252
|
-
@schedule.
|
252
|
+
@schedule.must be_match(previous)
|
253
253
|
end
|
254
254
|
|
255
255
|
it "should not match if the times are 23 hours and 58 minutes apart and the current hour is 23 and the current minute is 59" do
|
@@ -261,7 +261,7 @@ describe Puppet::Type.type(:schedule) do
|
|
261
261
|
now = previous + (23 * 3600) + (59 * 60)
|
262
262
|
|
263
263
|
Time.stubs(:now).returns(now)
|
264
|
-
@schedule.
|
264
|
+
@schedule.must_not be_match(previous)
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
@@ -278,7 +278,7 @@ describe Puppet::Type.type(:schedule) do
|
|
278
278
|
Time.stubs(:now).returns(now)
|
279
279
|
previous = Time.utc(2010, "nov", 6, 23, 59, 59) # Sat
|
280
280
|
|
281
|
-
@schedule.
|
281
|
+
@schedule.must be_match(previous)
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should not match if the previous time is after the most recent Saturday" do
|
@@ -286,7 +286,7 @@ describe Puppet::Type.type(:schedule) do
|
|
286
286
|
Time.stubs(:now).returns(now)
|
287
287
|
previous = Time.utc(2010, "nov", 7, 0, 0, 0) # Sunday
|
288
288
|
|
289
|
-
@schedule.
|
289
|
+
@schedule.must_not be_match(previous)
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
@@ -303,7 +303,7 @@ describe Puppet::Type.type(:schedule) do
|
|
303
303
|
Time.stubs(:now).returns(now)
|
304
304
|
previous = Time.utc(2010, "oct", 31, 23, 59, 59)
|
305
305
|
|
306
|
-
@schedule.
|
306
|
+
@schedule.must be_match(previous)
|
307
307
|
end
|
308
308
|
|
309
309
|
it "should not match when the previous time is after the last day of last month" do
|
@@ -311,7 +311,7 @@ describe Puppet::Type.type(:schedule) do
|
|
311
311
|
Time.stubs(:now).returns(now)
|
312
312
|
previous = Time.utc(2010, "nov", 1, 0, 0, 0)
|
313
313
|
|
314
|
-
@schedule.
|
314
|
+
@schedule.must_not be_match(previous)
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
@@ -327,17 +327,17 @@ describe Puppet::Type.type(:schedule) do
|
|
327
327
|
|
328
328
|
it "should fail if the periodmatch is 'number'" do
|
329
329
|
@schedule[:periodmatch] = :number
|
330
|
-
proc { @schedule[:repeat] = 2 }.
|
330
|
+
proc { @schedule[:repeat] = 2 }.must raise_error(Puppet::Error)
|
331
331
|
end
|
332
332
|
|
333
333
|
it "should match if the previous run was further away than the distance divided by the repeat" do
|
334
334
|
previous = Time.now - (3600 * 13)
|
335
|
-
@schedule.
|
335
|
+
@schedule.must be_match(previous)
|
336
336
|
end
|
337
337
|
|
338
338
|
it "should not match if the previous run was closer than the distance divided by the repeat" do
|
339
339
|
previous = Time.now - (3600 * 11)
|
340
|
-
@schedule.
|
340
|
+
@schedule.must_not be_match(previous)
|
341
341
|
end
|
342
342
|
end
|
343
343
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'puppet/util/diff'
|
4
|
+
|
5
|
+
describe Puppet::Util::Diff do
|
6
|
+
describe ".diff" do
|
7
|
+
it "should execute the diff command with arguments" do
|
8
|
+
Puppet[:diff] = 'foo'
|
9
|
+
Puppet[:diff_args] = 'bar'
|
10
|
+
|
11
|
+
subject.expects(:execute).with(['foo', 'bar', 'a', 'b'], {:failonfail => false}).returns('baz')
|
12
|
+
subject.diff('a', 'b').should == 'baz'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should omit diff arguments if none are specified" do
|
16
|
+
Puppet[:diff] = 'foo'
|
17
|
+
Puppet[:diff_args] = ''
|
18
|
+
|
19
|
+
subject.expects(:execute).with(['foo', 'a', 'b'], {:failonfail => false}).returns('baz')
|
20
|
+
subject.diff('a', 'b').should == 'baz'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return empty string if the diff command is empty" do
|
24
|
+
Puppet[:diff] = ''
|
25
|
+
|
26
|
+
subject.expects(:execute).never
|
27
|
+
subject.diff('a', 'b').should == ''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -16,8 +16,7 @@ describe Puppet::Util::ExecutionStub do
|
|
16
16
|
Puppet::Util::ExecutionStub.current_value.should == nil
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
it "should restore normal execution after 'reset' is called", :fails_on_windows => true do
|
19
|
+
it "should restore normal execution after 'reset' is called" do
|
21
20
|
# Note: "true" exists at different paths in different OSes
|
22
21
|
if Puppet.features.microsoft_windows?
|
23
22
|
true_command = [Puppet::Util.which('cmd.exe').tr('/', '\\'), '/c', 'exit 0']
|
@@ -109,3 +109,54 @@ describe Puppet::Util::Log.desttypes[:syslog] do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
describe Puppet::Util::Log.desttypes[:console] do
|
113
|
+
describe "when color is available" do
|
114
|
+
it "should support color output" do
|
115
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
116
|
+
subject.colorize(:red, 'version').should == "\e[0;31mversion\e[0m"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should withhold color output when not appropriate" do
|
120
|
+
Puppet.stubs(:[]).with(:color).returns(false)
|
121
|
+
subject.colorize(:red, 'version').should == "version"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should handle multiple overlapping colors in a stack-like way" do
|
125
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
126
|
+
vstring = subject.colorize(:red, 'version')
|
127
|
+
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[0;31mversion\e[0;32m)\e[0m"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should handle resets in a stack-like way" do
|
131
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
132
|
+
vstring = subject.colorize(:reset, 'version')
|
133
|
+
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[mversion\e[0;32m)\e[0m"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe Puppet::Util::Log.desttypes[:telly_prototype_console] do
|
139
|
+
describe "when color is available" do
|
140
|
+
it "should support color output" do
|
141
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
142
|
+
subject.colorize(:red, 'version').should == "\e[0;31mversion\e[0m"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should withhold color output when not appropriate" do
|
146
|
+
Puppet.stubs(:[]).with(:color).returns(false)
|
147
|
+
subject.colorize(:red, 'version').should == "version"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should handle multiple overlapping colors in a stack-like way" do
|
151
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
152
|
+
vstring = subject.colorize(:red, 'version')
|
153
|
+
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[0;31mversion\e[0;32m)\e[0m"
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should handle resets in a stack-like way" do
|
157
|
+
Puppet.stubs(:[]).with(:color).returns(true)
|
158
|
+
vstring = subject.colorize(:reset, 'version')
|
159
|
+
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[mversion\e[0;32m)\e[0m"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|