ohai 15.3.1 → 15.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -6
  3. data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
  4. data/lib/ohai/plugins/aix/network.rb +3 -8
  5. data/lib/ohai/plugins/darwin/network.rb +6 -4
  6. data/lib/ohai/plugins/filesystem.rb +166 -0
  7. data/lib/ohai/plugins/network.rb +5 -5
  8. data/lib/ohai/plugins/openstack.rb +2 -1
  9. data/lib/ohai/plugins/solaris2/network.rb +6 -4
  10. data/lib/ohai/version.rb +1 -1
  11. data/ohai.gemspec +1 -1
  12. metadata +3 -162
  13. data/Rakefile +0 -42
  14. data/lib/ohai/plugins/windows/filesystem.rb +0 -147
  15. data/spec/data/plugins/dpkg-query.output +0 -4
  16. data/spec/data/plugins/lslpp.output +0 -50
  17. data/spec/data/plugins/pacman.output +0 -51
  18. data/spec/data/plugins/pkg-query.output +0 -58
  19. data/spec/data/plugins/pkginfo.output +0 -50
  20. data/spec/data/plugins/pkglist.output +0 -24
  21. data/spec/data/plugins/rpmquery.output +0 -7
  22. data/spec/functional/application_spec.rb +0 -107
  23. data/spec/functional/loader_spec.rb +0 -53
  24. data/spec/functional/plugins/powershell_spec.rb +0 -88
  25. data/spec/functional/plugins/root_group_spec.rb +0 -41
  26. data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
  27. data/spec/ohai_spec.rb +0 -27
  28. data/spec/rcov.opts +0 -2
  29. data/spec/spec.opts +0 -2
  30. data/spec/spec_helper.rb +0 -124
  31. data/spec/support/integration_helper.rb +0 -61
  32. data/spec/support/platform_helpers.rb +0 -38
  33. data/spec/unit/application_spec.rb +0 -96
  34. data/spec/unit/config_spec.rb +0 -57
  35. data/spec/unit/dsl/plugin_spec.rb +0 -634
  36. data/spec/unit/hints_spec.rb +0 -65
  37. data/spec/unit/loader_spec.rb +0 -195
  38. data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
  39. data/spec/unit/mixin/command_spec.rb +0 -151
  40. data/spec/unit/mixin/dmi_decode.rb +0 -75
  41. data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
  42. data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
  43. data/spec/unit/plugin_config_spec.rb +0 -117
  44. data/spec/unit/plugins/abort_spec.rb +0 -69
  45. data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
  46. data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
  47. data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
  48. data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
  49. data/spec/unit/plugins/aix/memory_spec.rb +0 -49
  50. data/spec/unit/plugins/aix/network_spec.rb +0 -313
  51. data/spec/unit/plugins/aix/platform_spec.rb +0 -44
  52. data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
  53. data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
  54. data/spec/unit/plugins/azure_spec.rb +0 -243
  55. data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
  56. data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
  57. data/spec/unit/plugins/c_spec.rb +0 -341
  58. data/spec/unit/plugins/chef_spec.rb +0 -44
  59. data/spec/unit/plugins/cloud_spec.rb +0 -484
  60. data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
  61. data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
  62. data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
  63. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
  64. data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
  65. data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
  66. data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
  67. data/spec/unit/plugins/darwin/network_spec.rb +0 -849
  68. data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
  69. data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
  70. data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
  71. data/spec/unit/plugins/dmi_spec.rb +0 -156
  72. data/spec/unit/plugins/docker_spec.rb +0 -100
  73. data/spec/unit/plugins/ec2_spec.rb +0 -452
  74. data/spec/unit/plugins/elixir_spec.rb +0 -55
  75. data/spec/unit/plugins/erlang_spec.rb +0 -71
  76. data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
  77. data/spec/unit/plugins/fail_spec.rb +0 -260
  78. data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
  79. data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
  80. data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
  81. data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
  82. data/spec/unit/plugins/gce_spec.rb +0 -81
  83. data/spec/unit/plugins/go_spec.rb +0 -48
  84. data/spec/unit/plugins/groovy_spec.rb +0 -66
  85. data/spec/unit/plugins/haskell_spec.rb +0 -231
  86. data/spec/unit/plugins/hostname_spec.rb +0 -162
  87. data/spec/unit/plugins/init_package_spec.rb +0 -60
  88. data/spec/unit/plugins/java_spec.rb +0 -230
  89. data/spec/unit/plugins/joyent_spec.rb +0 -100
  90. data/spec/unit/plugins/kernel_spec.rb +0 -38
  91. data/spec/unit/plugins/linode_spec.rb +0 -135
  92. data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
  93. data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
  94. data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
  95. data/spec/unit/plugins/linux/fips_spec.rb +0 -60
  96. data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
  97. data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
  98. data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
  99. data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
  100. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  101. data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
  102. data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
  103. data/spec/unit/plugins/linux/memory_spec.rb +0 -256
  104. data/spec/unit/plugins/linux/network_spec.rb +0 -1392
  105. data/spec/unit/plugins/linux/platform_spec.rb +0 -812
  106. data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
  107. data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
  108. data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
  109. data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
  110. data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
  111. data/spec/unit/plugins/lua_spec.rb +0 -60
  112. data/spec/unit/plugins/mono_spec.rb +0 -67
  113. data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
  114. data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
  115. data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
  116. data/spec/unit/plugins/network_spec.rb +0 -1078
  117. data/spec/unit/plugins/nodejs_spec.rb +0 -55
  118. data/spec/unit/plugins/ohai_spec.rb +0 -32
  119. data/spec/unit/plugins/ohai_time_spec.rb +0 -44
  120. data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
  121. data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
  122. data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
  123. data/spec/unit/plugins/openstack_spec.rb +0 -311
  124. data/spec/unit/plugins/os_spec.rb +0 -115
  125. data/spec/unit/plugins/packages_spec.rb +0 -353
  126. data/spec/unit/plugins/passwd_spec.rb +0 -65
  127. data/spec/unit/plugins/perl_spec.rb +0 -62
  128. data/spec/unit/plugins/php_spec.rb +0 -97
  129. data/spec/unit/plugins/platform_spec.rb +0 -65
  130. data/spec/unit/plugins/powershell_spec.rb +0 -71
  131. data/spec/unit/plugins/python_spec.rb +0 -51
  132. data/spec/unit/plugins/rackspace_spec.rb +0 -350
  133. data/spec/unit/plugins/root_group_spec.rb +0 -90
  134. data/spec/unit/plugins/ruby_spec.rb +0 -60
  135. data/spec/unit/plugins/rust_spec.rb +0 -43
  136. data/spec/unit/plugins/scala_spec.rb +0 -58
  137. data/spec/unit/plugins/scaleway_spec.rb +0 -93
  138. data/spec/unit/plugins/scsi_spec.rb +0 -69
  139. data/spec/unit/plugins/shard_spec.rb +0 -121
  140. data/spec/unit/plugins/shells_spec.rb +0 -56
  141. data/spec/unit/plugins/softlayer_spec.rb +0 -60
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
  143. data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
  144. data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
  145. data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
  146. data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
  147. data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
  148. data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
  149. data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
  150. data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
  151. data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
  152. data/spec/unit/plugins/sysconf_spec.rb +0 -680
  153. data/spec/unit/plugins/timezone_spec.rb +0 -30
  154. data/spec/unit/plugins/vbox_host_spec.rb +0 -14
  155. data/spec/unit/plugins/virtualbox_spec.rb +0 -375
  156. data/spec/unit/plugins/vmware_spec.rb +0 -81
  157. data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
  158. data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
  159. data/spec/unit/plugins/windows/fips_spec.rb +0 -60
  160. data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
  161. data/spec/unit/plugins/windows/memory_spec.rb +0 -52
  162. data/spec/unit/plugins/windows/network_spec.rb +0 -137
  163. data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
  164. data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
  165. data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
  166. data/spec/unit/plugins/zpools_spec.rb +0 -244
  167. data/spec/unit/provides_map_spec.rb +0 -208
  168. data/spec/unit/runner_spec.rb +0 -422
  169. data/spec/unit/system_spec.rb +0 -416
  170. data/spec/unit/util/file_helper_spec.rb +0 -47
  171. data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,812 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2018, Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- describe Ohai::System, "Linux plugin platform" do
22
- let(:plugin) { get_plugin("linux/platform") }
23
-
24
- describe "#read_os_release_info" do
25
- let(:file_contents) { "COW=MOO\nDOG=\"BARK\"" }
26
-
27
- it "returns nil if the file does not exist" do
28
- allow(File).to receive(:exist?).with("/etc/test-release").and_return(false)
29
- expect(plugin.read_os_release_info("/etc/test-release")).to be nil
30
- end
31
-
32
- it "returns a hash of expected contents" do
33
- allow(File).to receive(:exist?).with("/etc/test-release").and_return(true)
34
- allow(File).to receive(:read).with("/etc/test-release").and_return(file_contents)
35
- release_info = plugin.read_os_release_info("/etc/test-release")
36
-
37
- expect(release_info["COW"]).to eq("MOO")
38
- expect(release_info["DOG"]).to eq("BARK")
39
- end
40
- end
41
-
42
- describe "#os_release_info" do
43
- context "when CISCO_RELEASE_INFO is not populated" do
44
- let(:release_info) { { "ID" => "os_id" } }
45
-
46
- before do
47
- allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
48
- allow(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
49
- end
50
-
51
- it "reads the os-release file" do
52
- expect(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
53
- plugin.os_release_info
54
- end
55
-
56
- it "returns a hash of expected contents" do
57
- expect(plugin.os_release_info["ID"]).to eq("os_id")
58
- end
59
- end
60
-
61
- context "when CISCO_RELEASE_INFO is populated" do
62
- let(:release_info) { { "ID" => "os_id", "CISCO_RELEASE_INFO" => "/etc/cisco-release" } }
63
- let(:cisco_release_info) { { "ID" => "cisco_id" } }
64
-
65
- before do
66
- allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
67
- allow(File).to receive(:exist?).with("/etc/cisco-release").and_return(true)
68
- allow(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
69
- allow(plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(cisco_release_info)
70
- end
71
-
72
- it "reads the os-release AND the cisco-release file" do
73
- expect(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
74
- expect(plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(release_info)
75
- plugin.os_release_info
76
- end
77
-
78
- it "returns the ID from the cisco-release file instead of the os-release file" do
79
- expect(plugin.os_release_info["ID"]).to eq("cisco_id")
80
- end
81
- end
82
- end
83
-
84
- describe "#platform_id_remap" do
85
- # https://github.com/chef/os_release/blob/master/redhat_7
86
- it "returns redhat for rhel os-release id" do
87
- expect(plugin.platform_id_remap("rhel")).to eq("redhat")
88
- end
89
-
90
- # https://github.com/chef/os_release/blob/master/amazon_2018
91
- it "returns amazon for amzn os-release id" do
92
- expect(plugin.platform_id_remap("amzn")).to eq("amazon")
93
- end
94
-
95
- # https://github.com/chef/os_release/blob/master/oracle_7
96
- it "returns oracle for ol os-release id" do
97
- expect(plugin.platform_id_remap("ol")).to eq("oracle")
98
- end
99
-
100
- # https://github.com/chef/os_release/blob/master/sles_sap_12_3
101
- it "returns suse for sles_sap os-release id" do
102
- expect(plugin.platform_id_remap("sles_sap")).to eq("suse")
103
- end
104
-
105
- # https://github.com/chef/os_release/blob/master/archarm
106
- it "returns arch for archarm" do
107
- expect(plugin.platform_id_remap("archarm")).to eq("arch")
108
- end
109
-
110
- # https://github.com/chef/os_release/blob/master/sles_15_0
111
- it "returns suse for sles os-release id" do
112
- expect(plugin.platform_id_remap("sles")).to eq("suse")
113
- end
114
-
115
- # https://github.com/chef/os_release/blob/master/opensuseleap_15_0
116
- it "returns opensuseleap for opensuse-leap os-release id" do
117
- expect(plugin.platform_id_remap("opensuse-leap")).to eq("opensuseleap")
118
- end
119
-
120
- # https://github.com/chef/os_release/blob/master/xenserver_7_6
121
- it "returns xenserver for xenenterprise os-release id" do
122
- expect(plugin.platform_id_remap("xenenterprise")).to eq("xenserver")
123
- end
124
-
125
- # https://github.com/chef/os_release/blob/master/cumulus_3_7
126
- it "returns cumulus for cumulus-linux os-release id" do
127
- expect(plugin.platform_id_remap("cumulus-linux")).to eq("cumulus")
128
- end
129
-
130
- it "does not transformation for any other platform" do
131
- expect(plugin.platform_id_remap("ubuntu")).to eq("ubuntu")
132
- end
133
-
134
- context "on a centos subshell on a nexus switch" do
135
- let(:os_release_content) do
136
- <<~OS_RELEASE
137
- NAME="CentOS Linux"
138
- VERSION="7 (Core)"
139
- ID="centos"
140
- ID_LIKE="rhel fedora"
141
- VERSION_ID="7"
142
- PRETTY_NAME="CentOS Linux 7 (Core)"
143
-
144
- CISCO_RELEASE_INFO=/etc/shared/os-release
145
- OS_RELEASE
146
- end
147
-
148
- let(:cisco_release_content) do
149
- <<~CISCO_RELEASE
150
- ID=nexus
151
- ID_LIKE=wrlinux
152
- NAME=Nexus
153
- VERSION="7.0(3)I2(0.475E.6)"
154
- VERSION_ID="7.0(3)I2"
155
- PRETTY_NAME="Nexus 7.0(3)I2"
156
- HOME_URL=http://www.cisco.com
157
- BUILD_ID=6
158
- CISCO_RELEASE_INFO=/etc/shared/os-release
159
- CISCO_RELEASE
160
- end
161
-
162
- it "returns nexus_centos for centos os-release id" do
163
- expect(File).to receive(:exist?).at_least(:once).with("/etc/shared/os-release").and_return(true)
164
- expect(File).to receive(:exist?).at_least(:once).with("/etc/os-release").and_return(true)
165
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
166
- expect(File).to receive(:read).with("/etc/shared/os-release").and_return(cisco_release_content)
167
- expect(plugin.platform_id_remap("centos")).to eq("nexus_centos")
168
- end
169
- end
170
- end
171
-
172
- describe "#platform_family_from_platform" do
173
- %w{oracle centos redhat scientific enterpriseenterprise xenserver cloudlinux ibm_powerkvm parallels nexus_centos clearos bigip}.each do |p|
174
- it "returns rhel for #{p} platform" do
175
- expect(plugin.platform_family_from_platform(p)).to eq("rhel")
176
- end
177
- end
178
-
179
- %w{suse sles opensuse opensuseleap sled}.each do |p|
180
- it "returns suse for #{p} platform_family" do
181
- expect(plugin.platform_family_from_platform(p)).to eq("suse")
182
- end
183
- end
184
-
185
- %w{fedora pidora arista_eos}.each do |p|
186
- it "returns fedora for #{p} platform_family" do
187
- expect(plugin.platform_family_from_platform(p)).to eq("fedora")
188
- end
189
- end
190
-
191
- %w{nexus ios_xr}.each do |p|
192
- it "returns wrlinux for #{p} platform_family" do
193
- expect(plugin.platform_family_from_platform(p)).to eq("wrlinux")
194
- end
195
- end
196
-
197
- %w{arch manjaro antergos}.each do |p|
198
- it "returns arch for #{p} platform_family" do
199
- expect(plugin.platform_family_from_platform(p)).to eq("arch")
200
- end
201
- end
202
-
203
- %w{amazon slackware gentoo exherbo alpine clearlinux}.each do |same_name|
204
- it "returns #{same_name} for #{same_name} platform_family" do
205
- expect(plugin.platform_family_from_platform(same_name)).to eq(same_name)
206
- end
207
- end
208
-
209
- it "returns mandriva for mangeia platform" do
210
- expect(plugin.platform_family_from_platform("mangeia")).to eq("mandriva")
211
- end
212
- end
213
-
214
- describe "on system with /etc/os-release" do
215
- before do
216
- allow(plugin).to receive(:collect_os).and_return(:linux)
217
- allow(::File).to receive(:exist?).with("/etc/os-release").and_return(true)
218
- end
219
-
220
- context "when os-release data is correct" do
221
- let(:os_data) do
222
- <<~OS_DATA
223
- NAME="Ubuntu"
224
- VERSION="14.04.5 LTS, Trusty Tahr"
225
- ID=ubuntu
226
- ID_LIKE=debian
227
- PRETTY_NAME="Ubuntu 14.04.5 LTS"
228
- VERSION_ID="14.04"
229
- OS_DATA
230
- end
231
-
232
- before do
233
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
234
- end
235
-
236
- it "sets platform, platform_family, and platform_version from os-release" do
237
- plugin.run
238
- expect(plugin[:platform]).to eq("ubuntu")
239
- expect(plugin[:platform_family]).to eq("debian")
240
- expect(plugin[:platform_version]).to eq("14.04")
241
- end
242
- end
243
-
244
- context "when os-release data is missing a version_id" do
245
- let(:os_data) do
246
- <<~OS_DATA
247
- NAME="Arch Linux"
248
- PRETTY_NAME="Arch Linux"
249
- ID=arch
250
- ID_LIKE=archlinux
251
- OS_DATA
252
- end
253
-
254
- before do
255
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
256
- end
257
-
258
- it "sets platform_version using kernel version from uname" do
259
- allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
260
- plugin.run
261
- expect(plugin[:platform]).to eq("arch")
262
- expect(plugin[:platform_family]).to eq("arch")
263
- expect(plugin[:platform_version]).to eq("3.18.2-2-ARCH")
264
- end
265
- end
266
-
267
- context "when platform requires remapping" do
268
- let(:os_data) do
269
- <<~OS_DATA
270
- NAME="openSUSE Leap"
271
- VERSION="15.0"
272
- ID="opensuse-leap"
273
- ID_LIKE="suse opensuse"
274
- VERSION_ID="15.0"
275
- PRETTY_NAME="openSUSE Leap 15.0"
276
- OS_DATA
277
- end
278
-
279
- before do
280
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
281
- end
282
-
283
- it "sets platform, platform_family, and platform_version from os-release" do
284
- plugin.run
285
- expect(plugin[:platform]).to eq("opensuseleap")
286
- expect(plugin[:platform_family]).to eq("suse")
287
- expect(plugin[:platform_version]).to eq("15.0")
288
- end
289
- end
290
-
291
- context "when on centos where version data in os-release is wrong" do
292
- let(:os_data) do
293
- <<~OS_DATA
294
- NAME="CentOS Linux"
295
- VERSION="7 (Core)"
296
- ID="centos"
297
- ID_LIKE="rhel fedora"
298
- VERSION_ID="7"
299
- PRETTY_NAME="CentOS Linux 7 (Core)"
300
- OS_DATA
301
- end
302
-
303
- before do
304
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
305
- expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS Linux release 7.5.1804 (Core)")
306
- end
307
-
308
- it "sets platform, platform_family, and platform_version from os-release" do
309
- plugin.run
310
- expect(plugin[:platform]).to eq("centos")
311
- expect(plugin[:platform_family]).to eq("rhel")
312
- expect(plugin[:platform_version]).to eq("7.5.1804")
313
- end
314
- end
315
- end
316
-
317
- context "on system without /etc/os-release (legacy)" do
318
- let(:have_debian_version) { false }
319
- let(:have_redhat_release) { false }
320
- let(:have_exherbo_release) { false }
321
- let(:have_eos_release) { false }
322
- let(:have_suse_release) { false }
323
- let(:have_system_release) { false }
324
- let(:have_slackware_version) { false }
325
- let(:have_enterprise_release) { false }
326
- let(:have_oracle_release) { false }
327
- let(:have_parallels_release) { false }
328
- let(:have_os_release) { false }
329
- let(:have_os_release) { false }
330
- let(:have_usr_lib_os_release) { false }
331
- let(:have_cisco_release) { false }
332
- let(:have_f5_release) { false }
333
-
334
- before do
335
- allow(plugin).to receive(:collect_os).and_return(:linux)
336
- plugin[:lsb] = Mash.new
337
- allow(File).to receive(:exist?).with("/etc/debian_version").and_return(have_debian_version)
338
- allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release)
339
- allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release)
340
- allow(File).to receive(:exist?).with("/etc/Eos-release").and_return(have_eos_release)
341
- allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release)
342
- allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release)
343
- allow(File).to receive(:exist?).with("/etc/slackware-version").and_return(have_slackware_version)
344
- allow(File).to receive(:exist?).with("/etc/enterprise-release").and_return(have_enterprise_release)
345
- allow(File).to receive(:exist?).with("/etc/oracle-release").and_return(have_oracle_release)
346
- allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
347
- allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
348
- allow(File).to receive(:exist?).with("/etc/f5-release").and_return(have_f5_release)
349
- allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release)
350
- allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release)
351
-
352
- allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
353
- end
354
-
355
- describe "on lsb compliant distributions" do
356
- before do
357
- plugin[:lsb][:id] = "Ubuntu"
358
- plugin[:lsb][:release] = "18.04"
359
- end
360
-
361
- it "sets platform to lowercased lsb[:id]" do
362
- plugin.run
363
- expect(plugin[:platform]).to eq("ubuntu")
364
- end
365
-
366
- it "sets platform_version to lsb[:release]" do
367
- plugin.run
368
- expect(plugin[:platform_version]).to eq("18.04")
369
- end
370
-
371
- it "sets platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do
372
- plugin[:lsb][:id] = "Ubuntu"
373
- plugin.run
374
- expect(plugin[:platform]).to eq("ubuntu")
375
- expect(plugin[:platform_family]).to eq("debian")
376
- end
377
-
378
- it "sets platform to debian and platform_family to debian [:lsb][:id] contains Debian" do
379
- plugin[:lsb][:id] = "Debian"
380
- plugin.run
381
- expect(plugin[:platform]).to eq("debian")
382
- expect(plugin[:platform_family]).to eq("debian")
383
- end
384
-
385
- it "sets platform to redhat and platform_family to rhel when [:lsb][:id] contains Redhat" do
386
- plugin[:lsb][:id] = "RedHatEnterpriseServer"
387
- plugin[:lsb][:release] = "7.5"
388
- plugin.run
389
- expect(plugin[:platform]).to eq("redhat")
390
- expect(plugin[:platform_family]).to eq("rhel")
391
- end
392
-
393
- it "sets platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
394
- plugin[:lsb][:id] = "AmazonAMI"
395
- plugin[:lsb][:release] = "2018.03"
396
- plugin.run
397
- expect(plugin[:platform]).to eq("amazon")
398
- expect(plugin[:platform_family]).to eq("amazon")
399
- end
400
-
401
- it "sets platform to scientific when [:lsb][:id] contains ScientificSL" do
402
- plugin[:lsb][:id] = "ScientificSL"
403
- plugin[:lsb][:release] = "7.5"
404
- plugin.run
405
- expect(plugin[:platform]).to eq("scientific")
406
- end
407
-
408
- it "sets platform to ibm_powerkvm and platform_family to rhel when [:lsb][:id] contains IBM_PowerKVM" do
409
- plugin[:lsb][:id] = "IBM_PowerKVM"
410
- plugin[:lsb][:release] = "2.1"
411
- plugin.run
412
- expect(plugin[:platform]).to eq("ibm_powerkvm")
413
- expect(plugin[:platform_family]).to eq("rhel")
414
- end
415
- end
416
-
417
- describe "on debian" do
418
-
419
- let(:have_debian_version) { true }
420
-
421
- before do
422
- plugin.lsb = nil
423
- end
424
-
425
- it "reads the version from /etc/debian_version" do
426
- expect(File).to receive(:read).with("/etc/debian_version").and_return("9.5")
427
- plugin.run
428
- expect(plugin[:platform_version]).to eq("9.5")
429
- end
430
-
431
- it "correctlies strip any newlines" do
432
- expect(File).to receive(:read).with("/etc/debian_version").and_return("9.5\n")
433
- plugin.run
434
- expect(plugin[:platform_version]).to eq("9.5")
435
- end
436
-
437
- # Ubuntu has /etc/debian_version as well
438
- it "detects Ubuntu as itself rather than debian" do
439
- plugin[:lsb][:id] = "Ubuntu"
440
- plugin[:lsb][:release] = "18.04"
441
- plugin.run
442
- expect(plugin[:platform]).to eq("ubuntu")
443
- end
444
- end
445
-
446
- describe "on slackware" do
447
-
448
- let(:have_slackware_version) { true }
449
-
450
- before do
451
- plugin.lsb = nil
452
- end
453
-
454
- it "sets platform and platform_family to slackware" do
455
- expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
456
- plugin.run
457
- expect(plugin[:platform]).to eq("slackware")
458
- expect(plugin[:platform_family]).to eq("slackware")
459
- end
460
-
461
- it "sets platform_version on slackware" do
462
- expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
463
- plugin.run
464
- expect(plugin[:platform_version]).to eq("12.0.0")
465
- end
466
- end
467
-
468
- describe "on arista eos" do
469
-
470
- let(:have_system_release) { true }
471
- let(:have_redhat_release) { true }
472
- let(:have_eos_release) { true }
473
-
474
- before do
475
- plugin.lsb = nil
476
- end
477
-
478
- it "sets platform to arista_eos" do
479
- expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.21.1.1F")
480
- plugin.run
481
- expect(plugin[:platform]).to eq("arista_eos")
482
- expect(plugin[:platform_family]).to eq("fedora")
483
- expect(plugin[:platform_version]).to eq("4.21.1.1F")
484
- end
485
- end
486
-
487
- describe "on f5 big-ip" do
488
-
489
- let(:have_f5_release) { true }
490
-
491
- before do
492
- plugin.lsb = nil
493
- end
494
-
495
- it "sets platform to bigip" do
496
- expect(File).to receive(:read).with("/etc/f5-release").and_return("BIG-IP release 13.0.0 (Final)")
497
- plugin.run
498
- expect(plugin[:platform]).to eq("bigip")
499
- expect(plugin[:platform_family]).to eq("rhel")
500
- expect(plugin[:platform_version]).to eq("13.0.0")
501
- end
502
- end
503
-
504
- describe "on exherbo" do
505
-
506
- let(:have_exherbo_release) { true }
507
-
508
- before do
509
- allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
510
- plugin.lsb = nil
511
- end
512
-
513
- it "sets platform and platform_family to exherbo" do
514
- plugin.run
515
- expect(plugin[:platform]).to eq("exherbo")
516
- expect(plugin[:platform_family]).to eq("exherbo")
517
- end
518
-
519
- it "sets platform_version to kernel release" do
520
- plugin.run
521
- expect(plugin[:platform_version]).to eq("3.18.2-2-ARCH")
522
- end
523
-
524
- end
525
-
526
- describe "on redhat breeds" do
527
- describe "with lsb_release results" do
528
- it "sets the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do
529
- plugin[:lsb][:id] = "RedHatEnterpriseServer"
530
- plugin[:lsb][:release] = "7.5"
531
- plugin.run
532
- expect(plugin[:platform]).to eq("redhat")
533
- expect(plugin[:platform_version]).to eq("7.5")
534
- expect(plugin[:platform_family]).to eq("rhel")
535
- end
536
-
537
- it "sets the platform to centos and platform_family to rhel" do
538
- plugin[:lsb][:id] = "CentOS"
539
- plugin[:lsb][:release] = "7.5"
540
- plugin.run
541
- expect(plugin[:platform]).to eq("centos")
542
- expect(plugin[:platform_version]).to eq("7.5")
543
- expect(plugin[:platform_family]).to eq("rhel")
544
- end
545
- end
546
-
547
- describe "without lsb_release results" do
548
-
549
- let(:have_redhat_release) { true }
550
-
551
- before do
552
- plugin.lsb = nil
553
- end
554
-
555
- it "reads the platform as centos and version as 7.5" do
556
- expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS Linux release 7.5.1804 (Core)")
557
- plugin.run
558
- expect(plugin[:platform]).to eq("centos")
559
- expect(plugin[:platform_version]).to eq("7.5.1804")
560
- end
561
-
562
- it "reads platform of Red Hat with a space" do
563
- expect(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.5 (Santiago)")
564
- plugin.run
565
- expect(plugin[:platform]).to eq("redhat")
566
- end
567
-
568
- it "reads the platform as redhat without a space" do
569
- expect(File).to receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
570
- plugin.run
571
- expect(plugin[:platform]).to eq("redhat")
572
- expect(plugin[:platform_version]).to eq("5.3")
573
- end
574
- end
575
-
576
- end
577
-
578
- describe "on pcs linux" do
579
-
580
- let(:have_redhat_release) { true }
581
- let(:have_parallels_release) { true }
582
-
583
- describe "with lsb_result" do
584
-
585
- it "reads the platform as parallels and version as 6.0.5" do
586
- plugin[:lsb][:id] = "CloudLinuxServer"
587
- plugin[:lsb][:release] = "6.5"
588
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
589
- expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
590
- plugin.run
591
- expect(plugin[:platform]).to eq("parallels")
592
- expect(plugin[:platform_version]).to eq("6.0.5")
593
- expect(plugin[:platform_family]).to eq("rhel")
594
- end
595
- end
596
-
597
- describe "without lsb_results" do
598
-
599
- before do
600
- plugin.lsb = nil
601
- end
602
-
603
- it "reads the platform as parallels and version as 6.0.5" do
604
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
605
- expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
606
- plugin.run
607
- expect(plugin[:platform]).to eq("parallels")
608
- expect(plugin[:platform_version]).to eq("6.0.5")
609
- expect(plugin[:platform_family]).to eq("rhel")
610
- end
611
- end
612
- end
613
-
614
- describe "on oracle enterprise linux" do
615
-
616
- let(:have_redhat_release) { true }
617
-
618
- context "with lsb_results" do
619
-
620
- context "on version 5.x" do
621
-
622
- let(:have_enterprise_release) { true }
623
-
624
- it "reads the platform as oracle and version as 5.7" do
625
- plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
626
- plugin[:lsb][:release] = "5.7"
627
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
628
- expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
629
- plugin.run
630
- expect(plugin[:platform]).to eq("oracle")
631
- expect(plugin[:platform_version]).to eq("5.7")
632
- end
633
- end
634
-
635
- context "on version 6.x" do
636
-
637
- let(:have_oracle_release) { true }
638
-
639
- it "reads the platform as oracle and version as 6.1" do
640
- plugin[:lsb][:id] = "OracleServer"
641
- plugin[:lsb][:release] = "6.1"
642
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
643
- expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
644
- plugin.run
645
- expect(plugin[:platform]).to eq("oracle")
646
- expect(plugin[:platform_version]).to eq("6.1")
647
- end
648
-
649
- end
650
- end
651
-
652
- context "without lsb_results" do
653
- before do
654
- plugin.lsb = nil
655
- end
656
-
657
- context "on version 5.x" do
658
-
659
- let(:have_enterprise_release) { true }
660
-
661
- it "reads the platform as oracle and version as 5" do
662
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
663
- expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
664
- plugin.run
665
- expect(plugin[:platform]).to eq("oracle")
666
- expect(plugin[:platform_version]).to eq("5")
667
- end
668
-
669
- it "reads the platform as oracle and version as 5.1" do
670
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
671
- expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
672
- plugin.run
673
- expect(plugin[:platform]).to eq("oracle")
674
- expect(plugin[:platform_version]).to eq("5.1")
675
- end
676
-
677
- it "reads the platform as oracle and version as 5.7" do
678
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
679
- expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
680
- plugin.run
681
- expect(plugin[:platform]).to eq("oracle")
682
- expect(plugin[:platform_version]).to eq("5.7")
683
- end
684
-
685
- end
686
-
687
- context "on version 6.x" do
688
-
689
- let(:have_oracle_release) { true }
690
-
691
- it "reads the platform as oracle and version as 6.0" do
692
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
693
- expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
694
- plugin.run
695
- expect(plugin[:platform]).to eq("oracle")
696
- expect(plugin[:platform_version]).to eq("6.0")
697
- end
698
-
699
- it "reads the platform as oracle and version as 6.1" do
700
- allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
701
- expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
702
- plugin.run
703
- expect(plugin[:platform]).to eq("oracle")
704
- expect(plugin[:platform_version]).to eq("6.1")
705
- end
706
- end
707
- end
708
- end
709
-
710
- describe "on suse" do
711
- context "on versions that have no /etc/os-release but /etc/SuSE-release (e.g. SLES12.1)" do
712
- let(:have_suse_release) { true }
713
- let(:have_os_release) { false }
714
-
715
- describe "with lsb_release results" do
716
- before do
717
- plugin[:lsb][:id] = "SUSE LINUX"
718
- end
719
-
720
- it "reads the platform as opensuse on openSUSE" do
721
- plugin[:lsb][:release] = "12.1"
722
- expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
723
- plugin.run
724
- expect(plugin[:platform]).to eq("opensuse")
725
- expect(plugin[:platform_family]).to eq("suse")
726
- end
727
- end
728
- end
729
-
730
- context "on openSUSE and older SLES versions" do
731
- let(:have_suse_release) { true }
732
-
733
- describe "without lsb_release results" do
734
- before do
735
- plugin.lsb = nil
736
- end
737
-
738
- it "sets platform and platform_family to suse and bogus verion to 10.0" do
739
- expect(File).to receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
740
- plugin.run
741
- expect(plugin[:platform]).to eq("suse")
742
- expect(plugin[:platform_family]).to eq("suse")
743
- end
744
-
745
- it "reads the version as 11.2" do
746
- expect(File).to receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
747
- plugin.run
748
- expect(plugin[:platform]).to eq("suse")
749
- expect(plugin[:platform_version]).to eq("11.2")
750
- expect(plugin[:platform_family]).to eq("suse")
751
- end
752
-
753
- it "[OHAI-272] should read the version as 11.3" do
754
- expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
755
- plugin.run
756
- expect(plugin[:platform]).to eq("opensuse")
757
- expect(plugin[:platform_version]).to eq("11.3")
758
- expect(plugin[:platform_family]).to eq("suse")
759
- end
760
-
761
- it "[OHAI-272] should read the version as 11.4" do
762
- expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
763
- plugin.run
764
- expect(plugin[:platform]).to eq("opensuse")
765
- expect(plugin[:platform_version]).to eq("11.4")
766
- expect(plugin[:platform_family]).to eq("suse")
767
- end
768
-
769
- it "reads the platform as opensuse on openSUSE" do
770
- expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
771
- plugin.run
772
- expect(plugin[:platform]).to eq("opensuse")
773
- expect(plugin[:platform_family]).to eq("suse")
774
- end
775
-
776
- it "reads the platform as opensuseleap on openSUSE Leap" do
777
- expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 42.1 (x86_64)\nVERSION = 42.1\nCODENAME = Malachite\n")
778
- plugin.run
779
- expect(plugin[:platform]).to eq("opensuseleap")
780
- expect(plugin[:platform_family]).to eq("suse")
781
- end
782
- end
783
- end
784
- end
785
-
786
- describe "on clearlinux" do
787
- let(:have_usr_lib_os_release) { true }
788
- let(:usr_lib_os_release_content) do
789
- <<~CLEARLINUX_RELEASE
790
- NAME="Clear Linux OS"
791
- VERSION=1
792
- ID=clear-linux-os
793
- ID_LIKE=clear-linux-os
794
- VERSION_ID=26290
795
- PRETTY_NAME="Clear Linux OS"
796
- CLEARLINUX_RELEASE
797
- end
798
-
799
- before do
800
- expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)
801
- end
802
-
803
- it "sets platform to clearlinux and platform_family to clearlinux" do
804
- plugin.lsb = nil
805
- plugin.run
806
- expect(plugin[:platform]).to eq("clearlinux")
807
- expect(plugin[:platform_family]).to eq("clearlinux")
808
- expect(plugin[:platform_version]).to eq("26290")
809
- end
810
- end
811
- end
812
- end