summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRessl Robert <r.ressl@safematix.com>2018-11-25 03:43:43 +0100
committerRessl Robert <r.ressl@safematix.com>2018-11-25 03:43:43 +0100
commit0ef38689e322dc665f4b8a83ec603d403168ab5d (patch)
tree33a50f4d3163da058b39473b970264e5ae76cd77
parent030a2c6f62b0839ece4e55856ca15c0f7094c789 (diff)
downloadohai-0ef38689e322dc665f4b8a83ec603d403168ab5d.tar.gz
:umbrella: :pencil: add tests for function to load hyper_v hostname from guest
Signed-off-by: Ressl Robert <r.ressl@safematix.com>
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index fa1eb767..264a357d 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -30,6 +30,7 @@ describe Ohai::System, "Linux virtualization platform" do
allow(File).to receive(:exist?).with("/proc/modules").and_return(false)
allow(File).to receive(:exist?).with("/proc/cpuinfo").and_return(false)
allow(File).to receive(:exist?).with("/usr/sbin/dmidecode").and_return(false)
+ allow(File).to receive(:exist?).with("/var/lib/hyperv/.kvp_pool_3").and_return(false)
allow(File).to receive(:exist?).with("/proc/self/status").and_return(false)
allow(File).to receive(:exist?).with("/proc/bc/0").and_return(false)
allow(File).to receive(:exist?).with("/proc/vz").and_return(false)
@@ -384,6 +385,18 @@ VEERTU
end
end
+ describe "when we are checking for Hyper-V guest and host hostname" do
+ it "sets Hyper-V guest if /var/lib/hyperv/.kvp_pool_3 contains hyper_v.example.com" do
+ expect(File).to receive(:exist?).with("/var/lib/hyperv/.kvp_pool_3").and_return(true)
+ allow(File).to receive(:read).with("/var/lib/hyperv/.kvp_pool_3").and_return("HostNamehyper_v.example.comHostingSystemEditionId")
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("hyperv")
+ expect(plugin[:virtualization][:role]).to eq("guest")
+ expect(plugin[:virtualization][:systems]["hyperv"]).to eq("guest")
+ expect(plugin[:virtualization]["host"]).to eq("hyper_v.example.com")
+ end
+ end
+
describe "when we are checking for Linux-VServer" do
it "sets Linux-VServer host if /proc/self/status contains s_context: 0" do
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)