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
@@ -22,28 +22,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "Linux plugin uptime" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("uptime")
|
25
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
26
26
|
@double_file = double("/proc/uptime", { :gets => "18423 989" })
|
27
|
-
File.
|
27
|
+
allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should set uptime_seconds to uptime" do
|
31
31
|
@plugin.run
|
32
|
-
@plugin[:uptime_seconds].
|
32
|
+
expect(@plugin[:uptime_seconds]).to eq(18423)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should set uptime to a human readable date" do
|
36
36
|
@plugin.run
|
37
|
-
@plugin[:uptime].
|
37
|
+
expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set idletime_seconds to uptime" do
|
41
41
|
@plugin.run
|
42
|
-
@plugin[:idletime_seconds].
|
42
|
+
expect(@plugin[:idletime_seconds]).to eq(989)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should set idletime to a human readable date" do
|
46
46
|
@plugin.run
|
47
|
-
@plugin[:idletime].
|
47
|
+
expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
|
48
48
|
end
|
49
49
|
end
|
@@ -21,130 +21,130 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
describe Ohai::System, "Linux virtualization platform" do
|
22
22
|
before(:each) do
|
23
23
|
@plugin = get_plugin("linux/virtualization")
|
24
|
-
@plugin.
|
24
|
+
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
|
26
26
|
# default to all requested Files not existing
|
27
|
-
File.
|
28
|
-
File.
|
29
|
-
File.
|
30
|
-
File.
|
31
|
-
File.
|
32
|
-
File.
|
33
|
-
File.
|
34
|
-
File.
|
35
|
-
File.
|
27
|
+
allow(File).to receive(:exists?).with("/proc/xen").and_return(false)
|
28
|
+
allow(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
|
29
|
+
allow(File).to receive(:exists?).with("/proc/modules").and_return(false)
|
30
|
+
allow(File).to receive(:exists?).with("/proc/cpuinfo").and_return(false)
|
31
|
+
allow(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(false)
|
32
|
+
allow(File).to receive(:exists?).with("/proc/self/status").and_return(false)
|
33
|
+
allow(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
34
|
+
allow(File).to receive(:exists?).with("/proc/vz").and_return(false)
|
35
|
+
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "when we are checking for xen" do
|
39
39
|
it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
|
40
|
-
File.
|
41
|
-
File.
|
40
|
+
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
41
|
+
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
|
42
42
|
@plugin.run
|
43
|
-
@plugin[:virtualization][:system].
|
44
|
-
@plugin[:virtualization][:role].
|
45
|
-
@plugin[:virtualization][:systems][:xen].
|
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
46
|
end
|
47
47
|
|
48
48
|
it "should set xen host if /proc/xen/capabilities contains control_d " do
|
49
|
-
File.
|
50
|
-
File.
|
51
|
-
File.
|
49
|
+
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
50
|
+
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
51
|
+
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("control_d")
|
52
52
|
@plugin.run
|
53
|
-
@plugin[:virtualization][:system].
|
54
|
-
@plugin[:virtualization][:role].
|
55
|
-
@plugin[:virtualization][:systems][:xen].
|
53
|
+
expect(@plugin[:virtualization][:system]).to eq("xen")
|
54
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
55
|
+
expect(@plugin[:virtualization][:systems][:xen]).to eq("host")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should set xen guest if /proc/xen/capabilities exists but is empty" do
|
59
|
-
File.
|
60
|
-
File.
|
61
|
-
File.
|
59
|
+
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
60
|
+
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
61
|
+
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("")
|
62
62
|
@plugin.run
|
63
|
-
@plugin[:virtualization][:system].
|
64
|
-
@plugin[:virtualization][:role].
|
65
|
-
@plugin[:virtualization][:systems][:xen].
|
63
|
+
expect(@plugin[:virtualization][:system]).to eq("xen")
|
64
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
65
|
+
expect(@plugin[:virtualization][:systems][:xen]).to eq("guest")
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should not set virtualization if xen isn't there" do
|
69
|
-
File.
|
69
|
+
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
70
70
|
@plugin.run
|
71
|
-
@plugin[:virtualization].
|
71
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
describe "when we are checking for kvm" do
|
76
76
|
it "should set kvm host if /proc/modules contains kvm" do
|
77
|
-
File.
|
78
|
-
File.
|
77
|
+
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
78
|
+
allow(File).to receive(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
|
79
79
|
@plugin.run
|
80
|
-
@plugin[:virtualization][:system].
|
81
|
-
@plugin[:virtualization][:role].
|
82
|
-
@plugin[:virtualization][:systems][:kvm].
|
80
|
+
expect(@plugin[:virtualization][:system]).to eq("kvm")
|
81
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
82
|
+
expect(@plugin[:virtualization][:systems][:kvm]).to eq("host")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
|
86
|
-
File.
|
87
|
-
File.
|
86
|
+
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
87
|
+
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
|
88
88
|
@plugin.run
|
89
|
-
@plugin[:virtualization][:system].
|
90
|
-
@plugin[:virtualization][:role].
|
91
|
-
@plugin[:virtualization][:systems][:kvm].
|
89
|
+
expect(@plugin[:virtualization][:system]).to eq("kvm")
|
90
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
91
|
+
expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should set kvm guest if /proc/cpuinfo contains Common KVM processor" do
|
95
|
-
File.
|
96
|
-
File.
|
95
|
+
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
96
|
+
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
|
97
97
|
@plugin.run
|
98
|
-
@plugin[:virtualization][:system].
|
99
|
-
@plugin[:virtualization][:role].
|
100
|
-
@plugin[:virtualization][:systems][:kvm].
|
98
|
+
expect(@plugin[:virtualization][:system]).to eq("kvm")
|
99
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
100
|
+
expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should set kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
|
104
|
-
File.
|
105
|
-
File.
|
104
|
+
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
105
|
+
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
|
106
106
|
@plugin.run
|
107
|
-
@plugin[:virtualization][:system].
|
108
|
-
@plugin[:virtualization][:role].
|
109
|
-
@plugin[:virtualization][:systems][:kvm].
|
107
|
+
expect(@plugin[:virtualization][:system]).to eq("kvm")
|
108
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
109
|
+
expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should not set virtualization if kvm isn't there" do
|
113
|
-
File.
|
113
|
+
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
114
114
|
@plugin.run
|
115
|
-
@plugin[:virtualization].
|
115
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "when we are checking for VirtualBox" do
|
120
120
|
it "should set vbox host if /proc/modules contains vboxdrv" do
|
121
|
-
File.
|
122
|
-
File.
|
121
|
+
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
122
|
+
allow(File).to receive(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
|
123
123
|
@plugin.run
|
124
|
-
@plugin[:virtualization][:system].
|
125
|
-
@plugin[:virtualization][:role].
|
126
|
-
@plugin[:virtualization][:systems][:vbox].
|
124
|
+
expect(@plugin[:virtualization][:system]).to eq("vbox")
|
125
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
126
|
+
expect(@plugin[:virtualization][:systems][:vbox]).to eq("host")
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should set vbox gues if /proc/modules contains vboxguest" do
|
130
|
-
File.
|
131
|
-
File.
|
130
|
+
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
131
|
+
allow(File).to receive(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
|
132
132
|
@plugin.run
|
133
|
-
@plugin[:virtualization][:system].
|
134
|
-
@plugin[:virtualization][:role].
|
135
|
-
@plugin[:virtualization][:systems][:vbox].
|
133
|
+
expect(@plugin[:virtualization][:system]).to eq("vbox")
|
134
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
135
|
+
expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should not set virtualization if vbox isn't there" do
|
139
|
-
File.
|
139
|
+
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
140
140
|
@plugin.run
|
141
|
-
@plugin[:virtualization].
|
141
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
describe "when we are parsing dmidecode" do
|
146
146
|
before(:each) do
|
147
|
-
File.
|
147
|
+
expect(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should set virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
|
@@ -157,11 +157,11 @@ System Information
|
|
157
157
|
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
158
158
|
Wake-up Type: Power Switch
|
159
159
|
MSVPC
|
160
|
-
@plugin.
|
160
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
|
161
161
|
@plugin.run
|
162
|
-
@plugin[:virtualization][:system].
|
163
|
-
@plugin[:virtualization][:role].
|
164
|
-
@plugin[:virtualization][:systems][:virtualpc].
|
162
|
+
expect(@plugin[:virtualization][:system]).to eq("virtualpc")
|
163
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
164
|
+
expect(@plugin[:virtualization][:systems][:virtualpc]).to eq("guest")
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should set vmware guest if dmidecode detects VMware Virtual Platform" do
|
@@ -176,11 +176,11 @@ System Information
|
|
176
176
|
SKU Number: Not Specified
|
177
177
|
Family: Not Specified
|
178
178
|
VMWARE
|
179
|
-
@plugin.
|
179
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
|
180
180
|
@plugin.run
|
181
|
-
@plugin[:virtualization][:system].
|
182
|
-
@plugin[:virtualization][:role].
|
183
|
-
@plugin[:virtualization][:systems][:vmware].
|
181
|
+
expect(@plugin[:virtualization][:system]).to eq("vmware")
|
182
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
183
|
+
expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest")
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should set vbox guest if dmidecode detects Oracle Corporation" do
|
@@ -197,105 +197,105 @@ Base Board Information
|
|
197
197
|
Type: Motherboard
|
198
198
|
Contained Object Handles: 0
|
199
199
|
VBOX
|
200
|
-
@plugin.
|
200
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
|
201
201
|
@plugin.run
|
202
|
-
@plugin[:virtualization][:system].
|
203
|
-
@plugin[:virtualization][:role].
|
204
|
-
@plugin[:virtualization][:systems][:vbox].
|
202
|
+
expect(@plugin[:virtualization][:system]).to eq("vbox")
|
203
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
204
|
+
expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should run dmidecode and not set virtualization if nothing is detected" do
|
208
|
-
@plugin.
|
208
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
|
209
209
|
@plugin.run
|
210
|
-
@plugin[:virtualization].
|
210
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
214
|
describe "when we are checking for Linux-VServer" do
|
215
215
|
it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do
|
216
|
-
File.
|
217
|
-
File.
|
216
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
217
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 0")
|
218
218
|
@plugin.run
|
219
|
-
@plugin[:virtualization][:system].
|
220
|
-
@plugin[:virtualization][:role].
|
221
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
219
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
220
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
221
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
222
222
|
end
|
223
223
|
|
224
224
|
it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
|
225
|
-
File.
|
226
|
-
File.
|
225
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
226
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
227
227
|
@plugin.run
|
228
|
-
@plugin[:virtualization][:system].
|
229
|
-
@plugin[:virtualization][:role].
|
230
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
228
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
229
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
230
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should set Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
|
234
|
-
File.
|
235
|
-
File.
|
234
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
235
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
236
236
|
@plugin.run
|
237
|
-
@plugin[:virtualization][:system].
|
238
|
-
@plugin[:virtualization][:role].
|
239
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
237
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
238
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
239
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should set Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do
|
243
|
-
File.
|
244
|
-
File.
|
243
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
244
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID:\t0")
|
245
245
|
@plugin.run
|
246
|
-
@plugin[:virtualization][:system].
|
247
|
-
@plugin[:virtualization][:role].
|
248
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
246
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
247
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
248
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
249
249
|
end
|
250
250
|
|
251
251
|
it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
|
252
|
-
File.
|
253
|
-
File.
|
252
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
253
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 2")
|
254
254
|
@plugin.run
|
255
|
-
@plugin[:virtualization][:system].
|
256
|
-
@plugin[:virtualization][:role].
|
257
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
255
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
256
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
257
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
|
258
258
|
end
|
259
259
|
|
260
260
|
it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
|
261
|
-
File.
|
262
|
-
File.
|
261
|
+
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
262
|
+
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 2")
|
263
263
|
@plugin.run
|
264
|
-
@plugin[:virtualization][:system].
|
265
|
-
@plugin[:virtualization][:role].
|
266
|
-
@plugin[:virtualization][:systems]['linux-vserver'].
|
264
|
+
expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
|
265
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
266
|
+
expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
|
267
267
|
end
|
268
268
|
|
269
269
|
it "should not set virtualization if Linux-VServer isn't there" do
|
270
|
-
File.
|
270
|
+
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
271
271
|
@plugin.run
|
272
|
-
@plugin[:virtualization].
|
272
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
276
|
describe "when we are checking for openvz" do
|
277
277
|
it "should set openvz host if /proc/bc/0 exists" do
|
278
|
-
File.
|
278
|
+
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(true)
|
279
279
|
@plugin.run
|
280
|
-
@plugin[:virtualization][:system].
|
281
|
-
@plugin[:virtualization][:role].
|
282
|
-
@plugin[:virtualization][:systems][:openvz].
|
280
|
+
expect(@plugin[:virtualization][:system]).to eq("openvz")
|
281
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
282
|
+
expect(@plugin[:virtualization][:systems][:openvz]).to eq("host")
|
283
283
|
end
|
284
284
|
|
285
285
|
it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
|
286
|
-
File.
|
287
|
-
File.
|
286
|
+
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
287
|
+
expect(File).to receive(:exists?).with("/proc/vz").and_return(true)
|
288
288
|
@plugin.run
|
289
|
-
@plugin[:virtualization][:system].
|
290
|
-
@plugin[:virtualization][:role].
|
291
|
-
@plugin[:virtualization][:systems][:openvz].
|
289
|
+
expect(@plugin[:virtualization][:system]).to eq("openvz")
|
290
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
291
|
+
expect(@plugin[:virtualization][:systems][:openvz]).to eq("guest")
|
292
292
|
end
|
293
293
|
|
294
294
|
it "should not set virtualization if openvz isn't there" do
|
295
|
-
File.
|
296
|
-
File.
|
295
|
+
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
296
|
+
expect(File).to receive(:exists?).with("/proc/vz").and_return(false)
|
297
297
|
@plugin.run
|
298
|
-
@plugin[:virtualization].
|
298
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
@@ -311,12 +311,12 @@ VBOX
|
|
311
311
|
2:cpu:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
312
312
|
1:cpuset:/
|
313
313
|
CGROUP
|
314
|
-
File.
|
315
|
-
File.
|
314
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
315
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
316
316
|
@plugin.run
|
317
|
-
@plugin[:virtualization][:system].
|
318
|
-
@plugin[:virtualization][:role].
|
319
|
-
@plugin[:virtualization][:systems][:lxc].
|
317
|
+
expect(@plugin[:virtualization][:system]).to eq("lxc")
|
318
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
319
|
+
expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
320
320
|
end
|
321
321
|
|
322
322
|
it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
|
@@ -330,12 +330,12 @@ CGROUP
|
|
330
330
|
2:cpu:/lxc/vanilla
|
331
331
|
1:cpuset:/lxc/vanilla
|
332
332
|
CGROUP
|
333
|
-
File.
|
334
|
-
File.
|
333
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
334
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
335
335
|
@plugin.run
|
336
|
-
@plugin[:virtualization][:system].
|
337
|
-
@plugin[:virtualization][:role].
|
338
|
-
@plugin[:virtualization][:systems][:lxc].
|
336
|
+
expect(@plugin[:virtualization][:system]).to eq("lxc")
|
337
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
338
|
+
expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should set lxc guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
|
@@ -351,12 +351,12 @@ CGROUP
|
|
351
351
|
3:cpuset:/
|
352
352
|
2:name=systemd:/system.slice/docker.service
|
353
353
|
CGROUP
|
354
|
-
File.
|
355
|
-
File.
|
354
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
355
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
356
356
|
@plugin.run
|
357
|
-
@plugin[:virtualization][:system].
|
358
|
-
@plugin[:virtualization][:role].
|
359
|
-
@plugin[:virtualization][:systems][:lxc].
|
357
|
+
expect(@plugin[:virtualization][:system]).to eq("lxc")
|
358
|
+
expect(@plugin[:virtualization][:role]).to eq("guest")
|
359
|
+
expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
360
360
|
end
|
361
361
|
|
362
362
|
it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
@@ -370,10 +370,10 @@ CGROUP
|
|
370
370
|
2:cpu:/Charlie
|
371
371
|
1:cpuset:/Charlie
|
372
372
|
CGROUP
|
373
|
-
File.
|
374
|
-
File.
|
373
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
374
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
375
375
|
@plugin.run
|
376
|
-
@plugin[:virtualization].
|
376
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
377
377
|
end
|
378
378
|
|
379
379
|
context "/proc/self/cgroup only has / mounts" do
|
@@ -388,47 +388,47 @@ CGROUP
|
|
388
388
|
2:cpu:/
|
389
389
|
1:cpuset:/
|
390
390
|
CGROUP
|
391
|
-
File.
|
392
|
-
File.
|
391
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
392
|
+
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
393
393
|
end
|
394
394
|
|
395
395
|
it "sets lxc host if lxc-version exists" do
|
396
|
-
@plugin.
|
396
|
+
allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
|
397
397
|
@plugin.run
|
398
|
-
@plugin[:virtualization][:system].
|
399
|
-
@plugin[:virtualization][:role].
|
400
|
-
@plugin[:virtualization][:systems][:lxc].
|
398
|
+
expect(@plugin[:virtualization][:system]).to eq("lxc")
|
399
|
+
expect(@plugin[:virtualization][:role]).to eq("host")
|
400
|
+
expect(@plugin[:virtualization][:systems][:lxc]).to eq("host")
|
401
401
|
end
|
402
402
|
|
403
403
|
it "does not set the old virtualization attributes if they are already set" do
|
404
|
-
@plugin.
|
404
|
+
allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
|
405
405
|
@plugin[:virtualization] = Mash.new
|
406
406
|
@plugin[:virtualization][:system] = "the cloud"
|
407
407
|
@plugin[:virtualization][:role] = "cumulonimbus"
|
408
408
|
@plugin.run
|
409
|
-
@plugin[:virtualization][:system].
|
410
|
-
@plugin[:virtualization][:role].
|
409
|
+
expect(@plugin[:virtualization][:system]).not_to eq("lxc")
|
410
|
+
expect(@plugin[:virtualization][:role]).not_to eq("host")
|
411
411
|
end
|
412
412
|
|
413
413
|
it "does not set lxc host if lxc-version does not exist" do
|
414
|
-
@plugin.
|
414
|
+
allow(@plugin).to receive(:lxc_version_exists?).and_return(false)
|
415
415
|
@plugin.run
|
416
|
-
@plugin[:virtualization][:system].
|
417
|
-
@plugin[:virtualization][:role].
|
418
|
-
@plugin[:virtualization].
|
416
|
+
expect(@plugin[:virtualization][:system]).to be_nil
|
417
|
+
expect(@plugin[:virtualization][:role]).to be_nil
|
418
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
419
419
|
end
|
420
420
|
|
421
421
|
end
|
422
422
|
|
423
423
|
it "should not set virtualization if /proc/self/cgroup isn't there" do
|
424
|
-
File.
|
424
|
+
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
425
425
|
@plugin.run
|
426
|
-
@plugin[:virtualization].
|
426
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
430
430
|
it "should not set virtualization if no tests match" do
|
431
431
|
@plugin.run
|
432
|
-
@plugin[:virtualization].
|
432
|
+
expect(@plugin[:virtualization]).to eq({'systems' => {}})
|
433
433
|
end
|
434
434
|
end
|