ohai 15.2.5 → 15.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai/application.rb +2 -2
- data/lib/ohai/mixin/dmi_decode.rb +4 -1
- data/lib/ohai/plugins/linux/sysctl.rb +38 -0
- data/lib/ohai/plugins/linux/virtualization.rb +11 -10
- data/lib/ohai/plugins/openstack.rb +8 -3
- data/lib/ohai/plugins/passwd.rb +4 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/application_spec.rb +5 -5
- data/spec/functional/loader_spec.rb +2 -2
- data/spec/functional/plugins/powershell_spec.rb +11 -5
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +3 -3
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -8
- data/spec/support/integration_helper.rb +3 -3
- data/spec/unit/application_spec.rb +5 -5
- data/spec/unit/dsl/plugin_spec.rb +8 -7
- data/spec/unit/mixin/command_spec.rb +2 -2
- data/spec/unit/mixin/dmi_decode.rb +8 -1
- data/spec/unit/plugins/abort_spec.rb +4 -4
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/aix/hostname_spec.rb +2 -2
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +5 -5
- data/spec/unit/plugins/aix/network_spec.rb +4 -1
- data/spec/unit/plugins/aix/platform_spec.rb +4 -4
- data/spec/unit/plugins/aix/uptime_spec.rb +3 -3
- data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/azure_spec.rb +8 -8
- data/spec/unit/plugins/bsd/filesystem_spec.rb +17 -16
- data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/c_spec.rb +6 -5
- data/spec/unit/plugins/chef_spec.rb +2 -2
- data/spec/unit/plugins/cloud_spec.rb +4 -4
- data/spec/unit/plugins/darwin/cpu_spec.rb +11 -11
- data/spec/unit/plugins/darwin/filesystem_spec.rb +14 -13
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -1
- data/spec/unit/plugins/darwin/hostname_spec.rb +3 -3
- data/spec/unit/plugins/darwin/kernel_spec.rb +5 -5
- data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
- data/spec/unit/plugins/darwin/network_spec.rb +3 -3
- data/spec/unit/plugins/darwin/platform_spec.rb +9 -9
- data/spec/unit/plugins/darwin/virtualization_spec.rb +10 -10
- data/spec/unit/plugins/digital_ocean_spec.rb +14 -12
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/docker_spec.rb +2 -2
- data/spec/unit/plugins/ec2_spec.rb +41 -30
- data/spec/unit/plugins/elixir_spec.rb +2 -2
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +17 -13
- data/spec/unit/plugins/fail_spec.rb +15 -15
- data/spec/unit/plugins/freebsd/cpu_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/platform_spec.rb +3 -3
- data/spec/unit/plugins/gce_spec.rb +9 -7
- data/spec/unit/plugins/go_spec.rb +2 -2
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +10 -10
- data/spec/unit/plugins/hostname_spec.rb +15 -14
- data/spec/unit/plugins/init_package_spec.rb +4 -4
- data/spec/unit/plugins/java_spec.rb +7 -3
- data/spec/unit/plugins/joyent_spec.rb +4 -4
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
- data/spec/unit/plugins/linux/cpu_spec.rb +9 -8
- data/spec/unit/plugins/linux/filesystem_spec.rb +36 -35
- data/spec/unit/plugins/linux/fips_spec.rb +7 -5
- data/spec/unit/plugins/linux/hostname_spec.rb +4 -4
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +3 -3
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
- data/spec/unit/plugins/linux/machineid_spec.rb +3 -3
- data/spec/unit/plugins/linux/mdadm_spec.rb +13 -13
- data/spec/unit/plugins/linux/memory_spec.rb +39 -39
- data/spec/unit/plugins/linux/network_spec.rb +20 -19
- data/spec/unit/plugins/linux/platform_spec.rb +60 -57
- data/spec/unit/plugins/linux/sessions_spec.rb +3 -3
- data/spec/unit/plugins/linux/sysctl_spec.rb +53 -0
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +3 -3
- data/spec/unit/plugins/linux/uptime_spec.rb +5 -5
- data/spec/unit/plugins/linux/virtualization_spec.rb +4 -4
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/hostname_spec.rb +3 -3
- data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/netbsd/platform_spec.rb +3 -3
- data/spec/unit/plugins/network_spec.rb +3 -3
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +2 -2
- data/spec/unit/plugins/ohai_time_spec.rb +4 -4
- data/spec/unit/plugins/openbsd/hostname_spec.rb +3 -3
- data/spec/unit/plugins/openbsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/openbsd/platform_spec.rb +2 -2
- data/spec/unit/plugins/openstack_spec.rb +13 -8
- data/spec/unit/plugins/os_spec.rb +12 -12
- data/spec/unit/plugins/packages_spec.rb +10 -7
- data/spec/unit/plugins/passwd_spec.rb +18 -19
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +1 -1
- data/spec/unit/plugins/platform_spec.rb +7 -7
- data/spec/unit/plugins/powershell_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +25 -20
- data/spec/unit/plugins/root_group_spec.rb +14 -10
- data/spec/unit/plugins/ruby_spec.rb +2 -2
- data/spec/unit/plugins/rust_spec.rb +3 -3
- data/spec/unit/plugins/scala_spec.rb +2 -2
- data/spec/unit/plugins/scaleway_spec.rb +14 -12
- data/spec/unit/plugins/scsi_spec.rb +2 -1
- data/spec/unit/plugins/shard_spec.rb +18 -16
- data/spec/unit/plugins/solaris2/cpu_spec.rb +29 -29
- data/spec/unit/plugins/solaris2/dmi_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/filesystem.rb +3 -3
- data/spec/unit/plugins/solaris2/hostname_spec.rb +2 -2
- data/spec/unit/plugins/solaris2/kernel_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/memory_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/platform_spec.rb +9 -9
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +4 -1
- data/spec/unit/plugins/sysconf_spec.rb +2 -2
- data/spec/unit/plugins/timezone_spec.rb +2 -2
- data/spec/unit/plugins/virtualbox_spec.rb +10 -10
- data/spec/unit/plugins/vmware_spec.rb +4 -4
- data/spec/unit/plugins/windows/cpu_spec.rb +13 -13
- data/spec/unit/plugins/windows/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/windows/fips_spec.rb +7 -5
- data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +4 -4
- data/spec/unit/plugins/windows/network_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +2 -2
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/zpools_spec.rb +2 -0
- data/spec/unit/provides_map_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +29 -29
- data/spec/unit/system_spec.rb +13 -13
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +6 -6
- metadata +4 -2
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Joshua Miller <joshmiller@fb.com>
|
3
|
+
# Copyright:: Copyright (c) 2019 Facebook
|
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_relative "../../../spec_helper.rb"
|
20
|
+
|
21
|
+
describe Ohai::System, "sysctl plugin", :unix_only do
|
22
|
+
let(:plugin) { get_plugin("linux/sysctl") }
|
23
|
+
|
24
|
+
it "should populate sysctl if sysctl is found" do
|
25
|
+
sysctl_out = <<-SYSCTL_OUT
|
26
|
+
vm.nr_overcommit_hugepages = 0
|
27
|
+
vm.numa_stat = 1
|
28
|
+
vm.numa_zonelist_order = Node
|
29
|
+
vm.oom_dump_tasks = 1
|
30
|
+
vm.oom_kill_allocating_task = 0
|
31
|
+
vm.overcommit_kbytes = 0
|
32
|
+
SYSCTL_OUT
|
33
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
34
|
+
allow(plugin).to receive(:which).with("sysctl").and_return("/usr/sbin/sysctl")
|
35
|
+
allow(plugin).to receive(:shell_out).with("/usr/sbin/sysctl -a").and_return(mock_shell_out(0, sysctl_out, ""))
|
36
|
+
plugin.run
|
37
|
+
expect(plugin[:sysctl].to_hash).to eq({
|
38
|
+
"vm.nr_overcommit_hugepages" => "0",
|
39
|
+
"vm.numa_stat" => "1",
|
40
|
+
"vm.numa_zonelist_order" => "Node",
|
41
|
+
"vm.oom_dump_tasks" => "1",
|
42
|
+
"vm.oom_kill_allocating_task" => "0",
|
43
|
+
"vm.overcommit_kbytes" => "0",
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not populate sysctl if sysctl is not found" do
|
48
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
49
|
+
allow(plugin).to receive(:which).with("sysctl").and_return(false)
|
50
|
+
plugin.run
|
51
|
+
expect(plugin[:sysctl]).to be(nil)
|
52
|
+
end
|
53
|
+
end
|
@@ -21,11 +21,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
|
|
21
21
|
describe Ohai::System, "Linux systemd paths plugin" do
|
22
22
|
let(:plugin) { get_plugin("linux/systemd_paths") }
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "populates systemd_paths if systemd-path is found" do
|
29
29
|
systemd_path_out = <<~SYSTEMD_PATH_OUT
|
30
30
|
temporary: /tmp
|
31
31
|
temporary-large: /var/tmp
|
@@ -114,7 +114,7 @@ describe Ohai::System, "Linux systemd paths plugin" do
|
|
114
114
|
})
|
115
115
|
end
|
116
116
|
|
117
|
-
it "
|
117
|
+
it "does not populate systemd paths if systemd-path is not found" do
|
118
118
|
allow(plugin).to receive(:which).with("systemd-path").and_return(false)
|
119
119
|
plugin.run
|
120
120
|
expect(plugin[:systemd_paths]).to be(nil)
|
@@ -19,29 +19,29 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux plugin uptime" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("uptime")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
@double_file = double("/proc/uptime", { gets: "18423 989" })
|
26
26
|
allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "sets uptime_seconds to uptime" do
|
30
30
|
@plugin.run
|
31
31
|
expect(@plugin[:uptime_seconds]).to eq(18423)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "sets uptime to a human readable date" do
|
35
35
|
@plugin.run
|
36
36
|
expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "sets idletime_seconds to uptime" do
|
40
40
|
@plugin.run
|
41
41
|
expect(@plugin[:idletime_seconds]).to eq(989)
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "sets idletime to a human readable date" do
|
45
45
|
@plugin.run
|
46
46
|
expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
|
47
47
|
end
|
@@ -21,7 +21,7 @@ require "spec_helper"
|
|
21
21
|
describe Ohai::System, "Linux virtualization platform" do
|
22
22
|
let(:plugin) { get_plugin("linux/virtualization") }
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
26
26
|
|
27
27
|
# default to all requested Files not existing
|
@@ -396,7 +396,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
396
396
|
end
|
397
397
|
|
398
398
|
context "/proc/self/cgroup only has / mounts" do
|
399
|
-
before
|
399
|
+
before do
|
400
400
|
self_cgroup = <<~CGROUP
|
401
401
|
8:blkio:/
|
402
402
|
7:net_cls:/
|
@@ -539,7 +539,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
539
539
|
|
540
540
|
# Relevant at least starting docker 1.6.2, kernel 4.0.5 & systemd 224-1.
|
541
541
|
# Doi not exactly know which software/version really matters here.
|
542
|
-
it "
|
542
|
+
it "sets docker guest if /proc/self/cgroup exists and there are /system.slice/docker-<hexadecimal> mounts (systemd managed cgroup)" do
|
543
543
|
self_cgroup = <<~CGROUP
|
544
544
|
8:devices:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope
|
545
545
|
7:cpuset:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope
|
@@ -577,7 +577,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
577
577
|
end
|
578
578
|
|
579
579
|
context "/proc/self/cgroup only has / mounts" do
|
580
|
-
before
|
580
|
+
before do
|
581
581
|
self_cgroup = <<~CGROUP
|
582
582
|
8:blkio:/
|
583
583
|
7:net_cls:/
|
@@ -24,7 +24,7 @@ describe Ohai::System, "plugin lua" do
|
|
24
24
|
|
25
25
|
let(:plugin) { get_plugin("lua") }
|
26
26
|
|
27
|
-
before
|
27
|
+
before do
|
28
28
|
plugin[:languages] = Mash.new
|
29
29
|
@message = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
|
30
30
|
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @message))
|
@@ -21,7 +21,7 @@ require "spec_helper"
|
|
21
21
|
describe Ohai::System, "plugin mono" do
|
22
22
|
let(:plugin) { get_plugin("mono") }
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
plugin[:languages] = Mash.new
|
26
26
|
@stdout = <<~OUT
|
27
27
|
Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "NetBSD hostname plugin" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("hostname")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
25
25
|
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
|
@@ -31,12 +31,12 @@ describe Ohai::System, "NetBSD hostname plugin" do
|
|
31
31
|
|
32
32
|
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "uses #resolve_fqdn to find the fqdn" do
|
35
35
|
@plugin.run
|
36
36
|
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "sets the domain to everything after the first dot of the fqdn" do
|
40
40
|
@plugin.run
|
41
41
|
expect(@plugin[:domain]).to eq("bethell")
|
42
42
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "NetBSD kernel plugin" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("kernel")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
25
25
|
allow(@plugin).to receive(:init_kernel).and_return({})
|
@@ -28,7 +28,7 @@ describe Ohai::System, "NetBSD kernel plugin" do
|
|
28
28
|
allow(@plugin).to receive(:shell_out).with((Ohai.abs_path( "/usr/bin/modstat" )).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "sets the kernel_os to the kernel_name value" do
|
32
32
|
@plugin.run
|
33
33
|
expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
|
34
34
|
end
|
@@ -19,19 +19,19 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "NetBSD plugin platform" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("netbsd/platform")
|
24
24
|
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
|
25
25
|
allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
26
26
|
allow(@plugin).to receive(:collect_os).and_return(:netbsd)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "sets platform to lowercased lsb[:id]" do
|
30
30
|
@plugin.run
|
31
31
|
expect(@plugin[:platform]).to eq("netbsd")
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "sets platform_version to lsb[:release]" do
|
35
35
|
@plugin.run
|
36
36
|
expect(@plugin[:platform_version]).to eq("4.5")
|
37
37
|
end
|
@@ -329,7 +329,7 @@ describe Ohai::System, "Network Plugin" do
|
|
329
329
|
}
|
330
330
|
|
331
331
|
describe "on linux" do
|
332
|
-
before
|
332
|
+
before do
|
333
333
|
@plugin = get_plugin("network")
|
334
334
|
@plugin["network"] = basic_data["linux"]["network"]
|
335
335
|
end
|
@@ -490,7 +490,7 @@ describe Ohai::System, "Network Plugin" do
|
|
490
490
|
expect(@plugin["ip6address"]).to be_nil
|
491
491
|
end
|
492
492
|
|
493
|
-
it "
|
493
|
+
it "warns about it" do
|
494
494
|
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
495
495
|
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
|
496
496
|
expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
|
@@ -853,7 +853,7 @@ describe Ohai::System, "Network Plugin" do
|
|
853
853
|
# specs using network plugin data for each mocked OS (freebsd,linux,windows)
|
854
854
|
basic_data.keys.sort.each do |os|
|
855
855
|
describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
|
856
|
-
before
|
856
|
+
before do
|
857
857
|
@plugin["network"] = basic_data[os]["network"]
|
858
858
|
end
|
859
859
|
|
@@ -24,7 +24,7 @@ describe Ohai::System, "plugin nodejs" do
|
|
24
24
|
|
25
25
|
let(:plugin) { get_plugin("nodejs") }
|
26
26
|
|
27
|
-
before
|
27
|
+
before do
|
28
28
|
plugin[:languages] = Mash.new
|
29
29
|
@stdout = "v0.8.11\n"
|
30
30
|
allow(plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
|
@@ -21,11 +21,11 @@
|
|
21
21
|
require "spec_helper"
|
22
22
|
|
23
23
|
describe Ohai::System, "plugin ohai" do
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
@plugin = get_plugin("ohai")
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "sets [:chef_packages][:ohai][:version] to the current version" do
|
29
29
|
@plugin.run
|
30
30
|
expect(@plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION)
|
31
31
|
end
|
@@ -19,23 +19,23 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "plugin ohai_time" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("ohai_time")
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "gets the current time" do
|
27
27
|
expect(Time).to receive(:now)
|
28
28
|
@plugin.run
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "turns the time into a floating point number" do
|
32
32
|
time = Time.now
|
33
33
|
expect(time).to receive(:to_f)
|
34
34
|
allow(Time).to receive(:now).and_return(time)
|
35
35
|
@plugin.run
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "sets ohai_time to the current time" do
|
39
39
|
time = Time.now
|
40
40
|
allow(Time).to receive(:now).and_return(time)
|
41
41
|
@plugin.run
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "OpenBSD hostname plugin" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("hostname")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
25
25
|
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
|
@@ -31,12 +31,12 @@ describe Ohai::System, "OpenBSD hostname plugin" do
|
|
31
31
|
|
32
32
|
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "uses #resolve_fqdn to find the fqdn" do
|
35
35
|
@plugin.run
|
36
36
|
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "sets the domain to everything after the first dot of the fqdn" do
|
40
40
|
@plugin.run
|
41
41
|
expect(@plugin[:domain]).to eq("bethell")
|
42
42
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "OpenBSD kernel plugin" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("kernel")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
25
25
|
allow(@plugin).to receive(:init_kernel).and_return({})
|
@@ -28,7 +28,7 @@ describe Ohai::System, "OpenBSD kernel plugin" do
|
|
28
28
|
allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "sets the kernel_os to the kernel_name value" do
|
32
32
|
@plugin.run
|
33
33
|
expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
|
34
34
|
end
|
@@ -19,14 +19,14 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "OpenBSD plugin platform" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("openbsd/platform")
|
24
24
|
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
|
25
25
|
allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
26
26
|
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "sets platform_version to lsb[:release]" do
|
30
30
|
@plugin.run
|
31
31
|
expect(@plugin[:platform_version]).to eq("4.5")
|
32
32
|
end
|
@@ -23,9 +23,10 @@ describe Ohai::System, "plugin openstack" do
|
|
23
23
|
let(:plugin) { get_plugin("openstack") }
|
24
24
|
let(:default_timeout) { 2 }
|
25
25
|
|
26
|
-
before
|
26
|
+
before do
|
27
|
+
PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
|
27
28
|
allow(plugin).to receive(:hint?).with("openstack").and_return(false)
|
28
|
-
plugin[:virtualization] = {
|
29
|
+
plugin[:virtualization] = { systems: {} }
|
29
30
|
end
|
30
31
|
|
31
32
|
context "when there is no relevant hint or virtualization data" do
|
@@ -35,17 +36,18 @@ describe Ohai::System, "plugin openstack" do
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
context "when virtualization data is Openstack" do
|
39
|
+
context "when virtualization data is Openstack", :unix_only do
|
39
40
|
context "and the metadata service is not available" do
|
40
41
|
before do
|
41
42
|
allow(plugin).to receive(:can_socket_connect?)
|
42
43
|
.with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
|
43
44
|
.and_return(false)
|
44
|
-
plugin[:virtualization] = {
|
45
|
+
plugin[:virtualization] = { systems: { openstack: "guest" } }
|
46
|
+
expect(Etc).to receive(:getpwnam).and_raise(ArgumentError)
|
45
47
|
plugin.run
|
46
48
|
end
|
47
49
|
|
48
|
-
it "sets
|
50
|
+
it "sets provider attribute to openstack" do
|
49
51
|
expect(plugin[:openstack][:provider]).to eq("openstack")
|
50
52
|
end
|
51
53
|
|
@@ -55,13 +57,14 @@ describe Ohai::System, "plugin openstack" do
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
context "when running on dreamhost" do
|
60
|
+
context "when running on dreamhost", :unix_only do
|
59
61
|
it "sets openstack provider attribute to dreamhost" do
|
60
62
|
plugin["etc"] = { "passwd" => { "dhc-user" => {} } }
|
61
63
|
allow(plugin).to receive(:can_socket_connect?)
|
62
64
|
.with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
|
63
65
|
.and_return(false)
|
64
|
-
plugin[:virtualization] = {
|
66
|
+
plugin[:virtualization] = { systems: { openstack: "guest" } }
|
67
|
+
expect(Etc).to receive(:getpwnam).and_return(PasswdEntry.new("dhc-user", 800, 800, "/var/www", "/bin/false", "The dreamhost user"))
|
65
68
|
plugin.run
|
66
69
|
expect(plugin[:openstack][:provider]).to eq("dreamhost")
|
67
70
|
end
|
@@ -86,9 +89,11 @@ describe Ohai::System, "plugin openstack" do
|
|
86
89
|
end
|
87
90
|
context "when timout was set" do
|
88
91
|
let(:override_timout) { 10 }
|
92
|
+
|
89
93
|
before do
|
90
94
|
Ohai::Config.ohai[:openstack_metadata_timeout] = override_timout
|
91
95
|
end
|
96
|
+
|
92
97
|
after do
|
93
98
|
Ohai::Config.ohai[:openstack_metadata_timeout] = nil
|
94
99
|
end
|
@@ -290,7 +295,7 @@ describe Ohai::System, "plugin openstack" do
|
|
290
295
|
allow(plugin).to receive(:can_socket_connect?)
|
291
296
|
.with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
|
292
297
|
.and_return(false)
|
293
|
-
plugin[:virtualization] = {
|
298
|
+
plugin[:virtualization] = { systems: { openstack: "guest" } }
|
294
299
|
plugin.run
|
295
300
|
end
|
296
301
|
|
@@ -24,7 +24,7 @@ require "spec_helper"
|
|
24
24
|
ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG["host_os"]
|
25
25
|
|
26
26
|
describe Ohai::System, "plugin os" do
|
27
|
-
before
|
27
|
+
before do
|
28
28
|
@plugin = get_plugin("os")
|
29
29
|
@plugin[:kernel] = Mash.new
|
30
30
|
@plugin[:kernel][:release] = "kings of leon"
|
@@ -34,28 +34,28 @@ describe Ohai::System, "plugin os" do
|
|
34
34
|
::RbConfig::CONFIG["host_os"] = ORIGINAL_CONFIG_HOST_OS
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "sets os_version to kernel_release" do
|
38
38
|
@plugin.run
|
39
39
|
expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release])
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "on linux" do
|
43
|
-
before
|
43
|
+
before do
|
44
44
|
::RbConfig::CONFIG["host_os"] = "linux"
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "sets the os to linux" do
|
48
48
|
@plugin.run
|
49
49
|
expect(@plugin[:os]).to eq("linux")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "on darwin" do
|
54
|
-
before
|
54
|
+
before do
|
55
55
|
::RbConfig::CONFIG["host_os"] = "darwin10.0"
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "sets the os to darwin" do
|
59
59
|
@plugin.run
|
60
60
|
expect(@plugin[:os]).to eq("darwin")
|
61
61
|
end
|
@@ -73,30 +73,30 @@ describe Ohai::System, "plugin os" do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
describe "on AIX" do
|
76
|
-
before
|
76
|
+
before do
|
77
77
|
@plugin = get_plugin("os")
|
78
78
|
allow(@plugin).to receive(:collect_os).and_return(:aix)
|
79
79
|
allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
|
80
80
|
@plugin.run
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
84
|
-
expect(@plugin[:os]).to
|
83
|
+
it "sets the top-level os attribute" do
|
84
|
+
expect(@plugin[:os]).to be(:aix)
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "sets the top-level os_level attribute" do
|
88
88
|
expect(@plugin[:os_version]).to eql("7200-00-01-1543")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe "on FreeBSD" do
|
93
|
-
before
|
93
|
+
before do
|
94
94
|
@plugin = get_plugin("os")
|
95
95
|
allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
|
96
96
|
allow(@plugin).to receive(:collect_os).and_return(:freebsd)
|
97
97
|
end
|
98
98
|
|
99
|
-
it "
|
99
|
+
it "sets os_version to __FreeBSD_version" do
|
100
100
|
@plugin.run
|
101
101
|
expect(@plugin[:os_version]).to eq("902001")
|
102
102
|
end
|