ohai 15.3.1 → 15.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
- data/lib/ohai/plugins/aix/network.rb +3 -8
- data/lib/ohai/plugins/darwin/network.rb +6 -4
- data/lib/ohai/plugins/filesystem.rb +166 -0
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +3 -162
- data/Rakefile +0 -42
- data/lib/ohai/plugins/windows/filesystem.rb +0 -147
- data/spec/data/plugins/dpkg-query.output +0 -4
- data/spec/data/plugins/lslpp.output +0 -50
- data/spec/data/plugins/pacman.output +0 -51
- data/spec/data/plugins/pkg-query.output +0 -58
- data/spec/data/plugins/pkginfo.output +0 -50
- data/spec/data/plugins/pkglist.output +0 -24
- data/spec/data/plugins/rpmquery.output +0 -7
- data/spec/functional/application_spec.rb +0 -107
- data/spec/functional/loader_spec.rb +0 -53
- data/spec/functional/plugins/powershell_spec.rb +0 -88
- data/spec/functional/plugins/root_group_spec.rb +0 -41
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
- data/spec/ohai_spec.rb +0 -27
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -124
- data/spec/support/integration_helper.rb +0 -61
- data/spec/support/platform_helpers.rb +0 -38
- data/spec/unit/application_spec.rb +0 -96
- data/spec/unit/config_spec.rb +0 -57
- data/spec/unit/dsl/plugin_spec.rb +0 -634
- data/spec/unit/hints_spec.rb +0 -65
- data/spec/unit/loader_spec.rb +0 -195
- data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
- data/spec/unit/mixin/command_spec.rb +0 -151
- data/spec/unit/mixin/dmi_decode.rb +0 -75
- data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
- data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
- data/spec/unit/plugin_config_spec.rb +0 -117
- data/spec/unit/plugins/abort_spec.rb +0 -69
- data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
- data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
- data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
- data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
- data/spec/unit/plugins/aix/memory_spec.rb +0 -49
- data/spec/unit/plugins/aix/network_spec.rb +0 -313
- data/spec/unit/plugins/aix/platform_spec.rb +0 -44
- data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
- data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
- data/spec/unit/plugins/azure_spec.rb +0 -243
- data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
- data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
- data/spec/unit/plugins/c_spec.rb +0 -341
- data/spec/unit/plugins/chef_spec.rb +0 -44
- data/spec/unit/plugins/cloud_spec.rb +0 -484
- data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
- data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
- data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
- data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
- data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
- data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
- data/spec/unit/plugins/darwin/network_spec.rb +0 -849
- data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
- data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
- data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
- data/spec/unit/plugins/dmi_spec.rb +0 -156
- data/spec/unit/plugins/docker_spec.rb +0 -100
- data/spec/unit/plugins/ec2_spec.rb +0 -452
- data/spec/unit/plugins/elixir_spec.rb +0 -55
- data/spec/unit/plugins/erlang_spec.rb +0 -71
- data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
- data/spec/unit/plugins/fail_spec.rb +0 -260
- data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
- data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/gce_spec.rb +0 -81
- data/spec/unit/plugins/go_spec.rb +0 -48
- data/spec/unit/plugins/groovy_spec.rb +0 -66
- data/spec/unit/plugins/haskell_spec.rb +0 -231
- data/spec/unit/plugins/hostname_spec.rb +0 -162
- data/spec/unit/plugins/init_package_spec.rb +0 -60
- data/spec/unit/plugins/java_spec.rb +0 -230
- data/spec/unit/plugins/joyent_spec.rb +0 -100
- data/spec/unit/plugins/kernel_spec.rb +0 -38
- data/spec/unit/plugins/linode_spec.rb +0 -135
- data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
- data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
- data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
- data/spec/unit/plugins/linux/fips_spec.rb +0 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
- data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
- data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
- data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
- data/spec/unit/plugins/linux/memory_spec.rb +0 -256
- data/spec/unit/plugins/linux/network_spec.rb +0 -1392
- data/spec/unit/plugins/linux/platform_spec.rb +0 -812
- data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
- data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
- data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
- data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
- data/spec/unit/plugins/lua_spec.rb +0 -60
- data/spec/unit/plugins/mono_spec.rb +0 -67
- data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
- data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/network_spec.rb +0 -1078
- data/spec/unit/plugins/nodejs_spec.rb +0 -55
- data/spec/unit/plugins/ohai_spec.rb +0 -32
- data/spec/unit/plugins/ohai_time_spec.rb +0 -44
- data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
- data/spec/unit/plugins/openstack_spec.rb +0 -311
- data/spec/unit/plugins/os_spec.rb +0 -115
- data/spec/unit/plugins/packages_spec.rb +0 -353
- data/spec/unit/plugins/passwd_spec.rb +0 -65
- data/spec/unit/plugins/perl_spec.rb +0 -62
- data/spec/unit/plugins/php_spec.rb +0 -97
- data/spec/unit/plugins/platform_spec.rb +0 -65
- data/spec/unit/plugins/powershell_spec.rb +0 -71
- data/spec/unit/plugins/python_spec.rb +0 -51
- data/spec/unit/plugins/rackspace_spec.rb +0 -350
- data/spec/unit/plugins/root_group_spec.rb +0 -90
- data/spec/unit/plugins/ruby_spec.rb +0 -60
- data/spec/unit/plugins/rust_spec.rb +0 -43
- data/spec/unit/plugins/scala_spec.rb +0 -58
- data/spec/unit/plugins/scaleway_spec.rb +0 -93
- data/spec/unit/plugins/scsi_spec.rb +0 -69
- data/spec/unit/plugins/shard_spec.rb +0 -121
- data/spec/unit/plugins/shells_spec.rb +0 -56
- data/spec/unit/plugins/softlayer_spec.rb +0 -60
- data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
- data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
- data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
- data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
- data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
- data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
- data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
- data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
- data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
- data/spec/unit/plugins/sysconf_spec.rb +0 -680
- data/spec/unit/plugins/timezone_spec.rb +0 -30
- data/spec/unit/plugins/vbox_host_spec.rb +0 -14
- data/spec/unit/plugins/virtualbox_spec.rb +0 -375
- data/spec/unit/plugins/vmware_spec.rb +0 -81
- data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
- data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
- data/spec/unit/plugins/windows/fips_spec.rb +0 -60
- data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
- data/spec/unit/plugins/windows/memory_spec.rb +0 -52
- data/spec/unit/plugins/windows/network_spec.rb +0 -137
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
- data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
- data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
- data/spec/unit/plugins/zpools_spec.rb +0 -244
- data/spec/unit/provides_map_spec.rb +0 -208
- data/spec/unit/runner_spec.rb +0 -422
- data/spec/unit/system_spec.rb +0 -416
- data/spec/unit/util/file_helper_spec.rb +0 -47
- data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,52 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
|
17
|
-
require "spec_helper"
|
18
|
-
|
19
|
-
describe Ohai::System, "Windows memory plugin", :windows_only do
|
20
|
-
before do
|
21
|
-
require "wmi-lite/wmi"
|
22
|
-
@plugin = get_plugin("windows/memory")
|
23
|
-
mock_os = {
|
24
|
-
"TotalVisibleMemorySize" => "10485760",
|
25
|
-
"FreePhysicalMemory" => "5242880",
|
26
|
-
"SizeStoredInPagingFiles" => "20971520",
|
27
|
-
"FreeSpaceInPagingFiles" => "15728640",
|
28
|
-
}
|
29
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(mock_os)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "gets total memory" do
|
33
|
-
@plugin.run
|
34
|
-
expect(@plugin["memory"]["total"]).to eql("10485760kB")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "gets free memory" do
|
38
|
-
@plugin.run
|
39
|
-
expect(@plugin["memory"]["free"]).to eql("5242880kB")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "gets total swap" do
|
43
|
-
@plugin.run
|
44
|
-
expect(@plugin["memory"]["swap"]["total"]).to eql("20971520kB")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "gets free memory" do
|
48
|
-
@plugin.run
|
49
|
-
expect(@plugin["memory"]["swap"]["free"]).to eql("15728640kB")
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Nimesh Pathi <nimesh.patni@msystechnologies.com>
|
3
|
-
# Copyright:: Copyright (c) 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
|
-
require "ipaddress"
|
21
|
-
|
22
|
-
describe Ohai::System, "Windows Network Plugin" do
|
23
|
-
let(:plugin) { get_plugin("windows/network") }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#interface_code" do
|
30
|
-
let(:interface_idx) { 1 }
|
31
|
-
let(:index) { 2 }
|
32
|
-
context "when interface index is given" do
|
33
|
-
it "Returns a valid string having hexadecimal interface_index" do
|
34
|
-
index = nil
|
35
|
-
expect(plugin.interface_code(interface_idx, index)).to eq("0x1")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
context "when interface index is not given" do
|
39
|
-
it "Returns a valid string having hexadecimal index" do
|
40
|
-
interface_idx = nil
|
41
|
-
expect(plugin.interface_code(interface_idx, index)).to eq("0x2")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#prefer_ipv4" do
|
47
|
-
let(:inet4) { "192.168.1.1" }
|
48
|
-
let(:inet6) { "fe80::2fe:c8ff:fef5:c88f" }
|
49
|
-
context "When Array is not passed" do
|
50
|
-
it "Returns nil" do
|
51
|
-
expect(plugin.prefer_ipv4("Invalid")).to be_nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
context "When no address is passed in Array" do
|
55
|
-
it "Returns nil" do
|
56
|
-
expect(plugin.prefer_ipv4([])).to be_nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
context "Preferred chances of IPV4 address" do
|
60
|
-
it "Returns the address when only IPV4 address is passed" do
|
61
|
-
expect(plugin.prefer_ipv4([inet4])).to eq(inet4)
|
62
|
-
end
|
63
|
-
it "Returns the address when IPV6 is also present at latter place" do
|
64
|
-
expect(plugin.prefer_ipv4([inet4, inet6])).to eq(inet4)
|
65
|
-
end
|
66
|
-
it "Returns the address when IPV6 is also present at former place" do
|
67
|
-
expect(plugin.prefer_ipv4([inet6, inet4])).to eq(inet4)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
context "Preferred chances of IPV6 address" do
|
71
|
-
it "Returns the address when only IPV6 address is passed" do
|
72
|
-
expect(plugin.prefer_ipv4([inet4])).to eq(inet4)
|
73
|
-
end
|
74
|
-
it "Does not return the address if IPV4 is also present at former place" do
|
75
|
-
expect(plugin.prefer_ipv4([inet4, inet6])).not_to eq(inet6)
|
76
|
-
end
|
77
|
-
it "Does not return the address if IPV4 is also present at latter place" do
|
78
|
-
expect(plugin.prefer_ipv4([inet6, inet4])).not_to eq(inet6)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#favored_default_route_windows" do
|
84
|
-
let(:interface1) do
|
85
|
-
{ "index" => 1,
|
86
|
-
"interface_index" => 1,
|
87
|
-
"ip_connection_metric" => 10,
|
88
|
-
"default_ip_gateway" => ["fe80::2fe:c8ff:fef5:c88f", "192.168.1.1"] }
|
89
|
-
end
|
90
|
-
let(:iface_config) { { 1 => interface1 } }
|
91
|
-
context "When a hash is not passed" do
|
92
|
-
it "Returns nil" do
|
93
|
-
expect(plugin.favored_default_route_windows("Invalid")).to be_nil
|
94
|
-
end
|
95
|
-
end
|
96
|
-
context "When no interface is passed in Hash" do
|
97
|
-
it "Returns nil" do
|
98
|
-
expect(plugin.favored_default_route_windows({})).to be_nil
|
99
|
-
end
|
100
|
-
end
|
101
|
-
context "When an interface configuration is passed" do
|
102
|
-
context "without default_ip_gateway" do
|
103
|
-
it "Returns nil" do
|
104
|
-
interface1["default_ip_gateway"] = nil
|
105
|
-
expect(plugin.favored_default_route_windows(iface_config)).to be_nil
|
106
|
-
end
|
107
|
-
end
|
108
|
-
context "with default_ip_gateway" do
|
109
|
-
it "Returns a hash with details" do
|
110
|
-
expect(plugin.favored_default_route_windows(iface_config)).to be_a(Hash)
|
111
|
-
expect(plugin.favored_default_route_windows(iface_config)).not_to be_empty
|
112
|
-
end
|
113
|
-
it "Returns the default_gateway in IPV4 format" do
|
114
|
-
expect(plugin.favored_default_route_windows(iface_config)).to include(default_ip_gateway: "192.168.1.1")
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
context "When multiple interfaces are passed" do
|
119
|
-
let(:interface2) do
|
120
|
-
{ "index" => 2,
|
121
|
-
"interface_index" => 3,
|
122
|
-
"ip_connection_metric" => 20,
|
123
|
-
"default_ip_gateway" => ["192.168.1.2"] }
|
124
|
-
end
|
125
|
-
let(:iface_config) do
|
126
|
-
{ 1 => interface1,
|
127
|
-
2 => interface2 }
|
128
|
-
end
|
129
|
-
it "Returns the default route as least metric interface" do
|
130
|
-
expect(plugin.favored_default_route_windows(iface_config)).to include(interface_index: 1)
|
131
|
-
end
|
132
|
-
it "Returns its default_gateway in IPV4 format" do
|
133
|
-
expect(plugin.favored_default_route_windows(iface_config)).to include(default_ip_gateway: "192.168.1.1")
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Stuart Preston (<stuart@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 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, "System Enclosure", :windows_only do
|
22
|
-
before do
|
23
|
-
require "wmi-lite/wmi"
|
24
|
-
@plugin = get_plugin("windows/system_enclosure")
|
25
|
-
manufacturer = double("WIN32OLE", name: "manufacturer", value: "My Fake Manufacturer")
|
26
|
-
serialnumber = double("WIN32OLE", name: "serialnumber", value: "1234123412341234")
|
27
|
-
property_map = [ manufacturer, serialnumber ]
|
28
|
-
|
29
|
-
wmi_ole_object = double( "WIN32OLE", properties_: property_map)
|
30
|
-
allow(wmi_ole_object).to receive(:invoke).with(manufacturer.name).and_return(manufacturer.value)
|
31
|
-
allow(wmi_ole_object).to receive(:invoke).with(serialnumber.name).and_return(serialnumber.value)
|
32
|
-
wmi_object = WmiLite::Wmi::Instance.new(wmi_ole_object)
|
33
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with(("Win32_SystemEnclosure")).and_return(wmi_object)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "returns the manufacturer" do
|
37
|
-
@plugin.run
|
38
|
-
expect(@plugin["system_enclosure"]["manufacturer"]).to eql("My Fake Manufacturer")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns a serial number" do
|
42
|
-
@plugin.run
|
43
|
-
expect(@plugin["system_enclosure"]["serialnumber"]).to eql("1234123412341234")
|
44
|
-
end
|
45
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Aliasgar Batterywala (<aliasgar.batterywala@msystechnologies.com>)
|
3
|
-
# Copyright:: Copyright (c) 2016 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, "Windows plugin uptime" do
|
22
|
-
|
23
|
-
let(:plugin) { get_plugin("uptime") }
|
24
|
-
let(:wmi) { double("wmi", { first_of: "" }) }
|
25
|
-
|
26
|
-
before do
|
27
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
|
28
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "uses Win32_OperatingSystem WMI class to fetch the system's uptime" do
|
32
|
-
expect(wmi).to receive(:first_of).with("Win32_OperatingSystem")
|
33
|
-
expect(Time).to receive(:new)
|
34
|
-
expect(Time).to receive(:parse)
|
35
|
-
expect(plugin).to receive(:seconds_to_human)
|
36
|
-
plugin.run
|
37
|
-
end
|
38
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Pavel Yudin (<pyudin@parallels.com>)
|
3
|
-
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2015 Pavel Yudin
|
5
|
-
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
|
6
|
-
# License:: Apache License, Version 2.0
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
#
|
20
|
-
|
21
|
-
require "spec_helper"
|
22
|
-
|
23
|
-
describe Ohai::System, "Windows virtualization platform" do
|
24
|
-
let(:plugin) { get_plugin("windows/virtualization") }
|
25
|
-
let(:wmi) { double("WmiLite::Wmi") }
|
26
|
-
|
27
|
-
before do
|
28
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
|
29
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "it sets virtualization guest status from Win32_ComputerSystemProduct data" do
|
33
|
-
it "system is vmware" do
|
34
|
-
allow(wmi).to receive(:first_of).with("Win32_ComputerSystemProduct").and_return( { "caption" => "Computer System Product",
|
35
|
-
"description" => "Computer System Product",
|
36
|
-
"identifyingnumber" => "ec2d6aad-f59b-a10d-5784-ca9b7ba4f727",
|
37
|
-
"name" => "HVM domU",
|
38
|
-
"skunumber" => nil,
|
39
|
-
"uuid" => "EC2D6AAD-F59B-A10D-5784-CA9B7BA4F727",
|
40
|
-
"vendor" => "Xen",
|
41
|
-
"version" => "4.2.amazon" } )
|
42
|
-
plugin.run
|
43
|
-
expect(plugin[:virtualization][:system]).to eq("xen")
|
44
|
-
expect(plugin[:virtualization][:role]).to eq("guest")
|
45
|
-
expect(plugin[:virtualization][:systems][:xen]).to eq("guest")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "when running on a hardware system" do
|
50
|
-
it "does not set virtualization attributes" do
|
51
|
-
allow(wmi).to receive(:first_of).with("Win32_ComputerSystemProduct").and_return({ "caption" => "Computer System Product",
|
52
|
-
"description" => "Computer System Product",
|
53
|
-
"identifyingnumber" => "0123456789",
|
54
|
-
"name" => "X10SLH-N6-ST031",
|
55
|
-
"skunumber" => nil,
|
56
|
-
"uuid" => "00000000-0000-0000-0000-0CC47A8F7618",
|
57
|
-
"vendor" => "Supermicro",
|
58
|
-
"version" => "0123456789" })
|
59
|
-
plugin.run
|
60
|
-
expect(plugin[:virtualization]).to eq("systems" => {})
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,244 +0,0 @@
|
|
1
|
-
# License:: Apache License, Version 2.0
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#
|
15
|
-
|
16
|
-
require "spec_helper"
|
17
|
-
|
18
|
-
describe Ohai::System, "zpools plugin" do
|
19
|
-
let(:plugin) { get_plugin("zpools") }
|
20
|
-
|
21
|
-
context "on Linux" do
|
22
|
-
let(:zpool_status_tank) do
|
23
|
-
<<-EOST
|
24
|
-
pool: tank
|
25
|
-
state: ONLINE
|
26
|
-
scan: scrub repaired 0 in 0h0m with 0 errors on Fri Jun 6 14:43:40 2014
|
27
|
-
config:
|
28
|
-
|
29
|
-
NAME STATE READ WRITE CKSUM
|
30
|
-
tank ONLINE 0 0 0
|
31
|
-
raidz2-0 ONLINE 0 0 0
|
32
|
-
sdc ONLINE 0 0 0
|
33
|
-
sdd ONLINE 0 0 0
|
34
|
-
sde ONLINE 0 0 0
|
35
|
-
sdf ONLINE 0 0 0
|
36
|
-
sdg ONLINE 0 0 0
|
37
|
-
sdh ONLINE 0 0 0
|
38
|
-
raidz2-1 ONLINE 0 0 0
|
39
|
-
sdi ONLINE 0 0 0
|
40
|
-
sdj ONLINE 0 0 0
|
41
|
-
sdk ONLINE 0 0 0
|
42
|
-
sdl ONLINE 0 0 0
|
43
|
-
sdm ONLINE 0 0 0
|
44
|
-
sdn ONLINE 0 0 0
|
45
|
-
EOST
|
46
|
-
end
|
47
|
-
let(:zpool_out) do
|
48
|
-
<<~EOZO
|
49
|
-
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE -
|
50
|
-
tank 130T 4.91M 130T 0% 1.00x ONLINE -
|
51
|
-
EOZO
|
52
|
-
end
|
53
|
-
let(:zpool_status_rpool) do
|
54
|
-
<<-EOSR
|
55
|
-
pool: rpool
|
56
|
-
state: ONLINE
|
57
|
-
scan: none requested
|
58
|
-
config:
|
59
|
-
|
60
|
-
NAME STATE READ WRITE CKSUM
|
61
|
-
rpool ONLINE 0 0 0
|
62
|
-
mirror-0 ONLINE 0 0 0
|
63
|
-
sda ONLINE 0 0 0
|
64
|
-
sdb ONLINE 0 0 0
|
65
|
-
|
66
|
-
errors: No known data errors
|
67
|
-
EOSR
|
68
|
-
end
|
69
|
-
|
70
|
-
before do
|
71
|
-
allow(plugin).to receive(:platform_family).and_return("rhel")
|
72
|
-
allow(plugin).to receive(:collect_os).and_return(:linux)
|
73
|
-
allow(plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, zpool_out, ""))
|
74
|
-
allow(plugin).to receive(:shell_out).with("zpool status rpool").and_return(mock_shell_out(0, zpool_status_rpool, ""))
|
75
|
-
allow(plugin).to receive(:shell_out).with("zpool status tank").and_return(mock_shell_out(0, zpool_status_tank, ""))
|
76
|
-
end
|
77
|
-
|
78
|
-
it "Has entries for both zpools" do
|
79
|
-
plugin.run
|
80
|
-
expect(plugin[:zpools][:rpool]).to be
|
81
|
-
expect(plugin[:zpools][:tank]).to be
|
82
|
-
end
|
83
|
-
|
84
|
-
it "Has the correct pool size" do
|
85
|
-
plugin.run
|
86
|
-
expect(plugin[:zpools][:rpool][:pool_size]).to match("109G")
|
87
|
-
expect(plugin[:zpools][:tank][:pool_size]).to match("130T")
|
88
|
-
end
|
89
|
-
|
90
|
-
it "Has the correct pool allocated size" do
|
91
|
-
plugin.run
|
92
|
-
expect(plugin[:zpools][:rpool][:pool_allocated]).to match("66.2G")
|
93
|
-
expect(plugin[:zpools][:tank][:pool_allocated]).to match("4.91M")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "Has the correct pool free size" do
|
97
|
-
plugin.run
|
98
|
-
expect(plugin[:zpools][:rpool][:pool_free]).to match("42.8G")
|
99
|
-
expect(plugin[:zpools][:tank][:pool_free]).to match("130T")
|
100
|
-
end
|
101
|
-
|
102
|
-
it "Has the correct capacity_used" do
|
103
|
-
plugin.run
|
104
|
-
expect(plugin[:zpools][:rpool][:capacity_used]).to match("60%")
|
105
|
-
expect(plugin[:zpools][:tank][:capacity_used]).to match("0%")
|
106
|
-
end
|
107
|
-
|
108
|
-
it "Has the correct dedup_factor" do
|
109
|
-
plugin.run
|
110
|
-
expect(plugin[:zpools][:rpool][:dedup_factor]).to match("1.00x")
|
111
|
-
expect(plugin[:zpools][:tank][:dedup_factor]).to match("1.00x")
|
112
|
-
end
|
113
|
-
|
114
|
-
it "Has the correct health" do
|
115
|
-
plugin.run
|
116
|
-
expect(plugin[:zpools][:rpool][:health]).to match("ONLINE")
|
117
|
-
expect(plugin[:zpools][:tank][:health]).to match("ONLINE")
|
118
|
-
end
|
119
|
-
|
120
|
-
it "Has the correct number of devices" do
|
121
|
-
plugin.run
|
122
|
-
expect(plugin[:zpools][:rpool][:devices].keys.size).to match(2)
|
123
|
-
expect(plugin[:zpools][:tank][:devices].keys.size).to match(12)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "Won't have a version number" do
|
127
|
-
plugin.run
|
128
|
-
expect(plugin[:zpools][:rpool][:zpool_version]).to be_nil
|
129
|
-
expect(plugin[:zpools][:tank][:zpool_version]).to be_nil
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "on Solaris2" do
|
134
|
-
let(:zpool_status_tank) do
|
135
|
-
<<~EOST
|
136
|
-
pool: tank
|
137
|
-
state: ONLINE
|
138
|
-
scan: scrub repaired 0 in 0h0m with 0 errors on Fri Jun 6 14:43:40 2014
|
139
|
-
config:
|
140
|
-
|
141
|
-
NAME STATE READ WRITE CKSUM
|
142
|
-
tank ONLINE 0 0 0
|
143
|
-
raidz2-0 ONLINE 0 0 0
|
144
|
-
c1t50014EE209D1DBA9d0 ONLINE 0 0 0
|
145
|
-
c1t50014EE20A0ECED2d0 ONLINE 0 0 0
|
146
|
-
c1t50014EE20A106BFFd0 ONLINE 0 0 0
|
147
|
-
c1t50014EE20A1423E8d0 ONLINE 0 0 0
|
148
|
-
c1t50014EE20A145447d0 ONLINE 0 0 0
|
149
|
-
c1t50014EE20A29EE56d0 ONLINE 0 0 0
|
150
|
-
raidz2-1 ONLINE 0 0 0
|
151
|
-
c1t50014EE20A2B984Cd0 ONLINE 0 0 0
|
152
|
-
c1t50014EE20A2BBC78d0 ONLINE 0 0 0
|
153
|
-
c1t50014EE20A2BDCA9d0 ONLINE 0 0 0
|
154
|
-
c1t50014EE25F697DC4d0 ONLINE 0 0 0
|
155
|
-
c1t50014EE25F698BECd0 ONLINE 0 0 0
|
156
|
-
c1t50014EE25F6998DAd0 ONLINE 0 0 0
|
157
|
-
EOST
|
158
|
-
end
|
159
|
-
let(:zpool_out) do
|
160
|
-
<<~EOZO
|
161
|
-
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
|
162
|
-
tank 130T 4.91M 130T 0% 1.00x ONLINE 34
|
163
|
-
EOZO
|
164
|
-
end
|
165
|
-
let(:zpool_status_rpool) do
|
166
|
-
<<~EOSR
|
167
|
-
pool: rpool
|
168
|
-
state: ONLINE
|
169
|
-
scan: resilvered 65.6G in 0h8m with 0 errors on Fri Jun 6 14:22:40 2014
|
170
|
-
config:
|
171
|
-
|
172
|
-
NAME STATE READ WRITE CKSUM
|
173
|
-
rpool ONLINE 0 0 0
|
174
|
-
mirror-0 ONLINE 0 0 0
|
175
|
-
c3t5d0s0 ONLINE 0 0 0
|
176
|
-
c3t4d0s0 ONLINE 0 0 0
|
177
|
-
|
178
|
-
errors: No known data errors
|
179
|
-
EOSR
|
180
|
-
end
|
181
|
-
|
182
|
-
before do
|
183
|
-
allow(plugin).to receive(:platform_family).and_return("solaris2")
|
184
|
-
allow(plugin).to receive(:collect_os).and_return(:solaris2)
|
185
|
-
allow(plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, zpool_out, ""))
|
186
|
-
allow(plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0, zpool_status_rpool, ""))
|
187
|
-
allow(plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0, zpool_status_tank, ""))
|
188
|
-
end
|
189
|
-
|
190
|
-
it "Has entries for both zpools" do
|
191
|
-
plugin.run
|
192
|
-
expect(plugin[:zpools][:rpool]).to be
|
193
|
-
expect(plugin[:zpools][:tank]).to be
|
194
|
-
end
|
195
|
-
|
196
|
-
it "Has the correct pool size" do
|
197
|
-
plugin.run
|
198
|
-
expect(plugin[:zpools][:rpool][:pool_size]).to match("109G")
|
199
|
-
expect(plugin[:zpools][:tank][:pool_size]).to match("130T")
|
200
|
-
end
|
201
|
-
|
202
|
-
it "Has the correct pool allocated size" do
|
203
|
-
plugin.run
|
204
|
-
expect(plugin[:zpools][:rpool][:pool_allocated]).to match("66.2G")
|
205
|
-
expect(plugin[:zpools][:tank][:pool_allocated]).to match("4.91M")
|
206
|
-
end
|
207
|
-
|
208
|
-
it "Has the correct pool free size" do
|
209
|
-
plugin.run
|
210
|
-
expect(plugin[:zpools][:rpool][:pool_free]).to match("42.8G")
|
211
|
-
expect(plugin[:zpools][:tank][:pool_free]).to match("130T")
|
212
|
-
end
|
213
|
-
|
214
|
-
it "Has the correct capacity_used" do
|
215
|
-
plugin.run
|
216
|
-
expect(plugin[:zpools][:rpool][:capacity_used]).to match("60%")
|
217
|
-
expect(plugin[:zpools][:tank][:capacity_used]).to match("0%")
|
218
|
-
end
|
219
|
-
|
220
|
-
it "Has the correct dedup_factor" do
|
221
|
-
plugin.run
|
222
|
-
expect(plugin[:zpools][:rpool][:dedup_factor]).to match("1.00x")
|
223
|
-
expect(plugin[:zpools][:tank][:dedup_factor]).to match("1.00x")
|
224
|
-
end
|
225
|
-
|
226
|
-
it "Has the correct health" do
|
227
|
-
plugin.run
|
228
|
-
expect(plugin[:zpools][:rpool][:health]).to match("ONLINE")
|
229
|
-
expect(plugin[:zpools][:tank][:health]).to match("ONLINE")
|
230
|
-
end
|
231
|
-
|
232
|
-
it "Has the correct number of devices" do
|
233
|
-
plugin.run
|
234
|
-
expect(plugin[:zpools][:rpool][:devices].keys.size).to match(2)
|
235
|
-
expect(plugin[:zpools][:tank][:devices].keys.size).to match(12)
|
236
|
-
end
|
237
|
-
|
238
|
-
it "Has a version number" do
|
239
|
-
plugin.run
|
240
|
-
expect(plugin[:zpools][:rpool][:zpool_version]).to match("34")
|
241
|
-
expect(plugin[:zpools][:tank][:zpool_version]).to match("34")
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|