puppet 6.0.4-x64-mingw32 → 6.0.5-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.

Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/Rakefile +3 -1
  4. data/ext/solaris/smf/svc-puppetd +8 -1
  5. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  6. data/lib/puppet/application/device.rb +48 -32
  7. data/lib/puppet/application/ssl.rb +31 -17
  8. data/lib/puppet/defaults.rb +2 -1
  9. data/lib/puppet/face/config.rb +1 -1
  10. data/lib/puppet/forge.rb +4 -1
  11. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  12. data/lib/puppet/pops/model/pn_transformer.rb +5 -0
  13. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  14. data/lib/puppet/pops/types/string_converter.rb +11 -2
  15. data/lib/puppet/provider/package/dnf.rb +2 -1
  16. data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
  17. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  18. data/lib/puppet/provider/package/windows/package.rb +9 -1
  19. data/lib/puppet/provider/package/yum.rb +1 -1
  20. data/lib/puppet/provider/parsedfile.rb +25 -4
  21. data/lib/puppet/provider/service/smf.rb +54 -0
  22. data/lib/puppet/provider/service/systemd.rb +2 -0
  23. data/lib/puppet/provider/service/upstart.rb +1 -0
  24. data/lib/puppet/rest/route.rb +1 -1
  25. data/lib/puppet/ssl/host.rb +23 -11
  26. data/lib/puppet/transaction.rb +4 -1
  27. data/lib/puppet/transaction/event_manager.rb +13 -1
  28. data/lib/puppet/transaction/resource_harness.rb +3 -1
  29. data/lib/puppet/util/command_line.rb +2 -3
  30. data/lib/puppet/util/filetype.rb +36 -4
  31. data/lib/puppet/util/selinux.rb +1 -1
  32. data/lib/puppet/util/windows/api_types.rb +1 -1
  33. data/lib/puppet/util/windows/registry.rb +29 -5
  34. data/lib/puppet/util/windows/service.rb +106 -99
  35. data/lib/puppet/version.rb +1 -1
  36. data/locales/ja/puppet.po +232 -183
  37. data/locales/puppet.pot +145 -117
  38. data/man/man5/puppet.conf.5 +3 -3
  39. data/man/man8/puppet-agent.8 +1 -1
  40. data/man/man8/puppet-apply.8 +1 -1
  41. data/man/man8/puppet-catalog.8 +1 -1
  42. data/man/man8/puppet-config.8 +2 -2
  43. data/man/man8/puppet-describe.8 +1 -1
  44. data/man/man8/puppet-device.8 +23 -19
  45. data/man/man8/puppet-doc.8 +1 -1
  46. data/man/man8/puppet-epp.8 +1 -1
  47. data/man/man8/puppet-facts.8 +1 -1
  48. data/man/man8/puppet-filebucket.8 +1 -1
  49. data/man/man8/puppet-generate.8 +1 -1
  50. data/man/man8/puppet-help.8 +1 -1
  51. data/man/man8/puppet-key.8 +1 -1
  52. data/man/man8/puppet-lookup.8 +1 -1
  53. data/man/man8/puppet-man.8 +1 -1
  54. data/man/man8/puppet-module.8 +1 -1
  55. data/man/man8/puppet-node.8 +1 -1
  56. data/man/man8/puppet-parser.8 +1 -1
  57. data/man/man8/puppet-plugin.8 +1 -1
  58. data/man/man8/puppet-report.8 +1 -1
  59. data/man/man8/puppet-resource.8 +1 -1
  60. data/man/man8/puppet-script.8 +1 -1
  61. data/man/man8/puppet-ssl.8 +6 -3
  62. data/man/man8/puppet-status.8 +1 -1
  63. data/man/man8/puppet.8 +2 -2
  64. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  65. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  66. data/spec/integration/ssl/key_spec.rb +0 -4
  67. data/spec/integration/transaction_spec.rb +559 -0
  68. data/spec/integration/util/windows/registry_spec.rb +39 -0
  69. data/spec/unit/application/device_spec.rb +10 -7
  70. data/spec/unit/application/lookup_spec.rb +2 -1
  71. data/spec/unit/application/ssl_spec.rb +21 -2
  72. data/spec/unit/forge/forge_spec.rb +4 -2
  73. data/spec/unit/functions/logging_spec.rb +10 -3
  74. data/spec/unit/indirector/yaml_spec.rb +1 -1
  75. data/spec/unit/pops/loaders/loader_spec.rb +6 -7
  76. data/spec/unit/pops/model/pn_transformer_spec.rb +4 -0
  77. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  78. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  79. data/spec/unit/pops/types/string_converter_spec.rb +20 -0
  80. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  81. data/spec/unit/provider/group/pw_spec.rb +7 -10
  82. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  83. data/spec/unit/provider/package/aix_spec.rb +5 -8
  84. data/spec/unit/provider/package/apt_spec.rb +3 -6
  85. data/spec/unit/provider/package/dnf_spec.rb +36 -37
  86. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  87. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  88. data/spec/unit/provider/package/gem_spec.rb +41 -41
  89. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  90. data/spec/unit/provider/package/macports_spec.rb +13 -15
  91. data/spec/unit/provider/package/nim_spec.rb +3 -10
  92. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  93. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  94. data/spec/unit/provider/package/pip_spec.rb +45 -49
  95. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  96. data/spec/unit/provider/package/pkgng_spec.rb +21 -24
  97. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  98. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  99. data/spec/unit/provider/package/yum_spec.rb +30 -16
  100. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  101. data/spec/unit/provider/service/bsd_spec.rb +7 -9
  102. data/spec/unit/provider/service/daemontools_spec.rb +12 -16
  103. data/spec/unit/provider/service/debian_spec.rb +6 -10
  104. data/spec/unit/provider/service/freebsd_spec.rb +2 -2
  105. data/spec/unit/provider/service/openbsd_spec.rb +13 -17
  106. data/spec/unit/provider/service/rcng_spec.rb +2 -4
  107. data/spec/unit/provider/service/redhat_spec.rb +12 -11
  108. data/spec/unit/provider/service/runit_spec.rb +7 -14
  109. data/spec/unit/provider/service/smf_spec.rb +77 -13
  110. data/spec/unit/provider/service/src_spec.rb +11 -16
  111. data/spec/unit/provider/service/systemd_spec.rb +18 -0
  112. data/spec/unit/provider/user/hpux_spec.rb +3 -5
  113. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  114. data/spec/unit/provider/user/pw_spec.rb +10 -13
  115. data/spec/unit/rest/route_spec.rb +1 -1
  116. data/spec/unit/ssl/host_spec.rb +21 -0
  117. data/spec/unit/ssl/key_spec.rb +2 -4
  118. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  119. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  120. data/spec/unit/transaction_spec.rb +25 -0
  121. data/spec/unit/util/filetype_spec.rb +13 -5
  122. data/spec/unit/util/logging_spec.rb +0 -41
  123. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  124. data/spec/unit/util/selinux_spec.rb +4 -0
  125. 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', unless: Puppet::Util::Platform.jruby? do
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
- describe "when enabling" do
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
- describe "when disabling" do
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
- describe "when checking whether it is enabled" do
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
- describe "when checking service status" do
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', unless: Puppet::Util::Platform.jruby? do
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
- unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
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
- describe "#instances" do
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
- describe "#start" do
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
- describe "#stop" do
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
- describe "#status" do
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
- describe "#restart" do
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
- describe "#enabled?" do
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
- describe "#enable" do
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
- describe "#disable" do
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
- describe "#running?" do
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
- describe "#flags" do
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
- describe "#flags=" do
198
- it "should run rcctl to set flags", :unless => Puppet::Util::Platform.windows? || RUBY_PLATFORM == 'java' do
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
- :unless => Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
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
- describe "#enable" do
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
- :if => Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
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
- describe "when getting all service instances" do
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
- describe "when checking enabled? on Suse" do
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
- describe "when checking status" do
136
- describe "when hasstatus is :true" do
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
- describe "when hasstatus is not :true" do
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
- describe "when restarting and hasrestart is not :true" do
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
- describe "when starting" do
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
- describe "when stopping" do
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
- describe "when restarting" do
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
- describe "when enabling" do
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
- describe "when disabling" do
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
- describe "when checking status" do
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
- describe "when checking status" do
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
- if: Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
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
- describe ".instances" do
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
- describe "when starting" do
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
- describe "when starting a service with a manifest" do
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
- describe "when stopping" do
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
- describe "when restarting" do
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