puppet 5.5.8 → 5.5.10
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,9 +1,6 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:package).provider(:puppet_gem) do
|
7
4
|
let(:resource) do
|
8
5
|
Puppet::Type.type(:package).new(
|
9
6
|
:name => 'myresource',
|
@@ -12,7 +9,7 @@ describe provider_class do
|
|
12
9
|
end
|
13
10
|
|
14
11
|
let(:provider) do
|
15
|
-
provider =
|
12
|
+
provider = described_class.new
|
16
13
|
provider.resource = resource
|
17
14
|
provider
|
18
15
|
end
|
@@ -27,9 +24,9 @@ describe provider_class do
|
|
27
24
|
resource.provider = provider
|
28
25
|
end
|
29
26
|
|
30
|
-
|
27
|
+
context "when installing" do
|
31
28
|
it "should use the path to the gem" do
|
32
|
-
|
29
|
+
described_class.expects(:which).with(puppet_gem).returns(puppet_gem)
|
33
30
|
provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
|
34
31
|
provider.install
|
35
32
|
end
|
@@ -46,9 +43,9 @@ describe provider_class do
|
|
46
43
|
end
|
47
44
|
end
|
48
45
|
|
49
|
-
|
46
|
+
context "when uninstalling" do
|
50
47
|
it "should use the path to the gem" do
|
51
|
-
|
48
|
+
described_class.expects(:which).with(puppet_gem).returns(puppet_gem)
|
52
49
|
provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
|
53
50
|
provider.install
|
54
51
|
end
|
@@ -2,17 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
# Note that much of the functionality of the tdnf provider is already tested with yum provider tests,
|
4
4
|
# as yum is the parent provider, via dnf
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
context 'default' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
describe Puppet::Type.type(:package).provider(:tdnf) do
|
6
|
+
it_behaves_like 'RHEL package provider', described_class, 'tdnf'
|
7
|
+
|
8
|
+
context 'default' do
|
9
|
+
it 'should be the default provider on PhotonOS' do
|
10
|
+
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
11
|
+
Facter.stubs(:value).with(:operatingsystem).returns("PhotonOS")
|
12
|
+
expect(described_class).to be_default
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
16
|
-
describe provider_class do
|
17
|
-
it_behaves_like 'RHEL package provider', provider_class, 'tdnf'
|
18
|
-
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:package).provider(:yum) do
|
7
4
|
include PuppetSpec::Fixtures
|
8
|
-
|
5
|
+
|
6
|
+
it_behaves_like 'RHEL package provider', described_class, 'yum'
|
9
7
|
|
10
8
|
describe "when supplied the source param" do
|
11
9
|
let(:name) { 'baz' }
|
@@ -18,12 +16,12 @@ describe provider_class do
|
|
18
16
|
end
|
19
17
|
|
20
18
|
let(:provider) do
|
21
|
-
provider =
|
19
|
+
provider = described_class.new
|
22
20
|
provider.resource = resource
|
23
21
|
provider
|
24
22
|
end
|
25
23
|
|
26
|
-
before {
|
24
|
+
before { described_class.stubs(:command).with(:cmd).returns("/usr/bin/yum") }
|
27
25
|
|
28
26
|
context "when installing" do
|
29
27
|
it "should use the supplied source as the explicit path to a package to install" do
|
@@ -51,16 +49,18 @@ describe provider_class do
|
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
54
|
-
|
55
|
-
|
52
|
+
context "parsing the output of check-update" do
|
53
|
+
context "with no multiline entries" do
|
56
54
|
let(:check_update) { File.read(my_fixture("yum-check-update-simple.txt")) }
|
57
55
|
let(:output) { described_class.parse_updates(check_update) }
|
56
|
+
|
58
57
|
it 'creates an entry for each package keyed on the package name' do
|
59
58
|
expect(output['curl']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'i686'}, {:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
|
60
59
|
expect(output['gawk']).to eq([{:name => 'gawk', :epoch => '0', :version => '4.1.0', :release => '3.fc20', :arch => 'i686'}])
|
61
60
|
expect(output['dhclient']).to eq([{:name => 'dhclient', :epoch => '12', :version => '4.1.1', :release => '38.P1.fc20', :arch => 'i686'}])
|
62
61
|
expect(output['selinux-policy']).to eq([{:name => 'selinux-policy', :epoch => '0', :version => '3.12.1', :release => '163.fc20', :arch => 'noarch'}])
|
63
62
|
end
|
63
|
+
|
64
64
|
it 'creates an entry for each package keyed on the package name and package architecture' do
|
65
65
|
expect(output['curl.i686']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'i686'}])
|
66
66
|
expect(output['curl.x86_64']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
|
@@ -70,55 +70,69 @@ describe provider_class do
|
|
70
70
|
expect(output['java-1.8.0-openjdk.x86_64']).to eq([{:name => 'java-1.8.0-openjdk', :epoch => '1', :version => '1.8.0.131', :release => '2.b11.el7_3', :arch => 'x86_64'}])
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
|
+
context "with multiline entries" do
|
74
75
|
let(:check_update) { File.read(my_fixture("yum-check-update-multiline.txt")) }
|
75
76
|
let(:output) { described_class.parse_updates(check_update) }
|
77
|
+
|
76
78
|
it "parses multi-line values as a single package tuple" do
|
77
79
|
expect(output['libpcap']).to eq([{:name => 'libpcap', :epoch => '14', :version => '1.4.0', :release => '1.20130826git2dbcaa1.el6', :arch => 'x86_64'}])
|
78
80
|
end
|
79
81
|
end
|
80
|
-
|
82
|
+
|
83
|
+
context "with obsoleted packages" do
|
81
84
|
let(:check_update) { File.read(my_fixture("yum-check-update-obsoletes.txt")) }
|
82
85
|
let(:output) { described_class.parse_updates(check_update) }
|
86
|
+
|
83
87
|
it "ignores all entries including and after 'Obsoleting Packages'" do
|
84
88
|
expect(output).not_to include("Obsoleting")
|
85
89
|
expect(output).not_to include("NetworkManager-bluetooth.x86_64")
|
86
90
|
expect(output).not_to include("1:1.0.0-14.git20150121.b4ea599c.el7")
|
87
91
|
end
|
88
92
|
end
|
89
|
-
|
93
|
+
|
94
|
+
context "with security notifications" do
|
90
95
|
let(:check_update) { File.read(my_fixture("yum-check-update-security.txt")) }
|
91
96
|
let(:output) { described_class.parse_updates(check_update) }
|
97
|
+
|
92
98
|
it "ignores all entries including and after 'Security'" do
|
93
99
|
expect(output).not_to include("Security")
|
94
100
|
end
|
101
|
+
|
95
102
|
it "includes updates before 'Security'" do
|
96
103
|
expect(output).to include("yum-plugin-fastestmirror.noarch")
|
97
104
|
end
|
98
105
|
end
|
99
|
-
|
106
|
+
|
107
|
+
context "with broken update notices" do
|
100
108
|
let(:check_update) { File.read(my_fixture("yum-check-update-broken-notices.txt")) }
|
101
109
|
let(:output) { described_class.parse_updates(check_update) }
|
110
|
+
|
102
111
|
it "ignores all entries including and after 'Update'" do
|
103
112
|
expect(output).not_to include("Update")
|
104
113
|
end
|
114
|
+
|
105
115
|
it "includes updates before 'Update'" do
|
106
116
|
expect(output).to include("yum-plugin-fastestmirror.noarch")
|
107
117
|
end
|
108
118
|
end
|
109
|
-
|
119
|
+
|
120
|
+
context "with improper package names in output" do
|
110
121
|
it "raises an exception parsing package name" do
|
111
122
|
expect {
|
112
123
|
described_class.update_to_hash('badpackagename', '1')
|
113
124
|
}.to raise_exception(Exception, /Failed to parse/)
|
114
125
|
end
|
115
126
|
end
|
116
|
-
|
127
|
+
|
128
|
+
context "with trailing plugin output" do
|
117
129
|
let(:check_update) { File.read(my_fixture("yum-check-update-plugin-output.txt")) }
|
118
130
|
let(:output) { described_class.parse_updates(check_update) }
|
131
|
+
|
119
132
|
it "parses correctly formatted entries" do
|
120
133
|
expect(output['bash']).to eq([{:name => 'bash', :epoch => '0', :version => '4.2.46', :release => '12.el7', :arch => 'x86_64'}])
|
121
134
|
end
|
135
|
+
|
122
136
|
it "ignores all mentions of plugin output" do
|
123
137
|
expect(output).not_to include("Random plugin")
|
124
138
|
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
describe provider_class do
|
3
|
+
describe Puppet::Type.type(:package).provider(:zypper) do
|
7
4
|
before(:each) do
|
8
5
|
# Create a mock resource
|
9
6
|
@resource = stub 'resource'
|
@@ -16,35 +13,35 @@ describe provider_class do
|
|
16
13
|
@resource.stubs(:[]).with(:ensure).returns :installed
|
17
14
|
@resource.stubs(:command).with(:zypper).returns "/usr/bin/zypper"
|
18
15
|
|
19
|
-
@provider =
|
16
|
+
@provider = described_class.new(@resource)
|
20
17
|
end
|
21
18
|
|
22
19
|
it "should have an install method" do
|
23
|
-
@provider =
|
20
|
+
@provider = described_class.new
|
24
21
|
expect(@provider).to respond_to(:install)
|
25
22
|
end
|
26
23
|
|
27
24
|
it "should have an uninstall method" do
|
28
|
-
@provider =
|
25
|
+
@provider = described_class.new
|
29
26
|
expect(@provider).to respond_to(:uninstall)
|
30
27
|
end
|
31
28
|
|
32
29
|
it "should have an update method" do
|
33
|
-
@provider =
|
30
|
+
@provider = described_class.new
|
34
31
|
expect(@provider).to respond_to(:update)
|
35
32
|
end
|
36
33
|
|
37
34
|
it "should have a latest method" do
|
38
|
-
@provider =
|
35
|
+
@provider = described_class.new
|
39
36
|
expect(@provider).to respond_to(:latest)
|
40
37
|
end
|
41
38
|
|
42
39
|
it "should have a install_options method" do
|
43
|
-
@provider =
|
40
|
+
@provider = described_class.new
|
44
41
|
expect(@provider).to respond_to(:install_options)
|
45
42
|
end
|
46
43
|
|
47
|
-
|
44
|
+
context "when installing with zypper version >= 1.0" do
|
48
45
|
it "should use a command-line with versioned package'" do
|
49
46
|
@resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
|
50
47
|
@resource.stubs(:allow_virtual?).returns false
|
@@ -65,7 +62,7 @@ describe provider_class do
|
|
65
62
|
end
|
66
63
|
end
|
67
64
|
|
68
|
-
|
65
|
+
context "when installing with zypper version = 0.6.104" do
|
69
66
|
it "should use a command-line with versioned package'" do
|
70
67
|
@resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
|
71
68
|
@resource.stubs(:allow_virtual?).returns false
|
@@ -86,7 +83,7 @@ describe provider_class do
|
|
86
83
|
end
|
87
84
|
end
|
88
85
|
|
89
|
-
|
86
|
+
context "when installing with zypper version = 0.6.13" do
|
90
87
|
it "should use a command-line with versioned package'" do
|
91
88
|
@resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
|
92
89
|
@resource.stubs(:allow_virtual?).returns false
|
@@ -107,15 +104,16 @@ describe provider_class do
|
|
107
104
|
end
|
108
105
|
end
|
109
106
|
|
110
|
-
|
107
|
+
context "when updating" do
|
111
108
|
it "should call install method of instance" do
|
112
109
|
@provider.expects(:install)
|
113
110
|
@provider.update
|
114
111
|
end
|
115
112
|
end
|
116
113
|
|
117
|
-
|
118
|
-
after
|
114
|
+
context "when getting latest version" do
|
115
|
+
after { described_class.reset! }
|
116
|
+
|
119
117
|
context "when the package has available update" do
|
120
118
|
it "should return a version string with valid list-updates data from SLES11sp1" do
|
121
119
|
fake_data = File.read(my_fixture('zypper-list-updates-SLES11sp1.out'))
|
@@ -144,7 +142,7 @@ describe provider_class do
|
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
147
|
-
|
145
|
+
context "should install a virtual package" do
|
148
146
|
it "when zypper version = 0.6.13" do
|
149
147
|
@resource.stubs(:should).with(:ensure).returns :installed
|
150
148
|
@resource.stubs(:allow_virtual?).returns true
|
@@ -164,7 +162,7 @@ describe provider_class do
|
|
164
162
|
end
|
165
163
|
end
|
166
164
|
|
167
|
-
|
165
|
+
context "when installing with zypper install options" do
|
168
166
|
it "should install the package without checking keys" do
|
169
167
|
@resource.stubs(:[]).with(:name).returns "php5"
|
170
168
|
@resource.stubs(:[]).with(:install_options).returns ['--no-gpg-check', {'-p' => '/vagrant/files/localrepo/'}]
|
@@ -215,7 +213,7 @@ describe provider_class do
|
|
215
213
|
end
|
216
214
|
end
|
217
215
|
|
218
|
-
|
216
|
+
context 'when uninstalling' do
|
219
217
|
it 'should use remove to uninstall on zypper version 1.6 and above' do
|
220
218
|
@provider.stubs(:zypper_version).returns '1.6.308'
|
221
219
|
@provider.expects(:zypper).with(:remove, '--no-confirm', 'mypackage')
|
@@ -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(:bsd), :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.conf.d')
|
13
|
-
@provider =
|
9
|
+
@provider = subject()
|
14
10
|
@provider.stubs(:initscript)
|
15
11
|
end
|
16
12
|
|
17
|
-
|
13
|
+
context "#instances" do
|
18
14
|
it "should have an instances method" do
|
19
15
|
expect(described_class).to respond_to :instances
|
20
16
|
end
|
@@ -24,7 +20,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
27
|
-
|
23
|
+
context "#disable" do
|
28
24
|
it "should have a disable method" do
|
29
25
|
expect(@provider).to respond_to(:disable)
|
30
26
|
end
|
@@ -45,7 +41,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
|
44
|
+
context "#enable" do
|
49
45
|
it "should have an enable method" do
|
50
46
|
expect(@provider).to respond_to(:enable)
|
51
47
|
end
|
@@ -70,7 +66,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
73
|
-
|
69
|
+
context "#enabled?" do
|
74
70
|
it "should have an enabled? method" do
|
75
71
|
expect(@provider).to respond_to(:enabled?)
|
76
72
|
end
|
@@ -90,7 +86,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
90
86
|
end
|
91
87
|
end
|
92
88
|
|
93
|
-
|
89
|
+
context "#startcmd" do
|
94
90
|
it "should have a startcmd method" do
|
95
91
|
expect(@provider).to respond_to(:startcmd)
|
96
92
|
end
|
@@ -109,7 +105,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
109
105
|
end
|
110
106
|
end
|
111
107
|
|
112
|
-
|
108
|
+
context "#stopcmd" do
|
113
109
|
it "should have a stopcmd method" do
|
114
110
|
expect(@provider).to respond_to(:stopcmd)
|
115
111
|
end
|
@@ -1,20 +1,11 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Unit testing for the Daemontools 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(:daemontools) 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 = "/var/lib/service"
|
@@ -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 use 'svc' to start the service" do
|
68
59
|
@provider.stubs(:enabled?).returns :true
|
69
60
|
@provider.expects(:svc).with("-u", "/etc/service/myservice")
|
@@ -81,7 +72,7 @@ describe provider_class do
|
|
81
72
|
end
|
82
73
|
end
|
83
74
|
|
84
|
-
|
75
|
+
context "when stopping" do
|
85
76
|
it "should use 'svc' to stop the service" do
|
86
77
|
@provider.stubs(:disable)
|
87
78
|
@provider.expects(:svc).with("-d", "/etc/service/myservice")
|
@@ -90,7 +81,7 @@ describe provider_class do
|
|
90
81
|
end
|
91
82
|
end
|
92
83
|
|
93
|
-
|
84
|
+
context "when restarting" do
|
94
85
|
it "should use 'svc' to restart the service" do
|
95
86
|
@provider.expects(:svc).with("-t", "/etc/service/myservice")
|
96
87
|
|
@@ -98,7 +89,7 @@ describe provider_class do
|
|
98
89
|
end
|
99
90
|
end
|
100
91
|
|
101
|
-
|
92
|
+
context "when enabling" do
|
102
93
|
it "should create a symlink between daemon dir and service dir", :if => Puppet.features.manages_symlinks? do
|
103
94
|
daemon_path = File.join(@daemondir, "myservice")
|
104
95
|
service_path = File.join(@servicedir, "myservice")
|
@@ -109,7 +100,7 @@ describe provider_class do
|
|
109
100
|
end
|
110
101
|
end
|
111
102
|
|
112
|
-
|
103
|
+
context "when disabling" do
|
113
104
|
it "should remove the symlink between daemon dir and service dir" do
|
114
105
|
FileTest.stubs(:directory?).returns(false)
|
115
106
|
path = File.join(@servicedir,"myservice")
|
@@ -128,7 +119,7 @@ describe provider_class do
|
|
128
119
|
end
|
129
120
|
end
|
130
121
|
|
131
|
-
|
122
|
+
context "when checking if the service is enabled?" do
|
132
123
|
it "should return true if it is running" do
|
133
124
|
@provider.stubs(:status).returns(:running)
|
134
125
|
|
@@ -146,26 +137,27 @@ describe provider_class do
|
|
146
137
|
end
|
147
138
|
end
|
148
139
|
|
149
|
-
|
140
|
+
context "when checking status" do
|
150
141
|
it "should call the external command 'svstat /etc/service/myservice'" do
|
151
142
|
@provider.expects(:svstat).with(File.join(@servicedir,"myservice"))
|
152
143
|
@provider.status
|
153
144
|
end
|
154
145
|
end
|
155
146
|
|
156
|
-
|
147
|
+
context "when checking status" do
|
157
148
|
it "and svstat fails, properly raise a Puppet::Error" do
|
158
149
|
@provider.expects(:svstat).with(File.join(@servicedir,"myservice")).raises(Puppet::ExecutionFailure, "failure")
|
159
150
|
expect { @provider.status }.to raise_error(Puppet::Error, 'Could not get status for service Service[myservice]: failure')
|
160
151
|
end
|
152
|
+
|
161
153
|
it "and svstat returns up, then return :running" do
|
162
154
|
@provider.expects(:svstat).with(File.join(@servicedir,"myservice")).returns("/etc/service/myservice: up (pid 454) 954326 seconds")
|
163
155
|
expect(@provider.status).to eq(:running)
|
164
156
|
end
|
157
|
+
|
165
158
|
it "and svstat returns not running, then return :stopped" do
|
166
159
|
@provider.expects(:svstat).with(File.join(@servicedir,"myservice")).returns("/etc/service/myservice: supervise not running")
|
167
160
|
expect(@provider.status).to eq(:stopped)
|
168
161
|
end
|
169
162
|
end
|
170
|
-
|
171
163
|
end
|