diff options
author | Prabhu Das <prabhu.das@clogeny.com> | 2013-08-16 12:05:42 +0530 |
---|---|---|
committer | adamedx <adamed@opscode.com> | 2013-08-19 11:52:45 -0700 |
commit | 176c36e051dec2cb5a60a754032373d8fbd75270 (patch) | |
tree | 9aaafb3a4597d9c161cac02cd04569f9d5bd1a8e | |
parent | 52415bb76de03a84159c3fefc37ad479de887416 (diff) | |
download | ohai-176c36e051dec2cb5a60a754032373d8fbd75270.tar.gz |
Unit tests for cpu, kernel and platform plugins of AIX.
-rw-r--r-- | lib/ohai/plugins/aix/cpu.rb | 3 | ||||
-rw-r--r-- | spec/unit/plugins/aix/cpu_spec.rb | 78 | ||||
-rw-r--r-- | spec/unit/plugins/aix/kernel_spec.rb | 52 | ||||
-rw-r--r-- | spec/unit/plugins/aix/platform_spec.rb | 4 |
4 files changed, 136 insertions, 1 deletions
diff --git a/lib/ohai/plugins/aix/cpu.rb b/lib/ohai/plugins/aix/cpu.rb index 475968d0..3c1af9ce 100644 --- a/lib/ohai/plugins/aix/cpu.rb +++ b/lib/ohai/plugins/aix/cpu.rb @@ -1,5 +1,6 @@ # # Author:: Joshua Timberman <joshua@opscode.com> +# Author:: Prabhu Das (<prabhu.das@clogeny.com>) # Copyright:: Copyright (c) 2013, Opscode, Inc. # License:: Apache License, Version 2.0 # @@ -18,7 +19,7 @@ provides "cpu" -cpu = Mash.new +cpu Mash.new # IBM is the only maker of CPUs for AIX systems. cpu[:vendor_id] = "IBM" diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb new file mode 100644 index 00000000..2ffb4977 --- /dev/null +++ b/spec/unit/plugins/aix/cpu_spec.rb @@ -0,0 +1,78 @@ +# +# Author:: Prabhu Das (<prabhu.das@clogeny.com>) +# Copyright:: Copyright (c) 2013 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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') + +describe Ohai::System, "AIX cpu plugin" do + before do + @lsdev_Cc_processor = <<-LSDEV_CC_PROCESSOR +proc0 Available 00-00 Processor +proc4 Defined 00-04 Processor +LSDEV_CC_PROCESSOR + + @lsattr_El_proc0 = <<-LSATTR_EL +frequency 1654344000 Processor Speed False +smt_enabled true Processor SMT enabled False +smt_threads 2 Processor SMT threads False +state enable Processor state False +type PowerPC_POWER5 Processor type False +LSATTR_EL + @ohai = Ohai::System.new + @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("aix/cpu.rb", PLUGIN_PATH)) + @plugin.stub(:from).with("lsdev -Cc processor").and_return(@lsdev_Cc_processor) + @plugin.stub(:from).with("lsattr -El proc0").and_return(@lsattr_El_proc0) + @plugin.run + end + + it "sets the vendor id to IBM" do + @plugin[:cpu][:vendor_id].should == "IBM" + end + + it "sets the available attribute" do + @plugin[:cpu][:available].should == 1 + end + + it "sets the total number of devices" do + @plugin[:cpu][:total].should == 2 + end + + it "detects the model" do + @plugin[:cpu][:model].should == "PowerPC_POWER5" + end + + it "detects the mhz" do + @plugin[:cpu][:mhz].should == 1615570 + end + + it "detects the status of the device" do + @plugin[:cpu][:proc0][:status].should == "Available" + end + + it "detects the location of the device" do + @plugin[:cpu][:proc0][:location].should == "00-00" + end + + context "lsattr -El device_name" do + it "detects all the attributes of the device" do + @plugin[:cpu][:proc0][:frequency].should == "1654344000" + @plugin[:cpu][:proc0][:smt_enabled].should == "true" + @plugin[:cpu][:proc0][:smt_threads].should == "2" + @plugin[:cpu][:proc0][:state].should == "enable" + @plugin[:cpu][:proc0][:type].should == "PowerPC_POWER5" + end + end +end diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb new file mode 100644 index 00000000..48a7d639 --- /dev/null +++ b/spec/unit/plugins/aix/kernel_spec.rb @@ -0,0 +1,52 @@ +# +# Author:: Prabhu Das (<prabhu.das@clogeny.com>) +# Copyright:: Copyright (c) 2013 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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') + +describe Ohai::System, "AIX kernel plugin" do + before do + @ohai = Ohai::System.new + @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("aix/kernel.rb", PLUGIN_PATH)) + @plugin.stub(:from).with("uname -s").and_return("AIX") + @plugin.stub(:from).with("uname -r").and_return(1) + @plugin.stub(:from).with("uname -v").and_return(6) + @plugin.stub(:from).with("uname -p").and_return("powerpc") + @plugin.run + @modules = Mash.new + @plugin[:kernel].stub(:modules).and_return(@modules) + end + + it "uname -s detects the name" do + @plugin[:kernel][:name].should == "aix" + end + + it "uname -r detects the release" do + @plugin[:kernel][:release].should == 1 + end + + it "uname -v detects the version" do + @plugin[:kernel][:version].should == 6 + end + + it "uname -p detects the machine" do + @plugin[:kernel][:machine].should == "powerpc" + end + + it "detects the modules" do + @plugin[:kernel][:modules].should == @modules + end +end diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb index bc679185..aa90411b 100644 --- a/spec/unit/plugins/aix/platform_spec.rb +++ b/spec/unit/plugins/aix/platform_spec.rb @@ -36,4 +36,8 @@ describe Ohai::System, "Aix plugin platform" do it "should set the platform_version" do @plugin[:platform_version].should == "1.0" end + + it "should set platform_family" do + @plugin[:platform_family].should == @plugin[:platform] + end end |