diff options
author | sersut <serdar@opscode.com> | 2014-01-13 12:09:50 -0800 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-01-13 12:09:50 -0800 |
commit | d5f2ee37ab3717ccc92e79c098b77ee5697b5e85 (patch) | |
tree | 59277c4e7ce38a2506f70a67441c8a8276bd1668 /spec | |
parent | edfedd70fddc608bba8504bd85f337bd77640223 (diff) | |
download | ohai-d5f2ee37ab3717ccc92e79c098b77ee5697b5e85.tar.gz |
Convert AIX plugins to use shell_out.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/plugins/aix/cpu_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/aix/filesystem_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/aix/kernel_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/plugins/aix/network_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/plugins/aix/uptime_spec.rb | 2 |
5 files changed, 23 insertions, 21 deletions
diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb index d47e87ea..5a58d18d 100644 --- a/spec/unit/plugins/aix/cpu_spec.rb +++ b/spec/unit/plugins/aix/cpu_spec.rb @@ -34,8 +34,8 @@ LSATTR_EL @plugin = get_plugin("aix/cpu") @plugin.stub(:collect_os).and_return(:aix) - @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.stub(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil)) + @plugin.stub(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil)) @plugin.run end diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb index 4c903787..c03f2c01 100644 --- a/spec/unit/plugins/aix/filesystem_spec.rb +++ b/spec/unit/plugins/aix/filesystem_spec.rb @@ -48,8 +48,9 @@ MOUNT @plugin = get_plugin("aix/filesystem") @plugin.stub(:collect_os).and_return(:aix) @plugin[:filesystem] = Mash.new - @plugin.stub(:popen4).with("df -P").and_yield(nil, StringIO.new, StringIO.new(@df_P), nil) - @plugin.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new(@mount), nil) + @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil)) + @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil)) + @plugin.run end @@ -93,8 +94,9 @@ MOUNT # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys context "having node values" do before do - @plugin.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new("192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys"), nil) + @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, "192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys", nil)) end + it "returns the filesystem mount location" do @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount'].should == "/stage/middleware" end diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb index 89173a6b..f1018e5b 100644 --- a/spec/unit/plugins/aix/kernel_spec.rb +++ b/spec/unit/plugins/aix/kernel_spec.rb @@ -21,10 +21,10 @@ describe Ohai::System, "AIX kernel plugin" do before(:each) do @plugin = get_plugin("aix/kernel") @plugin.stub(:collect_os).and_return(:aix) - @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.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil)) + @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil)) + @plugin.stub(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil)) + @plugin.stub(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil)) @modules = Mash.new @plugin.stub(:modules).and_return(@modules) @plugin.run @@ -35,11 +35,11 @@ describe Ohai::System, "AIX kernel plugin" do end it "uname -r detects the release" do - @plugin[:kernel][:release].should == 1 + @plugin[:kernel][:release].should == "1" end it "uname -v detects the version" do - @plugin[:kernel][:version].should == 6 + @plugin[:kernel][:version].should == "6" end it "uname -p detects the machine" do diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index f6806992..1aa00a9e 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -74,13 +74,13 @@ ARP_AN @plugin = get_plugin("aix/network") @plugin.stub(:collect_os).and_return(:aix) @plugin[:network] = Mash.new - @plugin.stub(:popen4).with("route -n get 0").and_yield(nil, StringIO.new, StringIO.new(@route_n_get_0), nil) - @plugin.stub(:popen4).with("lsdev -Cc if").and_yield(nil, StringIO.new, StringIO.new(@lsdev_Cc_if), nil) - @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new(@ifconfig_en0), nil) - @plugin.stub(:popen4).with("entstat -d en0 | grep \"Hardware Address\"").and_yield(nil, StringIO.new, StringIO.new("Hardware Address: be:42:80:00:b0:05"), nil) - @plugin.stub(:popen4).with("netstat -nrf inet").and_yield(nil, StringIO.new, StringIO.new(@netstat_nrf_inet), nil) - @plugin.stub(:popen4).with("netstat -nrf inet6").and_yield(nil, StringIO.new, StringIO.new("::1%1 ::1%1 UH 1 109392 en0 - -"), nil) - @plugin.stub(:popen4).with("arp -an").and_yield(nil, StringIO.new, StringIO.new(@aix_arp_an), nil) + @plugin.stub(:shell_out).with("route -n get 0").and_return(mock_shell_out(0, @route_n_get_0, nil)) + @plugin.stub(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil)) + @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil)) + @plugin.stub(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil)) + @plugin.stub(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil)) + @plugin.stub(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil)) + @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil)) end describe "run" do @@ -164,7 +164,7 @@ ARP_AN # For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255 context "with no netmask in the output" do before do - @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet 172.29.174.59 broadcast 172.29.191.255"), nil) + @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil)) end it "detects the default prefixlen" do @@ -181,7 +181,7 @@ ARP_AN context "inet6 entries" do before do - @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet6 ::1%1/0"), nil) + @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet6 ::1%1/0", nil)) @plugin.run @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["::1%1"] end diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb index bf7716c1..2f66b031 100644 --- a/spec/unit/plugins/aix/uptime_spec.rb +++ b/spec/unit/plugins/aix/uptime_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "Aix plugin uptime" do @plugin.stub(:collect_os).and_return(:aix) Time.stub_chain(:now, :to_i).and_return(1374258600) DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1373392260) - @plugin.stub(:popen4).with("who -b").and_yield(nil, StringIO.new, StringIO.new(" . system boot Jul 9 17:51"), nil) + @plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Jul 9 17:51", nil)) @plugin.run end |