summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2015-11-23 23:24:21 -0800
committerTim Smith <tsmith84@gmail.com>2015-11-24 10:05:01 -0800
commit132d09369cb415ef18d7cdf135d6586efae11a4c (patch)
tree16c96daf9f41359f395b7214084de87284413b20
parent065259a390e0c3170362f8b7e1d936341ebb98b3 (diff)
downloadohai-132d09369cb415ef18d7cdf135d6586efae11a4c.tar.gz
Virtualization specs for windows
-rw-r--r--spec/unit/plugins/windows/virtualization_spec.rb214
1 files changed, 182 insertions, 32 deletions
diff --git a/spec/unit/plugins/windows/virtualization_spec.rb b/spec/unit/plugins/windows/virtualization_spec.rb
index 213aba13..2e4fd41f 100644
--- a/spec/unit/plugins/windows/virtualization_spec.rb
+++ b/spec/unit/plugins/windows/virtualization_spec.rb
@@ -1,6 +1,8 @@
#
# Author:: Pavel Yudin (<pyudin@parallels.com>)
+# Author:: Tim Smith (<tsmith@chef.io>)
# Copyright:: Copyright (c) 2015 Pavel Yudin
+# Copyright:: Copyright (c) 2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,47 +20,195 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
-describe Ohai::System, "Windows virtualization platform" do
- let(:plugin) { get_plugin("windows/virtualization")}
+describe Ohai::System, 'Windows virtualization platform' do
+ let(:plugin) { get_plugin('windows/virtualization') }
before(:each) do
allow(plugin).to receive(:collect_os).and_return(:windows)
- allow(plugin).to receive(:powershell_exists?).and_return(false)
end
- describe "when we are checking for parallels" do
- it "should set parallels guest if powershell exists and it's output contains 'Parallels Software International Inc.'" do
- allow(plugin).to receive(:powershell_exists?).and_return(true)
- bios=<<-BIOS
-SMBIOSBIOSVersion : 10.2.0 (28956) rev 0
-Manufacturer : Parallels Software International Inc.
-Name : Default System BIOS
-SerialNumber : Parallels-92 05 B4 56 97 11 4F FA B1 95 1A FF 8E F9 DD CE
-Version : PRLS - 1
- BIOS
- shellout = double("shellout")
- allow(shellout).to receive(:stdout).and_return(bios)
- allow(plugin).to receive(:shell_out).with('powershell.exe "Get-WmiObject -Class Win32_BIOS"').and_return(shellout)
+ context 'when running on vmware' do
+ it 'system is vmware' do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 8, 9, 10, 11, 12, 14, 15, 16, 19, 26, 27, 28, 29, 30, 32, 39, 40, 41, 42, 50, 57, 58],
+ 'biosversion' => ['INTEL - 6040000', 'PhoenixBIOS 4.0 Release 6.0 '],
+ 'buildnumber' => nil,
+ 'caption' => 'PhoenixBIOS 4.0 Release 6.0 ',
+ 'codeset' => nil, 'currentlanguage' => nil,
+ 'description' => 'PhoenixBIOS 4.0 Release 6.0 ',
+ 'identificationcode' => nil,
+ 'installablelanguages' => nil,
+ 'installdate' => nil,
+ 'languageedition' => nil,
+ 'listoflanguages' => nil,
+ 'manufacturer' => 'Phoenix Technologies LTD',
+ 'name' => 'PhoenixBIOS 4.0 Release 6.0 ',
+ 'othertargetos' => nil,
+ 'primarybios' => true,
+ 'releasedate' => '20130731000000.000000+000',
+ 'serialnumber' => 'VMware-56 4d 65 24 ac cf ec 72-fa 29 b2 7d 8f df b2 7a',
+ 'smbiosbiosversion' => '6.00',
+ 'smbiosmajorversion' => 2,
+ 'smbiosminorversion' => 4,
+ 'smbiospresent' => true,
+ 'softwareelementid' => 'PhoenixBIOS 4.0 Release 6.0 ',
+ 'softwareelementstate' => 3,
+ 'status' => 'OK',
+ 'targetoperatingsystem' => 0,
+ 'version' => 'INTEL - 6040000'
+ }])
plugin.run
- expect(plugin[:virtualization][:system]).to eq("parallels")
- expect(plugin[:virtualization][:role]).to eq("guest")
- expect(plugin[:virtualization][:systems][:parallels]).to eq("guest")
+ expect(plugin[:virtualization][:system]).to eq('vmware')
+ expect(plugin[:virtualization][:role]).to eq('guest')
+ expect(plugin[:virtualization][:systems][:vmware]).to eq('guest')
end
+ end
+
+ context 'when running on parallels desktop' do
+ it 'system is parallels' do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 9, 10, 15, 24, 25, 27, 28, 29, 30, 32, 42, 44, 48, 49, 51, 64, 65, 67],
+ 'biosversion' => ['PRLS - 1'],
+ 'buildnumber' => nil,
+ 'caption' => 'Default System BIOS',
+ 'codeset' => nil,
+ 'currentlanguage' => nil,
+ 'description' => 'Default System BIOS',
+ 'identificationcode' => nil,
+ 'installablelanguages' => nil,
+ 'installdate' => nil,
+ 'languageedition' => nil,
+ 'listoflanguages' => nil,
+ 'manufacturer' => 'Parallels Software International Inc.',
+ 'name' => 'Default System BIOS',
+ 'othertargetos' => nil,
+ 'primarybios' => true,
+ 'releasedate' => '20151005000000.000000+000',
+ 'serialnumber' => 'Parallels-82 75 A0 A0 9B B4 47 7C 87 A9 D9 E1 2B 90 4B 1F',
+ 'smbiosbiosversion' => '11.0.2 (31348)',
+ 'smbiosmajorversion' => 2,
+ 'smbiosminorversion' => 7,
+ 'smbiospresent' => true,
+ 'softwareelementid' => 'Default System BIOS',
+ 'softwareelementstate' => 3,
+ 'status' => 'OK',
+ 'targetoperatingsystem' => 0,
+ 'version' => 'PRLS - 1'
+ }])
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq('parallels')
+ expect(plugin[:virtualization][:role]).to eq('guest')
+ expect(plugin[:virtualization][:systems][:parallels]).to eq('guest')
+ end
+ end
+
+ context 'when running on kvm' do
+ it 'system is kvm' do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [3, 42, 48, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
+ 'biosversion' => ['BOCHS - 1'],
+ 'buildnumber' => nil,
+ 'caption' => 'Default System BIOS',
+ 'codeset' => nil,
+ 'currentlanguage' => nil,
+ 'description' => 'Default System BIOS',
+ 'identificationcode' => nil,
+ 'installablelanguages' => nil,
+ 'installdate' => nil,
+ 'languageedition' => nil,
+ 'listoflanguages' => nil,
+ 'manufacturer' => 'Bochs',
+ 'name' => 'Default System BIOS',
+ 'othertargetos' => nil,
+ 'primarybios' => true,
+ 'releasedate' => '20110101******.******+***',
+ 'serialnumber' => nil,
+ 'smbiosbiosversion' => 'Bochs',
+ 'smbiosmajorversion' => 2,
+ 'smbiosminorversion' => 4,
+ 'smbiospresent' => true,
+ 'softwareelementid' => 'Default System BIOS',
+ 'softwareelementstate' => 3,
+ 'status' => 'OK',
+ 'targetoperatingsystem' => 0, 'version' => 'BOCHS -1'
+ }])
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq('kvm')
+ expect(plugin[:virtualization][:role]).to eq('guest')
+ expect(plugin[:virtualization][:systems][:kvm]).to eq('guest')
+ end
+ end
+
+ context 'when running on virtualbox' do
+ it 'system is vbox' do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 15, 16, 27, 30, 32],
+ 'biosversion' => ['VBOX - 1'],
+ 'buildnumber' => nil,
+ 'caption' => 'Default System BIOS',
+ 'codeset' => nil,
+ 'currentlanguage' => nil,
+ 'description' => 'Default System BIOS',
+ 'identificationcode' => nil,
+ 'installablelanguages' => nil,
+ 'installdate' => nil,
+ 'languageedition' => nil,
+ 'listoflanguages' => nil,
+ 'manufacturer' => 'innotek GmbH',
+ 'name' => 'Default System BIOS',
+ 'othertargetos' => nil,
+ 'primarybios' => true,
+ 'releasedate' => '20061201000000.000000+000',
+ 'serialnumber' => '0',
+ 'smbiosbiosversion' => 'VirtualBox',
+ 'smbiosmajorversion' => 2,
+ 'smbiosminorversion' => 5,
+ 'smbiospresent' => true,
+ 'softwareelementid' => 'Default System BIOS',
+ 'softwareelementstate' => 3,
+ 'status' => 'OK',
+ 'targetoperatingsystem' => 0,
+ 'version' => 'VBOX - 1'
+ }])
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq('vbox')
+ expect(plugin[:virtualization][:role]).to eq('guest')
+ expect(plugin[:virtualization][:systems][:vbox]).to eq('guest')
+ end
+ end
- it "should not set parallels guest if powershell exists and it's output not contain 'Parallels Software International Inc.'" do
- allow(plugin).to receive(:ioreg_exists?).and_return(true)
- bios=<<-BIOS
-SMBIOSBIOSVersion : 4.6.5
-Manufacturer      : American Megatrends Inc.
-Name              : BIOS Date: 10/23/12 15:38:23 Ver: 04.06.05
-SerialNumber      : 334281-001
-Version           : Dealin - 1072009
- BIOS
- shellout = double("shellout")
- allow(shellout).to receive(:stdout).and_return(bios)
- allow(plugin).to receive(:shell_out).with('powershell.exe "Get-WmiObject -Class Win32_BIOS"').and_return(shellout)
+ context 'when running on a hardware system' do
+ it 'does not set virtualization attributes' do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [7, 11, 12, 15, 16, 17, 19, 23, 24, 25, 26, 27, 28, 29, 32, 33, 40, 42, 43],
+ 'biosversion' => ['DELL - 1072009', 'A10', 'American Megatrends - 4028D'],
+ 'buildnumber' => nil,
+ 'caption' => 'A10',
+ 'codeset' => nil,
+ 'currentlanguage' => nil,
+ 'description' => 'A10',
+ 'embeddedcontrollermajorversion' => 255,
+ 'embeddedcontrollerminorversion' => 255,
+ 'identificationcode' => nil,
+ 'installablelanguages' => nil,
+ 'installdate' => nil,
+ 'languageedition' => nil,
+ 'listoflanguages' => nil,
+ 'manufacturer' => 'Dell Inc.',
+ 'name' => 'A10',
+ 'othertargetos' => nil,
+ 'primarybios' => true,
+ 'releasedate' => '20130513000000.000000+000',
+ 'serialnumber' => '87GBNY1',
+ 'smbiosbiosversion' => 'A10',
+ 'smbiosmajorversion' => 2,
+ 'smbiosminorversion' => 7,
+ 'smbiospresent' => true,
+ 'softwareelementid' => 'A10',
+ 'softwareelementstate' => 3,
+ 'status' => 'OK',
+ 'systembiosmajorversion' => 4,
+ 'systembiosminorversion' => 6,
+ 'targetoperatingsystem' => 0,
+ 'version' => 'DELL - 1072009'
+ }])
plugin.run
- expect(plugin[:virtualization]).to eq({'systems' => {}})
+ expect(plugin[:virtualization]).to eq('systems' => {})
end
end
end