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,550 +0,0 @@
1
- #
2
- # Author:: Matthew Kent (<mkent@magoazul.com>)
3
- # Copyright:: Copyright (c) 2011-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 filesystem plugin" do
22
- let(:plugin) { get_plugin("filesystem") }
23
-
24
- before do
25
- allow(plugin).to receive(:collect_os).and_return(:linux)
26
-
27
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
28
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
29
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
30
- allow(plugin).to receive(:which).with("lsblk").and_return(nil)
31
- allow(plugin).to receive(:which).with("df").and_return("/bin/df")
32
- allow(plugin).to receive(:which).with("mount").and_return("/bin/mount")
33
- allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
34
- allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, "", ""))
35
-
36
- allow(plugin).to receive(:shell_out)
37
- .with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60)
38
- .and_return(mock_shell_out(0, "", ""))
39
-
40
- allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
41
-
42
- %w{sdb1 sdb2 sda1 sda2 md0 md1 md2}.each do |name|
43
- allow(File).to receive(:exist?).with("/dev/#{name}").and_return(true)
44
- end
45
- %w{
46
- sys.vg-root.lv
47
- sys.vg-swap.lv
48
- sys.vg-tmp.lv
49
- sys.vg-usr.lv
50
- sys.vg-var.lv
51
- sys.vg-home.lv
52
- debian--7-root
53
- }.each do |name|
54
- allow(File).to receive(:exist?).with("/dev/#{name}").and_return(false)
55
- allow(File).to receive(:exist?).with("/dev/mapper/#{name}").and_return(true)
56
- end
57
- end
58
-
59
- describe "when gathering filesystem usage data from df" do
60
- before do
61
- @stdout = <<~DF
62
- Filesystem 1024-blocks Used Available Capacity Mounted on
63
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
64
- tmpfs 2030944 0 2030944 0% /lib/init/rw
65
- udev 2025576 228 2025348 1% /dev
66
- tmpfs 2030944 2960 2027984 1% /dev/shm
67
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
68
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
69
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
70
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
71
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
72
- /dev/md0 960492 36388 875312 4% /boot
73
- DF
74
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
75
-
76
- @inode_stdout = <<~DFI
77
- Filesystem Inodes IUsed IFree IUse% Mounted on
78
- /dev/xvda1 1310720 107407 1203313 9% /
79
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
80
- tmpfs 126922 273 126649 1% /run
81
- none 126922 1 126921 1% /run/lock
82
- none 126922 1 126921 1% /run/shm
83
- DFI
84
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
85
- end
86
-
87
- it "runs df -P and df -iP" do
88
- expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
89
- expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
90
- plugin.run
91
- end
92
-
93
- it "sets kb_size to value from df -P" do
94
- plugin.run
95
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
96
- end
97
-
98
- it "sets kb_used to value from df -P" do
99
- plugin.run
100
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
101
- end
102
-
103
- it "sets kb_available to value from df -P" do
104
- plugin.run
105
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
106
- end
107
-
108
- it "sets percent_used to value from df -P" do
109
- plugin.run
110
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
111
- end
112
-
113
- it "sets mount to value from df -P" do
114
- plugin.run
115
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
116
- end
117
-
118
- it "sets total_inodes to value from df -iP" do
119
- plugin.run
120
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
121
- end
122
-
123
- it "sets inodes_used to value from df -iP" do
124
- plugin.run
125
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
126
- end
127
-
128
- it "sets inodes_available to value from df -iP" do
129
- plugin.run
130
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
131
- end
132
- end
133
-
134
- describe "when gathering mounted filesystem data from mount" do
135
- before do
136
- @stdout = <<~MOUNT
137
- /dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro)
138
- tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
139
- proc on /proc type proc (rw,noexec,nosuid,nodev)
140
- sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
141
- udev on /dev type tmpfs (rw,mode=0755)
142
- tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
143
- devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
144
- /dev/mapper/sys.vg-home.lv on /home type xfs (rw,noatime)
145
- /dev/mapper/sys.vg-special.lv on /special type xfs (ro,noatime)
146
- /dev/mapper/sys.vg-tmp.lv on /tmp type ext4 (rw,noatime)
147
- /dev/mapper/sys.vg-usr.lv on /usr type ext4 (rw,noatime)
148
- /dev/mapper/sys.vg-var.lv on /var type ext4 (rw,noatime)
149
- /dev/md0 on /boot type ext3 (rw,noatime,errors=remount-ro)
150
- fusectl on /sys/fs/fuse/connections type fusectl (rw)
151
- binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
152
- MOUNT
153
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
154
- end
155
-
156
- it "runs mount" do
157
- expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
158
- plugin.run
159
- end
160
-
161
- it "sets mount to value from mount" do
162
- plugin.run
163
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
164
- end
165
-
166
- it "sets fs_type to value from mount" do
167
- plugin.run
168
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
169
- end
170
-
171
- it "sets mount_options to an array of values from mount" do
172
- plugin.run
173
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
174
- end
175
- end
176
-
177
- describe "when gathering filesystem type data from blkid" do
178
- before do
179
- # blkid and lsblk output are coorelated with df/mount output, so the
180
- # most full test of them actually requires we have both
181
- @dfstdout = <<~DF
182
- Filesystem 1024-blocks Used Available Capacity Mounted on
183
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
184
- tmpfs 2030944 0 2030944 0% /lib/init/rw
185
- udev 2025576 228 2025348 1% /dev
186
- tmpfs 2030944 2960 2027984 1% /dev/shm
187
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
188
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
189
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
190
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
191
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
192
- /dev/md0 960492 36388 875312 4% /boot
193
- DF
194
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
195
-
196
- @inode_stdout = <<~DFI
197
- Filesystem Inodes IUsed IFree IUse% Mounted on
198
- /dev/xvda1 1310720 107407 1203313 9% /
199
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
200
- tmpfs 126922 273 126649 1% /run
201
- none 126922 1 126921 1% /run/lock
202
- none 126922 1 126921 1% /run/shm
203
- DFI
204
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
205
-
206
- @stdout = <<~BLKID_TYPE
207
- /dev/sdb1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
208
- /dev/sdb2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
209
- /dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
210
- /dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
211
- /dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
212
- /dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
213
- /dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
214
- /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
215
- /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
216
- /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
217
- /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
218
- /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
219
- BLKID_TYPE
220
- allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, @stdout, ""))
221
- end
222
-
223
- it "runs blkid" do
224
- plugin.run
225
- end
226
-
227
- it "sets kb_size to value from blkid" do
228
- plugin.run
229
- expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
230
- expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
231
- expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
232
- end
233
- end
234
-
235
- describe "when gathering filesystem type data from lsblk" do
236
- before do
237
- @dfstdout = <<~DF
238
- Filesystem 1024-blocks Used Available Capacity Mounted on
239
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
240
- tmpfs 2030944 0 2030944 0% /lib/init/rw
241
- udev 2025576 228 2025348 1% /dev
242
- tmpfs 2030944 2960 2027984 1% /dev/shm
243
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
244
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
245
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
246
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
247
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
248
- /dev/md0 960492 36388 875312 4% /boot
249
- DF
250
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
251
-
252
- @inode_stdout = <<~DFI
253
- Filesystem Inodes IUsed IFree IUse% Mounted on
254
- /dev/xvda1 1310720 107407 1203313 9% /
255
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
256
- tmpfs 126922 273 126649 1% /run
257
- none 126922 1 126921 1% /run/lock
258
- none 126922 1 126921 1% /run/shm
259
- DFI
260
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
261
-
262
- allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
263
- allow(plugin).to receive(:which).with("blkid").and_return(nil)
264
- @stdout = <<~BLKID_TYPE
265
- NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
266
- NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
267
- NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
268
- NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
269
- NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
270
- NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
271
- NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
272
- NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
273
- NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
274
- NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" FSTYPE=\"ext4\"
275
- NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
276
- NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
277
- NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
278
- BLKID_TYPE
279
- allow(plugin).to receive(:shell_out)
280
- .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60)
281
- .and_return(mock_shell_out(0, @stdout, ""))
282
- end
283
-
284
- it "runs lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
285
- plugin.run
286
- end
287
-
288
- it "sets kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
289
- plugin.run
290
- expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
291
- expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
292
- expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
293
- end
294
-
295
- it "ignores extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
296
- plugin.run
297
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
298
- end
299
-
300
- end
301
-
302
- describe "when gathering filesystem type data from both lsblk and blkid" do
303
- before do
304
- @dfstdout = <<~DF
305
- Filesystem 1024-blocks Used Available Capacity Mounted on
306
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
307
- tmpfs 2030944 0 2030944 0% /lib/init/rw
308
- udev 2025576 228 2025348 1% /dev
309
- tmpfs 2030944 2960 2027984 1% /dev/shm
310
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
311
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
312
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
313
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
314
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
315
- /dev/md0 960492 36388 875312 4% /boot
316
- DF
317
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
318
-
319
- @inode_stdout = <<~DFI
320
- Filesystem Inodes IUsed IFree IUse% Mounted on
321
- /dev/xvda1 1310720 107407 1203313 9% /
322
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
323
- tmpfs 126922 273 126649 1% /run
324
- none 126922 1 126921 1% /run/lock
325
- none 126922 1 126921 1% /run/shm
326
- DFI
327
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
328
-
329
- allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
330
- allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
331
- @stdout = <<~BLKID_TYPE
332
- NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
333
- NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
334
- NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
335
- NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
336
- NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
337
- NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
338
- NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\"
339
- NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
340
- NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
341
- NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\"
342
- NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
343
- NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/BADhome\" FSTYPE=\"xfs\"
344
- NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
345
- BLKID_TYPE
346
- allow(plugin).to receive(:shell_out)
347
- .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60)
348
- .and_return(mock_shell_out(0, @stdout, ""))
349
- @stdout = <<~BLKID_TYPE
350
- /dev/sdb1: LABEL=\"fuego:0\" TYPE=\"linux_raid_member\"
351
- /dev/sdb2: LABEL=\"fuego:1\" TYPE=\"linux_raid_member\"
352
- /dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
353
- /dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
354
- /dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
355
- /dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
356
- /dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
357
- /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
358
- /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
359
- /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
360
- /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
361
- /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
362
- BLKID_TYPE
363
- allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, @stdout, ""))
364
- end
365
-
366
- it "fills in missing FS data from lsblk using blkid" do
367
- plugin.run
368
- pairs = plugin[:filesystem]["by_pair"]
369
- expect(pairs["/dev/mapper/sys.vg-root.lv,/"]["fs_type"]).to eq("ext4")
370
- expect(pairs["/dev/mapper/sys.vg-usr.lv,/usr"]["fs_type"]).to eq("ext4")
371
- end
372
-
373
- it "fills in missing FS data from blkid using lsblk" do
374
- plugin.run
375
- pairs = plugin[:filesystem]["by_pair"]
376
- expect(pairs["/dev/sdb1,"]["uuid"]).to eq("bd1197e0-6997-1f3a-e27e-7801388308b5")
377
- expect(pairs["/dev/sdb2,"]["uuid"]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
378
- end
379
-
380
- it "prefers lsblk data to blkid data when they conflict" do
381
- plugin.run
382
- pairs = plugin[:filesystem]["by_pair"]
383
- expect(pairs["/dev/mapper/sys.vg-home.lv,/home"]["label"]).to eq("/home")
384
- end
385
-
386
- end
387
-
388
- describe "when gathering data from /proc/mounts" do
389
- before do
390
- allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
391
- @double_file = double("/proc/mounts")
392
- @mounts = <<~MOUNTS
393
- rootfs / rootfs rw 0 0
394
- none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
395
- none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
396
- none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0
397
- none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
398
- /dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0
399
- tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
400
- tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0
401
- /dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0
402
- /dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0
403
- /dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0
404
- /dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0
405
- /dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0
406
- /dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0
407
- fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
408
- binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
409
- MOUNTS
410
- @counter = 0
411
- allow(@double_file).to receive(:read_nonblock) do
412
- @counter += 1
413
- raise EOFError if @counter == 2
414
-
415
- @mounts
416
- end
417
- allow(@double_file).to receive(:close)
418
- allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file)
419
- end
420
-
421
- it "sets mount to value from /proc/mounts" do
422
- plugin.run
423
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
424
- end
425
-
426
- it "sets fs_type to value from /proc/mounts" do
427
- plugin.run
428
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
429
- end
430
-
431
- it "sets mount_options to an array of values from /proc/mounts" do
432
- plugin.run
433
- expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
434
- end
435
- end
436
-
437
- describe "when gathering filesystem data with devices mounted more than once" do
438
- before do
439
- # there's a few different examples one can run into in this output:
440
- # 1. A device physically mounted in more than one place: /home and /home2
441
- # 2. A bind-mounted directory, which shows up as the same device in a
442
- # subdir: / and /var/chroot
443
- # 3. tmpfs in multiple places.
444
- @dfstdout = <<~DF
445
- Filesystem 1024-blocks Used Available Capacity Mounted on
446
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
447
- tmpfs 2030944 0 2030944 0% /lib/init/rw
448
- udev 2025576 228 2025348 1% /dev
449
- tmpfs 2030944 2960 2027984 1% /dev/shm
450
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
451
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2
452
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot
453
- DF
454
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
455
-
456
- @inode_stdout = <<~DFI
457
- Filesystem Inodes IUsed IFree IUse% Mounted on
458
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
459
- tmpfs 126922 273 126649 1% /lib/init/rw
460
- none 126922 1 126921 1% /dev/shm
461
- udev 126922 1 126921 1% /dev
462
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
463
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2
464
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot
465
- DFI
466
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
467
-
468
- allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
469
- allow(plugin).to receive(:which).with("blkid").and_return(nil)
470
- @stdout = <<~BLKID_TYPE
471
- NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
472
- NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
473
- BLKID_TYPE
474
- allow(plugin).to receive(:shell_out)
475
- .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60)
476
- .and_return(mock_shell_out(0, @stdout, ""))
477
- end
478
-
479
- it "provides a devices view with all mountpoints" do
480
- plugin.run
481
- expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
482
- expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
483
- expect(plugin[:filesystem]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
484
- end
485
- end
486
-
487
- describe "when gathering filesystem data with double-mounts" do
488
- before do
489
- @dfstdout = <<~DF
490
- Filesystem 1024-blocks Used Available Capacity Mounted on
491
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
492
- tmpfs 2030944 0 2030944 0% /lib/init/rw
493
- udev 2025576 228 2025348 1% /dev
494
- tmpfs 2030944 2960 2027984 1% /dev/shm
495
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
496
- /dev/sdb1 97605056 53563252 44041804 55% /mnt
497
- /dev/sdc1 4805760 378716 4182924 9% /mnt
498
- DF
499
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
500
-
501
- @inode_stdout = <<~DFI
502
- Filesystem Inodes IUsed IFree IUse% Mounted on
503
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
504
- tmpfs 126922 273 126649 1% /lib/init/rw
505
- none 126922 1 126921 1% /dev/shm
506
- udev 126922 1 126921 1% /dev
507
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
508
- /dev/sdb1 60891136 4696030 56195106 8% /mnt
509
- /dev/sdc1 1310720 107407 1203313 9% /mnt
510
- DFI
511
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
512
-
513
- allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
514
- allow(plugin).to receive(:which).with("blkid").and_return(nil)
515
- @stdout = <<~BLKID_TYPE
516
- NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
517
- NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
518
- NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
519
- NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
520
- BLKID_TYPE
521
- allow(plugin).to receive(:shell_out)
522
- .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60)
523
- .and_return(mock_shell_out(0, @stdout, ""))
524
- end
525
-
526
- it "provides a mounts view with all devices" do
527
- plugin.run
528
- expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
529
- end
530
- end
531
-
532
- %w{df mount}.each do |command|
533
- describe "when :allow_partial_data set, #{command} does not exist" do
534
- before do
535
- Ohai.config[:plugin][:filesystem][:allow_partial_data] = true
536
- end
537
-
538
- after do
539
- Ohai.config[:plugin][:filesystem][:allow_partial_data] = false
540
- end
541
-
542
- it "logs warning about #{command} missing" do
543
- Ohai.config[:plugin][:filesystem][:allow_partial_data] = true
544
- allow(plugin).to receive(:shell_out).with(/#{command}/).and_raise(Ohai::Exceptions::Exec)
545
- expect_any_instance_of(Mixlib::Log::Child).to receive(:warn).with("Plugin Filesystem: #{command} binary is not available. Some data will not be available.")
546
- plugin.run
547
- end
548
- end
549
- end
550
- end