ohai 7.6.0.rc.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +4 -4
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -12
- data/spec/unit/dsl/plugin_spec.rb +40 -40
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +16 -16
- data/spec/unit/mixin/cloudstack_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +6 -6
- data/spec/unit/mixin/ec2_metadata_spec.rb +8 -8
- data/spec/unit/plugins/aix/cpu_spec.rb +15 -15
- data/spec/unit/plugins/aix/filesystem_spec.rb +15 -15
- data/spec/unit/plugins/aix/hostname_spec.rb +3 -3
- data/spec/unit/plugins/aix/kernel_spec.rb +14 -14
- data/spec/unit/plugins/aix/network_spec.rb +43 -43
- data/spec/unit/plugins/aix/platform_spec.rb +5 -5
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -7
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/azure_spec.rb +18 -18
- data/spec/unit/plugins/c_spec.rb +52 -52
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +31 -31
- data/spec/unit/plugins/cloud_v2_spec.rb +33 -33
- data/spec/unit/plugins/cloudstack_spec.rb +6 -6
- data/spec/unit/plugins/darwin/cpu_spec.rb +19 -19
- data/spec/unit/plugins/darwin/hostname_spec.rb +6 -6
- data/spec/unit/plugins/darwin/kernel_spec.rb +14 -14
- data/spec/unit/plugins/darwin/memory_spec.rb +7 -7
- data/spec/unit/plugins/darwin/network_spec.rb +358 -358
- data/spec/unit/plugins/darwin/platform_spec.rb +10 -10
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +80 -80
- data/spec/unit/plugins/erlang_spec.rb +7 -7
- data/spec/unit/plugins/eucalyptus_spec.rb +28 -28
- data/spec/unit/plugins/fail_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/cpu_spec.rb +10 -10
- data/spec/unit/plugins/freebsd/hostname_spec.rb +4 -4
- data/spec/unit/plugins/freebsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/freebsd/os_spec.rb +3 -3
- data/spec/unit/plugins/freebsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +20 -20
- data/spec/unit/plugins/gce_spec.rb +18 -18
- data/spec/unit/plugins/go_spec.rb +5 -5
- data/spec/unit/plugins/groovy_spec.rb +5 -5
- data/spec/unit/plugins/hostname_spec.rb +24 -24
- data/spec/unit/plugins/init_package_spec.rb +5 -5
- data/spec/unit/plugins/ip_scopes_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +23 -23
- data/spec/unit/plugins/joyent_spec.rb +13 -13
- data/spec/unit/plugins/kernel_spec.rb +20 -20
- data/spec/unit/plugins/linode_spec.rb +18 -18
- data/spec/unit/plugins/linux/cpu_spec.rb +25 -25
- data/spec/unit/plugins/linux/filesystem_spec.rb +61 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +7 -7
- data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
- data/spec/unit/plugins/linux/lsb_spec.rb +23 -23
- data/spec/unit/plugins/linux/mdadm_spec.rb +11 -11
- data/spec/unit/plugins/linux/platform_spec.rb +167 -167
- data/spec/unit/plugins/linux/uptime_spec.rb +6 -6
- data/spec/unit/plugins/linux/virtualization_spec.rb +156 -156
- data/spec/unit/plugins/lua_spec.rb +5 -5
- data/spec/unit/plugins/mono_spec.rb +5 -5
- data/spec/unit/plugins/netbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/network_spec.rb +116 -116
- data/spec/unit/plugins/nodejs_spec.rb +5 -5
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +5 -5
- data/spec/unit/plugins/openbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/platform_spec.rb +4 -4
- data/spec/unit/plugins/openstack_spec.rb +8 -8
- data/spec/unit/plugins/os_spec.rb +5 -5
- data/spec/unit/plugins/passwd_spec.rb +13 -13
- data/spec/unit/plugins/perl_spec.rb +8 -8
- data/spec/unit/plugins/php_spec.rb +7 -7
- data/spec/unit/plugins/platform_spec.rb +9 -9
- data/spec/unit/plugins/powershell_spec.rb +10 -10
- data/spec/unit/plugins/rackspace_spec.rb +72 -70
- data/spec/unit/plugins/root_group_spec.rb +14 -14
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/sigar/network_route_spec.rb +17 -17
- data/spec/unit/plugins/solaris2/cpu_spec.rb +18 -18
- data/spec/unit/plugins/solaris2/hostname_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/kernel_spec.rb +8 -8
- data/spec/unit/plugins/solaris2/memory_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/network_spec.rb +13 -13
- data/spec/unit/plugins/solaris2/platform_spec.rb +14 -14
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +26 -26
- data/spec/unit/system_spec.rb +54 -54
- data/spec/unit/util/file_helper_spec.rb +2 -2
- metadata +50 -95
@@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
describe Ohai::System, "Solaris2.X hostname plugin" do
|
22
22
|
before(:each) do
|
23
23
|
@plugin = get_plugin("hostname")
|
24
|
-
@plugin.
|
25
|
-
@plugin.
|
26
|
-
@plugin.
|
24
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
25
|
+
allow(@plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
|
26
|
+
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
|
27
27
|
# Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ describe Ohai::System, "Solaris2.X hostname plugin" do
|
|
31
31
|
|
32
32
|
it "should get the fqdn value from #resolve_fqdn" do
|
33
33
|
@plugin.run
|
34
|
-
@plugin["fqdn"].
|
34
|
+
expect(@plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz")
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -135,10 +135,10 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
135
135
|
|
136
136
|
before(:each) do
|
137
137
|
@plugin = get_plugin("kernel")
|
138
|
-
@plugin.
|
139
|
-
@plugin.
|
140
|
-
@plugin.
|
141
|
-
@plugin.
|
138
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
139
|
+
allow(@plugin).to receive(:init_kernel).and_return({})
|
140
|
+
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
|
141
|
+
allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
|
142
142
|
end
|
143
143
|
|
144
144
|
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
|
@@ -146,15 +146,15 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
146
146
|
it "gives excruciating detail about kernel modules" do
|
147
147
|
@plugin.run
|
148
148
|
|
149
|
-
@plugin[:kernel][:modules].
|
149
|
+
expect(@plugin[:kernel][:modules]).to have(107).modules
|
150
150
|
|
151
151
|
# Teh daterz
|
152
152
|
# Id Loadaddr Size Info Rev Module Name
|
153
153
|
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
|
154
154
|
teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"}
|
155
|
-
@plugin[:kernel][:modules].keys.
|
156
|
-
@plugin[:kernel][:modules].keys.
|
157
|
-
@plugin[:kernel][:modules]["specfs"].
|
155
|
+
expect(@plugin[:kernel][:modules].keys).to include("specfs")
|
156
|
+
expect(@plugin[:kernel][:modules].keys).not_to include("Module")
|
157
|
+
expect(@plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz)
|
158
158
|
end
|
159
159
|
|
160
160
|
end
|
@@ -19,12 +19,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
19
19
|
describe Ohai::System, "Solaris2.X memory plugin" do
|
20
20
|
before(:each) do
|
21
21
|
@plugin = get_plugin("solaris2/memory")
|
22
|
-
@plugin.
|
23
|
-
@plugin.
|
22
|
+
allow(@plugin).to receive(:collect_os).and_return("solaris2")
|
23
|
+
allow(@plugin).to receive(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should get the total memory" do
|
27
27
|
@plugin.run
|
28
|
-
@plugin['memory']['total'].
|
28
|
+
expect(@plugin['memory']['total']).to eql(8194)
|
29
29
|
end
|
30
30
|
end
|
@@ -112,40 +112,40 @@ ROUTE_GET
|
|
112
112
|
@ifconfig_lines = @solaris_ifconfig.split("\n")
|
113
113
|
|
114
114
|
@plugin = get_plugin("solaris2/network")
|
115
|
-
@plugin.
|
115
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
116
116
|
@plugin[:network] = Mash.new
|
117
117
|
|
118
|
-
@plugin.
|
119
|
-
@plugin.
|
120
|
-
@plugin.
|
118
|
+
allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
119
|
+
allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
|
120
|
+
allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
|
121
121
|
end
|
122
122
|
|
123
123
|
describe "gathering IP layer address info" do
|
124
124
|
before do
|
125
125
|
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
|
126
|
-
@plugin.
|
127
|
-
@plugin.
|
126
|
+
allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
127
|
+
allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
|
128
128
|
@plugin.run
|
129
129
|
end
|
130
130
|
|
131
131
|
it "completes the run" do
|
132
|
-
@plugin['network'].
|
132
|
+
expect(@plugin['network']).not_to be_nil
|
133
133
|
end
|
134
134
|
|
135
135
|
it "detects the interfaces" do
|
136
|
-
@plugin['network']['interfaces'].keys.sort.
|
136
|
+
expect(@plugin['network']['interfaces'].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"])
|
137
137
|
end
|
138
138
|
|
139
139
|
it "detects the ip addresses of the interfaces" do
|
140
|
-
@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys.
|
140
|
+
expect(@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys).to include('72.2.115.28')
|
141
141
|
end
|
142
142
|
|
143
143
|
it "detects the encapsulation type of the interfaces" do
|
144
|
-
@plugin['network']['interfaces']['e1000g0:3']['encapsulation'].
|
144
|
+
expect(@plugin['network']['interfaces']['e1000g0:3']['encapsulation']).to eq('Ethernet')
|
145
145
|
end
|
146
146
|
|
147
147
|
it "detects the L3PROTECT network flag" do
|
148
|
-
@plugin['network']['interfaces']['net0']['flags'].
|
148
|
+
expect(@plugin['network']['interfaces']['net0']['flags']).to include('L3PROTECT')
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -154,12 +154,12 @@ ROUTE_GET
|
|
154
154
|
describe "setting the node's default IP address attribute" do
|
155
155
|
before do
|
156
156
|
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
|
157
|
-
@plugin.
|
157
|
+
allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
|
158
158
|
@plugin.run
|
159
159
|
end
|
160
160
|
|
161
161
|
it "finds the default interface by asking which iface has the default route" do
|
162
|
-
@plugin[:network][:default_interface].
|
162
|
+
expect(@plugin[:network][:default_interface]).to eq('e1000g0')
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
describe Ohai::System, "Solaris plugin platform" do
|
22
22
|
before(:each) do
|
23
23
|
@plugin = get_plugin("solaris2/platform")
|
24
|
-
@plugin.
|
25
|
-
@plugin.
|
24
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
25
|
+
allow(@plugin).to receive(:shell_out).with("/sbin/uname -X")
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "on SmartOS" do
|
@@ -41,26 +41,26 @@ Origin# = 1
|
|
41
41
|
NumCPU = 16
|
42
42
|
UNAME_X
|
43
43
|
|
44
|
-
File.
|
45
|
-
@plugin.
|
44
|
+
allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
|
45
|
+
allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
|
46
46
|
|
47
47
|
@release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
|
48
|
-
File.
|
48
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should run uname and set platform and build" do
|
52
52
|
@plugin.run
|
53
|
-
@plugin[:platform_build].
|
53
|
+
expect(@plugin[:platform_build]).to eq("joyent_20120130T201844Z")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should set the platform" do
|
57
57
|
@plugin.run
|
58
|
-
@plugin[:platform].
|
58
|
+
expect(@plugin[:platform]).to eq("smartos")
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should set the platform_version" do
|
62
62
|
@plugin.run
|
63
|
-
@plugin[:platform_version].
|
63
|
+
expect(@plugin[:platform_version]).to eq("5.11")
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
@@ -81,26 +81,26 @@ Origin# = 1
|
|
81
81
|
NumCPU = 1
|
82
82
|
UNAME_X
|
83
83
|
|
84
|
-
File.
|
85
|
-
@plugin.
|
84
|
+
allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
|
85
|
+
allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
|
86
86
|
|
87
87
|
@release = StringIO.new(" Oracle Solaris 11.1 X86\n")
|
88
|
-
File.
|
88
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should run uname and set platform and build" do
|
92
92
|
@plugin.run
|
93
|
-
@plugin[:platform_build].
|
93
|
+
expect(@plugin[:platform_build]).to eq("11.1")
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should set the platform" do
|
97
97
|
@plugin.run
|
98
|
-
@plugin[:platform].
|
98
|
+
expect(@plugin[:platform]).to eq("solaris2")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should set the platform_version" do
|
102
102
|
@plugin.run
|
103
|
-
@plugin[:platform_version].
|
103
|
+
expect(@plugin[:platform_version]).to eq("5.11")
|
104
104
|
end
|
105
105
|
|
106
106
|
end
|
@@ -27,47 +27,47 @@ The physical processor has 1 virtual processor (0)
|
|
27
27
|
PSRINFO_PV
|
28
28
|
|
29
29
|
@plugin = get_plugin("solaris2/virtualization")
|
30
|
-
@plugin.
|
30
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
31
31
|
|
32
32
|
# default to all requested Files not existing
|
33
|
-
File.
|
34
|
-
File.
|
35
|
-
File.
|
36
|
-
@plugin.
|
37
|
-
@plugin.
|
33
|
+
allow(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(false)
|
34
|
+
allow(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(false)
|
35
|
+
allow(File).to receive(:exists?).with("/usr/sbin/zoneadm").and_return(false)
|
36
|
+
allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
|
37
|
+
allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "when we are checking for kvm" do
|
41
41
|
before(:each) do
|
42
|
-
File.
|
42
|
+
expect(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should run psrinfo -pv" do
|
46
|
-
@plugin.
|
46
|
+
expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
|
47
47
|
@plugin.run
|
48
48
|
end
|
49
49
|
|
50
50
|
it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
|
51
|
-
@plugin.
|
51
|
+
allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
|
52
52
|
@plugin.run
|
53
|
-
@plugin[:virtualization][:system].
|
54
|
-
@plugin[:virtualization][:role].
|
53
|
+
expect(@plugin[:virtualization][:system]).to eq("kvm")
|
54
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should not set virtualization if kvm isn't there" do
|
58
|
-
@plugin.
|
58
|
+
expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
|
59
59
|
@plugin.run
|
60
|
-
@plugin[:virtualization].
|
60
|
+
expect(@plugin[:virtualization]).to eq({})
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "when we are parsing smbios" do
|
65
65
|
before(:each) do
|
66
|
-
File.
|
66
|
+
expect(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(true)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should run smbios" do
|
70
|
-
@plugin.
|
70
|
+
expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
|
71
71
|
@plugin.run
|
72
72
|
end
|
73
73
|
|
@@ -84,10 +84,10 @@ ID SIZE TYPE
|
|
84
84
|
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
85
85
|
Wake-Up Event: 0x6 (power switch)
|
86
86
|
MSVPC
|
87
|
-
@plugin.
|
87
|
+
allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
|
88
88
|
@plugin.run
|
89
|
-
@plugin[:virtualization][:system].
|
90
|
-
@plugin[:virtualization][:role].
|
89
|
+
expect(@plugin[:virtualization][:system]).to eq("virtualpc")
|
90
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should set vmware guest if smbios detects VMware Virtual Platform" do
|
@@ -103,22 +103,22 @@ ID SIZE TYPE
|
|
103
103
|
UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
|
104
104
|
Wake-Up Event: 0x6 (power switch)
|
105
105
|
VMWARE
|
106
|
-
@plugin.
|
106
|
+
allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
|
107
107
|
@plugin.run
|
108
|
-
@plugin[:virtualization][:system].
|
109
|
-
@plugin[:virtualization][:role].
|
108
|
+
expect(@plugin[:virtualization][:system]).to eq("vmware")
|
109
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should run smbios and not set virtualization if nothing is detected" do
|
113
|
-
@plugin.
|
113
|
+
expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
|
114
114
|
@plugin.run
|
115
|
-
@plugin[:virtualization].
|
115
|
+
expect(@plugin[:virtualization]).to eq({})
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should not set virtualization if no tests match" do
|
120
120
|
@plugin.run
|
121
|
-
@plugin[:virtualization].
|
121
|
+
expect(@plugin[:virtualization]).to eq({})
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -18,7 +18,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
18
18
|
describe Ohai::System, "Solaris 2.x zpool plugin" do
|
19
19
|
before(:each) do
|
20
20
|
@plugin = get_plugin("solaris2/zpools")
|
21
|
-
@plugin.
|
21
|
+
allow(@plugin).to receive(:collect_os).and_return(:solaris2)
|
22
22
|
|
23
23
|
@zpool_status_rpool = <<-EOSR
|
24
24
|
pool: rpool
|
@@ -62,9 +62,9 @@ EOST
|
|
62
62
|
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
|
63
63
|
tank 130T 4.91M 130T 0% 1.00x ONLINE 34
|
64
64
|
EOZO
|
65
|
-
@plugin.
|
66
|
-
@plugin.
|
67
|
-
@plugin.
|
65
|
+
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,""))
|
66
|
+
allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,""))
|
67
|
+
allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,""))
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "On Solaris2 Common" do
|
@@ -123,7 +123,7 @@ EOZO
|
|
123
123
|
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE -
|
124
124
|
tank 130T 4.91M 130T 0% 1.00x ONLINE -
|
125
125
|
EOZO
|
126
|
-
@plugin.
|
126
|
+
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,""))
|
127
127
|
end
|
128
128
|
|
129
129
|
it "Won't have a version number" do
|
@@ -140,7 +140,7 @@ EOZO
|
|
140
140
|
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
|
141
141
|
tank 130T 4.91M 130T 0% 1.00x ONLINE 34
|
142
142
|
EOZO
|
143
|
-
@plugin.
|
143
|
+
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,""))
|
144
144
|
end
|
145
145
|
|
146
146
|
it "Should have a version number" do
|
@@ -24,43 +24,43 @@ describe Ohai::System, "ssh_host_key plugin" do
|
|
24
24
|
@plugin = get_plugin("ssh_host_key")
|
25
25
|
@plugin[:keys] = Mash.new
|
26
26
|
|
27
|
-
File.
|
28
|
-
File.
|
29
|
-
File.
|
30
|
-
File.
|
31
|
-
File.
|
32
|
-
File.
|
27
|
+
allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(true)
|
28
|
+
allow(File).to receive(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
|
29
|
+
allow(File).to receive(:exists?).and_return(true)
|
30
|
+
allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
|
31
|
+
allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
|
32
|
+
allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
|
33
33
|
|
34
34
|
# Ensure we can still use IO.read
|
35
35
|
io_read = IO.method(:read)
|
36
|
-
IO.
|
36
|
+
allow(IO).to receive(:read) { |file| io_read.call(file) }
|
37
37
|
|
38
38
|
# Return fake public key files so we don't have to go digging for them in unit tests
|
39
39
|
@dsa_key = "ssh-dss AAAAB3NzaC1kc3MAAACBAMHlT02xN8kietxPfhcb98xHueTzKCOTz6dZlP/dmKILHrQOAExuSEeNiA2uvmhHNVQvs/cBsRiDxgSKux3ie2q8+MB6vHCiSpSkoPjrL75iT57YDilCB4/sytt6IJpj+H42wRDWTX0/QRybMHUvmnmEL0cwZXykSvrIum0BKB6hAAAAFQDsi6WUCClhtZIiTY9uh8eAre+SbQAAAIEAgNnuw0uEuqtcVif+AYd/bCZvL9FPqg7DrmTkamNEcVinhUGwsPGJTLJf+o5ens1X4RzQoi1R6Y6zCTL2FN/hZgINJNO0z9BN402wWrZmQd+Vb1U5DyDtveuvipqyQS+fm9neRwdLuv36Fc9f9nkZ7YHpkGPJp+yJpG4OoeREhwgAAACBAIf9kKLf2XiXnlByzlJ2Naa55d/hp2E059VKCRsBS++xFKYKvSqjnDQBFiMtAUhb8EdTyBGyalqOgqogDQVtwHfTZWZwqHAhry9aM06y92Eu/xSey4tWjKeknOsnRe640KC4zmKDBRTrjjkuAdrKPN9k3jl+OCc669JHlIfo6kqf oppa"
|
40
40
|
@rsa_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuhcVXV+nNapkyUC5p4TH1ymRxUjtMBKqYWmwyI29gVFnUNeHkKFHWon0KFeGJP2Rm8BfTiZa9ER9e8pRr4Nd+z1C1o0kVoxEEfB9tpSdTlpk1GG83D94l57fij8THRVIwuCEosViUlg1gDgC4SpxbqfdBkUN2qyf6JDOh7t2QpYh7berpDEWeBpb7BKdLEDT57uw7ijKzSNyaXqq8KkB9I+UFrRwpuos4W7ilX+PQ+mWLi2ZZJfTYZMxxVS+qJwiDtNxGCRwTOQZG03kI7eLBZG+igupr0uD4o6qeftPOr0kxgjoPU4nEKvYiGq8Rqd2vYrhiaJHLk9QB6xStQvS3Q== oppa"
|
41
41
|
@ecdsa_key = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBx8VgvxmHxs/sIn/ATh0iUcuz1I2Xc0e1ejXCGHBMZ98IE3FBt1ezlqCpNMcHVV2skQQ8vyLbKxzweyZuNSDU8= oppa"
|
42
|
-
IO.
|
43
|
-
IO.
|
44
|
-
IO.
|
42
|
+
allow(IO).to receive(:read).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(@dsa_key)
|
43
|
+
allow(IO).to receive(:read).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(@rsa_key)
|
44
|
+
allow(IO).to receive(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key)
|
45
45
|
end
|
46
46
|
|
47
47
|
shared_examples "loads keys" do
|
48
48
|
it "reads the key and sets the dsa attribute correctly" do
|
49
49
|
@plugin.run
|
50
|
-
@plugin[:keys][:ssh][:host_dsa_public].
|
51
|
-
@plugin[:keys][:ssh][:host_dsa_type].
|
50
|
+
expect(@plugin[:keys][:ssh][:host_dsa_public]).to eql(@dsa_key.split[1])
|
51
|
+
expect(@plugin[:keys][:ssh][:host_dsa_type]).to be_nil
|
52
52
|
end
|
53
53
|
|
54
54
|
it "reads the key and sets the rsa attribute correctly" do
|
55
55
|
@plugin.run
|
56
|
-
@plugin[:keys][:ssh][:host_rsa_public].
|
57
|
-
@plugin[:keys][:ssh][:host_rsa_type].
|
56
|
+
expect(@plugin[:keys][:ssh][:host_rsa_public]).to eql(@rsa_key.split[1])
|
57
|
+
expect(@plugin[:keys][:ssh][:host_rsa_type]).to be_nil
|
58
58
|
end
|
59
59
|
|
60
60
|
it "reads the key and sets the ecdsa attribute correctly" do
|
61
61
|
@plugin.run
|
62
|
-
@plugin[:keys][:ssh][:host_ecdsa_public].
|
63
|
-
@plugin[:keys][:ssh][:host_ecdsa_type].
|
62
|
+
expect(@plugin[:keys][:ssh][:host_ecdsa_public]).to eql(@ecdsa_key.split[1])
|
63
|
+
expect(@plugin[:keys][:ssh][:host_ecdsa_type]).to eql(@ecdsa_key.split[0])
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -93,8 +93,8 @@ EOS
|
|
93
93
|
nil
|
94
94
|
end
|
95
95
|
before do
|
96
|
-
File.
|
97
|
-
File.
|
96
|
+
allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(false)
|
97
|
+
allow(File).to receive(:exists?).with("/etc/sshd_config").and_return(false)
|
98
98
|
end
|
99
99
|
|
100
100
|
it_behaves_like "loads keys"
|
data/spec/unit/runner_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
29
29
|
|
30
30
|
describe "when running an invalid plugin" do
|
31
31
|
it "should raise error" do
|
32
|
-
|
32
|
+
expect { @runner.run_plugin(double("Ohai::NotPlugin")) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -40,7 +40,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
40
40
|
|
41
41
|
describe "version 7" do
|
42
42
|
it "should call run_v7_plugin" do
|
43
|
-
@runner.
|
43
|
+
expect(@runner).to receive(:run_v7_plugin)
|
44
44
|
@runner.run_plugin(plugin)
|
45
45
|
end
|
46
46
|
|
@@ -48,7 +48,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
48
48
|
let(:has_run) { true }
|
49
49
|
|
50
50
|
it "should not run the plugin" do
|
51
|
-
plugin.
|
51
|
+
expect(plugin).not_to receive(:safe_run)
|
52
52
|
@runner.run_plugin(plugin)
|
53
53
|
end
|
54
54
|
end
|
@@ -58,14 +58,14 @@ describe Ohai::Runner, "run_plugin" do
|
|
58
58
|
let(:version) { :version6 }
|
59
59
|
|
60
60
|
it "should call run_v6_plugin" do
|
61
|
-
@runner.
|
61
|
+
expect(@runner).to receive(:run_v6_plugin)
|
62
62
|
@runner.run_plugin(plugin)
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "if the plugin has not run before" do
|
66
66
|
describe "if safe_run is not set" do
|
67
67
|
it "safe_run should be called" do
|
68
|
-
plugin.
|
68
|
+
expect(plugin).to receive(:safe_run)
|
69
69
|
@runner.run_plugin(plugin)
|
70
70
|
end
|
71
71
|
end
|
@@ -74,7 +74,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
74
74
|
let(:safe_run) { false }
|
75
75
|
|
76
76
|
it "run should be called" do
|
77
|
-
plugin.
|
77
|
+
expect(plugin).to receive(:run)
|
78
78
|
@runner.run_plugin(plugin)
|
79
79
|
end
|
80
80
|
end
|
@@ -84,7 +84,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
84
84
|
let(:has_run) { true }
|
85
85
|
|
86
86
|
it "should not run" do
|
87
|
-
plugin.
|
87
|
+
expect(plugin).not_to receive(:safe_run)
|
88
88
|
@runner.run_plugin(plugin)
|
89
89
|
end
|
90
90
|
|
@@ -95,7 +95,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
95
95
|
let(:version) { :versionBla }
|
96
96
|
|
97
97
|
it "should raise error" do
|
98
|
-
|
98
|
+
expect { @runner.run_plugin(plugin) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -113,13 +113,13 @@ describe Ohai::Runner, "run_plugin" do
|
|
113
113
|
|
114
114
|
it "should run the plugin" do
|
115
115
|
@runner.run_plugin(plugin)
|
116
|
-
plugin.has_run
|
116
|
+
expect(plugin.has_run?).to be true
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should add plugin data to Ohai::System.data" do
|
120
120
|
@runner.run_plugin(plugin)
|
121
|
-
@ohai.data.
|
122
|
-
@ohai.data[:thing].
|
121
|
+
expect(@ohai.data).to have_key(:thing)
|
122
|
+
expect(@ohai.data[:thing]).to eql({})
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -142,7 +142,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
142
142
|
|
143
143
|
it "should not run the plugin" do
|
144
144
|
expect{ @runner.run_plugin(@plugin) }.to raise_error
|
145
|
-
@plugin.has_run
|
145
|
+
expect(@plugin.has_run?).to be false
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -174,7 +174,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
174
174
|
it "should run the plugins" do
|
175
175
|
@runner.run_plugin(@plugin2)
|
176
176
|
@plugins.each do |plugin|
|
177
|
-
plugin.has_run
|
177
|
+
expect(plugin.has_run?).to be true
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
@@ -208,7 +208,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
208
208
|
it "should run the plugins" do
|
209
209
|
@runner.run_plugin(@plugin3)
|
210
210
|
@plugins.each do |plugin|
|
211
|
-
plugin.has_run
|
211
|
+
expect(plugin.has_run?).to be true
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -251,7 +251,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
251
251
|
it "should run the plugins" do
|
252
252
|
@runner.run_plugin(@plugin3)
|
253
253
|
@plugins.each do |plugin|
|
254
|
-
plugin.has_run
|
254
|
+
expect(plugin.has_run?).to be true
|
255
255
|
end
|
256
256
|
end
|
257
257
|
end
|
@@ -306,8 +306,8 @@ describe Ohai::Runner, "run_plugin" do
|
|
306
306
|
end
|
307
307
|
|
308
308
|
it "should raise Ohai::Exceptions::DependencyCycle" do
|
309
|
-
runner.
|
310
|
-
runner.
|
309
|
+
allow(runner).to receive(:fetch_plugins).with(["thing"]).and_return([@plugin1])
|
310
|
+
allow(runner).to receive(:fetch_plugins).with(["other"]).and_return([@plugin2])
|
311
311
|
expected_error_string = "Dependency cycle detected. Please refer to the following plugins: Thing, Other"
|
312
312
|
expect { runner.run_plugin(@plugin1) }.to raise_error(Ohai::Exceptions::DependencyCycle, expected_error_string)
|
313
313
|
end
|
@@ -346,11 +346,11 @@ describe Ohai::Runner, "run_plugin" do
|
|
346
346
|
@ohai.provides_map.set_providers_for(@pluginB, ["B"])
|
347
347
|
@ohai.provides_map.set_providers_for(@pluginC, ["C"])
|
348
348
|
|
349
|
-
Ohai::Log.
|
349
|
+
expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
|
350
350
|
@runner.run_plugin(@pluginA)
|
351
351
|
|
352
352
|
@plugins.each do |plugin|
|
353
|
-
plugin.has_run
|
353
|
+
expect(plugin.has_run?).to be true
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
@@ -359,11 +359,11 @@ describe Ohai::Runner, "run_plugin" do
|
|
359
359
|
@ohai.provides_map.set_providers_for(@pluginC, ["C"])
|
360
360
|
@ohai.provides_map.set_providers_for(@pluginB, ["B"])
|
361
361
|
|
362
|
-
Ohai::Log.
|
362
|
+
expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
|
363
363
|
@runner.run_plugin(@pluginA)
|
364
364
|
|
365
365
|
@plugins.each do |plugin|
|
366
|
-
plugin.has_run
|
366
|
+
expect(plugin.has_run?).to be true
|
367
367
|
end
|
368
368
|
end
|
369
369
|
end
|
@@ -382,7 +382,7 @@ describe Ohai::Runner, "fetch_plugins" do
|
|
382
382
|
@ohai.provides_map.set_providers_for(plugin, ["top/middle/bottom"])
|
383
383
|
|
384
384
|
dependency_providers = @runner.fetch_plugins(["top/middle/bottom"])
|
385
|
-
dependency_providers.
|
385
|
+
expect(dependency_providers).to eql([plugin])
|
386
386
|
end
|
387
387
|
|
388
388
|
describe "when the attribute is not provided by any plugin" do
|
@@ -390,7 +390,7 @@ describe Ohai::Runner, "fetch_plugins" do
|
|
390
390
|
it "should return the providers for the parent" do
|
391
391
|
plugin = Ohai::DSL::Plugin.new(@ohai.data)
|
392
392
|
@provides_map.set_providers_for(plugin, ["test/attribute"])
|
393
|
-
@runner.fetch_plugins(["test/attribute/too_far"]).
|
393
|
+
expect(@runner.fetch_plugins(["test/attribute/too_far"])).to eql([plugin])
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
@@ -405,7 +405,7 @@ describe Ohai::Runner, "fetch_plugins" do
|
|
405
405
|
it "should return unique providers" do
|
406
406
|
plugin = Ohai::DSL::Plugin.new(@ohai.data)
|
407
407
|
@provides_map.set_providers_for(plugin, ["test", "test/too_far/way_too_far"])
|
408
|
-
@runner.fetch_plugins(["test", "test/too_far/way_too_far"]).
|
408
|
+
expect(@runner.fetch_plugins(["test", "test/too_far/way_too_far"])).to eql([plugin])
|
409
409
|
end
|
410
410
|
end
|
411
411
|
|
@@ -448,7 +448,7 @@ describe Ohai::Runner, "#get_cycle" do
|
|
448
448
|
cycle_start = @plugin1
|
449
449
|
|
450
450
|
cycle_names = @runner.get_cycle(cycle, cycle_start)
|
451
|
-
cycle_names.
|
451
|
+
expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
|
452
452
|
end
|
453
453
|
|
454
454
|
it "should return the sources for only the plugins in the cycle, when there are plugins before the cycle begins" do
|
@@ -456,6 +456,6 @@ describe Ohai::Runner, "#get_cycle" do
|
|
456
456
|
cycle_start = @plugin1
|
457
457
|
|
458
458
|
cycle_names = @runner.get_cycle(cycle, cycle_start)
|
459
|
-
cycle_names.
|
459
|
+
expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
|
460
460
|
end
|
461
461
|
end
|