diff options
author | Zeal Jagannatha <zealjagannatha@gmail.com> | 2017-10-29 14:39:32 -0700 |
---|---|---|
committer | Zeal Jagannatha <zealjagannatha@gmail.com> | 2017-11-20 10:33:34 -0800 |
commit | ef143fdc2097700d3e5efff195178e2cdf119cd8 (patch) | |
tree | 83c37839b113eb768856324b8c1ad4e7675b261e /spec | |
parent | 73a12b4d2d26273e5fbbb504382b2f764dcb3be8 (diff) | |
download | ohai-ef143fdc2097700d3e5efff195178e2cdf119cd8.tar.gz |
Added systemd-nspawn virtualization detection
Signed-off-by: Zeal Jagannatha <zealjagannatha@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/plugins/linux/virtualization_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index eb67e89b..aea96b13 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -40,6 +40,7 @@ describe Ohai::System, "Linux virtualization platform" do 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("/proc/1/environ").and_return(false) # default the which wrappers to nil allow(plugin).to receive(:which).with("lxc-version").and_return(nil) @@ -627,6 +628,19 @@ CGROUP end end + describe "when we are checking for systemd-nspawn" do + it "sets nspawn guest if /proc/1/environ has nspawn string in it" do + allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true) + allow(File).to receive(:exist?).with("/proc/1/environ").and_return(false) + one_environ = "container=systemd-nspawn_ttys=/dev/pts/0 /dev/pts/1 /dev/pts/2 /dev/pts/3".chomp + allow(File).to receive(:read).with("/proc/1/environ").and_return(one_environ) + allow(File).to receive(:read).with("/proc/self/cgroup").and_return('') + plugin.run + expect(plugin[:virtualization][:system]).to eq("nspawn") + expect(plugin[:virtualization][:role]).to eq("guest") + end + end + describe "when we are checking for docker" do it "sets docker guest if /proc/self/cgroup exist and there are /docker/<hexadecimal> mounts" do self_cgroup = <<-CGROUP |