ohai 8.0.1 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/mixin/gce_metadata.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +56 -6
- data/lib/ohai/plugins/cloud_v2.rb +29 -1
- data/lib/ohai/plugins/cloudstack.rb +7 -0
- data/lib/ohai/plugins/digital_ocean.rb +81 -0
- data/lib/ohai/plugins/elixir.rb +32 -0
- data/lib/ohai/plugins/linode.rb +1 -0
- data/lib/ohai/plugins/linux/block_device.rb +5 -0
- data/lib/ohai/plugins/linux/cpu.rb +21 -1
- data/lib/ohai/plugins/linux/filesystem.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +6 -2
- data/lib/ohai/plugins/linux/platform.rb +2 -0
- data/lib/ohai/plugins/linux/virtualization.rb +14 -3
- data/lib/ohai/plugins/php.rb +13 -6
- data/lib/ohai/plugins/ruby.rb +10 -10
- data/lib/ohai/plugins/rust.rb +32 -0
- data/lib/ohai/plugins/ssh_host_key.rb +6 -0
- data/lib/ohai/util/ip_helper.rb +52 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/data/plugins/php.output +16 -0
- data/spec/unit/plugins/cloud_spec.rb +63 -9
- data/spec/unit/plugins/cloud_v2_spec.rb +123 -25
- data/spec/unit/plugins/cloudstack_spec.rb +1 -1
- data/spec/unit/plugins/digital_ocean_spec.rb +211 -0
- data/spec/unit/plugins/elixir_spec.rb +46 -0
- data/spec/unit/plugins/linux/cpu_spec.rb +112 -35
- data/spec/unit/plugins/linux/filesystem_spec.rb +7 -7
- data/spec/unit/plugins/linux/network_spec.rb +63 -4
- data/spec/unit/plugins/linux/platform_spec.rb +13 -0
- data/spec/unit/plugins/linux/virtualization_spec.rb +146 -21
- data/spec/unit/plugins/php_spec.rb +37 -3
- data/spec/unit/plugins/rust_spec.rb +43 -0
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -0
- data/spec/unit/util/ip_helper_spec.rb +128 -0
- metadata +49 -41
@@ -24,7 +24,7 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
|
26
26
|
allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
|
27
|
-
allow(@plugin).to receive(:shell_out).with("df -
|
27
|
+
allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
|
28
28
|
allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
29
29
|
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
|
30
30
|
allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
|
@@ -81,12 +81,12 @@ tmpfs 126922 273 126649 1% /run
|
|
81
81
|
none 126922 1 126921 1% /run/lock
|
82
82
|
none 126922 1 126921 1% /run/shm
|
83
83
|
DFi
|
84
|
-
allow(@plugin).to receive(:shell_out).with("df -
|
84
|
+
allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
85
85
|
end
|
86
86
|
|
87
|
-
it "should run df -P and df -
|
87
|
+
it "should run df -P and df -iP" do
|
88
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 -
|
89
|
+
expect(@plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
90
90
|
@plugin.run
|
91
91
|
end
|
92
92
|
|
@@ -115,17 +115,17 @@ DFi
|
|
115
115
|
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
116
116
|
end
|
117
117
|
|
118
|
-
it "should set total_inodes to value from df -
|
118
|
+
it "should set total_inodes to value from df -iP" do
|
119
119
|
@plugin.run
|
120
120
|
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865")
|
121
121
|
end
|
122
122
|
|
123
|
-
it "should set inodes_used to value from df -
|
123
|
+
it "should set inodes_used to value from df -iP" do
|
124
124
|
@plugin.run
|
125
125
|
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380")
|
126
126
|
end
|
127
127
|
|
128
|
-
it "should set inodes_available to value from df -
|
128
|
+
it "should set inodes_available to value from df -iP" do
|
129
129
|
@plugin.run
|
130
130
|
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485")
|
131
131
|
end
|
@@ -115,6 +115,29 @@ lo Link encap:Local Loopback
|
|
115
115
|
TX packets:524 errors:0 dropped:0 overruns:0 carrier:0
|
116
116
|
collisions:0 txqueuelen:0
|
117
117
|
RX bytes:35224 (34.3 KiB) TX bytes:35224 (34.3 KiB)
|
118
|
+
|
119
|
+
eth3 Link encap:Ethernet HWaddr E8:39:35:C5:C8:54
|
120
|
+
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
121
|
+
RX packets:13395101 errors:0 dropped:0 overruns:0 frame:0
|
122
|
+
TX packets:9492909 errors:0 dropped:0 overruns:0 carrier:0
|
123
|
+
collisions:0 txqueuelen:1000
|
124
|
+
RX bytes:1325650573 (1.2 GiB) TX bytes:1666310189 (1.5 GiB)
|
125
|
+
Interrupt:36 Memory:f4800000-f4ffffff
|
126
|
+
|
127
|
+
ovs-system Link encap:Ethernet HWaddr 7A:7A:80:80:6C:24
|
128
|
+
BROADCAST MULTICAST MTU:1500 Metric:1
|
129
|
+
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
|
130
|
+
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
|
131
|
+
collisions:0 txqueuelen:0
|
132
|
+
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
|
133
|
+
|
134
|
+
xapi1 Link encap:Ethernet HWaddr E8:39:35:C5:C8:50
|
135
|
+
inet addr:192.168.13.34 Bcast:192.168.13.255 Mask:255.255.255.0
|
136
|
+
UP BROADCAST RUNNING MTU:1500 Metric:1
|
137
|
+
RX packets:160275 errors:0 dropped:0 overruns:0 frame:0
|
138
|
+
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
|
139
|
+
collisions:0 txqueuelen:0
|
140
|
+
RX bytes:21515031 (20.5 MiB) TX bytes:2052 (2.0 KiB)
|
118
141
|
'
|
119
142
|
# Note that ifconfig shows foo:veth0@eth0 but fails to show any address information.
|
120
143
|
# This was not a mistake collecting the output and Apparently ifconfig is broken in this regard.
|
@@ -198,6 +221,10 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
|
198
221
|
link/void
|
199
222
|
inet 127.0.0.2/32 scope host venet0
|
200
223
|
inet 172.16.19.48/32 scope global venet0:0
|
224
|
+
12: xapi1: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
|
225
|
+
link/ether e8:39:35:c5:c8:50 brd ff:ff:ff:ff:ff:ff
|
226
|
+
inet 192.168.13.34/24 brd 192.168.13.255 scope global xapi1
|
227
|
+
valid_lft forever preferred_lft forever
|
201
228
|
'
|
202
229
|
}
|
203
230
|
|
@@ -233,6 +260,24 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024
|
|
233
260
|
1392844460 2659966 0 0 0 0
|
234
261
|
TX: bytes packets errors dropped carrier collsns
|
235
262
|
691785313 1919690 0 0 0 0
|
263
|
+
10: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP mode DEFAULT qlen 1000
|
264
|
+
link/ether e8:39:35:c5:c8:54 brd ff:ff:ff:ff:ff:ff
|
265
|
+
RX: bytes packets errors dropped overrun mcast
|
266
|
+
1321907045 13357087 0 0 0 3126613
|
267
|
+
TX: bytes packets errors dropped carrier collsns
|
268
|
+
1661526184 9467091 0 0 0 0
|
269
|
+
11: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
|
270
|
+
link/ether 7a:7a:80:80:6c:24 brd ff:ff:ff:ff:ff:ff
|
271
|
+
RX: bytes packets errors dropped overrun mcast
|
272
|
+
0 0 0 0 0 0
|
273
|
+
TX: bytes packets errors dropped carrier collsns
|
274
|
+
0 0 0 0 0 0
|
275
|
+
12: xapi1: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT
|
276
|
+
link/ether e8:39:35:c5:c8:50 brd ff:ff:ff:ff:ff:ff
|
277
|
+
RX: bytes packets errors dropped overrun mcast
|
278
|
+
21468183 159866 0 0 0 0
|
279
|
+
TX: bytes packets errors dropped carrier collsns
|
280
|
+
2052 6 0 0 0 0
|
236
281
|
'
|
237
282
|
}
|
238
283
|
|
@@ -268,11 +313,21 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
|
|
268
313
|
allow(plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, linux_arp_an, ""))
|
269
314
|
end
|
270
315
|
|
316
|
+
describe "#iproute2_binary_available?" do
|
317
|
+
["/sbin/ip", "/usr/bin/ip"].each do |path|
|
318
|
+
it "accepts #{path}" do
|
319
|
+
allow(File).to receive(:exist?).and_return(false)
|
320
|
+
allow(File).to receive(:exist?).with(path).and_return(true)
|
321
|
+
expect(plugin.iproute2_binary_available?).to be_truthy
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
271
326
|
["ifconfig","iproute2"].each do |network_method|
|
272
327
|
|
273
328
|
describe "gathering IP layer address info via #{network_method}" do
|
274
329
|
before(:each) do
|
275
|
-
allow(
|
330
|
+
allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" )
|
276
331
|
plugin.run
|
277
332
|
end
|
278
333
|
|
@@ -282,7 +337,7 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
|
|
282
337
|
end
|
283
338
|
|
284
339
|
it "detects the interfaces" do
|
285
|
-
expect(plugin['network']['interfaces'].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "foo:veth0@eth0", "lo", "tun0", "venet0", "venet0:0"])
|
340
|
+
expect(plugin['network']['interfaces'].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
|
286
341
|
end
|
287
342
|
|
288
343
|
it "detects the ipv4 addresses of the ethernet interface" do
|
@@ -378,7 +433,7 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
|
|
378
433
|
|
379
434
|
describe "gathering interface counters via #{network_method}" do
|
380
435
|
before(:each) do
|
381
|
-
allow(
|
436
|
+
allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" )
|
382
437
|
plugin.run
|
383
438
|
end
|
384
439
|
|
@@ -416,7 +471,7 @@ fe80::21c:eff:fe12:3456 dev eth0.153 lladdr 00:1c:0e:30:28:00 router REACHABLE
|
|
416
471
|
|
417
472
|
describe "setting the node's default IP address attribute with #{network_method}" do
|
418
473
|
before(:each) do
|
419
|
-
allow(
|
474
|
+
allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" )
|
420
475
|
plugin.run
|
421
476
|
end
|
422
477
|
|
@@ -532,6 +587,10 @@ Destination Gateway Genmask Flags Metric Ref Use Iface
|
|
532
587
|
expect(plugin['network']['interfaces']['eth0.11']['state']).to eq('up')
|
533
588
|
end
|
534
589
|
|
590
|
+
it "detects interfaces only visible via ip link" do
|
591
|
+
expect(plugin['network']['interfaces']['eth3']['state']).to eq('up')
|
592
|
+
end
|
593
|
+
|
535
594
|
describe "when dealing with routes" do
|
536
595
|
it "adds routes" do
|
537
596
|
plugin.run
|
@@ -170,6 +170,12 @@ describe Ohai::System, "Linux plugin platform" do
|
|
170
170
|
expect(@plugin[:platform_family]).to eq("arch")
|
171
171
|
end
|
172
172
|
|
173
|
+
it "should set platform_version to kernel release" do
|
174
|
+
expect(@plugin).to receive(:`).with('uname -r').and_return('3.18.2-2-ARCH')
|
175
|
+
@plugin.run
|
176
|
+
expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH')
|
177
|
+
end
|
178
|
+
|
173
179
|
end
|
174
180
|
|
175
181
|
describe "on gentoo" do
|
@@ -197,6 +203,13 @@ describe Ohai::System, "Linux plugin platform" do
|
|
197
203
|
expect(@plugin[:platform]).to eq("exherbo")
|
198
204
|
expect(@plugin[:platform_family]).to eq("exherbo")
|
199
205
|
end
|
206
|
+
|
207
|
+
it "should set platform_version to kernel release" do
|
208
|
+
expect(@plugin).to receive(:`).with('uname -r').and_return('3.18.2-2-ARCH')
|
209
|
+
@plugin.run
|
210
|
+
expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH')
|
211
|
+
end
|
212
|
+
|
200
213
|
end
|
201
214
|
|
202
215
|
describe "on redhat breeds" do
|
@@ -33,6 +33,8 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
33
33
|
allow(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
34
34
|
allow(File).to receive(:exists?).with("/proc/vz").and_return(false)
|
35
35
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
36
|
+
allow(File).to receive(:exists?).with("/.dockerenv").and_return(false)
|
37
|
+
allow(File).to receive(:exists?).with("/.dockerinit").and_return(false)
|
36
38
|
end
|
37
39
|
|
38
40
|
describe "when we are checking for xen" do
|
@@ -204,6 +206,25 @@ VBOX
|
|
204
206
|
expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
205
207
|
end
|
206
208
|
|
209
|
+
it "should set openstack guest if dmidecode detects OpenStack" do
|
210
|
+
openstack_dmidecode=<<-OPENSTACK
|
211
|
+
System Information
|
212
|
+
Manufacturer: Red Hat Inc.
|
213
|
+
Product Name: OpenStack Nova
|
214
|
+
Version: 2014.1.2-1.el6
|
215
|
+
Serial Number: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
216
|
+
UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
217
|
+
Wake-up Type: Power Switch
|
218
|
+
SKU Number: Not Specified
|
219
|
+
Family: Red Hat Enterprise Linux
|
220
|
+
OPENSTACK
|
221
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, openstack_dmidecode, ""))
|
222
|
+
@plugin.run
|
223
|
+
expect(@plugin[:virtualization][:system]).to eq("openstack")
|
224
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
225
|
+
expect(@plugin[:virtualization][:systems][:openstack]).to eq("guest")
|
226
|
+
end
|
227
|
+
|
207
228
|
it "should run dmidecode and not set virtualization if nothing is detected" do
|
208
229
|
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
|
209
230
|
@plugin.run
|
@@ -338,27 +359,6 @@ CGROUP
|
|
338
359
|
expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
339
360
|
end
|
340
361
|
|
341
|
-
it "should set lxc guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
|
342
|
-
self_cgroup=<<-CGROUP
|
343
|
-
11:hugetlb:/
|
344
|
-
10:perf_event:/
|
345
|
-
9:blkio:/
|
346
|
-
8:net_cls:/
|
347
|
-
7:freezer:/
|
348
|
-
6:devices:/
|
349
|
-
5:memory:/
|
350
|
-
4:cpuacct,cpu:/docker/9c2adaa4c391ec0d3bf994fbd91ff30c3d317694d179e5b1dc7e1e4c8ed56b61
|
351
|
-
3:cpuset:/
|
352
|
-
2:name=systemd:/system.slice/docker.service
|
353
|
-
CGROUP
|
354
|
-
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
355
|
-
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
356
|
-
@plugin.run
|
357
|
-
expect(@plugin[:virtualization][:system]).to eq("lxc")
|
358
|
-
expect(@plugin[:virtualization][:role]).to eq("guest")
|
359
|
-
expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
360
|
-
end
|
361
|
-
|
362
362
|
it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
363
363
|
self_cgroup=<<-CGROUP
|
364
364
|
8:blkio:/Charlie
|
@@ -427,6 +427,131 @@ CGROUP
|
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
430
|
+
describe "when we are checking for docker" do
|
431
|
+
it "should set docker guest if /proc/self/cgroup exist and there are /docker/<hexadecimal> mounts" do
|
432
|
+
self_cgroup=<<-CGROUP
|
433
|
+
8:blkio:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
434
|
+
7:net_cls:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
435
|
+
6:freezer:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
436
|
+
5:devices:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
437
|
+
4:memory:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
438
|
+
3:cpuacct:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
439
|
+
2:cpu:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
440
|
+
1:cpuset:/
|
441
|
+
CGROUP
|
442
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
443
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
444
|
+
@plugin.run
|
445
|
+
expect(@plugin[:virtualization][:system]).to eq("docker")
|
446
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
447
|
+
expect(@plugin[:virtualization][:systems][:docker]).to eq("guest")
|
448
|
+
end
|
449
|
+
|
450
|
+
it "should set docker guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
|
451
|
+
self_cgroup=<<-CGROUP
|
452
|
+
8:blkio:/docker/vanilla
|
453
|
+
7:net_cls:/docker/vanilla
|
454
|
+
6:freezer:/docker/vanilla
|
455
|
+
5:devices:/docker/vanilla
|
456
|
+
4:memory:/docker/vanilla
|
457
|
+
3:cpuacct:/docker/vanilla
|
458
|
+
2:cpu:/docker/vanilla
|
459
|
+
1:cpuset:/docker/vanilla
|
460
|
+
CGROUP
|
461
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
462
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
463
|
+
@plugin.run
|
464
|
+
expect(@plugin[:virtualization][:system]).to eq("docker")
|
465
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
466
|
+
expect(@plugin[:virtualization][:systems][:docker]).to eq("guest")
|
467
|
+
end
|
468
|
+
|
469
|
+
it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
470
|
+
self_cgroup=<<-CGROUP
|
471
|
+
8:blkio:/Charlie
|
472
|
+
7:net_cls:/Charlie
|
473
|
+
6:freezer:/Charlie
|
474
|
+
5:devices:/Charlie
|
475
|
+
4:memory:/Charlie
|
476
|
+
3:cpuacct:/Charlie
|
477
|
+
2:cpu:/Charlie
|
478
|
+
1:cpuset:/Charlie
|
479
|
+
CGROUP
|
480
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
481
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
482
|
+
@plugin.run
|
483
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
484
|
+
end
|
485
|
+
|
486
|
+
context "/proc/self/cgroup only has / mounts" do
|
487
|
+
before(:each) do
|
488
|
+
self_cgroup=<<-CGROUP
|
489
|
+
8:blkio:/
|
490
|
+
7:net_cls:/
|
491
|
+
6:freezer:/
|
492
|
+
5:devices:/
|
493
|
+
4:memory:/
|
494
|
+
3:cpuacct:/
|
495
|
+
2:cpu:/
|
496
|
+
1:cpuset:/
|
497
|
+
CGROUP
|
498
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
499
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
500
|
+
@plugin.run
|
501
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
502
|
+
end
|
503
|
+
|
504
|
+
end
|
505
|
+
|
506
|
+
it "does not set the old virtualization attributes if they are already set" do
|
507
|
+
allow(@plugin).to receive(:docker_exists?).and_return("/usr/bin/docker")
|
508
|
+
@plugin[:virtualization] = Mash.new
|
509
|
+
@plugin[:virtualization][:system] = "the cloud"
|
510
|
+
@plugin[:virtualization][:role] = "cumulonimbus"
|
511
|
+
@plugin.run
|
512
|
+
expect(@plugin[:virtualization][:system]).not_to eq("docker")
|
513
|
+
expect(@plugin[:virtualization][:role]).not_to eq("host")
|
514
|
+
end
|
515
|
+
|
516
|
+
it "does not set docker host if docker does not exist" do
|
517
|
+
allow(@plugin).to receive(:docker_exists?).and_return(false)
|
518
|
+
@plugin.run
|
519
|
+
expect(@plugin[:virtualization][:system]).to be_nil
|
520
|
+
expect(@plugin[:virtualization][:role]).to be_nil
|
521
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
522
|
+
end
|
523
|
+
|
524
|
+
it "should not set virtualization if /proc/self/cgroup isn't there" do
|
525
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
526
|
+
@plugin.run
|
527
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
528
|
+
end
|
529
|
+
|
530
|
+
it "should set virtualization if /.dockerenv exists" do
|
531
|
+
allow(File).to receive(:exists?).with("/.dockerenv").and_return(true)
|
532
|
+
@plugin.run
|
533
|
+
expect(@plugin[:virtualization][:system]).to eq("docker")
|
534
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
535
|
+
expect(@plugin[:virtualization][:systems][:docker]).to eq("guest")
|
536
|
+
end
|
537
|
+
|
538
|
+
it "should set virtualization if /.dockerinit exists" do
|
539
|
+
allow(File).to receive(:exists?).with("/.dockerinit").and_return(true)
|
540
|
+
@plugin.run
|
541
|
+
expect(@plugin[:virtualization][:system]).to eq("docker")
|
542
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
543
|
+
expect(@plugin[:virtualization][:systems][:docker]).to eq("guest")
|
544
|
+
end
|
545
|
+
|
546
|
+
it "should not set virtualization if /.dockerenv or /.dockerinit doesn't exists" do
|
547
|
+
allow(File).to receive(:exists?).with("/.dockerenv").and_return(false)
|
548
|
+
allow(File).to receive(:exists?).with("/.dockerinit").and_return(false)
|
549
|
+
@plugin.run
|
550
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
551
|
+
end
|
552
|
+
|
553
|
+
end
|
554
|
+
|
430
555
|
it "should not set virtualization if no tests match" do
|
431
556
|
@plugin.run
|
432
557
|
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
@@ -25,7 +25,11 @@ describe Ohai::System, "plugin php" do
|
|
25
25
|
before(:each) do
|
26
26
|
@plugin = get_plugin("php")
|
27
27
|
@plugin[:languages] = Mash.new
|
28
|
-
@stdout =
|
28
|
+
@stdout = <<-OUT
|
29
|
+
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
|
30
|
+
Copyright (c) 1997-2006 The PHP Group
|
31
|
+
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
|
32
|
+
OUT
|
29
33
|
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
30
34
|
end
|
31
35
|
|
@@ -40,17 +44,47 @@ describe Ohai::System, "plugin php" do
|
|
40
44
|
end
|
41
45
|
|
42
46
|
it "should not set the languages[:php] tree up if php command fails" do
|
43
|
-
@stdout =
|
47
|
+
@stdout = <<-OUT
|
48
|
+
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
|
49
|
+
Copyright (c) 1997-2006 The PHP Group
|
50
|
+
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
|
51
|
+
OUT
|
44
52
|
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
|
45
53
|
@plugin.run
|
46
54
|
expect(@plugin.languages).not_to have_key(:php)
|
47
55
|
end
|
48
56
|
|
49
57
|
it "should parse builddate even if it's suhosin patched" do
|
50
|
-
@stdout =
|
58
|
+
@stdout = <<-OUT
|
59
|
+
PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30)
|
60
|
+
Copyright (c) 1997-2013 The PHP Group
|
61
|
+
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
|
62
|
+
OUT
|
51
63
|
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
52
64
|
@plugin.run
|
53
65
|
expect(@plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
|
54
66
|
end
|
55
67
|
|
68
|
+
it "should not set zend_optcache_version if not compiled with opcache" do
|
69
|
+
@stdout = <<-OUT
|
70
|
+
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
|
71
|
+
Copyright (c) 1997-2006 The PHP Group
|
72
|
+
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
|
73
|
+
OUT
|
74
|
+
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
75
|
+
@plugin.run
|
76
|
+
expect(@plugin.languages[:php]).not_to have_key(:zend_opcache_version)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should parse zend_optcache_version if compiled with opcache" do
|
80
|
+
@stdout = <<-OUT
|
81
|
+
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
|
82
|
+
Copyright (c) 1997-2014 The PHP Group
|
83
|
+
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
|
84
|
+
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
|
85
|
+
OUT
|
86
|
+
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
87
|
+
@plugin.run
|
88
|
+
expect(@plugin.languages[:php][:zend_opcache_version]).to eql("7.0.3")
|
89
|
+
end
|
56
90
|
end
|