puppet 6.0.4-x86-mingw32 → 6.0.5-x86-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 +15 -15
- 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 +48 -32
- data/lib/puppet/application/ssl.rb +31 -17
- data/lib/puppet/defaults.rb +2 -1
- 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/model/pn_transformer.rb +5 -0
- 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/package/dnf.rb +2 -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/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/provider/service/systemd.rb +2 -0
- data/lib/puppet/provider/service/upstart.rb +1 -0
- data/lib/puppet/rest/route.rb +1 -1
- data/lib/puppet/ssl/host.rb +23 -11
- 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/ja/puppet.po +232 -183
- data/locales/puppet.pot +145 -117
- data/man/man5/puppet.conf.5 +3 -3
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.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-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-ssl.8 +6 -3
- 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 +559 -0
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/unit/application/device_spec.rb +10 -7
- data/spec/unit/application/lookup_spec.rb +2 -1
- data/spec/unit/application/ssl_spec.rb +21 -2
- data/spec/unit/forge/forge_spec.rb +4 -2
- data/spec/unit/functions/logging_spec.rb +10 -3
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +6 -7
- data/spec/unit/pops/model/pn_transformer_spec.rb +4 -0
- 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/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- 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 +36 -37
- 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 +45 -49
- 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 +30 -16
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +7 -9
- data/spec/unit/provider/service/daemontools_spec.rb +12 -16
- data/spec/unit/provider/service/debian_spec.rb +6 -10
- data/spec/unit/provider/service/freebsd_spec.rb +2 -2
- data/spec/unit/provider/service/openbsd_spec.rb +13 -17
- data/spec/unit/provider/service/rcng_spec.rb +2 -4
- data/spec/unit/provider/service/redhat_spec.rb +12 -11
- data/spec/unit/provider/service/runit_spec.rb +7 -14
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +11 -16
- data/spec/unit/provider/service/systemd_spec.rb +18 -0
- data/spec/unit/provider/user/hpux_spec.rb +3 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/rest/route_spec.rb +1 -1
- data/spec/unit/ssl/host_spec.rb +21 -0
- 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 +8 -2
@@ -1,11 +1,7 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the debian service provider
|
4
|
-
#
|
5
|
-
|
6
1
|
require 'spec_helper'
|
7
2
|
|
8
|
-
describe 'Puppet::Type::Service::Provider::Debian',
|
3
|
+
describe 'Puppet::Type::Service::Provider::Debian',
|
4
|
+
unless: Puppet::Util::Platform.jruby? do
|
9
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:debian) }
|
10
6
|
|
11
7
|
if Puppet::Util::Platform.windows?
|
@@ -69,14 +65,14 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
|
|
69
65
|
expect(@provider).to respond_to(:disable)
|
70
66
|
end
|
71
67
|
|
72
|
-
|
68
|
+
context "when enabling" do
|
73
69
|
it "should call update-rc.d twice" do
|
74
70
|
@provider.expects(:update_rc).twice
|
75
71
|
@provider.enable
|
76
72
|
end
|
77
73
|
end
|
78
74
|
|
79
|
-
|
75
|
+
context "when disabling" do
|
80
76
|
it "should be able to disable services with newer sysv-rc versions" do
|
81
77
|
@provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "0"
|
82
78
|
|
@@ -95,7 +91,7 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
|
|
95
91
|
end
|
96
92
|
end
|
97
93
|
|
98
|
-
|
94
|
+
context "when checking whether it is enabled" do
|
99
95
|
it "should call Kernel.system() with the appropriate parameters" do
|
100
96
|
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
|
101
97
|
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
@@ -155,7 +151,7 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
|
|
155
151
|
end
|
156
152
|
end
|
157
153
|
|
158
|
-
|
154
|
+
context "when checking service status" do
|
159
155
|
it "should use the service command" do
|
160
156
|
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
161
157
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
|
@@ -1,7 +1,7 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
describe 'Puppet::Type::Service::Provider::Freebsd',
|
3
|
+
describe 'Puppet::Type::Service::Provider::Freebsd',
|
4
|
+
unless: Puppet::Util::Platform.jruby? do
|
5
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:freebsd) }
|
6
6
|
|
7
7
|
before :each do
|
@@ -1,11 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the OpenBSD service provider
|
4
|
-
|
5
1
|
require 'spec_helper'
|
6
2
|
|
7
3
|
describe 'Puppet::Type::Service::Provider::Openbsd',
|
8
|
-
|
4
|
+
unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
|
9
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:openbsd) }
|
10
6
|
|
11
7
|
before :each do
|
@@ -16,7 +12,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
16
12
|
FileTest.stubs(:executable?).with('/usr/sbin/rcctl').returns true
|
17
13
|
end
|
18
14
|
|
19
|
-
|
15
|
+
context "#instances" do
|
20
16
|
it "should have an instances method" do
|
21
17
|
expect(provider_class).to respond_to :instances
|
22
18
|
end
|
@@ -29,7 +25,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
|
28
|
+
context "#start" do
|
33
29
|
it "should use the supplied start command if specified" do
|
34
30
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :start => '/bin/foo'))
|
35
31
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
@@ -43,7 +39,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
43
39
|
end
|
44
40
|
end
|
45
41
|
|
46
|
-
|
42
|
+
context "#stop" do
|
47
43
|
it "should use the supplied stop command if specified" do
|
48
44
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :stop => '/bin/foo'))
|
49
45
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
@@ -57,7 +53,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
|
56
|
+
context "#status" do
|
61
57
|
it "should use the status command from the resource" do
|
62
58
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
|
63
59
|
provider.expects(:execute).with(['/usr/sbin/rcctl', :get, 'sshd', :status], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
@@ -82,7 +78,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
82
78
|
end
|
83
79
|
end
|
84
80
|
|
85
|
-
|
81
|
+
context "#restart" do
|
86
82
|
it "should use the supplied restart command if specified" do
|
87
83
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
|
88
84
|
provider.expects(:execute).with(['/usr/sbin/rcctl', '-f', :restart, 'sshd'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
@@ -105,7 +101,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
105
101
|
end
|
106
102
|
end
|
107
103
|
|
108
|
-
|
104
|
+
context "#enabled?" do
|
109
105
|
it "should return :true if the service is enabled" do
|
110
106
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
111
107
|
provider_class.stubs(:rcctl).with(:get, 'sshd', :status)
|
@@ -121,7 +117,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
121
117
|
end
|
122
118
|
end
|
123
119
|
|
124
|
-
|
120
|
+
context "#enable" do
|
125
121
|
it "should run rcctl enable to enable the service" do
|
126
122
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
127
123
|
provider_class.stubs(:rcctl).with(:enable, 'sshd').returns('')
|
@@ -139,7 +135,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
139
135
|
end
|
140
136
|
end
|
141
137
|
|
142
|
-
|
138
|
+
context "#disable" do
|
143
139
|
it "should run rcctl disable to disable the service" do
|
144
140
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
145
141
|
provider_class.stubs(:rcctl).with(:disable, 'sshd').returns('')
|
@@ -148,7 +144,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
148
144
|
end
|
149
145
|
end
|
150
146
|
|
151
|
-
|
147
|
+
context "#running?" do
|
152
148
|
it "should run rcctl check to check the service" do
|
153
149
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
154
150
|
provider_class.stubs(:rcctl).with(:check, 'sshd').returns('sshd(ok)')
|
@@ -171,7 +167,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
171
167
|
end
|
172
168
|
end
|
173
169
|
|
174
|
-
|
170
|
+
context "#flags" do
|
175
171
|
it "should return flags when set" do
|
176
172
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :flags => '-6'))
|
177
173
|
provider_class.stubs(:rcctl).with('get', 'sshd', 'flags').returns('-6')
|
@@ -194,8 +190,8 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
|
|
194
190
|
end
|
195
191
|
end
|
196
192
|
|
197
|
-
|
198
|
-
it "should run rcctl to set flags", :
|
193
|
+
context "#flags=" do
|
194
|
+
it "should run rcctl to set flags", unless: Puppet::Util::Platform.windows? || RUBY_PLATFORM == 'java' do
|
199
195
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
200
196
|
provider_class.stubs(:rcctl).with(:set, 'sshd', :flags, '-4').returns('')
|
201
197
|
provider.expects(:rcctl).with(:set, 'sshd', :flags, '-4')
|
@@ -1,9 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
3
|
describe 'Puppet::Type::Service::Provider::Rcng',
|
6
|
-
|
4
|
+
unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
|
7
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:rcng) }
|
8
6
|
|
9
7
|
before :each do
|
@@ -15,7 +13,7 @@ describe 'Puppet::Type::Service::Provider::Rcng',
|
|
15
13
|
@provider.stubs(:initscript)
|
16
14
|
end
|
17
15
|
|
18
|
-
|
16
|
+
context "#enable" do
|
19
17
|
it "should have an enable method" do
|
20
18
|
expect(@provider).to respond_to(:enable)
|
21
19
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the RedHat service Provider
|
4
|
-
#
|
5
1
|
require 'spec_helper'
|
6
2
|
|
7
3
|
describe 'Puppet::Type::Service::Provider::Redhat',
|
8
|
-
|
4
|
+
if: Puppet.features.posix? && !Puppet::Util::Platform.jruby?do
|
9
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:redhat) }
|
10
6
|
|
11
7
|
before :each do
|
@@ -40,7 +36,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
|
|
40
36
|
end
|
41
37
|
|
42
38
|
# test self.instances
|
43
|
-
|
39
|
+
context "when getting all service instances" do
|
44
40
|
before :each do
|
45
41
|
@services = ['one', 'two', 'three', 'four', 'kudzu', 'functions', 'halt', 'killall', 'single', 'linuxconf', 'boot', 'reboot']
|
46
42
|
@not_services = ['functions', 'halt', 'killall', 'single', 'linuxconf', 'reboot', 'boot']
|
@@ -78,7 +74,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
|
|
78
74
|
expect(@provider).to respond_to(:enabled?)
|
79
75
|
end
|
80
76
|
|
81
|
-
|
77
|
+
context "when checking enabled? on Suse" do
|
82
78
|
before :each do
|
83
79
|
Facter.expects(:value).with(:osfamily).returns 'Suse'
|
84
80
|
end
|
@@ -132,20 +128,23 @@ describe 'Puppet::Type::Service::Provider::Redhat',
|
|
132
128
|
end
|
133
129
|
end
|
134
130
|
|
135
|
-
|
136
|
-
|
131
|
+
context "when checking status" do
|
132
|
+
context "when hasstatus is :true" do
|
137
133
|
before :each do
|
138
134
|
@resource.stubs(:[]).with(:hasstatus).returns :true
|
139
135
|
end
|
136
|
+
|
140
137
|
it "should execute the service script with fail_on_failure false" do
|
141
138
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
142
139
|
@provider.status
|
143
140
|
end
|
141
|
+
|
144
142
|
it "should consider the process running if the command returns 0" do
|
145
143
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
146
144
|
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
147
145
|
expect(@provider.status).to eq(:running)
|
148
146
|
end
|
147
|
+
|
149
148
|
[-10,-1,1,10].each { |ec|
|
150
149
|
it "should consider the process stopped if the command returns something non-0" do
|
151
150
|
@provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
|
@@ -154,11 +153,13 @@ describe 'Puppet::Type::Service::Provider::Redhat',
|
|
154
153
|
end
|
155
154
|
}
|
156
155
|
end
|
157
|
-
|
156
|
+
|
157
|
+
context "when hasstatus is not :true" do
|
158
158
|
it "should consider the service :running if it has a pid" do
|
159
159
|
@provider.expects(:getpid).returns "1234"
|
160
160
|
expect(@provider.status).to eq(:running)
|
161
161
|
end
|
162
|
+
|
162
163
|
it "should consider the service :stopped if it doesn't have a pid" do
|
163
164
|
@provider.expects(:getpid).returns nil
|
164
165
|
expect(@provider.status).to eq(:stopped)
|
@@ -166,7 +167,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
|
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
169
|
-
|
170
|
+
context "when restarting and hasrestart is not :true" do
|
170
171
|
it "should stop and restart the process with the server script" do
|
171
172
|
@provider.expects(:texecute).with(:stop, ['/sbin/service', 'myservice', 'stop'], true)
|
172
173
|
@provider.expects(:texecute).with(:start, ['/sbin/service', 'myservice', 'start'], true)
|
@@ -1,9 +1,3 @@
|
|
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
3
|
describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platform.jruby? do
|
@@ -62,7 +56,7 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
62
56
|
expect(@provider).to respond_to(:disable)
|
63
57
|
end
|
64
58
|
|
65
|
-
|
59
|
+
context "when starting" do
|
66
60
|
it "should enable the service if it is not enabled" do
|
67
61
|
@provider.stubs(:sv)
|
68
62
|
|
@@ -80,21 +74,21 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
80
74
|
end
|
81
75
|
end
|
82
76
|
|
83
|
-
|
77
|
+
context "when stopping" do
|
84
78
|
it "should execute external command 'sv stop /etc/service/myservice'" do
|
85
79
|
@provider.expects(:sv).with("stop", "/etc/service/myservice")
|
86
80
|
@provider.stop
|
87
81
|
end
|
88
82
|
end
|
89
83
|
|
90
|
-
|
84
|
+
context "when restarting" do
|
91
85
|
it "should call 'sv restart /etc/service/myservice'" do
|
92
86
|
@provider.expects(:sv).with("restart","/etc/service/myservice")
|
93
87
|
@provider.restart
|
94
88
|
end
|
95
89
|
end
|
96
90
|
|
97
|
-
|
91
|
+
context "when enabling" do
|
98
92
|
it "should create a symlink between daemon dir and service dir", :if => Puppet.features.manages_symlinks? do
|
99
93
|
daemon_path = File.join(@daemondir,"myservice")
|
100
94
|
service_path = File.join(@servicedir,"myservice")
|
@@ -104,7 +98,7 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
104
98
|
end
|
105
99
|
end
|
106
100
|
|
107
|
-
|
101
|
+
context "when disabling" do
|
108
102
|
it "should remove the '/etc/service/myservice' symlink" do
|
109
103
|
path = File.join(@servicedir,"myservice")
|
110
104
|
# mocked_file = mock(path, :symlink? => true)
|
@@ -115,14 +109,14 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
115
109
|
end
|
116
110
|
end
|
117
111
|
|
118
|
-
|
112
|
+
context "when checking status" do
|
119
113
|
it "should call the external command 'sv status /etc/sv/myservice'" do
|
120
114
|
@provider.expects(:sv).with('status',File.join(@daemondir,"myservice"))
|
121
115
|
@provider.status
|
122
116
|
end
|
123
117
|
end
|
124
118
|
|
125
|
-
|
119
|
+
context "when checking status" do
|
126
120
|
it "and sv status fails, properly raise a Puppet::Error" do
|
127
121
|
@provider.expects(:sv).with('status',File.join(@daemondir,"myservice")).raises(Puppet::ExecutionFailure, "fail: /etc/sv/myservice: file not found")
|
128
122
|
expect { @provider.status }.to raise_error(Puppet::Error, 'Could not get status for service Service[myservice]: fail: /etc/sv/myservice: file not found')
|
@@ -140,5 +134,4 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
140
134
|
expect(@provider.status).to eq(:stopped)
|
141
135
|
end
|
142
136
|
end
|
143
|
-
|
144
137
|
end
|
@@ -1,13 +1,7 @@
|
|
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
3
|
describe 'Puppet::Type::Service::Provider::Smf',
|
10
|
-
|
4
|
+
if: Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
|
11
5
|
let(:provider_class) { Puppet::Type.type(:service).provider(:smf) }
|
12
6
|
|
13
7
|
before(:each) do
|
@@ -25,7 +19,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
25
19
|
Facter.stubs(:value).with(:operatingsystemrelease).returns '11.2'
|
26
20
|
end
|
27
21
|
|
28
|
-
|
22
|
+
context ".instances" do
|
29
23
|
it "should have an instances method" do
|
30
24
|
expect(provider_class).to respond_to :instances
|
31
25
|
end
|
@@ -70,6 +64,10 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
70
64
|
end
|
71
65
|
|
72
66
|
describe "when checking status" do
|
67
|
+
before(:each) do
|
68
|
+
@provider.stubs(:complete_service?).returns(true)
|
69
|
+
end
|
70
|
+
|
73
71
|
it "should call the external command 'svcs /system/myservice' once" do
|
74
72
|
@provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
|
75
73
|
@provider.status
|
@@ -78,6 +76,11 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
78
76
|
@provider.stubs(:svcs).raises(Puppet::ExecutionFailure.new("no svc found"))
|
79
77
|
expect(@provider.status).to eq(:stopped)
|
80
78
|
end
|
79
|
+
it "should return stopped for an incomplete service on Solaris 11" do
|
80
|
+
Facter.stubs(:value).with(:operatingsystemrelease).returns('11.3')
|
81
|
+
@provider.stubs(:complete_service?).returns(false)
|
82
|
+
expect(@provider.status).to eq(:stopped)
|
83
|
+
end
|
81
84
|
it "should return running if online in svcs output" do
|
82
85
|
@provider.stubs(:svcs).returns("online\t-")
|
83
86
|
expect(@provider.status).to eq(:running)
|
@@ -104,7 +107,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
104
107
|
end
|
105
108
|
end
|
106
109
|
|
107
|
-
|
110
|
+
context "when starting" do
|
108
111
|
it "should enable the service if it is not enabled" do
|
109
112
|
@provider.expects(:status).returns :stopped
|
110
113
|
@provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-rs', '/system/myservice'], true)
|
@@ -141,7 +144,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
144
|
-
|
147
|
+
context "when starting a service with a manifest" do
|
145
148
|
before(:each) do
|
146
149
|
@resource = Puppet::Type.type(:service).new(:name => "/system/myservice", :ensure => :running, :enable => :true, :manifest => "/tmp/myservice.xml")
|
147
150
|
@provider = provider_class.new(@resource)
|
@@ -149,6 +152,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
149
152
|
end
|
150
153
|
|
151
154
|
it "should import the manifest if service is missing" do
|
155
|
+
@provider.stubs(:complete_service?).returns(true)
|
152
156
|
@provider.expects(:svcs).with('-l', '/system/myservice').raises(Puppet::ExecutionFailure, "Exited 1")
|
153
157
|
@provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
|
154
158
|
@provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, '-rs', "/system/myservice"], true)
|
@@ -164,7 +168,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
167
|
-
|
171
|
+
context "when stopping" do
|
168
172
|
it "should execute external command 'svcadm disable /system/myservice'" do
|
169
173
|
@provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
|
170
174
|
@provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
|
@@ -178,8 +182,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
178
182
|
end
|
179
183
|
end
|
180
184
|
|
181
|
-
|
182
|
-
|
185
|
+
context "when restarting" do
|
183
186
|
it "should error if timeout occurs while restarting the service" do
|
184
187
|
@provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, '-s', "/system/myservice"], true)
|
185
188
|
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
@@ -212,6 +215,67 @@ describe 'Puppet::Type::Service::Provider::Smf',
|
|
212
215
|
@provider.restart
|
213
216
|
end
|
214
217
|
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe '#service_fmri' do
|
221
|
+
it 'raises a Puppet::Error if the service resource matches multiple FMRIs' do
|
222
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_multiple_fmris.out')))
|
223
|
+
|
224
|
+
expect { @provider.service_fmri }.to raise_error do |error|
|
225
|
+
expect(error).to be_a(Puppet::Error)
|
226
|
+
expect(error.message).to match(@provider.resource[:name])
|
227
|
+
expect(error.message).to match('multiple')
|
228
|
+
|
229
|
+
matched_fmris = ["svc:/application/tstapp:one", "svc:/application/tstapp:two"]
|
230
|
+
expect(error.message).to match(matched_fmris.join(', '))
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'raises a Puppet:ExecutionFailure if svcs fails' do
|
235
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).raises(
|
236
|
+
Puppet::ExecutionFailure, 'svcs failed!'
|
237
|
+
)
|
238
|
+
|
239
|
+
expect { @provider.service_fmri }.to raise_error do |error|
|
240
|
+
expect(error).to be_a(Puppet::ExecutionFailure)
|
241
|
+
expect(error.message).to match('svcs failed!')
|
242
|
+
end
|
243
|
+
end
|
215
244
|
|
245
|
+
it "returns the service resource's fmri and memoizes it" do
|
246
|
+
@provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_fmri.out')))
|
247
|
+
|
248
|
+
expected_fmri = 'svc:/application/tstapp:default'
|
249
|
+
|
250
|
+
expect(@provider.service_fmri).to eql(expected_fmri)
|
251
|
+
expect(@provider.instance_variable_get(:@fmri)).to eql(expected_fmri)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe '#complete_service?' do
|
256
|
+
let(:fmri) { 'service_fmri' }
|
257
|
+
|
258
|
+
before(:each) do
|
259
|
+
@provider.stubs(:service_fmri).returns(fmri)
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'should raise a Puppet::Error if it is called on an older Solaris machine' do
|
263
|
+
Facter.stubs(:value).with(:operatingsystemrelease).returns('10.0')
|
264
|
+
|
265
|
+
expect { @provider.complete_service? }.to raise_error(Puppet::Error)
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'should return false for an incomplete service' do
|
269
|
+
@provider.stubs(:svccfg).with('-s', fmri, 'listprop', 'general/complete').returns("")
|
270
|
+
expect(@provider.complete_service?).to be false
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'should return true for a complete service' do
|
274
|
+
@provider.stubs(:svccfg)
|
275
|
+
.with('-s', fmri, 'listprop', 'general/complete')
|
276
|
+
.returns("general/complete astring")
|
277
|
+
|
278
|
+
expect(@provider.complete_service?).to be true
|
279
|
+
end
|
216
280
|
end
|
217
281
|
end
|