ohai 13.3.0 → 13.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohai/mixin/azure_metadata.rb +53 -0
- data/lib/ohai/plugins/aix/uptime.rb +25 -10
- data/lib/ohai/plugins/azure.rb +68 -8
- data/lib/ohai/plugins/cloud.rb +4 -2
- data/lib/ohai/plugins/digital_ocean.rb +3 -3
- data/lib/ohai/plugins/dragonflybsd/os.rb +1 -2
- data/lib/ohai/plugins/ec2.rb +24 -16
- data/lib/ohai/plugins/eucalyptus.rb +4 -4
- data/lib/ohai/plugins/freebsd/os.rb +1 -2
- data/lib/ohai/plugins/gce.rb +3 -3
- data/lib/ohai/plugins/hostname.rb +3 -3
- data/lib/ohai/plugins/linux/cpu.rb +33 -2
- data/lib/ohai/plugins/linux/filesystem.rb +47 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +3 -4
- data/lib/ohai/plugins/linux/virtualization.rb +6 -2
- data/lib/ohai/plugins/network.rb +2 -3
- data/lib/ohai/plugins/openstack.rb +2 -3
- data/lib/ohai/plugins/os.rb +1 -2
- data/lib/ohai/plugins/packages.rb +28 -2
- data/lib/ohai/plugins/passwd.rb +1 -2
- data/lib/ohai/plugins/rackspace.rb +1 -2
- data/lib/ohai/plugins/shard.rb +1 -2
- data/lib/ohai/plugins/softlayer.rb +1 -2
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -2
- data/lib/ohai/plugins/uptime.rb +1 -2
- data/lib/ohai/version.rb +1 -1
- data/spec/data/plugins/pacman.output +51 -0
- data/spec/unit/mixin/azure_metadata_spec.rb +67 -0
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -9
- data/spec/unit/plugins/azure_spec.rb +81 -0
- data/spec/unit/plugins/cloud_spec.rb +37 -5
- data/spec/unit/plugins/ec2_spec.rb +34 -12
- data/spec/unit/plugins/linux/cpu_spec.rb +123 -87
- data/spec/unit/plugins/linux/filesystem_spec.rb +12 -0
- data/spec/unit/plugins/linux/virtualization_spec.rb +11 -0
- data/spec/unit/plugins/packages_spec.rb +37 -0
- metadata +6 -3
@@ -288,24 +288,56 @@ describe Ohai::System, "plugin cloud" do
|
|
288
288
|
describe "with Azure mash" do
|
289
289
|
before do
|
290
290
|
@plugin[:azure] = Mash.new
|
291
|
+
@plugin[:azure][:metadata] = {
|
292
|
+
"compute" =>
|
293
|
+
{
|
294
|
+
"location" => "westus",
|
295
|
+
"name" => "timtest",
|
296
|
+
"offer" => "UbuntuServer",
|
297
|
+
"osType" => "Linux",
|
298
|
+
"platformFaultDomain" => "0",
|
299
|
+
"platformUpdateDomain" => "0",
|
300
|
+
"publisher" => "Canonical",
|
301
|
+
"sku" => "16.04-LTS",
|
302
|
+
"version" => "16.04.201707270",
|
303
|
+
"vmId" => "f78151b3-da8b-4bd8-a592-d9ce8357e365",
|
304
|
+
"vmSize" => "Standard_DS2_v2",
|
305
|
+
},
|
306
|
+
"network" =>
|
307
|
+
{
|
308
|
+
"interfaces" =>
|
309
|
+
{
|
310
|
+
"000D3A37F080" =>
|
311
|
+
{
|
312
|
+
"mac" => "000D3A37F080",
|
313
|
+
"public_ipv6" => [],
|
314
|
+
"public_ipv4" => ["40.118.212.225"],
|
315
|
+
"local_ipv6" => [],
|
316
|
+
"local_ipv4" => ["10.0.1.6"],
|
317
|
+
},
|
318
|
+
},
|
319
|
+
"public_ipv4" => ["40.118.212.225"],
|
320
|
+
"local_ipv4" => ["10.0.1.6"],
|
321
|
+
"public_ipv6" => [],
|
322
|
+
"local_ipv6" => [],
|
323
|
+
},
|
324
|
+
}
|
291
325
|
end
|
292
326
|
|
293
327
|
it "populates cloud public ip" do
|
294
|
-
@plugin[:azure]["public_ip"] = "174.129.150.8"
|
295
328
|
@plugin.run
|
296
|
-
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(
|
329
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq("40.118.212.225")
|
297
330
|
end
|
298
331
|
|
299
332
|
it "doesn't populates cloud vm_name" do
|
300
|
-
@plugin[:azure]["vm_name"] = "linux-vm"
|
301
333
|
@plugin.run
|
302
|
-
expect(@plugin[:cloud][:vm_name]).not_to eq(
|
334
|
+
expect(@plugin[:cloud][:vm_name]).not_to eq("timtest")
|
303
335
|
end
|
304
336
|
|
305
337
|
it "populates cloud public_hostname" do
|
306
338
|
@plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net"
|
307
339
|
@plugin.run
|
308
|
-
expect(@plugin[:cloud][:public_hostname]).to eq(
|
340
|
+
expect(@plugin[:cloud][:public_hostname]).to eq("linux-vm-svc.cloudapp.net")
|
309
341
|
end
|
310
342
|
|
311
343
|
it "doesn't populate cloud public_ssh_port" do
|
@@ -23,14 +23,14 @@ require "base64"
|
|
23
23
|
|
24
24
|
describe Ohai::System, "plugin ec2" do
|
25
25
|
|
26
|
+
let(:plugin) { get_plugin("ec2") }
|
27
|
+
|
26
28
|
before(:each) do
|
27
29
|
allow(plugin).to receive(:hint?).with("ec2").and_return(false)
|
28
30
|
allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(false)
|
29
31
|
end
|
30
32
|
|
31
33
|
shared_examples_for "!ec2" do
|
32
|
-
let(:plugin) { get_plugin("ec2") }
|
33
|
-
|
34
34
|
it "DOESN'T attempt to fetch the ec2 metadata or set ec2 attribute" do
|
35
35
|
expect(plugin).not_to receive(:http_client)
|
36
36
|
expect(plugin[:ec2]).to be_nil
|
@@ -39,8 +39,6 @@ describe Ohai::System, "plugin ec2" do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
shared_examples_for "ec2" do
|
42
|
-
let(:plugin) { get_plugin("ec2") }
|
43
|
-
|
44
42
|
before(:each) do
|
45
43
|
@http_client = double("Net::HTTP client")
|
46
44
|
allow(plugin).to receive(:http_client).and_return(@http_client)
|
@@ -342,14 +340,6 @@ describe Ohai::System, "plugin ec2" do
|
|
342
340
|
end
|
343
341
|
end
|
344
342
|
|
345
|
-
describe "with amazon kernel data" do
|
346
|
-
it_behaves_like "ec2"
|
347
|
-
|
348
|
-
before(:each) do
|
349
|
-
plugin[:kernel] = { :os_info => { :organization => "Amazon.com" } }
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
343
|
describe "with EC2 Xen UUID" do
|
354
344
|
it_behaves_like "ec2"
|
355
345
|
|
@@ -368,6 +358,38 @@ describe Ohai::System, "plugin ec2" do
|
|
368
358
|
end
|
369
359
|
end
|
370
360
|
|
361
|
+
describe "with EC2 Identifying Number", :windows_only do
|
362
|
+
it_behaves_like "ec2"
|
363
|
+
|
364
|
+
before do
|
365
|
+
allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
|
366
|
+
{ "caption" => "Computer System Product",
|
367
|
+
"description" => "Computer System Product",
|
368
|
+
"identifyingnumber" => "ec2a355a-91cd-5fe8-bbfc-cc891d0bf9d6",
|
369
|
+
"name" => "HVM domU",
|
370
|
+
"skunumber" => nil,
|
371
|
+
"uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
|
372
|
+
"vendor" => "Xen",
|
373
|
+
"version" => "4.2.amazon" })
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
describe "without EC2 Identifying Number", :windows_only do
|
378
|
+
it_behaves_like "!ec2"
|
379
|
+
|
380
|
+
before do
|
381
|
+
allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
|
382
|
+
{ "caption" => "Computer System Product",
|
383
|
+
"description" => "Computer System Product",
|
384
|
+
"identifyingnumber" => "1234",
|
385
|
+
"name" => "HVM domU",
|
386
|
+
"skunumber" => nil,
|
387
|
+
"uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
|
388
|
+
"vendor" => "Xen",
|
389
|
+
"version" => "1.2.3" })
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
371
393
|
describe "with ec2 hint file" do
|
372
394
|
it_behaves_like "ec2"
|
373
395
|
|
@@ -79,30 +79,6 @@ end
|
|
79
79
|
describe Ohai::System, "General Linux cpu plugin" do
|
80
80
|
let(:plugin) { get_plugin("linux/cpu") }
|
81
81
|
|
82
|
-
let(:cpuinfo_contents) do
|
83
|
-
<<-EOF
|
84
|
-
processor : 0
|
85
|
-
vendor_id : GenuineIntel
|
86
|
-
cpu family : 6
|
87
|
-
model : 23
|
88
|
-
model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
|
89
|
-
stepping : 6
|
90
|
-
cpu MHz : 1968.770
|
91
|
-
cache size : 64 KB
|
92
|
-
fdiv_bug : no
|
93
|
-
hlt_bug : no
|
94
|
-
f00f_bug : no
|
95
|
-
coma_bug : no
|
96
|
-
fpu : yes
|
97
|
-
fpu_exception : yes
|
98
|
-
cpuid level : 10
|
99
|
-
wp : yes
|
100
|
-
flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov
|
101
|
-
bogomips : 2575.86
|
102
|
-
clflush size : 32
|
103
|
-
EOF
|
104
|
-
end
|
105
|
-
|
106
82
|
let(:tempfile_handle) do
|
107
83
|
tempfile = Tempfile.new("ohai-rspec-proc-cpuinfo")
|
108
84
|
tempfile.write cpuinfo_contents
|
@@ -124,81 +100,139 @@ clflush size : 32
|
|
124
100
|
end
|
125
101
|
end
|
126
102
|
|
127
|
-
|
103
|
+
context "with old kernel that doesn't include cores in /proc/cpuinfo" do
|
104
|
+
let(:cpuinfo_contents) do
|
105
|
+
<<-EOF
|
106
|
+
processor : 0
|
107
|
+
vendor_id : GenuineIntel
|
108
|
+
cpu family : 6
|
109
|
+
model : 23
|
110
|
+
model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
|
111
|
+
stepping : 6
|
112
|
+
cpu MHz : 1968.770
|
113
|
+
cache size : 64 KB
|
114
|
+
fdiv_bug : no
|
115
|
+
hlt_bug : no
|
116
|
+
f00f_bug : no
|
117
|
+
coma_bug : no
|
118
|
+
fpu : yes
|
119
|
+
fpu_exception : yes
|
120
|
+
cpuid level : 10
|
121
|
+
wp : yes
|
122
|
+
flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov
|
123
|
+
bogomips : 2575.86
|
124
|
+
clflush size : 32
|
125
|
+
EOF
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
let(:lscpu) do
|
129
|
+
<<-EOF
|
130
|
+
Architecture: x86_64
|
131
|
+
CPU op-mode(s): 32-bit, 64-bit
|
132
|
+
Byte Order: Little Endian
|
133
|
+
CPU(s): 1
|
134
|
+
On-line CPU(s) list: 0
|
135
|
+
Thread(s) per core: 1
|
136
|
+
Core(s) per socket: 1
|
137
|
+
Socket(s): 1
|
138
|
+
NUMA node(s): 1
|
139
|
+
Vendor ID: GenuineIntel
|
140
|
+
CPU family: 6
|
141
|
+
Model: 23
|
142
|
+
Model name: Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
|
143
|
+
Stepping: 2
|
144
|
+
CPU MHz: 1968.770
|
145
|
+
BogoMIPS: 2575.86
|
146
|
+
Hypervisor vendor: Xen
|
147
|
+
Virtualization type: full
|
148
|
+
L1d cache: 32K
|
149
|
+
L1i cache: 32K
|
150
|
+
L2 cache: 256K
|
151
|
+
L3 cache: 30720K
|
152
|
+
NUMA node0 CPU(s): 0
|
153
|
+
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
|
154
|
+
EOF
|
155
|
+
end
|
133
156
|
|
134
|
-
|
135
|
-
plugin.run
|
136
|
-
expect(plugin[:cpu]).not_to have_key("1")
|
137
|
-
end
|
157
|
+
it_behaves_like "Common cpu info", 1, 1
|
138
158
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
expect(plugin[:cpu]["0"]["vendor_id"]).to eql("GenuineIntel")
|
143
|
-
end
|
159
|
+
before(:each) do
|
160
|
+
allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, ""))
|
161
|
+
end
|
144
162
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
163
|
+
it "gets total cores" do
|
164
|
+
plugin.run
|
165
|
+
expect(plugin[:cpu][:cores]).to eql(1)
|
166
|
+
end
|
150
167
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
168
|
+
it "doesn't have a cpu 1" do
|
169
|
+
plugin.run
|
170
|
+
expect(plugin[:cpu]).not_to have_key("1")
|
171
|
+
end
|
156
172
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
173
|
+
it "has a vendor_id for cpu 0" do
|
174
|
+
plugin.run
|
175
|
+
expect(plugin[:cpu]["0"]).to have_key("vendor_id")
|
176
|
+
expect(plugin[:cpu]["0"]["vendor_id"]).to eql("GenuineIntel")
|
177
|
+
end
|
162
178
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
179
|
+
it "has a family for cpu 0" do
|
180
|
+
plugin.run
|
181
|
+
expect(plugin[:cpu]["0"]).to have_key("family")
|
182
|
+
expect(plugin[:cpu]["0"]["family"]).to eql("6")
|
183
|
+
end
|
167
184
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
185
|
+
it "has a model for cpu 0" do
|
186
|
+
plugin.run
|
187
|
+
expect(plugin[:cpu]["0"]).to have_key("model")
|
188
|
+
expect(plugin[:cpu]["0"]["model"]).to eql("23")
|
189
|
+
end
|
172
190
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
191
|
+
it "has a stepping for cpu 0" do
|
192
|
+
plugin.run
|
193
|
+
expect(plugin[:cpu]["0"]).to have_key("stepping")
|
194
|
+
expect(plugin[:cpu]["0"]["stepping"]).to eql("6")
|
195
|
+
end
|
177
196
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
end
|
197
|
+
it "doesn't have a phyiscal_id for cpu 0" do
|
198
|
+
plugin.run
|
199
|
+
expect(plugin[:cpu]["0"]).not_to have_key("physical_id")
|
200
|
+
end
|
183
201
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
202
|
+
it "doesn't have a core_id for cpu 0" do
|
203
|
+
plugin.run
|
204
|
+
expect(plugin[:cpu]["0"]).not_to have_key("core_id")
|
205
|
+
end
|
189
206
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
207
|
+
it "doesn't have a cores for cpu 0" do
|
208
|
+
plugin.run
|
209
|
+
expect(plugin[:cpu]["0"]).not_to have_key("cores")
|
210
|
+
end
|
195
211
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
212
|
+
it "has a model name for cpu 0" do
|
213
|
+
plugin.run
|
214
|
+
expect(plugin[:cpu]["0"]).to have_key("model_name")
|
215
|
+
expect(plugin[:cpu]["0"]["model_name"]).to eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
|
216
|
+
end
|
217
|
+
|
218
|
+
it "has a mhz for cpu 0" do
|
219
|
+
plugin.run
|
220
|
+
expect(plugin[:cpu]["0"]).to have_key("mhz")
|
221
|
+
expect(plugin[:cpu]["0"]["mhz"]).to eql("1968.770")
|
222
|
+
end
|
223
|
+
|
224
|
+
it "has a cache_size for cpu 0" do
|
225
|
+
plugin.run
|
226
|
+
expect(plugin[:cpu]["0"]).to have_key("cache_size")
|
227
|
+
expect(plugin[:cpu]["0"]["cache_size"]).to eql("64 KB")
|
228
|
+
end
|
201
229
|
|
230
|
+
it "has flags for cpu 0" do
|
231
|
+
plugin.run
|
232
|
+
expect(plugin[:cpu]["0"]).to have_key("flags")
|
233
|
+
expect(plugin[:cpu]["0"]["flags"]).to eq(%w{fpu pse tsc msr mce cx8 sep mtrr pge cmov})
|
234
|
+
end
|
235
|
+
end
|
202
236
|
context "with a dual-core hyperthreaded /proc/cpuinfo" do
|
203
237
|
let(:cpuinfo_contents) do
|
204
238
|
<<-EOF
|
@@ -331,6 +365,7 @@ describe Ohai::System, "S390 linux cpu plugin" do
|
|
331
365
|
|
332
366
|
before(:each) do
|
333
367
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
368
|
+
allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", ""))
|
334
369
|
|
335
370
|
@double_file = double("/proc/cpuinfo")
|
336
371
|
allow(@double_file).to receive(:each).
|
@@ -343,7 +378,7 @@ describe Ohai::System, "S390 linux cpu plugin" do
|
|
343
378
|
allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
|
344
379
|
end
|
345
380
|
|
346
|
-
it_behaves_like "Common cpu info", 2,
|
381
|
+
it_behaves_like "Common cpu info", 2, nil
|
347
382
|
|
348
383
|
it "has a cpu 1" do
|
349
384
|
plugin.run
|
@@ -377,6 +412,7 @@ describe Ohai::System, "arm64 linux cpu plugin" do
|
|
377
412
|
|
378
413
|
before(:each) do
|
379
414
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
415
|
+
allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", ""))
|
380
416
|
|
381
417
|
@double_file = double("/proc/cpuinfo")
|
382
418
|
allow(@double_file).to receive(:each).
|
@@ -391,7 +427,7 @@ describe Ohai::System, "arm64 linux cpu plugin" do
|
|
391
427
|
allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
|
392
428
|
end
|
393
429
|
|
394
|
-
it_behaves_like "Common cpu info", 2,
|
430
|
+
it_behaves_like "Common cpu info", 2, nil
|
395
431
|
|
396
432
|
it "has a cpu 1" do
|
397
433
|
plugin.run
|
@@ -27,6 +27,8 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
27
27
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
|
28
28
|
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
29
29
|
allow(plugin).to receive(:which).with("lsblk").and_return(nil)
|
30
|
+
allow(plugin).to receive(:which).with("df").and_return("/bin/df")
|
31
|
+
allow(plugin).to receive(:which).with("mount").and_return("/bin/mount")
|
30
32
|
allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
|
31
33
|
allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, "", ""))
|
32
34
|
|
@@ -529,4 +531,14 @@ BLKID_TYPE
|
|
529
531
|
expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
|
530
532
|
end
|
531
533
|
end
|
534
|
+
|
535
|
+
%w{df mount}.each do |command|
|
536
|
+
describe "when #{command} does not exist" do
|
537
|
+
it "logs warning about #{command} missing" do
|
538
|
+
allow(plugin).to receive(:shell_out).with(/#{command}/).and_raise(Ohai::Exceptions::Exec)
|
539
|
+
expect(Ohai::Log).to receive(:warn).with("Plugin Filesystem: #{command} binary is not available. Some data will not be available.")
|
540
|
+
plugin.run
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
532
544
|
end
|
@@ -552,6 +552,7 @@ CGROUP
|
|
552
552
|
2:cpu:/Charlie
|
553
553
|
1:cpuset:/Charlie
|
554
554
|
CGROUP
|
555
|
+
allow(File).to receive(:read).with("/proc/1/environ").and_return("")
|
555
556
|
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
556
557
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
557
558
|
plugin.run
|
@@ -572,6 +573,7 @@ CGROUP
|
|
572
573
|
CGROUP
|
573
574
|
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
574
575
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
576
|
+
allow(File).to receive(:read).with("/proc/1/environ").and_return("")
|
575
577
|
end
|
576
578
|
|
577
579
|
it "sets lxc host if lxc-version exists" do
|
@@ -600,6 +602,14 @@ CGROUP
|
|
600
602
|
expect(plugin[:virtualization]).to eq({ "systems" => {} })
|
601
603
|
end
|
602
604
|
|
605
|
+
it "sets lxc guest if /proc/1/environ has lxccontainer string in it" do
|
606
|
+
one_environ = "container=lxccontainer_ttys=/dev/pts/0 /dev/pts/1 /dev/pts/2 /dev/pts/3".chomp
|
607
|
+
allow(File).to receive(:read).with("/proc/1/environ").and_return(one_environ)
|
608
|
+
plugin.run
|
609
|
+
expect(plugin[:virtualization][:system]).to eq("lxc")
|
610
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
611
|
+
end
|
612
|
+
|
603
613
|
end
|
604
614
|
|
605
615
|
it "does not set virtualization if /proc/self/cgroup isn't there" do
|
@@ -682,6 +692,7 @@ CGROUP
|
|
682
692
|
CGROUP
|
683
693
|
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
684
694
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
695
|
+
allow(File).to receive(:read).with("/proc/1/environ").and_return("")
|
685
696
|
plugin.run
|
686
697
|
expect(plugin[:virtualization]).to eq({ "systems" => {} })
|
687
698
|
end
|