spec/unit/plugins/linux/virtualization_spec.rb in ohai-8.19.2 vs spec/unit/plugins/linux/virtualization_spec.rb in ohai-8.20.0
- old
+ new
@@ -36,10 +36,12 @@
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false)
allow(File).to receive(:exist?).with("/.dockerenv").and_return(false)
allow(File).to receive(:exist?).with("/.dockerinit").and_return(false)
allow(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(false)
allow(File).to receive(:exist?).with("/sys/devices/virtual/misc/kvm").and_return(false)
+ allow(File).to receive(:exist?).with("/dev/lxd/sock").and_return(false)
+ allow(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(false)
# default the which wrappers to nil
allow(plugin).to receive(:lxc_version_exists?).and_return(false)
allow(plugin).to receive(:docker_exists?).and_return(false)
allow(plugin).to receive(:nova_exists?).and_return(false)
@@ -459,9 +461,27 @@
DEVICES
expect(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(true)
allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices)
plugin.run
expect(plugin[:virtualization]).to eq({ "systems" => {} })
+ end
+ end
+
+ describe "when we are checking for lxd" do
+ it "sets lxc guest if /dev/lxd/sock exists" do
+ expect(File).to receive(:exist?).with("/dev/lxd/sock").and_return(true)
+
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("lxd")
+ expect(plugin[:virtualization][:role]).to eq("guest")
+ end
+
+ it "setx lxd host if /var/lib/lxd/devlxd exists" do
+ expect(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(true)
+
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("lxd")
+ expect(plugin[:virtualization][:role]).to eq("host")
end
end
describe "when we are checking for lxc" do
it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/<hexadecimal> mounts" do