ohai 8.16.0 → 8.17.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,15 +31,41 @@ serio_raw 13031 0
31
31
  virtio_balloon 13168 0
32
32
  floppy 55441 0
33
33
  ENV_LSMOD
34
+ @version_module = {
35
+ dm_crypt: "",
36
+ psmouse: "",
37
+ acpiphp: "",
38
+ microcode: "1.2.3",
39
+ serio_raw: "",
40
+ virtio_balloon: "",
41
+ floppy: "",
42
+ }
43
+
44
+ @expected_result = {
45
+ "dm_crypt" => { "size" => "22321", "refcount" => "0" },
46
+ "psmouse" => { "size" => "81038", "refcount" => "0" },
47
+ "acpiphp" => { "size" => "23314", "refcount" => "0" },
48
+ "microcode" => { "size" => "18286", "refcount" => "0", "version" => "1.2.3" },
49
+ "serio_raw" => { "size" => "13031", "refcount" => "0" },
50
+ "virtio_balloon" => { "size" => "13168", "refcount" => "0" },
51
+ "floppy" => { "size" => "55441", "refcount" => "0" },
52
+ }
34
53
  @plugin = get_plugin("kernel")
35
54
  allow(@plugin).to receive(:collect_os).and_return(:linux)
36
55
  allow(@plugin).to receive(:init_kernel).and_return({})
37
56
  allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
38
57
  allow(@plugin).to receive(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
58
+ @version_module.each do |mod, vers|
59
+ allow(File).to receive(:exist?).with("/sys/module/#{mod}/version").and_return(true)
60
+ allow(File).to receive(:read).with("/sys/module/#{mod}/version").and_return(vers)
61
+ end
39
62
  expect(@plugin).to receive(:shell_out).with("env lsmod").at_least(1).times
40
63
  @plugin.run
41
64
  end
42
65
 
43
66
  it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""])
44
67
 
68
+ it "collects linux::kernel::modules" do
69
+ expect(@plugin.data["kernel"]["modules"]).to eq(@expected_result)
70
+ end
45
71
  end
@@ -336,6 +336,22 @@ Settings for eth0:
336
336
  Current message level: 0x00000007 (7)
337
337
  drv probe link
338
338
  Link detected: yes
339
+ EOM
340
+ }
341
+
342
+ let(:linux_ethtool_g) { <<-EOM
343
+ Ring parameters for eth0:
344
+ Pre-set maximums:
345
+ RX: 8192
346
+ RX Mini: 0
347
+ RX Jumbo: 0
348
+ TX: 8192
349
+ Current hardware settings:
350
+ RX: 8192
351
+ RX Mini: 0
352
+ RX Jumbo: 0
353
+ TX: 8192
354
+
339
355
  EOM
340
356
  }
341
357
 
@@ -352,7 +368,8 @@ EOM
352
368
  allow(plugin).to receive(:shell_out).with("route -n").and_return(mock_shell_out(0, linux_route_n, ""))
353
369
  allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, linux_ifconfig, ""))
354
370
  allow(plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, linux_arp_an, ""))
355
- allow(plugin).to receive(:shell_out).with(/ethtool/).and_return(mock_shell_out(0, linux_ethtool, ""))
371
+ allow(plugin).to receive(:shell_out).with(/ethtool -g/).and_return(mock_shell_out(0, linux_ethtool_g, ""))
372
+ allow(plugin).to receive(:shell_out).with(/ethtool [^\-]/).and_return(mock_shell_out(0, linux_ethtool, ""))
356
373
  end
357
374
 
358
375
  describe "#iproute2_binary_available?" do
@@ -554,6 +571,10 @@ EOM
554
571
  expect(plugin["network"]["interfaces"]["eth0"]["transceiver"]).to eq("external")
555
572
  expect(plugin["network"]["interfaces"]["eth0"]["auto_negotiation"]).to eq("on")
556
573
  expect(plugin["network"]["interfaces"]["eth0"]["mdi_x"]).to be_nil
574
+ expect(plugin["network"]["interfaces"]["eth0"]["ring_params"]["max_tx"]).to eq(8192)
575
+ expect(plugin["network"]["interfaces"]["eth0"]["ring_params"]["max_rx"]).to eq(8192)
576
+ expect(plugin["network"]["interfaces"]["eth0"]["ring_params"]["current_tx"]).to eq(8192)
577
+ expect(plugin["network"]["interfaces"]["eth0"]["ring_params"]["current_rx"]).to eq(8192)
557
578
  end
558
579
 
559
580
  it "detects the ipv4 addresses of the ethernet interface" do
@@ -808,6 +829,10 @@ EOM
808
829
  expect(plugin["network"]["interfaces"]["eth3"]["state"]).to eq("up")
809
830
  end
810
831
 
832
+ it "detects tags on v6 addresses of the ethernet interface" do
833
+ expect(plugin["network"]["interfaces"]["eth0"]["addresses"]["2001:44b8:4160:8f00:a00:27ff:fe13:eacd"]["tags"]).to eq(["dynamic"])
834
+ end
835
+
811
836
  describe "when IPv6 is disabled" do
812
837
  before :each do
813
838
  allow(File).to receive(:exist?).with("/proc/net/if_inet6").and_return(false)
@@ -217,11 +217,16 @@ describe Ohai::System, "Linux plugin platform" do
217
217
  end
218
218
 
219
219
  it "should set platform and platform_family to gentoo" do
220
- expect(File).to receive(:read).with("/etc/gentoo-release").and_return("Gentoo Base System release 1.20.1.1")
221
220
  @plugin.run
222
221
  expect(@plugin[:platform]).to eq("gentoo")
223
222
  expect(@plugin[:platform_family]).to eq("gentoo")
224
223
  end
224
+
225
+ it "should set platform_version to kernel release" do
226
+ expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.7-gentoo")
227
+ @plugin.run
228
+ expect(@plugin[:platform_version]).to eq("3.18.7-gentoo")
229
+ end
225
230
  end
226
231
 
227
232
  describe "on alpine" do
@@ -27,6 +27,8 @@ describe Ohai::System, "plugin packages" do
27
27
  end
28
28
  end
29
29
 
30
+ let(:format) { '${Package}\t${Version}\t${Architecture}\n' }
31
+
30
32
  let(:stdout) do
31
33
  File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output"))
32
34
  end
@@ -34,20 +36,26 @@ describe Ohai::System, "plugin packages" do
34
36
  before(:each) do
35
37
  allow(plugin).to receive(:collect_os).and_return(:linux)
36
38
  allow(plugin).to receive(:shell_out)
37
- .with("dpkg-query -W")
39
+ .with("dpkg-query -W -f='#{format}'")
38
40
  .and_return(mock_shell_out(0, stdout, ""))
39
41
  plugin.run
40
42
  end
41
43
 
42
44
  it "calls dpkg query" do
43
45
  expect(plugin).to receive(:shell_out)
44
- .with("dpkg-query -W")
46
+ .with("dpkg-query -W -f='#{format}'")
45
47
  .and_return(mock_shell_out(0, stdout, ""))
46
48
  plugin.run
47
49
  end
48
50
 
49
- it "gets packages and versions" do
50
- expect(plugin[:packages]["vim-common"][:version]).to eq("2:7.4.052-1ubuntu3")
51
+ it "gets packages and versions - arch" do
52
+ expect(plugin[:packages]["libc6"][:version]).to eq("2.19-18+deb8u3")
53
+ expect(plugin[:packages]["libc6"][:arch]).to eq("amd64")
54
+ end
55
+
56
+ it "gets packages and versions - noarch" do
57
+ expect(plugin[:packages]["tzdata"][:version]).to eq("2015g-0+deb8u1")
58
+ expect(plugin[:packages]["tzdata"][:arch]).to eq("all")
51
59
  end
52
60
  end
53
61
 
@@ -58,7 +66,7 @@ describe Ohai::System, "plugin packages" do
58
66
  end
59
67
  end
60
68
 
61
- let(:format) { Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n' }
69
+ let(:format) { '%{NAME}\t%|EPOCH?{%{EPOCH}}:{0}|\t%{VERSION}\t%{RELEASE}\t%{INSTALLTIME}\t%{ARCH}\n' }
62
70
 
63
71
  let(:stdout) do
64
72
  File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output"))
@@ -66,20 +74,31 @@ describe Ohai::System, "plugin packages" do
66
74
 
67
75
  before(:each) do
68
76
  allow(plugin).to receive(:collect_os).and_return(:linux)
69
- allow(plugin).to receive(:shell_out).with("rpm -qa --queryformat #{format}").and_return(mock_shell_out(0, stdout, ""))
77
+ allow(plugin).to receive(:shell_out).with("rpm -qa --qf '#{format}'").and_return(mock_shell_out(0, stdout, ""))
70
78
  plugin.run
71
79
  end
72
80
 
73
81
  it "calls rpm -qa" do
74
82
  expect(plugin).to receive(:shell_out)
75
- .with("rpm -qa --queryformat #{format}")
83
+ .with("rpm -qa --qf '#{format}'")
76
84
  .and_return(mock_shell_out(0, stdout, ""))
77
85
  plugin.run
78
86
  end
79
87
 
80
- it "gets packages and versions/release" do
81
- expect(plugin[:packages]["vim-common"][:version]).to eq("7.2.411")
82
- expect(plugin[:packages]["vim-common"][:release]).to eq("1.8.el6")
88
+ it "gets packages and versions/release - arch" do
89
+ expect(plugin[:packages]["glibc"][:version]).to eq("2.17")
90
+ expect(plugin[:packages]["glibc"][:release]).to eq("106.el7_2.6")
91
+ expect(plugin[:packages]["glibc"][:epoch]).to eq("0")
92
+ expect(plugin[:packages]["glibc"][:installdate]).to eq("1463486666")
93
+ expect(plugin[:packages]["glibc"][:arch]).to eq("x86_64")
94
+ end
95
+
96
+ it "gets packages and versions/release - noarch" do
97
+ expect(plugin[:packages]["tzdata"][:version]).to eq("2016d")
98
+ expect(plugin[:packages]["tzdata"][:release]).to eq("1.el7")
99
+ expect(plugin[:packages]["tzdata"][:epoch]).to eq("0")
100
+ expect(plugin[:packages]["tzdata"][:installdate]).to eq("1463486618")
101
+ expect(plugin[:packages]["tzdata"][:arch]).to eq("noarch")
83
102
  end
84
103
  end
85
104
 
@@ -193,6 +212,31 @@ describe Ohai::System, "plugin packages" do
193
212
  end
194
213
  end
195
214
 
215
+ context "on freebsd" do
216
+ let(:plugin) { get_plugin("packages") }
217
+
218
+ let(:stdout) do
219
+ File.read(File.join(SPEC_PLUGIN_PATH, "pkg-query.output"))
220
+ end
221
+
222
+ before(:each) do
223
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
224
+ allow(plugin).to receive(:shell_out).with('pkg query -a "%n %v"').and_return(mock_shell_out(0, stdout, ""))
225
+ plugin.run
226
+ end
227
+
228
+ it 'calls pkg query -a "%n %v"' do
229
+ expect(plugin).to receive(:shell_out)
230
+ .with('pkg query -a "%n %v"')
231
+ .and_return(mock_shell_out(0, stdout, ""))
232
+ plugin.run
233
+ end
234
+
235
+ it "gets packages with version" do
236
+ expect(plugin[:packages]["rubygem-chef"][:version]).to eq("12.6.0_1")
237
+ end
238
+ end
239
+
196
240
  context "on solaris2" do
197
241
  let(:plugin) { get_plugin("packages") }
198
242
 
@@ -0,0 +1,30 @@
1
+ #
2
+ # Author:: John Bellone (<jbellone@bloomberg.net>)
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
+
20
+ describe Ohai::System, "timezone plugin" do
21
+ before(:each) do
22
+ @plugin = get_plugin("timezone")
23
+ allow(Time).to receive_message_chain(:now, :getlocal, :zone) { "ZZZ" }
24
+ end
25
+
26
+ it "should get the local timezone" do
27
+ @plugin.run
28
+ expect(@plugin["timezone"]).to eq("ZZZ")
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.16.0
4
+ version: 8.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-12 00:00:00.000000000 Z
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -422,6 +422,7 @@ files:
422
422
  - lib/ohai/plugins/solaris2/virtualization.rb
423
423
  - lib/ohai/plugins/solaris2/zpools.rb
424
424
  - lib/ohai/plugins/ssh_host_key.rb
425
+ - lib/ohai/plugins/timezone.rb
425
426
  - lib/ohai/plugins/uptime.rb
426
427
  - lib/ohai/plugins/virtualbox.rb
427
428
  - lib/ohai/plugins/virtualization.rb
@@ -460,6 +461,7 @@ files:
460
461
  - spec/data/plugins/node.output
461
462
  - spec/data/plugins/perl.output
462
463
  - spec/data/plugins/php.output
464
+ - spec/data/plugins/pkg-query.output
463
465
  - spec/data/plugins/pkginfo.output
464
466
  - spec/data/plugins/pkglist.output
465
467
  - spec/data/plugins/python.output
@@ -593,6 +595,7 @@ files:
593
595
  - spec/unit/plugins/solaris2/virtualization_spec.rb
594
596
  - spec/unit/plugins/solaris2/zpools_spec.rb
595
597
  - spec/unit/plugins/ssh_host_keys_spec.rb
598
+ - spec/unit/plugins/timezone_spec.rb
596
599
  - spec/unit/plugins/virtualbox_spec.rb
597
600
  - spec/unit/plugins/vmware_spec.rb
598
601
  - spec/unit/plugins/windows/cpu_spec.rb