diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-01 15:24:27 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-02 08:14:51 -0800 |
commit | 4906f0b6bea47b4e2c564d66c6232b1efa70114a (patch) | |
tree | 9aef1c31d00e7eecd052093a2547ce6856471ebf /spec | |
parent | 647680009efb898e4b5614114b6ed7f188f4033a (diff) | |
download | chef-4906f0b6bea47b4e2c564d66c6232b1efa70114a.tar.gz |
Use OHAI_SYSTEM where possible
Rerunning ohai wastes a lot of time. This should
get us back to within our time limits in appveyor
even with the perf regression in Ohai.
Don't rerun ohai for unit/regsitry_helper_spec
Ohai is slow. We don't need to rerun this, it's
already run in our spec_helper.
Don't keep rerunning ohai for reboot_pending_spec
Running Ohai is slow. This should know almost 2
mins off the runtime of the tests.
Don't need to run ohai for registry_spec
crypto_spec does not need its own ohai
cmdlet_spec does not need its own ohai
functional registry_helper_spec does not need its own ohai
Use spec ohai system for knife configure_spec
Use OHAI_SYSTEM for dsc_script_spec
use OHAI_SYSTEM for dsc_resource_spec
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/dsl/reboot_pending_spec.rb | 9 | ||||
-rw-r--r-- | spec/functional/dsl/registry_helper_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/knife/configure_spec.rb | 7 | ||||
-rw-r--r-- | spec/functional/resource/dsc_resource_spec.rb | 7 | ||||
-rw-r--r-- | spec/functional/resource/dsc_script_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/util/powershell/cmdlet_spec.rb | 5 | ||||
-rw-r--r-- | spec/functional/win32/crypto_spec.rb | 5 | ||||
-rw-r--r-- | spec/functional/win32/registry_spec.rb | 4 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 | ||||
-rw-r--r-- | spec/unit/dsl/regsitry_helper_spec.rb | 4 |
10 files changed, 11 insertions, 40 deletions
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb index 966f8b58c5..e92b83504f 100644 --- a/spec/functional/dsl/reboot_pending_spec.rb +++ b/spec/functional/dsl/reboot_pending_spec.rb @@ -22,17 +22,12 @@ require "spec_helper" describe Chef::DSL::RebootPending, :windows_only do def run_ohai - ohai = Ohai::System.new - # Would be nice to limit this to platform/kernel/arch etc for Ohai 7 - ohai.all_plugins - node.consume_external_attrs(ohai.data,{}) - - ohai + node.consume_external_attrs(OHAI_SYSTEM.data,{}) end let(:node) { Chef::Node.new } - let(:events) { Chef::EventDispatch::Dispatcher.new } let!(:ohai) { run_ohai } # Ensure we have necessary node data + let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:recipe) { Chef::Recipe.new("a windows cookbook", "the windows recipe", run_context) } let(:registry) { Chef::Win32::Registry.new(run_context) } diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb index 20efade913..1337f16a1e 100644 --- a/spec/functional/dsl/registry_helper_spec.rb +++ b/spec/functional/dsl/registry_helper_spec.rb @@ -31,9 +31,7 @@ describe Chef::Resource::RegistryKey, :windows_only do events = Chef::EventDispatch::Dispatcher.new node = Chef::Node.new - ohai = Ohai::System.new - ohai.all_plugins - node.consume_external_attrs(ohai.data,{}) + node.consume_external_attrs(OHAI_SYSTEM.data,{}) run_context = Chef::RunContext.new(node, {}, events) @resource = Chef::Resource.new("foo", run_context) end diff --git a/spec/functional/knife/configure_spec.rb b/spec/functional/knife/configure_spec.rb index 4c02f15200..7711a8581d 100644 --- a/spec/functional/knife/configure_spec.rb +++ b/spec/functional/knife/configure_spec.rb @@ -19,15 +19,10 @@ require "spec_helper" require "chef/knife/configure" -require "ohai" describe "knife configure" do let (:ohai) do - o = Ohai::System.new - o.load_plugins - o.require_plugin "os" - o.require_plugin "hostname" - o + OHAI_SYSTEM end it "loads the fqdn from Ohai" do diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb index 07c0bf5eb9..228baa6106 100644 --- a/spec/functional/resource/dsc_resource_spec.rb +++ b/spec/functional/resource/dsc_resource_spec.rb @@ -19,16 +19,11 @@ require "spec_helper" describe Chef::Resource::DscResource, :windows_powershell_dsc_only do - before(:all) do - @ohai = Ohai::System.new - @ohai.all_plugins(["platform", "os", "languages/powershell"]) - end - let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new } let(:node) { Chef::Node.new.tap do |n| - n.consume_external_attrs(@ohai.data, {}) + n.consume_external_attrs(OHAI_SYSTEM.data, {}) end } diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 67fa30d815..131ec20b4c 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -385,9 +385,7 @@ EOH before(:each) do delete_user(dsc_user) - ohai_reader = Ohai::System.new - ohai_reader.all_plugins(["platform", "os", "languages/powershell"]) - dsc_test_run_context.node.consume_external_attrs(ohai_reader.data,{}) + dsc_test_run_context.node.consume_external_attrs(OHAI_SYSTEM.data,{}) end let(:configuration_data_path) { 'C:\\configurationdata.psd1' } diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb index fe9438f467..7b023d9fb8 100644 --- a/spec/functional/util/powershell/cmdlet_spec.rb +++ b/spec/functional/util/powershell/cmdlet_spec.rb @@ -21,11 +21,8 @@ require File.expand_path("../../../../spec_helper", __FILE__) describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do before(:all) do - ohai = Ohai::System.new - ohai.load_plugins - ohai.run_plugins(true, ["platform", "kernel"]) @node = Chef::Node.new - @node.consume_external_attrs(ohai.data, {}) + @node.consume_external_attrs(OHAI_SYSTEM.data, {}) end let(:cmd_output_format) { :text } let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, {:depth => 2}) } diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb index 185231dbdd..2a290c8ea0 100644 --- a/spec/functional/win32/crypto_spec.rb +++ b/spec/functional/win32/crypto_spec.rb @@ -24,11 +24,8 @@ end describe "Chef::ReservedNames::Win32::Crypto", :windows_only do describe '#encrypt' do before(:all) do - ohai_reader = Ohai::System.new - ohai_reader.all_plugins("platform") - new_node = Chef::Node.new - new_node.consume_external_attrs(ohai_reader.data,{}) + new_node.consume_external_attrs(OHAI_SYSTEM.data,{}) events = Chef::EventDispatch::Dispatcher.new diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb index 4e18074271..9aacc88638 100644 --- a/spec/functional/win32/registry_spec.rb +++ b/spec/functional/win32/registry_spec.rb @@ -41,9 +41,7 @@ describe "Chef::Win32::Registry", :windows_only do #Create the node with ohai data events = Chef::EventDispatch::Dispatcher.new @node = Chef::Node.new - ohai = Ohai::System.new - ohai.all_plugins - @node.consume_external_attrs(ohai.data,{}) + @node.consume_external_attrs(OHAI_SYSTEM.data,{}) @run_context = Chef::RunContext.new(@node, {}, events) #Create a registry object that has access ot the node previously created diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f85369b6a6..464705eab0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -90,7 +90,7 @@ Dir["spec/support/**/*.rb"]. each { |f| require f } OHAI_SYSTEM = Ohai::System.new -OHAI_SYSTEM.all_plugins("platform") +OHAI_SYSTEM.all_plugins(["platform", "hostname", "languages/powershell"]) test_node = Chef::Node.new test_node.automatic["os"] = (OHAI_SYSTEM["os"] || "unknown_os").dup.freeze diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb index 8647b79020..d8b5d5670b 100644 --- a/spec/unit/dsl/regsitry_helper_spec.rb +++ b/spec/unit/dsl/regsitry_helper_spec.rb @@ -24,9 +24,7 @@ describe Chef::Resource::RegistryKey do before (:all) do events = Chef::EventDispatch::Dispatcher.new node = Chef::Node.new - ohai = Ohai::System.new - ohai.all_plugins - node.consume_external_attrs(ohai.data,{}) + node.consume_external_attrs(OHAI_SYSTEM.data,{}) run_context = Chef::RunContext.new(node, {}, events) @resource = Chef::Resource::new("foo", run_context) end |