ohai 8.17.1 → 8.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  #
2
2
  # Author:: Pavel Yudin (<pyudin@parallels.com>)
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
3
4
  # Copyright:: Copyright (c) 2015 Pavel Yudin
5
+ # Copyright:: Copyright (c) 2016 Chef Software, Inc.
4
6
  # License:: Apache License, Version 2.0
5
7
  #
6
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,9 +27,32 @@ describe Ohai::System, "Darwin virtualization platform" do
25
27
  allow(plugin).to receive(:collect_os).and_return(:darwin)
26
28
  allow(plugin).to receive(:prlctl_exists?).and_return(false)
27
29
  allow(plugin).to receive(:ioreg_exists?).and_return(false)
30
+ allow(plugin).to receive(:vboxmanage_exists?).and_return(false)
31
+ allow(plugin).to receive(:fusion_exists?).and_return(false)
28
32
  end
29
33
 
30
- describe "when we are checking for parallels" do
34
+ describe "when detecting OS X virtualization" do
35
+ it "should not set virtualization keys if no binaries are found" do
36
+ plugin.run
37
+ expect(plugin[:virtualization]).to eq({ "systems" => {} })
38
+ end
39
+
40
+ it "should set vmware host if /Applications/VMware\ Fusion.app exists" do
41
+ allow(plugin).to receive(:fusion_exists?).and_return(true)
42
+ plugin.run
43
+ expect(plugin[:virtualization][:system]).to eq("vmware")
44
+ expect(plugin[:virtualization][:role]).to eq("host")
45
+ expect(plugin[:virtualization][:systems][:vmware]).to eq("host")
46
+ end
47
+
48
+ it "should set vbox host if /usr/local/bin/VBoxManage exists" do
49
+ allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage")
50
+ plugin.run
51
+ expect(plugin[:virtualization][:system]).to eq("vbox")
52
+ expect(plugin[:virtualization][:role]).to eq("host")
53
+ expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
54
+ end
55
+
31
56
  it "should set parallels host if /usr/bin/prlctl exists" do
32
57
  allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl")
33
58
  plugin.run
@@ -36,13 +61,7 @@ describe Ohai::System, "Darwin virtualization platform" do
36
61
  expect(plugin[:virtualization][:systems][:parallels]).to eq("host")
37
62
  end
38
63
 
39
- it "should not set parallels host if /usr/bin/prlctl not exist" do
40
- allow(plugin).to receive(:prlctl_exists?).and_return(false)
41
- plugin.run
42
- expect(plugin[:virtualization]).to eq({ "systems" => {} })
43
- end
44
-
45
- it "should set parallels guest if /usr/sbin/ioreg exists and it's output contains pci1ab8,4000" do
64
+ it "should set parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do
46
65
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
47
66
  ioreg = <<-IOREG
48
67
  | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9>
@@ -76,7 +95,7 @@ describe Ohai::System, "Darwin virtualization platform" do
76
95
  expect(plugin[:virtualization][:systems][:parallels]).to eq("guest")
77
96
  end
78
97
 
79
- it "should not set parallels guest if /usr/sbin/ioreg exists and it's output not contain pci1ab8,4000" do
98
+ it "should not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do
80
99
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
81
100
  ioreg = <<-IOREG
82
101
  | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11>
@@ -50,9 +50,10 @@ describe Ohai::System, "Linux memory plugin" do
50
50
  and_yield("VmallocTotal: 34359738367 kB").
51
51
  and_yield("VmallocUsed: 276796 kB").
52
52
  and_yield("VmallocChunk: 34359461515 kB").
53
- and_yield("HugePages_Total: 0").
54
- and_yield("HugePages_Free: 0").
55
- and_yield("HugePages_Rsvd: 0").
53
+ and_yield("HugePages_Total: 11542").
54
+ and_yield("HugePages_Free: 11235").
55
+ and_yield("HugePages_Rsvd: 11226").
56
+ and_yield("HugePages_Surp: 0").
56
57
  and_yield("Hugepagesize: 2048 kB")
57
58
  allow(File).to receive(:open).with("/proc/meminfo").and_return(@double_file)
58
59
  end
@@ -197,4 +198,28 @@ describe Ohai::System, "Linux memory plugin" do
197
198
  expect(@plugin[:memory][:swap][:free]).to eql("14127356kB")
198
199
  end
199
200
 
201
+ it "should get total hugepages" do
202
+ @plugin.run
203
+ expect(@plugin[:memory][:hugepages][:total]).to eql("11542")
204
+ end
205
+
206
+ it "should get free hugepages" do
207
+ @plugin.run
208
+ expect(@plugin[:memory][:hugepages][:free]).to eql("11235")
209
+ end
210
+
211
+ it "should get reserved hugepages" do
212
+ @plugin.run
213
+ expect(@plugin[:memory][:hugepages][:reserved]).to eql("11226")
214
+ end
215
+
216
+ it "should get surplus hugepages" do
217
+ @plugin.run
218
+ expect(@plugin[:memory][:hugepages][:surplus]).to eql("0")
219
+ end
220
+
221
+ it "should get hugepage size" do
222
+ @plugin.run
223
+ expect(@plugin[:memory][:hugepage_size]).to eql("2048kB")
224
+ end
200
225
  end
@@ -21,70 +21,77 @@
21
21
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
22
22
 
23
23
  describe Ohai::System, "plugin php" do
24
+ let(:plugin) { get_plugin("php") }
24
25
 
25
26
  before(:each) do
26
- @plugin = get_plugin("php")
27
- @plugin[:languages] = Mash.new
27
+ plugin[:languages] = Mash.new
28
28
  @stdout = <<-OUT
29
29
  PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
30
30
  Copyright (c) 1997-2006 The PHP Group
31
31
  Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
32
32
  OUT
33
- allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
33
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
34
34
  end
35
35
 
36
- it "should get the php version from running php -V" do
37
- expect(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
38
- @plugin.run
36
+ it "gets the php version by running php -V" do
37
+ expect(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
38
+ plugin.run
39
39
  end
40
40
 
41
- it "should set languages[:php][:version]" do
42
- @plugin.run
43
- expect(@plugin.languages[:php][:version]).to eql("5.1.6")
41
+ it "sets languages[:php][:version] on PHP 5.X" do
42
+ plugin.run
43
+ expect(plugin.languages[:php][:version]).to eql("5.1.6")
44
44
  end
45
45
 
46
- it "should not set the languages[:php] tree up if php command fails" do
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
46
+ it "sets languages[:php][:version] on PHP 7.0" do
47
+ stdout = <<-OUT
48
+ PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
49
+ Copyright (c) 1997-2016 The PHP Group
50
+ Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
51
+ with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
51
52
  OUT
52
- allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
53
- @plugin.run
54
- expect(@plugin.languages).not_to have_key(:php)
53
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
54
+ plugin.run
55
+ expect(plugin.languages[:php][:version]).to eql("7.0.4-7ubuntu2.1")
55
56
  end
56
57
 
57
- it "should parse builddate even if it's suhosin patched" do
58
- @stdout = <<-OUT
58
+ it "does not set the languages[:php] tree up if php command fails" do
59
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, "", ""))
60
+ plugin.run
61
+ expect(plugin.languages).not_to have_key(:php)
62
+ end
63
+
64
+ it "parses builddate even if PHP is Suhosin patched" do
65
+ stdout = <<-OUT
59
66
  PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30)
60
67
  Copyright (c) 1997-2013 The PHP Group
61
68
  Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
62
69
  OUT
63
- allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
64
- @plugin.run
65
- expect(@plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
70
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
71
+ plugin.run
72
+ expect(plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
66
73
  end
67
74
 
68
- it "should not set zend_optcache_version if not compiled with opcache" do
69
- @stdout = <<-OUT
75
+ it "does not set zend_optcache_version if not compiled with opcache" do
76
+ stdout = <<-OUT
70
77
  PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
71
78
  Copyright (c) 1997-2006 The PHP Group
72
79
  Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
73
80
  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)
81
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
82
+ plugin.run
83
+ expect(plugin.languages[:php]).not_to have_key(:zend_opcache_version)
77
84
  end
78
85
 
79
- it "should parse zend_optcache_version if compiled with opcache" do
80
- @stdout = <<-OUT
86
+ it "sets zend_optcache_version if compiled with opcache" do
87
+ stdout = <<-OUT
81
88
  PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
82
89
  Copyright (c) 1997-2014 The PHP Group
83
90
  Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
84
91
  with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
85
92
  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")
93
+ allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
94
+ plugin.run
95
+ expect(plugin.languages[:php][:zend_opcache_version]).to eql("7.0.3")
89
96
  end
90
97
  end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Tim Smith (<tsmith@chef.io>)
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, "plugin shells" do
21
+ let(:plugin) { get_plugin("shells") }
22
+
23
+ # content from OS X 10.11
24
+ shell_file = ["# List of acceptable shells for chpass(1).\n",
25
+ "# Ftpd will not allow users to connect who are not using\n",
26
+ "# one of these shells.\n",
27
+ "\n",
28
+ "/bin/bash\n",
29
+ "/bin/csh\n",
30
+ "/bin/ksh\n",
31
+ "/bin/sh\n",
32
+ "/bin/tcsh\n",
33
+ "/bin/zsh\n"]
34
+
35
+ let(:shell_file_content) { shell_file }
36
+
37
+ it "does not set shells attribute if /etc/shells does not exist" do
38
+ allow(::File).to receive(:exist?).with("/etc/shells").and_return(false)
39
+ plugin.run
40
+ expect(plugin).not_to have_key(:shells)
41
+ end
42
+
43
+ it "sets shells to an array of shells if /etc/shells exists" do
44
+ allow(::File).to receive(:readlines).with("/etc/shells").and_return(shell_file_content)
45
+ allow(::File).to receive(:exist?).with("/etc/shells").and_return(true)
46
+ plugin.run
47
+ expect(plugin.shells).to match_array([
48
+ "/bin/bash",
49
+ "/bin/csh",
50
+ "/bin/ksh",
51
+ "/bin/sh",
52
+ "/bin/tcsh",
53
+ "/bin/zsh",
54
+ ])
55
+ end
56
+ 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.17.1
4
+ version: 8.18.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-06-30 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -331,6 +331,7 @@ files:
331
331
  - lib/ohai/plugins/darwin/cpu.rb
332
332
  - lib/ohai/plugins/darwin/filesystem.rb
333
333
  - lib/ohai/plugins/darwin/filesystem2.rb
334
+ - lib/ohai/plugins/darwin/hardware.rb
334
335
  - lib/ohai/plugins/darwin/memory.rb
335
336
  - lib/ohai/plugins/darwin/network.rb
336
337
  - lib/ohai/plugins/darwin/platform.rb
@@ -406,6 +407,7 @@ files:
406
407
  - lib/ohai/plugins/ruby.rb
407
408
  - lib/ohai/plugins/rust.rb
408
409
  - lib/ohai/plugins/scala.rb
410
+ - lib/ohai/plugins/shells.rb
409
411
  - lib/ohai/plugins/sigar/cpu.rb
410
412
  - lib/ohai/plugins/sigar/filesystem.rb
411
413
  - lib/ohai/plugins/sigar/memory.rb
@@ -511,6 +513,8 @@ files:
511
513
  - spec/unit/plugins/darwin/cpu_spec.rb
512
514
  - spec/unit/plugins/darwin/filesystem2_spec.rb
513
515
  - spec/unit/plugins/darwin/filesystem_spec.rb
516
+ - spec/unit/plugins/darwin/hardware_spec.rb
517
+ - spec/unit/plugins/darwin/hardware_system_profiler_output.rb
514
518
  - spec/unit/plugins/darwin/hostname_spec.rb
515
519
  - spec/unit/plugins/darwin/kernel_spec.rb
516
520
  - spec/unit/plugins/darwin/memory_spec.rb
@@ -582,6 +586,7 @@ files:
582
586
  - spec/unit/plugins/ruby_spec.rb
583
587
  - spec/unit/plugins/rust_spec.rb
584
588
  - spec/unit/plugins/scala_spec.rb
589
+ - spec/unit/plugins/shells_spec.rb
585
590
  - spec/unit/plugins/sigar/network_route_spec.rb
586
591
  - spec/unit/plugins/softlayer_spec.rb
587
592
  - spec/unit/plugins/solaris2/cpu_spec.rb
@@ -619,7 +624,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
619
624
  requirements:
620
625
  - - ">="
621
626
  - !ruby/object:Gem::Version
622
- version: 2.0.0
627
+ version: 2.1.0
623
628
  required_rubygems_version: !ruby/object:Gem::Requirement
624
629
  requirements:
625
630
  - - ">="
@@ -627,9 +632,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
627
632
  version: '0'
628
633
  requirements: []
629
634
  rubyforge_project:
630
- rubygems_version: 2.6.3
635
+ rubygems_version: 2.6.6
631
636
  signing_key:
632
637
  specification_version: 4
633
638
  summary: Ohai profiles your system and emits JSON
634
639
  test_files: []
635
- has_rdoc: