spec/unit/plugins/linux/virtualization_spec.rb in ohai-8.26.1 vs spec/unit/plugins/linux/virtualization_spec.rb in ohai-13.0.0
- old
+ new
@@ -14,11 +14,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
+require_relative "../../../spec_helper.rb"
describe Ohai::System, "Linux virtualization platform" do
let(:plugin) { get_plugin("linux/virtualization") }
before(:each) do
@@ -41,11 +41,10 @@
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)
end
describe "when we are checking for xen" do
it "sets xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
@@ -647,34 +646,10 @@
expect(plugin[:virtualization][:system]).to eq("docker")
expect(plugin[:virtualization][:role]).to eq("guest")
expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
end
- it "sets docker guest if /proc/self/cgroup exist and there are /docker/docker-ce/<hexadecimal> mounts" do
- self_cgroup = <<-CGROUP
-13:name=systemd:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-12:pids:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-11:hugetlb:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-10:net_prio:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-9:perf_event:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-8:net_cls:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-7:freezer:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-6:devices:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-5:memory:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-4:blkio:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-3:cpuacct:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-2:cpu:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-1:cpuset:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
-CGROUP
- allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
- allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
- plugin.run
- expect(plugin[:virtualization][:system]).to eq("docker")
- expect(plugin[:virtualization][:role]).to eq("guest")
- expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
- end
-
# Relevant at least starting docker 1.6.2, kernel 4.0.5 & systemd 224-1.
# Doi not exactly know which software/version really matters here.
it "should set docker guest if /proc/self/cgroup exists and there are /system.slice/docker-<hexadecimal> mounts (systemd managed cgroup)" do
self_cgroup = <<-CGROUP
8:devices:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope
@@ -730,20 +705,18 @@
end
end
it "does not set the old virtualization attributes if they are already set" do
- allow(plugin).to receive(:docker_exists?).and_return("/usr/bin/docker")
plugin[:virtualization] = Mash.new
plugin[:virtualization][:system] = "the cloud"
plugin[:virtualization][:role] = "cumulonimbus"
plugin.run
expect(plugin[:virtualization][:system]).not_to eq("docker")
expect(plugin[:virtualization][:role]).not_to eq("host")
end
it "does not set docker host if docker does not exist" do
- allow(plugin).to receive(:docker_exists?).and_return(false)
plugin.run
expect(plugin[:virtualization][:system]).to be_nil
expect(plugin[:virtualization][:role]).to be_nil
expect(plugin[:virtualization]).to eq({ "systems" => {} })
end