From a24e46e25963a67505d2fd1e540d5dc4d6959385 Mon Sep 17 00:00:00 2001 From: sersut Date: Thu, 9 Jan 2014 11:44:17 -0800 Subject: Move Ohai Platform Simulation tests to its own directory under spec. --- bin/grab_data.rb | 105 -------- platform_simulation_specs/README.md | 5 + platform_simulation_specs/common/lib/libc.so.6 | 6 + platform_simulation_specs/common/lib/libc.so.6.bat | 1 + platform_simulation_specs/common/lib64/libc.so.6 | 6 + .../common/lib64/libc.so.6.bat | 1 + .../common/ohai_plugin_common.rb | 288 +++++++++++++++++++++ .../common/ohai_plugin_common_spec.rb | 52 ++++ platform_simulation_specs/plugins/c_spec.rb | 56 ++++ platform_simulation_specs/plugins/erlang_spec.rb | 39 +++ platform_simulation_specs/plugins/groovy_spec.rb | 40 +++ platform_simulation_specs/plugins/java_spec.rb | 66 +++++ platform_simulation_specs/plugins/kernel_spec.rb | 30 +++ platform_simulation_specs/plugins/lua_spec.rb | 38 +++ platform_simulation_specs/plugins/nodejs_spec.rb | 35 +++ platform_simulation_specs/plugins/perl_spec.rb | 42 +++ platform_simulation_specs/plugins/php_spec.rb | 39 +++ platform_simulation_specs/plugins/python_spec.rb | 37 +++ platform_simulation_specs/tools/grab_data.rb | 105 ++++++++ spec/unit/path/ohai_plugin_common.rb | 286 -------------------- spec/unit/path/ohai_plugin_common_spec.rb | 52 ---- spec/unit/plugins/c_spec.rb | 33 --- spec/unit/plugins/erlang_spec.rb | 18 -- spec/unit/plugins/groovy_spec.rb | 17 -- spec/unit/plugins/java_spec.rb | 47 ---- spec/unit/plugins/linux/kernel_spec.rb | 7 - spec/unit/plugins/lua_spec.rb | 14 - spec/unit/plugins/nodejs_spec.rb | 14 - spec/unit/plugins/perl_spec.rb | 22 -- spec/unit/plugins/php_spec.rb | 17 -- spec/unit/plugins/python_spec.rb | 16 -- 31 files changed, 886 insertions(+), 648 deletions(-) delete mode 100644 bin/grab_data.rb create mode 100644 platform_simulation_specs/README.md create mode 100755 platform_simulation_specs/common/lib/libc.so.6 create mode 100644 platform_simulation_specs/common/lib/libc.so.6.bat create mode 100755 platform_simulation_specs/common/lib64/libc.so.6 create mode 100644 platform_simulation_specs/common/lib64/libc.so.6.bat create mode 100644 platform_simulation_specs/common/ohai_plugin_common.rb create mode 100644 platform_simulation_specs/common/ohai_plugin_common_spec.rb create mode 100644 platform_simulation_specs/plugins/c_spec.rb create mode 100644 platform_simulation_specs/plugins/erlang_spec.rb create mode 100644 platform_simulation_specs/plugins/groovy_spec.rb create mode 100644 platform_simulation_specs/plugins/java_spec.rb create mode 100644 platform_simulation_specs/plugins/kernel_spec.rb create mode 100644 platform_simulation_specs/plugins/lua_spec.rb create mode 100644 platform_simulation_specs/plugins/nodejs_spec.rb create mode 100644 platform_simulation_specs/plugins/perl_spec.rb create mode 100644 platform_simulation_specs/plugins/php_spec.rb create mode 100644 platform_simulation_specs/plugins/python_spec.rb create mode 100644 platform_simulation_specs/tools/grab_data.rb delete mode 100644 spec/unit/path/ohai_plugin_common.rb delete mode 100644 spec/unit/path/ohai_plugin_common_spec.rb diff --git a/bin/grab_data.rb b/bin/grab_data.rb deleted file mode 100644 index 10489d02..00000000 --- a/bin/grab_data.rb +++ /dev/null @@ -1,105 +0,0 @@ - -# Author:: Theodore Nordsieck -# 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. -# - -## -## This is a simple tool to grab shell command output from the local machine. -## -## To use, edit the parameters before running the command. This tool is meant -## integrate the built in fake command data in spec/data/plugins. If the -## appropriate yaml file is in this directory, this tool will append/overwrite -## the data in that file as appropriate. -## - -require 'yaml' -require 'set' -require 'mixlib/shellout' -require 'mixlib/cli' -require 'optparse' -require File.expand_path(File.dirname(__FILE__) + '/../spec/unit/path/ohai_plugin_common.rb') - -#get options -class MyCLI - include Mixlib::CLI - - option :command, - :short => "-c CMD", - :long => "--command CMD", - :description => "The command to run", - :required => true - - option :params, - :short => "-p [P1,P2,...]", - :long => "--params [P1,P2,...]", - :description => "List of parameters, applied one at a time", - #not sure how to use optparse's array syntax, so this is a hack to reproduce that behavior - :proc => Proc.new { |s| if s then s.split( "," ) end } - - option :platform, - :short => "-f PLATFORM", - :long => "--platform PLATFORM", - :description => "Description of the platform", - :required => true - - option :arch, - :short => "-a ARCH", - :long => "--architecture ARCH", - :description => "Description of the architecture", - :required => true - - option :env, - :short => "-e [E1,E2,...]", - :long => "--environment [E1,E2,...]", - :description => "List of labels that describe the environment", - :proc => Proc.new { |s| if s then s.split( "," ) end } #same here - -end -cli = MyCLI.new -cli.parse_options -cmd, params, platform, arch, env = cli.config[:command], cli.config[:params], cli.config[:platform], cli.config[:arch], cli.config[:env] - -# read in data -# filename = cmd + ".output" - -# Mixlib::ShellOut.new("touch #{filename}").run_command -# data = OhaiPluginCommon.read_output cmd, File.expand_path( File.dirname(__FILE__)) -data ||= {} -data[platform] ||= {} -data[platform][arch] ||= [] -params ||= [""] -env ||= [] - -# collect output - -results = params.map do |p| - m = Mixlib::ShellOut.new(cmd + ' ' + p) - begin - m.run_command - {:env => env, :params => p, :stdout => m.stdout, :stderr => m.stderr, :exit_status => m.exitstatus } - rescue Errno::ENOENT - {:env => env, :params => p, :stdout => '', :stderr => 'command not found', :exit_status => 127 } - end -end - -# write out data - -results.each do |r| - data[platform][arch] = data[platform][arch].reject { |e| e[:params] == r[:params] && e[:env] == r[:env] } - data[platform][arch] << r -end - -puts OhaiPluginCommon.data_to_string data diff --git a/platform_simulation_specs/README.md b/platform_simulation_specs/README.md new file mode 100644 index 00000000..3a5a1c15 --- /dev/null +++ b/platform_simulation_specs/README.md @@ -0,0 +1,5 @@ +# Ohai Platform Simulation Tests + +These tests are experimental tests that test Ohai simulating platforms. + +Currently these tests are disabled. \ No newline at end of file diff --git a/platform_simulation_specs/common/lib/libc.so.6 b/platform_simulation_specs/common/lib/libc.so.6 new file mode 100755 index 00000000..e20d9e88 --- /dev/null +++ b/platform_simulation_specs/common/lib/libc.so.6 @@ -0,0 +1,6 @@ +#!/Users/serdar/.rbenv/versions/1.9.3-p385/bin/ruby + +require 'yaml' +require '/Users/serdar/oc/ohai/spec/platform_simulation/common/ohai_plugin_common.rb' + +OhaiPluginCommon.fake_command OhaiPluginCommon.read_output( '___lib___libc.so.6' ), 'centos-5.5', 'x64', [] diff --git a/platform_simulation_specs/common/lib/libc.so.6.bat b/platform_simulation_specs/common/lib/libc.so.6.bat new file mode 100644 index 00000000..44bc5cd9 --- /dev/null +++ b/platform_simulation_specs/common/lib/libc.so.6.bat @@ -0,0 +1 @@ +@/Users/serdar/.rbenv/versions/1.9.3-p385/bin/ruby /Users/serdar/oc/ohai/spec/platform_simulation/common/lib/libc.so.6 %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/platform_simulation_specs/common/lib64/libc.so.6 b/platform_simulation_specs/common/lib64/libc.so.6 new file mode 100755 index 00000000..d84e8fdd --- /dev/null +++ b/platform_simulation_specs/common/lib64/libc.so.6 @@ -0,0 +1,6 @@ +#!/Users/serdar/.rbenv/versions/1.9.3-p385/bin/ruby + +require 'yaml' +require '/Users/serdar/oc/ohai/spec/platform_simulation/common/ohai_plugin_common.rb' + +OhaiPluginCommon.fake_command OhaiPluginCommon.read_output( '___lib64___libc.so.6' ), 'centos-5.5', 'x64', [] diff --git a/platform_simulation_specs/common/lib64/libc.so.6.bat b/platform_simulation_specs/common/lib64/libc.so.6.bat new file mode 100644 index 00000000..abbadd24 --- /dev/null +++ b/platform_simulation_specs/common/lib64/libc.so.6.bat @@ -0,0 +1 @@ +@/Users/serdar/.rbenv/versions/1.9.3-p385/bin/ruby /Users/serdar/oc/ohai/spec/platform_simulation/common/lib64/libc.so.6 %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/platform_simulation_specs/common/ohai_plugin_common.rb b/platform_simulation_specs/common/ohai_plugin_common.rb new file mode 100644 index 00000000..3087536c --- /dev/null +++ b/platform_simulation_specs/common/ohai_plugin_common.rb @@ -0,0 +1,288 @@ + +# Author:: Theodore Nordsieck +# 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 'rubygems' +require 'yajl' +require 'ohai' +require 'yaml' + +module OhaiPluginCommon + FAKE_SEP = "___" + + def fake_command(data, platform, arch, env) + + # If the platform or architecture aren't set, take the first one + # platform = ENV['OHAI_TEST_PLATFORM'] + # arch = ENV['OHAI_TEST_ARCH'] + # env = ENV['OHAI_TEST_ENVIRONMENT'] + + # env = JSON.load(env) + + argv = ARGV.map { |arg| if /\ / =~ arg then "\"" + arg + "\"" else arg end }.join ' ' + match = data[platform][arch].select{ |v| v[:params] == argv && v[:env] == env } + + raise "No canned output for these settings." if match.empty? + raise "More than one set of data matches these parameters." if match.size > 1 + match = match[0] + + $stdout.puts match[:stdout] if match[:stdout] != '' + $stderr.puts match[:stderr] if match[:stderr] != '' + exit match[:exit_status] + end + + def data_path + File.expand_path(File.dirname(__FILE__) + '../../../data/plugins') + end + + def get_path(path = '') + File.expand_path(File.dirname(__FILE__) + path) + end + + def plugin_path + get_path '/../../../lib/ohai/plugins' + end + + # read in the data file for fake executables + def read_output( cmd, path = "#{data_path}" ) + + #using an anonymous class to minimize scoping issues. + @data = Class.new do + @instances + + #DSL - make a list of hashes with + def push(param, value) + @instances ||= [] + @instances[0] ||= {} + current = {} + current = @instances.pop if @instances.last[param].nil? + current[param] = value + @instances << current + end + @methods = [:platform, :arch, :env, :params, :stdout, :stderr, :exit_status] + @methods.each { |m| self.send(:define_method, m.to_s) { |text| push m.to_sym, text }} + + #Format data into a form the rest of the app expects + def process + data = {} + + @instances ||= [] + + @instances.each do |i| + data[i[:platform]] ||= {} + data[i[:platform]][i[:arch]] ||= [] + data[i[:platform]][i[:arch]] << i.reject { |k,v| k == :platform || k == :arch } + end + data + end + end + + @data = @data.new + @data.instance_eval( File.read( "#{path}/#{cmd}.output" )) + @data.process + end + + # output a fake executable case in the DSL + def to_fake_exe_format(platform, arch, env, params, stdout, stderr, exit_status) + e = Yajl::Encoder.new + <<-eos +platform "#{platform}" +arch "#{arch}" +env #{env} +params #{e.encode( params )} +stdout #{e.encode( stdout )} +stderr #{e.encode( stderr )} +exit_status #{exit_status} +eos + end + + # prep fake executable data for writing to a file + def data_to_string(data) + a = data.map do |platform,v| + v.map do |arch,v| + v.map do |e| + to_fake_exe_format platform, arch, e[:env], e[:params], e[:stdout], e[:stderr], e[:exit_status] + end + end + end + a.flatten.join( "\n" ) + end + + def create_exe(cmd, path, platform, arch, env) + + # Create a list of directories needed to be created before the file is created. + # Assume that the #{path} directory exists, but that any directories included in #{cmd} may or may not. + dir_list = cmd.split(/\//).inject( [] ) do | acc, ele | + if acc == [] + acc << ele + else + acc << File.join( acc.last, ele ) + end + end.reject { | e | e == "" } + dir_list = dir_list.map { |e| File.join( path, e )} + cmd_path = dir_list.pop + bat_path = cmd_path + ".bat" + + # Ensure the directories in #{cmd} get created - this is for absolute path support + # This is a workaround: Dir.exists? doesn't exist in 1.8.7 + dir_list.each do | e | + exists = false + begin + Dir.new e + exists = true + rescue Errno::ENOENT + end + Dir.mkdir( e ) unless exists + end + + #fake exe + file = <<-eof +#!#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )} + +require 'yaml' +require '#{path}/ohai_plugin_common.rb' + +OhaiPluginCommon.fake_command OhaiPluginCommon.read_output( '#{cmd.gsub( /\//, OhaiPluginCommon::FAKE_SEP )}' ), '#{platform}', '#{arch}', #{Yajl::Encoder.encode( env )} +eof + File.open(cmd_path, "w") { |f| f.puts file } + + #.bat shim for windows + bat = <<-eof +@#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )} #{cmd_path} %1 %2 %3 %4 %5 %6 %7 %8 %9 +eof + File.open(bat_path, "w") { |f| f.puts bat } + + # sleep 0.01 until File.exists? cmd_path + Mixlib::ShellOut.new("chmod 755 #{cmd_path}").run_command + end + + # delete all files and folders in path except those that match + # the specified regex + def clean_path( path, regex ) + Dir.glob( File.join( path, "*" )). + reject { | e | e =~ regex }. + each { | e | Mixlib::ShellOut.new( "rm -rf #{ e }" ).run_command } + end + + module_function( :fake_command, :data_path, :get_path, :read_output, :clean_path, + :to_fake_exe_format, :data_to_string, :create_exe, :plugin_path ) +end + +# checks to see if the elements in test are also in source. Recursively decends into Hashes. +# nil values in test match against both nil and non-existance in source. +def subsumes?(source, test, path = [], &block) + if source.is_a?( Hash ) && test.is_a?( Hash ) + test.all? { |k,v| subsumes?( source[k], v, path.clone << k, &block )} + else + block.call( path, source, test ) if block + source == test + end +end + +# test that a plugin conforms populates ohai with the correct data +def test_plugin(plugin_names, cmd_list) + # + # Current platform simulation tests are disabled. Remove the line below + # in order to enable the platform simulation tests. + # + return + + # clean the path directory, in case a previous test was interrupted + OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ + + l = lambda do | *args | + platforms = args[0] + archs = args[1] + envs = args[2] + ohai = args[3] + pending_status = args[4] || nil + platforms.each do |platform| + describe "when the platform is #{platform}" do + archs.each do |arch| + describe "and the architecture is #{arch}" do + envs.each do |env| + describe "and the environment is #{env}" do + path = OhaiPluginCommon.get_path + cmd_not_found = Set.new + + begin + # preserve the path + old_path = ENV[ 'PATH' ] + + # create fake executables + cmd_list.each do | c | + data = OhaiPluginCommon.read_output( c.gsub( /\//, OhaiPluginCommon::FAKE_SEP )) + + data = data[platform][arch].select { |f| f[:env] == env } + if data.all? { |f| ( /not found/ =~ f[:stderr] ) && f[:exit_status] == 127 } + cmd_not_found.add c + else + OhaiPluginCommon.create_exe c, path, platform, arch, env + end + end + + # capture all executions in path dir + ENV['PATH'] = path + Ohai.instance_eval do + def self.abs_path( abs_path ) + File.join( OhaiPluginCommon.get_path, abs_path ) + end + end + + @ohai = Ohai::System.new + plugin_names.each do | plugin_name | + @plugin = get_plugin(plugin_name, @ohai, OhaiPluginCommon.plugin_path) + raise "Can not find plugin #{plugin_name}" if @plugin.nil? + @plugin.safe_run + end + ensure + Ohai.instance_eval do + def self.abs_path( abs_path ) + abs_path + end + end + ENV['PATH'] = old_path + OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ + end + + enc = Yajl::Encoder + subsumes?( @ohai.data, ohai ) do | path, source, test | + path_txt = path.map { |p| "[#{enc.encode( p )}]" }.join + if test.nil? + txt = "should not set #{path_txt}" + else + txt = "should set #{path_txt} to #{enc.encode( test )}" + end + it txt do + pending(pending_status) if !pending_status.nil? + source.should eq( test ) + end + end + end + end + end + end + end + end + end + + # human friendlier syntax + l.instance_exec do + alias :test :call + end + yield l +end diff --git a/platform_simulation_specs/common/ohai_plugin_common_spec.rb b/platform_simulation_specs/common/ohai_plugin_common_spec.rb new file mode 100644 index 00000000..5ea81ee5 --- /dev/null +++ b/platform_simulation_specs/common/ohai_plugin_common_spec.rb @@ -0,0 +1,52 @@ + +# Author:: Theodore Nordsieck +# 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__) + "/ohai_plugin_common.rb") + +describe OhaiPluginCommon, "subsumes?" do + before(:each) do + @hash = { "languages" => { "python" => { "version" => "1.6.2", "type" => "interpreted" }}} + end + + it "returns true if given an exact duplicate" do + subsumes?( @hash, @hash ).should be_true + end + + it "returns false if given an exact duplicate with extra info" do + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => "darwin", "type" => "interpreted" }}} ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => {}, "type" => "interpreted" }}} ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => { "name" => "darwin" }, "type" => "interpreted" }}} ).should be_false + end + + it "returns true if all elements in the second hash are in the first hash" do + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }}} ).should be_true + subsumes?( @hash, { "languages" => { "python" => {}}} ).should be_true + subsumes?( @hash, { "languages" => {}} ).should be_true + end + + it "returns true if the second hash contains a key pointing to a nil where the first hash has nothing" do + subsumes?( @hash, { "languages" => { "lua" => nil }} ).should be_true + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }, "lua" => nil }} ).should be_true + end + + it "returns false if the second hash has nil in the place of a real value" do + subsumes?( @hash, { "languages" => { "python" => { "version" => nil }}} ).should be_false + subsumes?( @hash, { "languages" => { "python" => nil }} ).should be_false + subsumes?( { "languages" => {}}, { "languages" => nil } ).should be_false + end +end diff --git a/platform_simulation_specs/plugins/c_spec.rb b/platform_simulation_specs/plugins/c_spec.rb new file mode 100644 index 00000000..fea35c51 --- /dev/null +++ b/platform_simulation_specs/plugins/c_spec.rb @@ -0,0 +1,56 @@ + +# Author:: Doug MacEachern +# Copyright:: Copyright (c) 2010 VMware, 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 'rbconfig' + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin c" do + test_plugin([ "languages", "c" ], [ "/lib/libc.so.6", "/lib64/libc.so.6", "gcc", "cl", "devenv.com", "xlc", "cc", "what" ]) do | p | + p.test([ "centos-5.5" ], [ "x64" ], [[]], { "languages" => { "c" => { + "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)" }, + "glibc" => { "version" => "2.5" , "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "centos-6.2" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => { + "gcc" => { "version" => "4.4.6", "description" => "gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) " }, + "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "c" => { + "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, + "gcc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") + p.test([ "ubuntu-12.10" ], [ "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") + p.test([ "centos-5.5" ], [ "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)" }, + "glibc" => { "version" => "2.5", "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "gcc" => { "version" => "4.4.7", "description" => "gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) " }, + "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "gcc" => { "version" => "4.4.3", "description" => "gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) " }, + "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) + p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "gcc" => { "version" => "4.6.3", "description" => "gcc verison 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) " }, + "glibc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}, "OC-9993" ) + end +end diff --git a/platform_simulation_specs/plugins/erlang_spec.rb b/platform_simulation_specs/plugins/erlang_spec.rb new file mode 100644 index 00000000..fcee1e64 --- /dev/null +++ b/platform_simulation_specs/plugins/erlang_spec.rb @@ -0,0 +1,39 @@ +# +# Author:: Adam Jacob () +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2008-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 'json' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin erlang" do + test_plugin([ "languages", "erlang" ], [ "erl" ]) do | p | + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "erlang" => nil }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "languages" => { "erlang" => nil }}) + p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) + p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.7.4", "options" => [ "ASYNC_THREADS", "HIPE" ], "emulator" => "BEAM" }}}) + p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.9.1", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) + end +end diff --git a/platform_simulation_specs/plugins/groovy_spec.rb b/platform_simulation_specs/plugins/groovy_spec.rb new file mode 100644 index 00000000..72697d04 --- /dev/null +++ b/platform_simulation_specs/plugins/groovy_spec.rb @@ -0,0 +1,40 @@ +# +# Author:: Doug MacEachern +# Copyright:: Copyright (c) 2009 VMware, 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.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin groovy" do + test_plugin([ "languages", "groovy" ], [ "groovy" ]) do | p | + p.test([ "centos-5.5", "ubuntu-12.10" ], [ "x64" ], [[]], + { "languages" => { "groovy" => nil }}) + p.test([ "centos-6.2", "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "groovy" => nil }}) + p.test([ "centos-5.5" ], [ "x64" ], [[ "java", "groovy" ]], + { "languages" => { "groovy" => { "version" => "2.1.7" }}}) + p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "java", "groovy" ]], + { "languages" => { "groovy" => { "version" => "2.1.7" }}}) + p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], + { "languages" => { "groovy" => { "version" => "1.6.4" }}}) + p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], + { "languages" => { "groovy" => { "version" => "1.8.6" }}}) + p.test([ "ubuntu-12.10" ], [ "x64" ], [[ "java", "groovy" ]], + { "languages" => { "groovy" => { "version" => "1.8.6" }}}) + end +end diff --git a/platform_simulation_specs/plugins/java_spec.rb b/platform_simulation_specs/plugins/java_spec.rb new file mode 100644 index 00000000..96b156a7 --- /dev/null +++ b/platform_simulation_specs/plugins/java_spec.rb @@ -0,0 +1,66 @@ +# +# Author:: Benjamin Black () +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2009-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') +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin java (Java5 Client VM)" do + test_plugin([ "languages", "java" ], [ "java" ]) do | p | + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "java" => nil }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "languages" => { "java" => nil }}) + p.test([ "centos-5.9" ], [ "x86" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_24", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-i386" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "centos-5.9" ], [ "x64" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_24", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-x86_64" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "centos-6.4" ], [ "x86" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_24", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-i386" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "centos-6.4" ], [ "x64" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_24", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-x86_64" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "ubuntu-10.04" ], [ "x86" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_27", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) + p.test([ "ubuntu-10.04" ], [ "x64" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_27", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "ubuntu-12.04" ], [ "x86" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_27", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) + p.test([ "ubuntu-12.04" ], [ "x64" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_27", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [["java"]], + { "languages" => { "java" => { "version" => "1.6.0_27", + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-1ubuntu1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + end +end diff --git a/platform_simulation_specs/plugins/kernel_spec.rb b/platform_simulation_specs/plugins/kernel_spec.rb new file mode 100644 index 00000000..8929c329 --- /dev/null +++ b/platform_simulation_specs/plugins/kernel_spec.rb @@ -0,0 +1,30 @@ +# +# Author:: Adam Jacob () +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2008-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') +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "Linux kernel plugin" do + test_plugin([ "kernel" ], [ "uname", "env" ]) do | p | + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "kernel" => { "os" => "GNU/Linux" }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "kernel" => { "os" => "GNU/Linux" }}) + end +end diff --git a/platform_simulation_specs/plugins/lua_spec.rb b/platform_simulation_specs/plugins/lua_spec.rb new file mode 100644 index 00000000..28d9166e --- /dev/null +++ b/platform_simulation_specs/plugins/lua_spec.rb @@ -0,0 +1,38 @@ +# +# Author:: Doug MacEachern +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2009 VMware, Inc. +# 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.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin lua" do + test_plugin([ "languages", "lua" ], [ "lua" ]) do | p | + p.test([ "centos-6.4" ], ["x86", "x64"], [[], ["lua"]], + { "languages" => { "lua" => { "version" => "5.1.4" }}}) + p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "lua" => nil }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "languages" => { "lua" => nil }}) + p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "lua" ]], + { "languages" => { "lua" => { "version" => "5.1.4" }}}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [["lua"]], + { "languages" => { "lua" => { "version" => "5.1.5" }}}) + end +end diff --git a/platform_simulation_specs/plugins/nodejs_spec.rb b/platform_simulation_specs/plugins/nodejs_spec.rb new file mode 100644 index 00000000..b2277039 --- /dev/null +++ b/platform_simulation_specs/plugins/nodejs_spec.rb @@ -0,0 +1,35 @@ +# +# Author:: Jacques Marneweck () +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) Jacques Marneweck +# 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.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin nodejs" do + test_plugin([ "languages", "nodejs" ], [ "node" ]) do | p | + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "nodejs" => nil }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "languages" => { "nodejs" => nil }}) + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "nodejs" ]], + { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "nodejs" ]], + { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) + end +end diff --git a/platform_simulation_specs/plugins/perl_spec.rb b/platform_simulation_specs/plugins/perl_spec.rb new file mode 100644 index 00000000..a275633f --- /dev/null +++ b/platform_simulation_specs/plugins/perl_spec.rb @@ -0,0 +1,42 @@ +# +# Author:: Joshua Timberman() +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2009-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') +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin perl" do + test_plugin([ "languages", "perl" ], [ "perl" ]) do | p | + p.test([ "centos-5.9" ], [ "x86" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "i386-linux-thread-multi" }}}) + p.test([ "centos-5.9" ], [ "x64" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "x86_64-linux-thread-multi" }}}) + p.test([ "centos-6.4" ], [ "x86" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i386-linux-thread-multi" }}}) + p.test([ "centos-6.4" ], [ "x64" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-thread-multi" }}}) + p.test([ "ubuntu-10.04" ], [ "x86" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i486-linux-gnu-thread-multi" }}}) + p.test([ "ubuntu-10.04" ], [ "x64" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-gnu-thread-multi" }}}) + p.test([ "ubuntu-12.04" ], [ "x86" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "i686-linux-gnu-thread-multi-64int" }}}) + p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x64" ], [[], [ "perl" ]], + { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "x86_64-linux-gnu-thread-multi" }}}) + end +end diff --git a/platform_simulation_specs/plugins/php_spec.rb b/platform_simulation_specs/plugins/php_spec.rb new file mode 100644 index 00000000..2956360c --- /dev/null +++ b/platform_simulation_specs/plugins/php_spec.rb @@ -0,0 +1,39 @@ +# +# Author:: Doug MacEachern +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2009 VMware, Inc. +# 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.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin php" do + test_plugin([ "languages", "php" ], [ "php" ]) do | p | + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], + { "languages" => { "php" => nil }}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], + { "languages" => { "php" => nil }}) + p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.3" }}}) + p.test([ "ubuntu-10.04" ], ["x86", "x64"], [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.2-1ubuntu4.20" }}}) + p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.10-1ubuntu3.7" }}}) + p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "php" ]], + { "languages" => { "php" => { "version" => "5.4.9-4ubuntu2.2" }}}) + end +end diff --git a/platform_simulation_specs/plugins/python_spec.rb b/platform_simulation_specs/plugins/python_spec.rb new file mode 100644 index 00000000..fbabb2e4 --- /dev/null +++ b/platform_simulation_specs/plugins/python_spec.rb @@ -0,0 +1,37 @@ +# +# Author:: Adam Jacob () +# Author:: Theodore Nordsieck () +# Copyright:: Copyright (c) 2008-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') +require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) + +describe Ohai::System, "plugin python" do + test_plugin([ "languages", "python" ], [ "python" ]) do | p | + p.test([ "centos-5.9" ], [ "x86", "x64" ], [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.4.3" }}}) + p.test([ "centos-6.4" ], [ "x86", "x64" ], [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.6.6" }}}) + p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.6.5" }}}) + p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.7.3"}}}) + p.test([ "ubuntu-13.04" ], ["x64"], [[], ["python"]], + { "languages" => { "python" => { "version" => "2.7.4"}}}) + end +end diff --git a/platform_simulation_specs/tools/grab_data.rb b/platform_simulation_specs/tools/grab_data.rb new file mode 100644 index 00000000..10489d02 --- /dev/null +++ b/platform_simulation_specs/tools/grab_data.rb @@ -0,0 +1,105 @@ + +# Author:: Theodore Nordsieck +# 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. +# + +## +## This is a simple tool to grab shell command output from the local machine. +## +## To use, edit the parameters before running the command. This tool is meant +## integrate the built in fake command data in spec/data/plugins. If the +## appropriate yaml file is in this directory, this tool will append/overwrite +## the data in that file as appropriate. +## + +require 'yaml' +require 'set' +require 'mixlib/shellout' +require 'mixlib/cli' +require 'optparse' +require File.expand_path(File.dirname(__FILE__) + '/../spec/unit/path/ohai_plugin_common.rb') + +#get options +class MyCLI + include Mixlib::CLI + + option :command, + :short => "-c CMD", + :long => "--command CMD", + :description => "The command to run", + :required => true + + option :params, + :short => "-p [P1,P2,...]", + :long => "--params [P1,P2,...]", + :description => "List of parameters, applied one at a time", + #not sure how to use optparse's array syntax, so this is a hack to reproduce that behavior + :proc => Proc.new { |s| if s then s.split( "," ) end } + + option :platform, + :short => "-f PLATFORM", + :long => "--platform PLATFORM", + :description => "Description of the platform", + :required => true + + option :arch, + :short => "-a ARCH", + :long => "--architecture ARCH", + :description => "Description of the architecture", + :required => true + + option :env, + :short => "-e [E1,E2,...]", + :long => "--environment [E1,E2,...]", + :description => "List of labels that describe the environment", + :proc => Proc.new { |s| if s then s.split( "," ) end } #same here + +end +cli = MyCLI.new +cli.parse_options +cmd, params, platform, arch, env = cli.config[:command], cli.config[:params], cli.config[:platform], cli.config[:arch], cli.config[:env] + +# read in data +# filename = cmd + ".output" + +# Mixlib::ShellOut.new("touch #{filename}").run_command +# data = OhaiPluginCommon.read_output cmd, File.expand_path( File.dirname(__FILE__)) +data ||= {} +data[platform] ||= {} +data[platform][arch] ||= [] +params ||= [""] +env ||= [] + +# collect output + +results = params.map do |p| + m = Mixlib::ShellOut.new(cmd + ' ' + p) + begin + m.run_command + {:env => env, :params => p, :stdout => m.stdout, :stderr => m.stderr, :exit_status => m.exitstatus } + rescue Errno::ENOENT + {:env => env, :params => p, :stdout => '', :stderr => 'command not found', :exit_status => 127 } + end +end + +# write out data + +results.each do |r| + data[platform][arch] = data[platform][arch].reject { |e| e[:params] == r[:params] && e[:env] == r[:env] } + data[platform][arch] << r +end + +puts OhaiPluginCommon.data_to_string data diff --git a/spec/unit/path/ohai_plugin_common.rb b/spec/unit/path/ohai_plugin_common.rb deleted file mode 100644 index ecc57e7a..00000000 --- a/spec/unit/path/ohai_plugin_common.rb +++ /dev/null @@ -1,286 +0,0 @@ - -# Author:: Theodore Nordsieck -# 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 'rubygems' -require 'yajl' -require 'ohai' -require 'yaml' - -module OhaiPluginCommon - FAKE_SEP = "___" - - def fake_command(data, platform, arch, env) - - # If the platform or architecture aren't set, take the first one - # platform = ENV['OHAI_TEST_PLATFORM'] - # arch = ENV['OHAI_TEST_ARCH'] - # env = ENV['OHAI_TEST_ENVIRONMENT'] - - # env = JSON.load(env) - - argv = ARGV.map { |arg| if /\ / =~ arg then "\"" + arg + "\"" else arg end }.join ' ' - match = data[platform][arch].select{ |v| v[:params] == argv && v[:env] == env } - - raise "No canned output for these settings." if match.empty? - raise "More than one set of data matches these parameters." if match.size > 1 - match = match[0] - - $stdout.puts match[:stdout] if match[:stdout] != '' - $stderr.puts match[:stderr] if match[:stderr] != '' - exit match[:exit_status] - end - - def data_path - File.expand_path(File.dirname(__FILE__) + '../../../data/plugins') - end - - def get_path(path = '') - File.expand_path(File.dirname(__FILE__) + path) - end - - def plugin_path - get_path '/../../../lib/ohai/plugins' - end - - # read in the data file for fake executables - def read_output( cmd, path = "#{data_path}" ) - - #using an anonymous class to minimize scoping issues. - @data = Class.new do - @instances - - #DSL - make a list of hashes with - def push(param, value) - @instances ||= [] - @instances[0] ||= {} - current = {} - current = @instances.pop if @instances.last[param].nil? - current[param] = value - @instances << current - end - @methods = [:platform, :arch, :env, :params, :stdout, :stderr, :exit_status] - @methods.each { |m| self.send(:define_method, m.to_s) { |text| push m.to_sym, text }} - - #Format data into a form the rest of the app expects - def process - data = {} - - @instances ||= [] - - @instances.each do |i| - data[i[:platform]] ||= {} - data[i[:platform]][i[:arch]] ||= [] - data[i[:platform]][i[:arch]] << i.reject { |k,v| k == :platform || k == :arch } - end - data - end - end - - @data = @data.new - @data.instance_eval( File.read( "#{path}/#{cmd}.output" )) - @data.process - end - - # output a fake executable case in the DSL - def to_fake_exe_format(platform, arch, env, params, stdout, stderr, exit_status) - e = Yajl::Encoder.new - <<-eos -platform "#{platform}" -arch "#{arch}" -env #{env} -params #{e.encode( params )} -stdout #{e.encode( stdout )} -stderr #{e.encode( stderr )} -exit_status #{exit_status} -eos - end - - # prep fake executable data for writing to a file - def data_to_string(data) - a = data.map do |platform,v| - v.map do |arch,v| - v.map do |e| - to_fake_exe_format platform, arch, e[:env], e[:params], e[:stdout], e[:stderr], e[:exit_status] - end - end - end - a.flatten.join( "\n" ) - end - - def create_exe(cmd, path, platform, arch, env) - - # Create a list of directories needed to be created before the file is created. - # Assume that the #{path} directory exists, but that any directories included in #{cmd} may or may not. - dir_list = cmd.split(/\//).inject( [] ) do | acc, ele | - if acc == [] - acc << ele - else - acc << File.join( acc.last, ele ) - end - end.reject { | e | e == "" } - dir_list = dir_list.map { |e| File.join( path, e )} - cmd_path = dir_list.pop - bat_path = cmd_path + ".bat" - - # Ensure the directories in #{cmd} get created - this is for absolute path support - # This is a workaround: Dir.exists? doesn't exist in 1.8.7 - dir_list.each do | e | - exists = false - begin - Dir.new e - exists = true - rescue Errno::ENOENT - end - Dir.mkdir( e ) unless exists - end - - #fake exe - file = <<-eof -#!#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )} - -require 'yaml' -require '#{path}/ohai_plugin_common.rb' - -OhaiPluginCommon.fake_command OhaiPluginCommon.read_output( '#{cmd.gsub( /\//, OhaiPluginCommon::FAKE_SEP )}' ), '#{platform}', '#{arch}', #{Yajl::Encoder.encode( env )} -eof - File.open(cmd_path, "w") { |f| f.puts file } - - #.bat shim for windows - bat = <<-eof -@#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )} #{cmd_path} %1 %2 %3 %4 %5 %6 %7 %8 %9 -eof - File.open(bat_path, "w") { |f| f.puts bat } - - # sleep 0.01 until File.exists? cmd_path - Mixlib::ShellOut.new("chmod 755 #{cmd_path}").run_command - end - - # delete all files and folders in path except those that match - # the specified regex - def clean_path( path, regex ) - Dir.glob( File.join( path, "*" )). - reject { | e | e =~ regex }. - each { | e | Mixlib::ShellOut.new( "rm -rf #{ e }" ).run_command } - end - - module_function( :fake_command, :data_path, :get_path, :read_output, :clean_path, - :to_fake_exe_format, :data_to_string, :create_exe, :plugin_path ) -end - -# checks to see if the elements in test are also in source. Recursively decends into Hashes. -# nil values in test match against both nil and non-existance in source. -def subsumes?(source, test, path = [], &block) - if source.is_a?( Hash ) && test.is_a?( Hash ) - test.all? { |k,v| subsumes?( source[k], v, path.clone << k, &block )} - else - block.call( path, source, test ) if block - source == test - end -end - -# test that a plugin conforms populates ohai with the correct data -def test_plugin(plugin_names, cmd_list) - puts "Functional testing is temporary disabled until plugin reloading is resolved." - return - - require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) - - # clean the path directory, in case a previous test was interrupted - OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ - - l = lambda do | *args | - platforms = args[0] - archs = args[1] - envs = args[2] - ohai = args[3] - pending_status = args[4] || nil - platforms.each do |platform| - describe "when the platform is #{platform}" do - archs.each do |arch| - describe "and the architecture is #{arch}" do - envs.each do |env| - describe "and the environment is #{env}" do - path = OhaiPluginCommon.get_path - cmd_not_found = Set.new - - begin - # preserve the path - old_path = ENV[ 'PATH' ] - - # create fake executables - cmd_list.each do | c | - data = OhaiPluginCommon.read_output( c.gsub( /\//, OhaiPluginCommon::FAKE_SEP )) - - data = data[platform][arch].select { |f| f[:env] == env } - if data.all? { |f| ( /not found/ =~ f[:stderr] ) && f[:exit_status] == 127 } - cmd_not_found.add c - else - OhaiPluginCommon.create_exe c, path, platform, arch, env - end - end - - # capture all executions in path dir - ENV['PATH'] = path - Ohai.instance_eval do - def self.abs_path( abs_path ) - File.join( OhaiPluginCommon.get_path, abs_path ) - end - end - - @ohai = Ohai::System.new - plugin_names.each do | plugin_name | - @plugin = get_plugin(plugin_name, @ohai, OhaiPluginCommon.plugin_path) - @plugin.safe_run - end - ensure - Ohai.instance_eval do - def self.abs_path( abs_path ) - abs_path - end - end - ENV['PATH'] = old_path - OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ - end - - enc = Yajl::Encoder - subsumes?( @ohai.data, ohai ) do | path, source, test | - path_txt = path.map { |p| "[#{enc.encode( p )}]" }.join - if test.nil? - txt = "should not set #{path_txt}" - else - txt = "should set #{path_txt} to #{enc.encode( test )}" - end - it txt do - pending(pending_status) if !pending_status.nil? - source.should eq( test ) - end - end - end - end - end - end - end - end - end - - # human friendlier syntax - l.instance_exec do - alias :test :call - end - yield l -end diff --git a/spec/unit/path/ohai_plugin_common_spec.rb b/spec/unit/path/ohai_plugin_common_spec.rb deleted file mode 100644 index 5ea81ee5..00000000 --- a/spec/unit/path/ohai_plugin_common_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ - -# Author:: Theodore Nordsieck -# 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__) + "/ohai_plugin_common.rb") - -describe OhaiPluginCommon, "subsumes?" do - before(:each) do - @hash = { "languages" => { "python" => { "version" => "1.6.2", "type" => "interpreted" }}} - end - - it "returns true if given an exact duplicate" do - subsumes?( @hash, @hash ).should be_true - end - - it "returns false if given an exact duplicate with extra info" do - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => "darwin", "type" => "interpreted" }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => {}, "type" => "interpreted" }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => { "name" => "darwin" }, "type" => "interpreted" }}} ).should be_false - end - - it "returns true if all elements in the second hash are in the first hash" do - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }}} ).should be_true - subsumes?( @hash, { "languages" => { "python" => {}}} ).should be_true - subsumes?( @hash, { "languages" => {}} ).should be_true - end - - it "returns true if the second hash contains a key pointing to a nil where the first hash has nothing" do - subsumes?( @hash, { "languages" => { "lua" => nil }} ).should be_true - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }, "lua" => nil }} ).should be_true - end - - it "returns false if the second hash has nil in the place of a real value" do - subsumes?( @hash, { "languages" => { "python" => { "version" => nil }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => nil }} ).should be_false - subsumes?( { "languages" => {}}, { "languages" => nil } ).should be_false - end -end diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 33daa21c..9668317e 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -305,37 +305,4 @@ describe Ohai::System, "plugin c" do @plugin[:languages][:c].should_not have_key(:hpcc) if @plugin[:languages][:c] end - require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'path', 'ohai_plugin_common.rb' )) - - test_plugin([ "languages", "c" ], [ "/lib/libc.so.6", "/lib64/libc.so.6", "gcc", "cl", "devenv.com", "xlc", "cc", "what" ]) do | p | - p.test([ "centos-5.5" ], [ "x64" ], [[]], { "languages" => { "c" => { - "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)" }, - "glibc" => { "version" => "2.5" , "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => { - "gcc" => { "version" => "4.4.6", "description" => "gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) " }, - "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "c" => { - "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, - "gcc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") - p.test([ "ubuntu-12.10" ], [ "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") - p.test([ "centos-5.5" ], [ "x64" ], [[ "gcc" ]], { "languages" => { "c" => { - "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)" }, - "glibc" => { "version" => "2.5", "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { - "gcc" => { "version" => "4.4.7", "description" => "gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) " }, - "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { - "gcc" => { "version" => "4.4.3", "description" => "gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) " }, - "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { - "gcc" => { "version" => "4.6.3", "description" => "gcc verison 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) " }, - "glibc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}, "OC-9993" ) - end end diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index fc7a2cb1..97c5cb14 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -19,7 +19,6 @@ require 'json' require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_plugin_common.rb')) describe Ohai::System, "plugin erlang" do @@ -59,21 +58,4 @@ describe Ohai::System, "plugin erlang" do @plugin.languages.should_not have_key(:erlang) end - - ########## - - test_plugin([ "languages", "erlang" ], [ "erl" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "erlang" => nil }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "erlang" => nil }}) - p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.7.4", "options" => [ "ASYNC_THREADS", "HIPE" ], "emulator" => "BEAM" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.9.1", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) - end end diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 5d072d16..81a1c557 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -18,7 +18,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_plugin_common.rb')) describe Ohai::System, "plugin groovy" do @@ -45,20 +44,4 @@ describe Ohai::System, "plugin groovy" do @plugin.languages.should_not have_key(:groovy) end - test_plugin([ "languages", "groovy" ], [ "groovy" ]) do | p | - p.test([ "centos-5.5", "ubuntu-12.10" ], [ "x64" ], [[]], - { "languages" => { "groovy" => nil }}) - p.test([ "centos-6.2", "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "groovy" => nil }}) - p.test([ "centos-5.5" ], [ "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "2.1.7" }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "2.1.7" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.6.4" }}}) - p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.8.6" }}}) - p.test([ "ubuntu-12.10" ], [ "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.8.6" }}}) - end end diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index cc3e3e0a..13f29996 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -166,51 +166,4 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do end end - - ########### - - require File.expand_path(File.dirname(__FILE__) + '/../path/ohai_plugin_common.rb') - - test_plugin([ "languages", "java" ], [ "java" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "java" => nil }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "java" => nil }}) - p.test([ "centos-5.9" ], [ "x86" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-i386" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "centos-5.9" ], [ "x64" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-x86_64" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "centos-6.4" ], [ "x86" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-i386" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "centos-6.4" ], [ "x64" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-x86_64" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "ubuntu-10.04" ], [ "x86" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) - p.test([ "ubuntu-10.04" ], [ "x64" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "ubuntu-12.04" ], [ "x86" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) - p.test([ "ubuntu-12.04" ], [ "x64" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [["java"]], - { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-1ubuntu1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) - end end diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index 068b8f10..3105a4fd 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -18,7 +18,6 @@ # require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') -require File.expand_path(File.dirname(__FILE__) + '/../../path/ohai_plugin_common.rb') describe Ohai::System, "Linux kernel plugin" do before(:each) do @@ -43,10 +42,4 @@ ENV_LSMOD it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""]) - test_plugin([ "kernel" ], [ "uname", "env" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "kernel" => { "os" => "GNU/Linux" }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "kernel" => { "os" => "GNU/Linux" }}) - end end diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 8dff19b6..16b34c7a 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -47,18 +47,4 @@ describe Ohai::System, "plugin lua" do @plugin.languages.should_not have_key(:lua) end - require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', '/ohai_plugin_common.rb')) - - test_plugin([ "languages", "lua" ], [ "lua" ]) do | p | - p.test([ "centos-6.4" ], ["x86", "x64"], [[], ["lua"]], - { "languages" => { "lua" => { "version" => "5.1.4" }}}) - p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "lua" => nil }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "lua" => nil }}) - p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "lua" ]], - { "languages" => { "lua" => { "version" => "5.1.4" }}}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [["lua"]], - { "languages" => { "lua" => { "version" => "5.1.5" }}}) - end end diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 15a596af..14e5ae3c 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -46,18 +46,4 @@ describe Ohai::System, "plugin nodejs" do @plugin.languages.should_not have_key(:nodejs) end - ############# - - require File.expand_path(File.dirname(__FILE__) + '/../path/ohai_plugin_common.rb') - - test_plugin([ "languages", "nodejs" ], [ "node" ]) do | p | - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "nodejs" => nil }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "nodejs" => nil }}) - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "nodejs" ]], - { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "nodejs" ]], - { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) - end end diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index 1922a3cf..0e84dfee 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -55,26 +55,4 @@ describe Ohai::System, "plugin perl" do @plugin.languages.should_not have_key(:perl) end - ######### - - require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_plugin_common.rb')) - - test_plugin([ "languages", "perl" ], [ "perl" ]) do | p | - p.test([ "centos-5.9" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "i386-linux-thread-multi" }}}) - p.test([ "centos-5.9" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "x86_64-linux-thread-multi" }}}) - p.test([ "centos-6.4" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i386-linux-thread-multi" }}}) - p.test([ "centos-6.4" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-thread-multi" }}}) - p.test([ "ubuntu-10.04" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i486-linux-gnu-thread-multi" }}}) - p.test([ "ubuntu-10.04" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-gnu-thread-multi" }}}) - p.test([ "ubuntu-12.04" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "i686-linux-gnu-thread-multi-64int" }}}) - p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "x86_64-linux-gnu-thread-multi" }}}) - end end diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index 0cf011e0..0046a665 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -20,7 +20,6 @@ require 'json' require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'path', 'ohai_plugin_common.rb')) describe Ohai::System, "plugin php" do @@ -55,20 +54,4 @@ describe Ohai::System, "plugin php" do @plugin.languages[:php][:builddate].should eql("Aug 30 2013 04:30:30") end - ######### - - test_plugin([ "languages", "php" ], [ "php" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "php" => nil }}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "php" => nil }}) - p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.3" }}}) - p.test([ "ubuntu-10.04" ], ["x86", "x64"], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.2-1ubuntu4.20" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.10-1ubuntu3.7" }}}) - p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.4.9-4ubuntu2.2" }}}) - end end diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index 68ef48c6..85892fc2 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -46,20 +46,4 @@ describe Ohai::System, "plugin python" do @plugin.languages.should_not have_key(:python) end - ########## - - require File.expand_path(File.dirname(__FILE__) + '/../path/ohai_plugin_common.rb') - - test_plugin([ "languages", "python" ], [ "python" ]) do | p | - p.test([ "centos-5.9" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.4.3" }}}) - p.test([ "centos-6.4" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.6.6" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.6.5" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.7.3"}}}) - p.test([ "ubuntu-13.04" ], ["x64"], [[], ["python"]], - { "languages" => { "python" => { "version" => "2.7.4"}}}) - end end -- cgit v1.2.1