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
@@ -15,11 +15,13 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
+
require 'resolv'
|
19
|
+
|
18
20
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
19
21
|
|
20
22
|
describe Ohai::System, "plugin rackspace" do
|
21
23
|
before(:each) do
|
22
|
-
Resolv.
|
24
|
+
allow(Resolv).to receive(:getname).and_return("1.2.3.4")
|
23
25
|
@plugin = get_plugin("rackspace")
|
24
26
|
@plugin[:hostname] = "katie"
|
25
27
|
@plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> {
|
@@ -67,13 +69,13 @@ describe Ohai::System, "plugin rackspace" do
|
|
67
69
|
|
68
70
|
# We need a generic stub here for the later stubs with arguments to work
|
69
71
|
# Because, magic.
|
70
|
-
@plugin.
|
72
|
+
allow(@plugin).to receive(:shell_out).and_return(mock_shell_out(1, "", ""))
|
71
73
|
end
|
72
74
|
|
73
75
|
shared_examples_for "!rackspace" do
|
74
76
|
it "should NOT create rackspace" do
|
75
77
|
@plugin.run
|
76
|
-
@plugin[:rackspace].
|
78
|
+
expect(@plugin[:rackspace]).to be_nil
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -81,44 +83,44 @@ describe Ohai::System, "plugin rackspace" do
|
|
81
83
|
|
82
84
|
it "should create rackspace" do
|
83
85
|
@plugin.run
|
84
|
-
@plugin[:rackspace].
|
86
|
+
expect(@plugin[:rackspace]).not_to be_nil
|
85
87
|
end
|
86
88
|
|
87
89
|
it "should have all required attributes" do
|
88
90
|
@plugin.run
|
89
|
-
@plugin[:rackspace][:public_ip].
|
90
|
-
@plugin[:rackspace][:private_ip].
|
91
|
-
@plugin[:rackspace][:public_ipv4].
|
92
|
-
@plugin[:rackspace][:local_ipv4].
|
93
|
-
@plugin[:rackspace][:public_ipv6].
|
94
|
-
@plugin[:rackspace][:local_ipv6].
|
95
|
-
@plugin[:rackspace][:local_hostname].
|
96
|
-
@plugin[:rackspace][:public_hostname].
|
91
|
+
expect(@plugin[:rackspace][:public_ip]).not_to be_nil
|
92
|
+
expect(@plugin[:rackspace][:private_ip]).not_to be_nil
|
93
|
+
expect(@plugin[:rackspace][:public_ipv4]).not_to be_nil
|
94
|
+
expect(@plugin[:rackspace][:local_ipv4]).not_to be_nil
|
95
|
+
expect(@plugin[:rackspace][:public_ipv6]).not_to be_nil
|
96
|
+
expect(@plugin[:rackspace][:local_ipv6]).to be_nil
|
97
|
+
expect(@plugin[:rackspace][:local_hostname]).not_to be_nil
|
98
|
+
expect(@plugin[:rackspace][:public_hostname]).not_to be_nil
|
97
99
|
end
|
98
100
|
|
99
101
|
it "should resolve hostname if reverse dns is set" do
|
100
|
-
Resolv.
|
102
|
+
allow(Resolv).to receive(:getname).and_return("1234.resolved.com")
|
101
103
|
@plugin.run
|
102
|
-
@plugin[:rackspace][:public_hostname].
|
104
|
+
expect(@plugin[:rackspace][:public_hostname]).to eq("1234.resolved.com")
|
103
105
|
end
|
104
106
|
|
105
107
|
[Resolv::ResolvError, Resolv::ResolvTimeout].each do |exception|
|
106
108
|
it "should return ip address when reverse dns returns exception: #{exception}" do
|
107
|
-
Resolv.
|
109
|
+
allow(Resolv).to receive(:getname).and_raise(exception)
|
108
110
|
@plugin.run
|
109
|
-
@plugin[:rackspace][:public_hostname].
|
111
|
+
expect(@plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
113
115
|
it "should have correct values for all attributes" do
|
114
116
|
@plugin.run
|
115
|
-
@plugin[:rackspace][:public_ip].
|
116
|
-
@plugin[:rackspace][:private_ip].
|
117
|
-
@plugin[:rackspace][:public_ipv4].
|
118
|
-
@plugin[:rackspace][:local_ipv4].
|
119
|
-
@plugin[:rackspace][:public_ipv6].
|
120
|
-
@plugin[:rackspace][:local_hostname].
|
121
|
-
@plugin[:rackspace][:public_hostname].
|
117
|
+
expect(@plugin[:rackspace][:public_ip]).to eq("1.2.3.4")
|
118
|
+
expect(@plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
|
119
|
+
expect(@plugin[:rackspace][:public_ipv4]).to eq("1.2.3.4")
|
120
|
+
expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
|
121
|
+
expect(@plugin[:rackspace][:public_ipv6]).to eq("2a00:1a48:7805:111:e875:efaf:ff08:75")
|
122
|
+
expect(@plugin[:rackspace][:local_hostname]).to eq('katie')
|
123
|
+
expect(@plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
|
122
124
|
end
|
123
125
|
|
124
126
|
it "should capture region information" do
|
@@ -129,9 +131,9 @@ server_id = "21301000"
|
|
129
131
|
created_at = "2012-12-06T22:08:16Z"
|
130
132
|
region = "dfw"
|
131
133
|
OUT
|
132
|
-
@plugin.
|
134
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/provider_data").and_return(mock_shell_out(0, provider_data, ""))
|
133
135
|
@plugin.run
|
134
|
-
@plugin[:rackspace][:region].
|
136
|
+
expect(@plugin[:rackspace][:region]).to eq("dfw")
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
@@ -139,13 +141,13 @@ OUT
|
|
139
141
|
it_should_behave_like "rackspace"
|
140
142
|
|
141
143
|
before(:each) do
|
142
|
-
Resolv.
|
143
|
-
File.
|
144
|
-
File.
|
145
|
-
File.
|
146
|
-
File.
|
147
|
-
File.
|
148
|
-
File.
|
144
|
+
allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
|
145
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
|
146
|
+
allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
|
147
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
148
|
+
allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
|
149
|
+
allow(File).to receive(:exist?).with('/etc/resolv.conf').and_return(true)
|
150
|
+
allow(File).to receive(:read).with('/etc/resolv.conf').and_return('')
|
149
151
|
end
|
150
152
|
|
151
153
|
describe 'with no public interfaces (empty eth0)' do
|
@@ -157,22 +159,22 @@ OUT
|
|
157
159
|
it "should have all required attributes" do
|
158
160
|
@plugin.run
|
159
161
|
# expliticly nil
|
160
|
-
@plugin[:rackspace][:public_ip].
|
161
|
-
@plugin[:rackspace][:public_ipv4].
|
162
|
-
@plugin[:rackspace][:public_ipv6].
|
163
|
-
@plugin[:rackspace][:public_hostname].
|
162
|
+
expect(@plugin[:rackspace][:public_ip]).to be_nil
|
163
|
+
expect(@plugin[:rackspace][:public_ipv4]).to be_nil
|
164
|
+
expect(@plugin[:rackspace][:public_ipv6]).to be_nil
|
165
|
+
expect(@plugin[:rackspace][:public_hostname]).to be_nil
|
164
166
|
# per normal
|
165
|
-
@plugin[:rackspace][:private_ip].
|
166
|
-
@plugin[:rackspace][:local_ipv4].
|
167
|
-
@plugin[:rackspace][:local_ipv6].
|
168
|
-
@plugin[:rackspace][:local_hostname].
|
167
|
+
expect(@plugin[:rackspace][:private_ip]).not_to be_nil
|
168
|
+
expect(@plugin[:rackspace][:local_ipv4]).not_to be_nil
|
169
|
+
expect(@plugin[:rackspace][:local_ipv6]).to be_nil
|
170
|
+
expect(@plugin[:rackspace][:local_hostname]).not_to be_nil
|
169
171
|
end
|
170
172
|
|
171
173
|
it "should have correct values for all attributes" do
|
172
174
|
@plugin.run
|
173
|
-
@plugin[:rackspace][:private_ip].
|
174
|
-
@plugin[:rackspace][:local_ipv4].
|
175
|
-
@plugin[:rackspace][:local_hostname].
|
175
|
+
expect(@plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
|
176
|
+
expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
|
177
|
+
expect(@plugin[:rackspace][:local_hostname]).to eq('katie')
|
176
178
|
end
|
177
179
|
end
|
178
180
|
end
|
@@ -181,8 +183,8 @@ OUT
|
|
181
183
|
it_should_behave_like "!rackspace"
|
182
184
|
|
183
185
|
before(:each) do
|
184
|
-
File.
|
185
|
-
File.
|
186
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
|
187
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
|
186
188
|
end
|
187
189
|
end
|
188
190
|
|
@@ -190,13 +192,13 @@ OUT
|
|
190
192
|
it_should_behave_like "!rackspace"
|
191
193
|
|
192
194
|
before(:each) do
|
193
|
-
File.
|
194
|
-
File.
|
195
|
-
File.
|
196
|
-
File.
|
195
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
|
196
|
+
allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
|
197
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
|
198
|
+
allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
|
197
199
|
|
198
|
-
File.
|
199
|
-
File.
|
200
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
|
201
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
@@ -205,7 +207,7 @@ OUT
|
|
205
207
|
|
206
208
|
before(:each) do
|
207
209
|
stdout = "Rackspace\n"
|
208
|
-
@plugin.
|
210
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
209
211
|
end
|
210
212
|
end
|
211
213
|
|
@@ -214,26 +216,26 @@ OUT
|
|
214
216
|
|
215
217
|
before(:each) do
|
216
218
|
stdout = "cumulonimbus\n"
|
217
|
-
@plugin.
|
219
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
218
220
|
end
|
219
221
|
end
|
220
222
|
|
221
223
|
describe "does not have private networks" do
|
222
224
|
before do
|
223
225
|
stdout = 'BC764E20422B = "{"label": "public"}"\n'
|
224
|
-
@plugin.
|
226
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
|
225
227
|
stdout = '{"label": "public", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
|
226
|
-
@plugin.
|
228
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
|
227
229
|
|
228
|
-
File.
|
229
|
-
File.
|
230
|
-
File.
|
231
|
-
File.
|
230
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
|
231
|
+
allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
|
232
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
233
|
+
allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
|
232
234
|
end
|
233
235
|
|
234
236
|
it "should not have private_networks object" do
|
235
237
|
@plugin.run
|
236
|
-
@plugin[:rackspace][:private_networks].
|
238
|
+
expect(@plugin[:rackspace][:private_networks]).to eq([])
|
237
239
|
end
|
238
240
|
end
|
239
241
|
|
@@ -255,26 +257,26 @@ OUT
|
|
255
257
|
}
|
256
258
|
}}
|
257
259
|
stdout = 'BC764E20422B = "{"label": "private-network"}"\n'
|
258
|
-
@plugin.
|
260
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
|
259
261
|
stdout = '{"label": "private-network", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
|
260
|
-
@plugin.
|
262
|
+
allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
|
261
263
|
|
262
|
-
File.
|
263
|
-
File.
|
264
|
-
File.
|
265
|
-
File.
|
264
|
+
allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
|
265
|
+
allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
|
266
|
+
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
267
|
+
allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
|
266
268
|
end
|
267
269
|
|
268
270
|
it "should private_networks object" do
|
269
271
|
@plugin.run
|
270
|
-
@plugin[:rackspace][:private_networks].
|
272
|
+
expect(@plugin[:rackspace][:private_networks]).not_to be_nil
|
271
273
|
end
|
272
274
|
|
273
275
|
it "should have correct values for all attributes" do
|
274
276
|
@plugin.run
|
275
|
-
@plugin[:rackspace][:private_networks][0][:label].
|
276
|
-
@plugin[:rackspace][:private_networks][0][:broadcast].
|
277
|
-
@plugin[:rackspace][:private_networks][0][:mac].
|
277
|
+
expect(@plugin[:rackspace][:private_networks][0][:label]).to eq("private-network")
|
278
|
+
expect(@plugin[:rackspace][:private_networks][0][:broadcast]).to eq("9.10.11.255")
|
279
|
+
expect(@plugin[:rackspace][:private_networks][0][:mac]).to eq("BC:76:4E:20:42:2B")
|
278
280
|
end
|
279
281
|
|
280
282
|
end
|
@@ -30,49 +30,49 @@ describe Ohai::System, 'root_group' do
|
|
30
30
|
# apparently didn't apply to this api. we're just trying to fake
|
31
31
|
# Etc.getgrgid(Etc.getpwnam('root').gid).name
|
32
32
|
@pwnam = Object.new
|
33
|
-
@pwnam.
|
34
|
-
Etc.
|
33
|
+
allow(@pwnam).to receive(:gid).and_return(0)
|
34
|
+
allow(Etc).to receive(:getpwnam).with('root').and_return(@pwnam)
|
35
35
|
@grgid = Object.new
|
36
|
-
Etc.
|
36
|
+
allow(Etc).to receive(:getgrgid).and_return(@grgid)
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'with wheel group' do
|
40
40
|
before(:each) do
|
41
|
-
@grgid.
|
41
|
+
allow(@grgid).to receive(:name).and_return('wheel')
|
42
42
|
end
|
43
43
|
it 'should have a root_group of wheel' do
|
44
44
|
@plugin.run
|
45
|
-
@plugin[:root_group].
|
45
|
+
expect(@plugin[:root_group]).to eq('wheel')
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe 'with root group' do
|
50
50
|
before(:each) do
|
51
|
-
@grgid.
|
51
|
+
allow(@grgid).to receive(:name).and_return('root')
|
52
52
|
end
|
53
53
|
it 'should have a root_group of root' do
|
54
54
|
@plugin.run
|
55
|
-
@plugin[:root_group].
|
55
|
+
expect(@plugin[:root_group]).to eq('root')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe 'platform hpux with sys group' do
|
60
60
|
before(:each) do
|
61
|
-
@pwnam.
|
62
|
-
@grgid.
|
61
|
+
allow(@pwnam).to receive(:gid).and_return(3)
|
62
|
+
allow(@grgid).to receive(:name).and_return('sys')
|
63
63
|
end
|
64
64
|
it 'should have a root_group of sys' do
|
65
65
|
@plugin.run
|
66
|
-
@plugin[:root_group].
|
66
|
+
expect(@plugin[:root_group]).to eq('sys')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
describe 'platform aix with system group' do
|
70
70
|
before(:each) do
|
71
|
-
@grgid.
|
71
|
+
allow(@grgid).to receive(:name).and_return('system')
|
72
72
|
end
|
73
73
|
it 'should have a root_group of system' do
|
74
74
|
@plugin.run
|
75
|
-
@plugin[:root_group].
|
75
|
+
expect(@plugin[:root_group]).to eq('system')
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -80,9 +80,9 @@ describe Ohai::System, 'root_group' do
|
|
80
80
|
describe 'windows platform' do
|
81
81
|
it 'should return the group administrators' do
|
82
82
|
stub_const('::RbConfig::CONFIG', { 'host_os' => 'windows'} )
|
83
|
-
Ohai::Util::Win32::GroupHelper.
|
83
|
+
expect(Ohai::Util::Win32::GroupHelper).to receive(:windows_root_group_name).and_return('administrators')
|
84
84
|
@plugin.run
|
85
|
-
@plugin[:root_group].
|
85
|
+
expect(@plugin[:root_group]).to eq('administrators')
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -34,7 +34,7 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
34
34
|
before(:each) do
|
35
35
|
@ohai = Ohai::System.new
|
36
36
|
@plugin = get_plugin("sigar/network", @ohai)
|
37
|
-
@plugin.
|
37
|
+
allow(@plugin).to receive(:collect_os).and_return(:sigar)
|
38
38
|
@sigar = double("Sigar")
|
39
39
|
@net_info_conf={
|
40
40
|
:default_gateway => "192.168.1.254",
|
@@ -45,7 +45,7 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
45
45
|
}
|
46
46
|
net_info=double("Sigar::NetInfo")
|
47
47
|
@net_info_conf.each_pair do |k,v|
|
48
|
-
net_info.
|
48
|
+
allow(net_info).to receive(k).and_return(v)
|
49
49
|
end
|
50
50
|
@net_route_conf={
|
51
51
|
:destination => "192.168.1.0",
|
@@ -62,7 +62,7 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
62
62
|
}
|
63
63
|
net_route=double("Sigar::NetRoute")
|
64
64
|
@net_route_conf.each_pair do |k,v|
|
65
|
-
net_route.
|
65
|
+
allow(net_route).to receive(k).and_return(v)
|
66
66
|
end
|
67
67
|
@net_interface_conf={
|
68
68
|
:flags => 2115,
|
@@ -79,7 +79,7 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
79
79
|
}
|
80
80
|
net_conf=double("Sigar::NetConf")
|
81
81
|
@net_interface_conf.each_pair do |k,v|
|
82
|
-
net_conf.
|
82
|
+
allow(net_conf).to receive(k).and_return(v)
|
83
83
|
end
|
84
84
|
@net_interface_stat={
|
85
85
|
:rx_bytes=>1369035618,
|
@@ -99,7 +99,7 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
99
99
|
}
|
100
100
|
net_stat=double("Sigar::NetStat")
|
101
101
|
@net_interface_stat.each_pair do |k,v|
|
102
|
-
net_stat.
|
102
|
+
allow(net_stat).to receive(k).and_return(v)
|
103
103
|
end
|
104
104
|
@net_arp_conf={
|
105
105
|
:address => "192.168.1.5",
|
@@ -110,24 +110,24 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
110
110
|
}
|
111
111
|
net_arp=double("Sigar::NetArp")
|
112
112
|
@net_arp_conf.each_pair do |k,v|
|
113
|
-
net_arp.
|
113
|
+
allow(net_arp).to receive(k).and_return(v)
|
114
114
|
end
|
115
|
-
@sigar.
|
116
|
-
@sigar.
|
117
|
-
@sigar.
|
118
|
-
@sigar.
|
119
|
-
@sigar.
|
120
|
-
@sigar.
|
115
|
+
allow(@sigar).to receive(:fqdn).and_return("localhost.localdomain")
|
116
|
+
expect(@sigar).to receive(:net_info).once.times.and_return(net_info)
|
117
|
+
expect(@sigar).to receive(:net_interface_list).once.and_return(["eth0"])
|
118
|
+
expect(@sigar).to receive(:net_interface_config).with("eth0").and_return(net_conf)
|
119
|
+
expect(@sigar).to receive(:net_interface_stat).with("eth0").and_return(net_stat)
|
120
|
+
expect(@sigar).to receive(:arp_list).once.and_return([net_arp])
|
121
121
|
|
122
122
|
# Since we double net_route_list here, flags never gets called
|
123
|
-
@sigar.
|
124
|
-
Sigar.
|
123
|
+
expect(@sigar).to receive(:net_route_list).once.and_return([net_route])
|
124
|
+
expect(Sigar).to receive(:new).once.and_return(@sigar)
|
125
125
|
|
126
126
|
@plugin.run
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should set the routes" do
|
130
|
-
@plugin[:network][:interfaces][:eth0].
|
130
|
+
expect(@plugin[:network][:interfaces][:eth0]).to have_key(:route)
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should set the route details" do
|
@@ -137,8 +137,8 @@ describe Ohai::System, "Sigar network route plugin" do
|
|
137
137
|
v="U"
|
138
138
|
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k] = v
|
139
139
|
end
|
140
|
-
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"].
|
141
|
-
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k].
|
140
|
+
expect(@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"]).to have_key(k)
|
141
|
+
expect(@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k]).to eql(v)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -19,9 +19,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
19
19
|
describe Ohai::System, "Solaris2.X cpu plugin" do
|
20
20
|
before(:each) do
|
21
21
|
@plugin = get_plugin("solaris2/cpu")
|
22
|
-
@plugin.
|
23
|
-
@plugin.
|
24
|
-
@plugin.
|
22
|
+
allow(@plugin).to receive(:collect_os).and_return("solaris2")
|
23
|
+
allow(@plugin).to receive(:shell_out).with("psrinfo | wc -l").and_return(mock_shell_out(0, "32\n", ""))
|
24
|
+
allow(@plugin).to receive(:shell_out).with("psrinfo -p").and_return(mock_shell_out(0, "4\n", ""))
|
25
25
|
|
26
26
|
psrinfo_output = <<-END.strip
|
27
27
|
x86 (GenuineIntel 206D7 family 6 model 45 step 7 clock 2600 MHz)
|
@@ -29,54 +29,54 @@ describe Ohai::System, "Solaris2.X cpu plugin" do
|
|
29
29
|
x86 (CrazyTown 206D7 family 12 model 93 step 9 clock 2900 MHz)
|
30
30
|
Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz
|
31
31
|
END
|
32
|
-
@plugin.
|
32
|
+
allow(@plugin).to receive(:shell_out).with('psrinfo -v -p | grep Hz').and_return(mock_shell_out(0, psrinfo_output, ""))
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should get the total virtual processor count" do
|
36
36
|
@plugin.run
|
37
|
-
@plugin['cpu']['total'].
|
37
|
+
expect(@plugin['cpu']['total']).to eql(32)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should get the total processor count' do
|
41
41
|
@plugin.run
|
42
|
-
@plugin['cpu']['real'].
|
42
|
+
expect(@plugin['cpu']['real']).to eql(4)
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'per-cpu information' do
|
46
46
|
it "should include vendor_id for processors" do
|
47
47
|
@plugin.run
|
48
|
-
@plugin['cpu']['0']['vendor_id'].
|
49
|
-
@plugin['cpu']['1']['vendor_id'].
|
48
|
+
expect(@plugin['cpu']['0']['vendor_id']).to eql('GenuineIntel')
|
49
|
+
expect(@plugin['cpu']['1']['vendor_id']).to eql('CrazyTown')
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should include family for processors" do
|
53
53
|
@plugin.run
|
54
|
-
@plugin['cpu']["0"]["family"].
|
55
|
-
@plugin['cpu']["1"]["family"].
|
54
|
+
expect(@plugin['cpu']["0"]["family"]).to eql("6")
|
55
|
+
expect(@plugin['cpu']["1"]["family"]).to eql("12")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should include model for processors" do
|
59
59
|
@plugin.run
|
60
|
-
@plugin['cpu']["0"]["model"].
|
61
|
-
@plugin['cpu']["1"]["model"].
|
60
|
+
expect(@plugin['cpu']["0"]["model"]).to eql("45")
|
61
|
+
expect(@plugin['cpu']["1"]["model"]).to eql("93")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should include stepping for processors" do
|
65
65
|
@plugin.run
|
66
|
-
@plugin['cpu']["0"]["stepping"].
|
67
|
-
@plugin['cpu']["1"]["stepping"].
|
66
|
+
expect(@plugin['cpu']["0"]["stepping"]).to eql("7")
|
67
|
+
expect(@plugin['cpu']["1"]["stepping"]).to eql("9")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should include model name for processors" do
|
71
71
|
@plugin.run
|
72
|
-
@plugin['cpu']["0"]["model_name"].
|
73
|
-
@plugin['cpu']["1"]["model_name"].
|
72
|
+
expect(@plugin['cpu']["0"]["model_name"]).to eql("Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz")
|
73
|
+
expect(@plugin['cpu']["1"]["model_name"]).to eql("Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should include mhz name for processors" do
|
77
77
|
@plugin.run
|
78
|
-
@plugin['cpu']["0"]["mhz"].
|
79
|
-
@plugin['cpu']["1"]["mhz"].
|
78
|
+
expect(@plugin['cpu']["0"]["mhz"]).to eql("2600")
|
79
|
+
expect(@plugin['cpu']["1"]["mhz"]).to eql("2900")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|