spec/unit/plugins/linux/virtualization_spec.rb in ohai-13.12.6 vs spec/unit/plugins/linux/virtualization_spec.rb in ohai-14.0.28
- old
+ new
@@ -38,15 +38,17 @@
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)
+ allow(File).to receive(:exist?).with("/var/snap/lxd/common/lxd/devlxd").and_return(false)
allow(File).to receive(:exist?).with("/proc/1/environ").and_return(false)
# default the which wrappers to nil
allow(plugin).to receive(:which).with("lxc-version").and_return(nil)
allow(plugin).to receive(:which).with("lxc-start").and_return(nil)
+ allow(plugin).to receive(:which).with("docker").and_return(nil)
allow(plugin).to receive(:nova_exists?).and_return(false)
end
describe "when we are checking for xen" do
it "sets xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
@@ -83,10 +85,20 @@
plugin.run
expect(plugin[:virtualization]).to eq({ "systems" => {} })
end
end
+ describe "when we are checking for docker" do
+ it "sets docker host if docker binary exists" do
+ allow(plugin).to receive(:which).with("docker").and_return(true)
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("docker")
+ expect(plugin[:virtualization][:role]).to eq("host")
+ expect(plugin[:virtualization][:systems][:docker]).to eq("host")
+ end
+ end
+
describe "when we are checking for openstack" do
it "sets openstack host if nova binary exists" do
allow(plugin).to receive(:nova_exists?).and_return("/usr/bin/nova")
plugin.run
expect(plugin[:virtualization][:system]).to eq("openstack")
@@ -493,11 +505,19 @@
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
+ it "sets 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
+
+ it "sets lxd host if /var/snap/lxd/common/lxd/devlxd exists" do
+ expect(File).to receive(:exist?).with("/var/snap/lxd/common/lxd/devlxd").and_return(true)
plugin.run
expect(plugin[:virtualization][:system]).to eq("lxd")
expect(plugin[:virtualization][:role]).to eq("host")
end