puppet 5.5.8-x64-mingw32 → 5.5.10-x64-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +14 -14
- data/Rakefile +3 -1
- data/ext/solaris/smf/svc-puppetd +8 -1
- data/ext/solaris/smf/svc-puppetmasterd +8 -1
- data/lib/puppet/application/device.rb +45 -29
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/forge.rb +4 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +11 -2
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
- data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/transaction.rb +4 -1
- data/lib/puppet/transaction/event_manager.rb +13 -1
- data/lib/puppet/transaction/resource_harness.rb +3 -1
- data/lib/puppet/util/command_line.rb +2 -3
- data/lib/puppet/util/filetype.rb +36 -4
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/registry.rb +29 -5
- data/lib/puppet/util/windows/service.rb +106 -99
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +97 -69
- data/man/man5/puppet.conf.5 +2 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +2 -2
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +23 -19
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
- data/spec/integration/ssl/key_spec.rb +0 -4
- data/spec/integration/transaction_spec.rb +1 -1
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/unit/application/device_spec.rb +4 -1
- data/spec/unit/application/lookup_spec.rb +10 -9
- data/spec/unit/forge/forge_spec.rb +4 -2
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +6 -7
- data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
- data/spec/unit/pops/types/string_converter_spec.rb +20 -0
- data/spec/unit/provider/cron/parsed_spec.rb +4 -3
- data/spec/unit/provider/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- data/spec/unit/provider/host/parsed_spec.rb +3 -17
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
- data/spec/unit/provider/package/aix_spec.rb +5 -8
- data/spec/unit/provider/package/apt_spec.rb +3 -6
- data/spec/unit/provider/package/dnf_spec.rb +29 -31
- data/spec/unit/provider/package/dpkg_spec.rb +18 -21
- data/spec/unit/provider/package/freebsd_spec.rb +4 -7
- data/spec/unit/provider/package/gem_spec.rb +41 -41
- data/spec/unit/provider/package/hpux_spec.rb +7 -10
- data/spec/unit/provider/package/macports_spec.rb +13 -15
- data/spec/unit/provider/package/nim_spec.rb +3 -10
- data/spec/unit/provider/package/openbsd_spec.rb +14 -17
- data/spec/unit/provider/package/pip3_spec.rb +3 -6
- data/spec/unit/provider/package/pip_spec.rb +44 -72
- data/spec/unit/provider/package/pkgin_spec.rb +13 -18
- data/spec/unit/provider/package/pkgng_spec.rb +21 -24
- data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
- data/spec/unit/provider/package/tdnf_spec.rb +9 -12
- data/spec/unit/provider/package/yum_spec.rb +29 -15
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +8 -12
- data/spec/unit/provider/service/daemontools_spec.rb +12 -20
- data/spec/unit/provider/service/debian_spec.rb +8 -16
- data/spec/unit/provider/service/freebsd_spec.rb +2 -5
- data/spec/unit/provider/service/openbsd_spec.rb +12 -18
- data/spec/unit/provider/service/rcng_spec.rb +3 -7
- data/spec/unit/provider/service/redhat_spec.rb +21 -23
- data/spec/unit/provider/service/runit_spec.rb +9 -19
- data/spec/unit/provider/service/smf_spec.rb +82 -21
- data/spec/unit/provider/service/src_spec.rb +14 -23
- data/spec/unit/provider/user/hpux_spec.rb +2 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/ssl/key_spec.rb +2 -4
- data/spec/unit/transaction/event_manager_spec.rb +12 -1
- data/spec/unit/transaction/resource_harness_spec.rb +18 -0
- data/spec/unit/transaction_spec.rb +25 -0
- data/spec/unit/util/filetype_spec.rb +13 -5
- data/spec/unit/util/logging_spec.rb +0 -41
- data/spec/unit/util/monkey_patches_spec.rb +18 -5
- data/spec/unit/util/selinux_spec.rb +4 -0
- metadata +6 -2
@@ -1,14 +1,6 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the debian service provider
|
4
|
-
#
|
5
|
-
|
6
1
|
require 'spec_helper'
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
describe provider_class do
|
11
|
-
|
3
|
+
describe Puppet::Type.type(:service).provider(:debian) do
|
12
4
|
if Puppet.features.microsoft_windows?
|
13
5
|
# Get a pid for $CHILD_STATUS to latch on to
|
14
6
|
command = "cmd.exe /c \"exit 0\""
|
@@ -19,7 +11,7 @@ describe provider_class do
|
|
19
11
|
# Create a mock resource
|
20
12
|
@resource = stub 'resource'
|
21
13
|
|
22
|
-
@provider =
|
14
|
+
@provider = subject()
|
23
15
|
|
24
16
|
# A catch all; no parameters set
|
25
17
|
@resource.stubs(:[]).returns(nil)
|
@@ -43,14 +35,14 @@ describe provider_class do
|
|
43
35
|
it "should be the default provider on CumulusLinux #{version}" do
|
44
36
|
Facter.expects(:value).with(:operatingsystem).at_least_once.returns('CumulusLinux')
|
45
37
|
Facter.expects(:value).with(:operatingsystemmajrelease).returns(version)
|
46
|
-
expect(
|
38
|
+
expect(described_class.default?).to be_truthy
|
47
39
|
end
|
48
40
|
end
|
49
41
|
|
50
42
|
it "should be the default provider on Debian" do
|
51
43
|
Facter.expects(:value).with(:operatingsystem).at_least_once.returns('Debian')
|
52
44
|
Facter.expects(:value).with(:operatingsystemmajrelease).returns('7')
|
53
|
-
expect(
|
45
|
+
expect(described_class.default?).to be_truthy
|
54
46
|
end
|
55
47
|
|
56
48
|
it "should have an enabled? method" do
|
@@ -65,14 +57,14 @@ describe provider_class do
|
|
65
57
|
expect(@provider).to respond_to(:disable)
|
66
58
|
end
|
67
59
|
|
68
|
-
|
60
|
+
context "when enabling" do
|
69
61
|
it "should call update-rc.d twice" do
|
70
62
|
@provider.expects(:update_rc).twice
|
71
63
|
@provider.enable
|
72
64
|
end
|
73
65
|
end
|
74
66
|
|
75
|
-
|
67
|
+
context "when disabling" do
|
76
68
|
it "should be able to disable services with newer sysv-rc versions" do
|
77
69
|
@provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "0"
|
78
70
|
|
@@ -91,7 +83,7 @@ describe provider_class do
|
|
91
83
|
end
|
92
84
|
end
|
93
85
|
|
94
|
-
|
86
|
+
context "when checking whether it is enabled" do
|
95
87
|
it "should call Kernel.system() with the appropriate parameters" do
|
96
88
|
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
|
97
89
|
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
@@ -151,7 +143,7 @@ describe provider_class do
|
|
151
143
|
end
|
152
144
|
end
|
153
145
|
|
154
|
-
|
146
|
+
context "when checking service status" do
|
155
147
|
it "should use the service command" do
|
156
148
|
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
157
149
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
|
@@ -1,11 +1,8 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:service).provider(:freebsd) do
|
7
4
|
before :each do
|
8
|
-
@provider =
|
5
|
+
@provider = subject()
|
9
6
|
@provider.stubs(:initscript)
|
10
7
|
Facter.stubs(:value).with(:osfamily).returns 'FreeBSD'
|
11
8
|
end
|
@@ -1,12 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the OpenBSD service provider
|
4
|
-
|
5
1
|
require 'spec_helper'
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
3
|
+
describe Puppet::Type.type(:service).provider(:openbsd), :unless => Puppet.features.microsoft_windows? do
|
10
4
|
before :each do
|
11
5
|
Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class
|
12
6
|
Facter.stubs(:value).with(:operatingsystem).returns :openbsd
|
@@ -15,7 +9,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
15
9
|
FileTest.stubs(:executable?).with('/usr/sbin/rcctl').returns true
|
16
10
|
end
|
17
11
|
|
18
|
-
|
12
|
+
context "#instances" do
|
19
13
|
it "should have an instances method" do
|
20
14
|
expect(described_class).to respond_to :instances
|
21
15
|
end
|
@@ -28,7 +22,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
31
|
-
|
25
|
+
context "#start" do
|
32
26
|
it "should use the supplied start command if specified" do
|
33
27
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :start => '/bin/foo'))
|
34
28
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
@@ -42,7 +36,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
42
36
|
end
|
43
37
|
end
|
44
38
|
|
45
|
-
|
39
|
+
context "#stop" do
|
46
40
|
it "should use the supplied stop command if specified" do
|
47
41
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :stop => '/bin/foo'))
|
48
42
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
@@ -56,7 +50,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
56
50
|
end
|
57
51
|
end
|
58
52
|
|
59
|
-
|
53
|
+
context "#status" do
|
60
54
|
it "should use the status command from the resource" do
|
61
55
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
|
62
56
|
provider.expects(:execute).with(['/usr/sbin/rcctl', :get, 'sshd', :status], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
@@ -81,7 +75,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
81
75
|
end
|
82
76
|
end
|
83
77
|
|
84
|
-
|
78
|
+
context "#restart" do
|
85
79
|
it "should use the supplied restart command if specified" do
|
86
80
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
|
87
81
|
provider.expects(:execute).with(['/usr/sbin/rcctl', '-f', :restart, 'sshd'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
@@ -104,7 +98,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
104
98
|
end
|
105
99
|
end
|
106
100
|
|
107
|
-
|
101
|
+
context "#enabled?" do
|
108
102
|
it "should return :true if the service is enabled" do
|
109
103
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
110
104
|
described_class.stubs(:rcctl).with(:get, 'sshd', :status)
|
@@ -120,7 +114,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
120
114
|
end
|
121
115
|
end
|
122
116
|
|
123
|
-
|
117
|
+
context "#enable" do
|
124
118
|
it "should run rcctl enable to enable the service" do
|
125
119
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
126
120
|
described_class.stubs(:rcctl).with(:enable, 'sshd').returns('')
|
@@ -138,7 +132,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
138
132
|
end
|
139
133
|
end
|
140
134
|
|
141
|
-
|
135
|
+
context "#disable" do
|
142
136
|
it "should run rcctl disable to disable the service" do
|
143
137
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
144
138
|
described_class.stubs(:rcctl).with(:disable, 'sshd').returns('')
|
@@ -147,7 +141,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
147
141
|
end
|
148
142
|
end
|
149
143
|
|
150
|
-
|
144
|
+
context "#running?" do
|
151
145
|
it "should run rcctl check to check the service" do
|
152
146
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
153
147
|
described_class.stubs(:rcctl).with(:check, 'sshd').returns('sshd(ok)')
|
@@ -170,7 +164,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
170
164
|
end
|
171
165
|
end
|
172
166
|
|
173
|
-
|
167
|
+
context "#flags" do
|
174
168
|
it "should return flags when set" do
|
175
169
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :flags => '-6'))
|
176
170
|
described_class.stubs(:rcctl).with('get', 'sshd', 'flags').returns('-6')
|
@@ -193,7 +187,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
193
187
|
end
|
194
188
|
end
|
195
189
|
|
196
|
-
|
190
|
+
context "#flags=" do
|
197
191
|
it "should run rcctl to set flags" do
|
198
192
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
199
193
|
described_class.stubs(:rcctl).with(:set, 'sshd', :flags, '-4').returns('')
|
@@ -1,20 +1,16 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
3
|
+
describe Puppet::Type.type(:service).provider(:rcng), :unless => Puppet.features.microsoft_windows? do
|
8
4
|
before :each do
|
9
5
|
Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class
|
10
6
|
Facter.stubs(:value).with(:operatingsystem).returns :netbsd
|
11
7
|
Facter.stubs(:value).with(:osfamily).returns 'NetBSD'
|
12
8
|
described_class.stubs(:defpath).returns('/etc/rc.d')
|
13
|
-
@provider =
|
9
|
+
@provider = subject()
|
14
10
|
@provider.stubs(:initscript)
|
15
11
|
end
|
16
12
|
|
17
|
-
|
13
|
+
context "#enable" do
|
18
14
|
it "should have an enable method" do
|
19
15
|
expect(@provider).to respond_to(:enable)
|
20
16
|
end
|
@@ -1,19 +1,12 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the RedHat service Provider
|
4
|
-
#
|
5
1
|
require 'spec_helper'
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
describe provider_class, :if => Puppet.features.posix? do
|
10
|
-
|
3
|
+
describe Puppet::Type.type(:service).provider(:redhat), :if => Puppet.features.posix? do
|
11
4
|
before :each do
|
12
5
|
@class = Puppet::Type.type(:service).provider(:redhat)
|
13
6
|
@resource = stub 'resource'
|
14
7
|
@resource.stubs(:[]).returns(nil)
|
15
8
|
@resource.stubs(:[]).with(:name).returns "myservice"
|
16
|
-
@provider =
|
9
|
+
@provider = subject()
|
17
10
|
@resource.stubs(:provider).returns @provider
|
18
11
|
@provider.resource = @resource
|
19
12
|
@provider.stubs(:get).with(:hasstatus).returns false
|
@@ -28,7 +21,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
28
21
|
osfamilies.each do |osfamily|
|
29
22
|
it "should be the default provider on #{osfamily}" do
|
30
23
|
Facter.expects(:value).with(:osfamily).returns(osfamily)
|
31
|
-
expect(
|
24
|
+
expect(described_class.default?).to be_truthy
|
32
25
|
end
|
33
26
|
end
|
34
27
|
|
@@ -40,7 +33,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
40
33
|
end
|
41
34
|
|
42
35
|
# test self.instances
|
43
|
-
|
36
|
+
context "when getting all service instances" do
|
44
37
|
before :each do
|
45
38
|
@services = ['one', 'two', 'three', 'four', 'kudzu', 'functions', 'halt', 'killall', 'single', 'linuxconf', 'boot', 'reboot']
|
46
39
|
@not_services = ['functions', 'halt', 'killall', 'single', 'linuxconf', 'reboot', 'boot']
|
@@ -64,13 +57,13 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
64
57
|
end
|
65
58
|
|
66
59
|
it "should use '--add' and 'on' when calling enable" do
|
67
|
-
|
68
|
-
|
60
|
+
described_class.expects(:chkconfig).with("--add", @resource[:name])
|
61
|
+
described_class.expects(:chkconfig).with(@resource[:name], :on)
|
69
62
|
@provider.enable
|
70
63
|
end
|
71
64
|
|
72
65
|
it "(#15797) should explicitly turn off the service in all run levels" do
|
73
|
-
|
66
|
+
described_class.expects(:chkconfig).with("--level", "0123456", @resource[:name], :off)
|
74
67
|
@provider.disable
|
75
68
|
end
|
76
69
|
|
@@ -78,28 +71,28 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
78
71
|
expect(@provider).to respond_to(:enabled?)
|
79
72
|
end
|
80
73
|
|
81
|
-
|
74
|
+
context "when checking enabled? on Suse" do
|
82
75
|
before :each do
|
83
76
|
Facter.expects(:value).with(:osfamily).returns 'Suse'
|
84
77
|
end
|
85
78
|
|
86
79
|
it "should check for on" do
|
87
|
-
|
80
|
+
described_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]} on"
|
88
81
|
expect(@provider.enabled?).to eq(:true)
|
89
82
|
end
|
90
83
|
|
91
84
|
it "should check for B" do
|
92
|
-
|
85
|
+
described_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]} B"
|
93
86
|
expect(@provider.enabled?).to eq(:true)
|
94
87
|
end
|
95
88
|
|
96
89
|
it "should check for off" do
|
97
|
-
|
90
|
+
described_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]} off"
|
98
91
|
expect(@provider.enabled?).to eq(:false)
|
99
92
|
end
|
100
93
|
|
101
94
|
it "should check for unknown service" do
|
102
|
-
|
95
|
+
described_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]}: unknown service"
|
103
96
|
expect(@provider.enabled?).to eq(:false)
|
104
97
|
end
|
105
98
|
end
|
@@ -132,20 +125,23 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
132
125
|
end
|
133
126
|
end
|
134
127
|
|
135
|
-
|
136
|
-
|
128
|
+
context "when checking status" do
|
129
|
+
context "when hasstatus is :true" do
|
137
130
|
before :each do
|
138
131
|
@resource.stubs(:[]).with(:hasstatus).returns :true
|
139
132
|
end
|
133
|
+
|
140
134
|
it "should execute the service script with fail_on_failure false" do
|
141
135
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
142
136
|
@provider.status
|
143
137
|
end
|
138
|
+
|
144
139
|
it "should consider the process running if the command returns 0" do
|
145
140
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
146
141
|
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
147
142
|
expect(@provider.status).to eq(:running)
|
148
143
|
end
|
144
|
+
|
149
145
|
[-10,-1,1,10].each { |ec|
|
150
146
|
it "should consider the process stopped if the command returns something non-0" do
|
151
147
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
@@ -154,11 +150,13 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
154
150
|
end
|
155
151
|
}
|
156
152
|
end
|
157
|
-
|
153
|
+
|
154
|
+
context "when hasstatus is not :true" do
|
158
155
|
it "should consider the service :running if it has a pid" do
|
159
156
|
@provider.expects(:getpid).returns "1234"
|
160
157
|
expect(@provider.status).to eq(:running)
|
161
158
|
end
|
159
|
+
|
162
160
|
it "should consider the service :stopped if it doesn't have a pid" do
|
163
161
|
@provider.expects(:getpid).returns nil
|
164
162
|
expect(@provider.status).to eq(:stopped)
|
@@ -166,7 +164,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
166
164
|
end
|
167
165
|
end
|
168
166
|
|
169
|
-
|
167
|
+
context "when restarting and hasrestart is not :true" do
|
170
168
|
it "should stop and restart the process with the server script" do
|
171
169
|
@provider.expects(:texecute).with(:stop, ['/sbin/service', 'myservice', 'stop'], true)
|
172
170
|
@provider.expects(:texecute).with(:start, ['/sbin/service', 'myservice', 'start'], true)
|
@@ -1,20 +1,11 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the Runit service Provider
|
4
|
-
#
|
5
|
-
# author Brice Figureau
|
6
|
-
#
|
7
1
|
require 'spec_helper'
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
describe provider_class do
|
12
|
-
|
3
|
+
describe Puppet::Type.type(:service).provider(:runit) do
|
13
4
|
before(:each) do
|
14
5
|
# Create a mock resource
|
15
6
|
@resource = stub 'resource'
|
16
7
|
|
17
|
-
@provider =
|
8
|
+
@provider = subject()
|
18
9
|
@servicedir = "/etc/service"
|
19
10
|
@provider.servicedir=@servicedir
|
20
11
|
@daemondir = "/etc/sv"
|
@@ -63,7 +54,7 @@ describe provider_class do
|
|
63
54
|
expect(@provider).to respond_to(:disable)
|
64
55
|
end
|
65
56
|
|
66
|
-
|
57
|
+
context "when starting" do
|
67
58
|
it "should enable the service if it is not enabled" do
|
68
59
|
@provider.stubs(:sv)
|
69
60
|
|
@@ -81,21 +72,21 @@ describe provider_class do
|
|
81
72
|
end
|
82
73
|
end
|
83
74
|
|
84
|
-
|
75
|
+
context "when stopping" do
|
85
76
|
it "should execute external command 'sv stop /etc/service/myservice'" do
|
86
77
|
@provider.expects(:sv).with("stop", "/etc/service/myservice")
|
87
78
|
@provider.stop
|
88
79
|
end
|
89
80
|
end
|
90
81
|
|
91
|
-
|
82
|
+
context "when restarting" do
|
92
83
|
it "should call 'sv restart /etc/service/myservice'" do
|
93
84
|
@provider.expects(:sv).with("restart","/etc/service/myservice")
|
94
85
|
@provider.restart
|
95
86
|
end
|
96
87
|
end
|
97
88
|
|
98
|
-
|
89
|
+
context "when enabling" do
|
99
90
|
it "should create a symlink between daemon dir and service dir", :if => Puppet.features.manages_symlinks? do
|
100
91
|
daemon_path = File.join(@daemondir,"myservice")
|
101
92
|
service_path = File.join(@servicedir,"myservice")
|
@@ -105,7 +96,7 @@ describe provider_class do
|
|
105
96
|
end
|
106
97
|
end
|
107
98
|
|
108
|
-
|
99
|
+
context "when disabling" do
|
109
100
|
it "should remove the '/etc/service/myservice' symlink" do
|
110
101
|
path = File.join(@servicedir,"myservice")
|
111
102
|
# mocked_file = mock(path, :symlink? => true)
|
@@ -116,14 +107,14 @@ describe provider_class do
|
|
116
107
|
end
|
117
108
|
end
|
118
109
|
|
119
|
-
|
110
|
+
context "when checking status" do
|
120
111
|
it "should call the external command 'sv status /etc/sv/myservice'" do
|
121
112
|
@provider.expects(:sv).with('status',File.join(@daemondir,"myservice"))
|
122
113
|
@provider.status
|
123
114
|
end
|
124
115
|
end
|
125
116
|
|
126
|
-
|
117
|
+
context "when checking status" do
|
127
118
|
it "and sv status fails, properly raise a Puppet::Error" do
|
128
119
|
@provider.expects(:sv).with('status',File.join(@daemondir,"myservice")).raises(Puppet::ExecutionFailure, "fail: /etc/sv/myservice: file not found")
|
129
120
|
expect { @provider.status }.to raise_error(Puppet::Error, 'Could not get status for service Service[myservice]: fail: /etc/sv/myservice: file not found')
|
@@ -141,5 +132,4 @@ describe provider_class do
|
|
141
132
|
expect(@provider.status).to eq(:stopped)
|
142
133
|
end
|
143
134
|
end
|
144
|
-
|
145
135
|
end
|
@@ -1,20 +1,11 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the SMF service Provider
|
4
|
-
#
|
5
|
-
# author Dominic Cleal
|
6
|
-
#
|
7
1
|
require 'spec_helper'
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
describe provider_class, :if => Puppet.features.posix? do
|
12
|
-
|
3
|
+
describe Puppet::Type.type(:service).provider(:smf), :if => Puppet.features.posix? do
|
13
4
|
before(:each) do
|
14
5
|
# Create a mock resource
|
15
6
|
@resource = Puppet::Type.type(:service).new(
|
16
7
|
:name => "/system/myservice", :ensure => :running, :enable => :true)
|
17
|
-
@provider =
|
8
|
+
@provider = described_class.new(@resource)
|
18
9
|
|
19
10
|
FileTest.stubs(:file?).with('/usr/sbin/svcadm').returns true
|
20
11
|
FileTest.stubs(:executable?).with('/usr/sbin/svcadm').returns true
|
@@ -25,14 +16,14 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
25
16
|
Facter.stubs(:value).with(:operatingsystemrelease).returns '11.2'
|
26
17
|
end
|
27
18
|
|
28
|
-
|
19
|
+
context ".instances" do
|
29
20
|
it "should have an instances method" do
|
30
|
-
expect(
|
21
|
+
expect(described_class).to respond_to :instances
|
31
22
|
end
|
32
23
|
|
33
24
|
it "should get a list of services (excluding legacy)" do
|
34
|
-
|
35
|
-
instances =
|
25
|
+
described_class.expects(:svcs).with('-H', '-o', 'state,fmri').returns File.read(my_fixture('svcs.out'))
|
26
|
+
instances = described_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
|
36
27
|
# we dont manage legacy
|
37
28
|
expect(instances.size).to eq(3)
|
38
29
|
expect(instances[0]).to eq({:name => 'svc:/system/svc/restarter:default', :ensure => :running })
|
@@ -70,6 +61,10 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
70
61
|
end
|
71
62
|
|
72
63
|
describe "when checking status" do
|
64
|
+
before(:each) do
|
65
|
+
@provider.stubs(:complete_service?).returns(true)
|
66
|
+
end
|
67
|
+
|
73
68
|
it "should call the external command 'svcs /system/myservice' once" do
|
74
69
|
@provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
|
75
70
|
@provider.status
|
@@ -78,6 +73,11 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
78
73
|
@provider.stubs(:svcs).raises(Puppet::ExecutionFailure.new("no svc found"))
|
79
74
|
expect(@provider.status).to eq(:stopped)
|
80
75
|
end
|
76
|
+
it "should return stopped for an incomplete service on Solaris 11" do
|
77
|
+
Facter.stubs(:value).with(:operatingsystemrelease).returns('11.3')
|
78
|
+
@provider.stubs(:complete_service?).returns(false)
|
79
|
+
expect(@provider.status).to eq(:stopped)
|
80
|
+
end
|
81
81
|
it "should return running if online in svcs output" do
|
82
82
|
@provider.stubs(:svcs).returns("online\t-")
|
83
83
|
expect(@provider.status).to eq(:running)
|
@@ -104,7 +104,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
|
107
|
+
context "when starting" do
|
108
108
|
it "should enable the service if it is not enabled" do
|
109
109
|
@provider.expects(:status).returns :stopped
|
110
110
|
@provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-rs', '/system/myservice'], true)
|
@@ -141,14 +141,15 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
context "when starting a service with a manifest" do
|
145
145
|
before(:each) do
|
146
146
|
@resource = Puppet::Type.type(:service).new(:name => "/system/myservice", :ensure => :running, :enable => :true, :manifest => "/tmp/myservice.xml")
|
147
|
-
@provider =
|
147
|
+
@provider = described_class.new(@resource)
|
148
148
|
$CHILD_STATUS.stubs(:exitstatus).returns(1)
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should import the manifest if service is missing" do
|
152
|
+
@provider.stubs(:complete_service?).returns(true)
|
152
153
|
@provider.expects(:svcs).with('-l', '/system/myservice').raises(Puppet::ExecutionFailure, "Exited 1")
|
153
154
|
@provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
|
154
155
|
@provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, '-rs', "/system/myservice"], true)
|
@@ -164,7 +165,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
164
165
|
end
|
165
166
|
end
|
166
167
|
|
167
|
-
|
168
|
+
context "when stopping" do
|
168
169
|
it "should execute external command 'svcadm disable /system/myservice'" do
|
169
170
|
@provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
|
170
171
|
@provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
|
@@ -178,8 +179,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
178
179
|
end
|
179
180
|
end
|
180
181
|
|
181
|
-
|
182
|
-
|
182
|
+
context "when restarting" do
|
183
183
|
it "should error if timeout occurs while restarting the service" do
|
184
184
|
@provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, '-s', "/system/myservice"], true)
|
185
185
|
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
@@ -212,6 +212,67 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
212
212
|
@provider.restart
|
213
213
|
end
|
214
214
|
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe '#service_fmri' do
|
218
|
+
it 'raises a Puppet::Error if the service resource matches multiple FMRIs' do
|
219
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_multiple_fmris.out')))
|
220
|
+
|
221
|
+
expect { @provider.service_fmri }.to raise_error do |error|
|
222
|
+
expect(error).to be_a(Puppet::Error)
|
223
|
+
expect(error.message).to match(@provider.resource[:name])
|
224
|
+
expect(error.message).to match('multiple')
|
225
|
+
|
226
|
+
matched_fmris = ["svc:/application/tstapp:one", "svc:/application/tstapp:two"]
|
227
|
+
expect(error.message).to match(matched_fmris.join(', '))
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'raises a Puppet:ExecutionFailure if svcs fails' do
|
232
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).raises(
|
233
|
+
Puppet::ExecutionFailure, 'svcs failed!'
|
234
|
+
)
|
235
|
+
|
236
|
+
expect { @provider.service_fmri }.to raise_error do |error|
|
237
|
+
expect(error).to be_a(Puppet::ExecutionFailure)
|
238
|
+
expect(error.message).to match('svcs failed!')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
it "returns the service resource's fmri and memoizes it" do
|
243
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_fmri.out')))
|
244
|
+
|
245
|
+
expected_fmri = 'svc:/application/tstapp:default'
|
215
246
|
|
247
|
+
expect(@provider.service_fmri).to eql(expected_fmri)
|
248
|
+
expect(@provider.instance_variable_get(:@fmri)).to eql(expected_fmri)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '#complete_service?' do
|
253
|
+
let(:fmri) { 'service_fmri' }
|
254
|
+
|
255
|
+
before(:each) do
|
256
|
+
@provider.stubs(:service_fmri).returns(fmri)
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should raise a Puppet::Error if it is called on an older Solaris machine' do
|
260
|
+
Facter.stubs(:value).with(:operatingsystemrelease).returns('10.0')
|
261
|
+
|
262
|
+
expect { @provider.complete_service? }.to raise_error(Puppet::Error)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'should return false for an incomplete service' do
|
266
|
+
@provider.stubs(:svccfg).with('-s', fmri, 'listprop', 'general/complete').returns("")
|
267
|
+
expect(@provider.complete_service?).to be false
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'should return true for a complete service' do
|
271
|
+
@provider.stubs(:svccfg)
|
272
|
+
.with('-s', fmri, 'listprop', 'general/complete')
|
273
|
+
.returns("general/complete astring")
|
274
|
+
|
275
|
+
expect(@provider.complete_service?).to be true
|
276
|
+
end
|
216
277
|
end
|
217
278
|
end
|