spec/ohai/plugins/linux/virtualization_spec.rb in ohai-0.6.12 vs spec/ohai/plugins/linux/virtualization_spec.rb in ohai-0.6.14.rc.1
- old
+ new
@@ -30,11 +30,12 @@
File.stub!(:exists?).with("/proc/xen/capabilities").and_return(false)
File.stub!(:exists?).with("/proc/modules").and_return(false)
File.stub!(:exists?).with("/proc/cpuinfo").and_return(false)
File.stub!(:exists?).with("/usr/sbin/dmidecode").and_return(false)
File.stub!(:exists?).with("/proc/self/status").and_return(false)
- File.stub!(:exists?).with("/proc/user_beancounters").and_return(false)
+ File.stub!(:exists?).with("/proc/bc/0").and_return(false)
+ File.stub!(:exists?).with("/proc/vz").and_return(false)
end
describe "when we are checking for xen" do
it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
File.should_receive(:exists?).with("/proc/xen").and_return(true)
@@ -214,27 +215,27 @@
@ohai._require_plugin("linux::virtualization")
@ohai[:virtualization].should == {}
end
end
describe "when we are checking for openvz" do
- it "should set openvz host if /proc/user_beancounters contains 0:" do
- File.should_receive(:exists?).with("/proc/user_beancounters").and_return(true)
- File.stub!(:read).with("/proc/user_beancounters").and_return("\n 0: ")
+ it "should set openvz host if /proc/bc/0 exists" do
+ File.should_receive(:exists?).with("/proc/bc/0").and_return(true)
@ohai._require_plugin("linux::virtualization")
- @ohai[:virtualization][:emulator].should == "openvz"
+ @ohai[:virtualization][:system].should == "openvz"
@ohai[:virtualization][:role].should == "host"
end
- it "should set openvz guest if /proc/user_beancounters doesn't contain 0:" do
- File.should_receive(:exists?).with("/proc/user_beancounters").and_return(true)
- File.stub!(:read).with("/proc/user_beancounters").and_return("101:")
+ it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
+ File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
+ File.should_receive(:exists?).with("/proc/vz").and_return(true)
@ohai._require_plugin("linux::virtualization")
- @ohai[:virtualization][:emulator].should == "openvz"
+ @ohai[:virtualization][:system].should == "openvz"
@ohai[:virtualization][:role].should == "guest"
end
it "should not set virtualization if openvz isn't there" do
- File.should_receive(:exists?).at_least(:once).and_return(false)
+ File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
+ File.should_receive(:exists?).with("/proc/vz").and_return(false)
@ohai._require_plugin("linux::virtualization")
@ohai[:virtualization].should == {}
end
end