ohai 7.6.0.rc.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +4 -4
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -12
- data/spec/unit/dsl/plugin_spec.rb +40 -40
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +16 -16
- data/spec/unit/mixin/cloudstack_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +6 -6
- data/spec/unit/mixin/ec2_metadata_spec.rb +8 -8
- data/spec/unit/plugins/aix/cpu_spec.rb +15 -15
- data/spec/unit/plugins/aix/filesystem_spec.rb +15 -15
- data/spec/unit/plugins/aix/hostname_spec.rb +3 -3
- data/spec/unit/plugins/aix/kernel_spec.rb +14 -14
- data/spec/unit/plugins/aix/network_spec.rb +43 -43
- data/spec/unit/plugins/aix/platform_spec.rb +5 -5
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -7
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/azure_spec.rb +18 -18
- data/spec/unit/plugins/c_spec.rb +52 -52
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +31 -31
- data/spec/unit/plugins/cloud_v2_spec.rb +33 -33
- data/spec/unit/plugins/cloudstack_spec.rb +6 -6
- data/spec/unit/plugins/darwin/cpu_spec.rb +19 -19
- data/spec/unit/plugins/darwin/hostname_spec.rb +6 -6
- data/spec/unit/plugins/darwin/kernel_spec.rb +14 -14
- data/spec/unit/plugins/darwin/memory_spec.rb +7 -7
- data/spec/unit/plugins/darwin/network_spec.rb +358 -358
- data/spec/unit/plugins/darwin/platform_spec.rb +10 -10
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +80 -80
- data/spec/unit/plugins/erlang_spec.rb +7 -7
- data/spec/unit/plugins/eucalyptus_spec.rb +28 -28
- data/spec/unit/plugins/fail_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/cpu_spec.rb +10 -10
- data/spec/unit/plugins/freebsd/hostname_spec.rb +4 -4
- data/spec/unit/plugins/freebsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/freebsd/os_spec.rb +3 -3
- data/spec/unit/plugins/freebsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +20 -20
- data/spec/unit/plugins/gce_spec.rb +18 -18
- data/spec/unit/plugins/go_spec.rb +5 -5
- data/spec/unit/plugins/groovy_spec.rb +5 -5
- data/spec/unit/plugins/hostname_spec.rb +24 -24
- data/spec/unit/plugins/init_package_spec.rb +5 -5
- data/spec/unit/plugins/ip_scopes_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +23 -23
- data/spec/unit/plugins/joyent_spec.rb +13 -13
- data/spec/unit/plugins/kernel_spec.rb +20 -20
- data/spec/unit/plugins/linode_spec.rb +18 -18
- data/spec/unit/plugins/linux/cpu_spec.rb +25 -25
- data/spec/unit/plugins/linux/filesystem_spec.rb +61 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +7 -7
- data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
- data/spec/unit/plugins/linux/lsb_spec.rb +23 -23
- data/spec/unit/plugins/linux/mdadm_spec.rb +11 -11
- data/spec/unit/plugins/linux/platform_spec.rb +167 -167
- data/spec/unit/plugins/linux/uptime_spec.rb +6 -6
- data/spec/unit/plugins/linux/virtualization_spec.rb +156 -156
- data/spec/unit/plugins/lua_spec.rb +5 -5
- data/spec/unit/plugins/mono_spec.rb +5 -5
- data/spec/unit/plugins/netbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/network_spec.rb +116 -116
- data/spec/unit/plugins/nodejs_spec.rb +5 -5
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +5 -5
- data/spec/unit/plugins/openbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/platform_spec.rb +4 -4
- data/spec/unit/plugins/openstack_spec.rb +8 -8
- data/spec/unit/plugins/os_spec.rb +5 -5
- data/spec/unit/plugins/passwd_spec.rb +13 -13
- data/spec/unit/plugins/perl_spec.rb +8 -8
- data/spec/unit/plugins/php_spec.rb +7 -7
- data/spec/unit/plugins/platform_spec.rb +9 -9
- data/spec/unit/plugins/powershell_spec.rb +10 -10
- data/spec/unit/plugins/rackspace_spec.rb +72 -70
- data/spec/unit/plugins/root_group_spec.rb +14 -14
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/sigar/network_route_spec.rb +17 -17
- data/spec/unit/plugins/solaris2/cpu_spec.rb +18 -18
- data/spec/unit/plugins/solaris2/hostname_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/kernel_spec.rb +8 -8
- data/spec/unit/plugins/solaris2/memory_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/network_spec.rb +13 -13
- data/spec/unit/plugins/solaris2/platform_spec.rb +14 -14
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +26 -26
- data/spec/unit/system_spec.rb +54 -54
- data/spec/unit/util/file_helper_spec.rb +2 -2
- metadata +50 -95
@@ -49,24 +49,24 @@ describe Ohai::System, "plugin linode" do
|
|
49
49
|
shared_examples_for "!linode" do
|
50
50
|
it "does not create the linode mash" do
|
51
51
|
@plugin.run
|
52
|
-
@plugin[:linode].
|
52
|
+
expect(@plugin[:linode]).to be_nil
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
shared_examples_for "linode" do
|
57
57
|
it "creates a linode mash" do
|
58
58
|
@plugin.run
|
59
|
-
@plugin[:linode].
|
59
|
+
expect(@plugin[:linode]).not_to be_nil
|
60
60
|
end
|
61
61
|
|
62
62
|
it "has all required attributes" do
|
63
63
|
@plugin.run
|
64
|
-
@plugin[:linode][:public_ip].
|
64
|
+
expect(@plugin[:linode][:public_ip]).not_to be_nil
|
65
65
|
end
|
66
66
|
|
67
67
|
it "has correct values for all attributes" do
|
68
68
|
@plugin.run
|
69
|
-
@plugin[:linode][:public_ip].
|
69
|
+
expect(@plugin[:linode][:public_ip]).to eq("1.2.3.4")
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
@@ -111,8 +111,8 @@ describe Ohai::System, "plugin linode" do
|
|
111
111
|
|
112
112
|
it "detects and sets the private ip" do
|
113
113
|
@plugin.run
|
114
|
-
@plugin[:linode][:private_ip].
|
115
|
-
@plugin[:linode][:private_ip].
|
114
|
+
expect(@plugin[:linode][:private_ip]).not_to be_nil
|
115
|
+
expect(@plugin[:linode][:private_ip]).to eq("5.6.7.8")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -120,10 +120,10 @@ describe Ohai::System, "plugin linode" do
|
|
120
120
|
|
121
121
|
describe "with linode cloud file" do
|
122
122
|
before do
|
123
|
-
File.
|
124
|
-
File.
|
125
|
-
File.
|
126
|
-
File.
|
123
|
+
allow(File).to receive(:exist?).with(hint_path_nix).and_return(true)
|
124
|
+
allow(File).to receive(:read).with(hint_path_nix).and_return('')
|
125
|
+
allow(File).to receive(:exist?).with(hint_path_win).and_return(true)
|
126
|
+
allow(File).to receive(:read).with(hint_path_win).and_return('')
|
127
127
|
end
|
128
128
|
|
129
129
|
it_should_behave_like "linode"
|
@@ -131,8 +131,8 @@ describe Ohai::System, "plugin linode" do
|
|
131
131
|
|
132
132
|
describe "without cloud file" do
|
133
133
|
before do
|
134
|
-
File.
|
135
|
-
File.
|
134
|
+
allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
|
135
|
+
allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
|
136
136
|
end
|
137
137
|
|
138
138
|
it_should_behave_like "!linode"
|
@@ -143,13 +143,13 @@ describe Ohai::System, "plugin linode" do
|
|
143
143
|
let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' }
|
144
144
|
|
145
145
|
before do
|
146
|
-
File.
|
147
|
-
File.
|
146
|
+
allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
|
147
|
+
allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
|
148
148
|
|
149
|
-
File.
|
150
|
-
File.
|
151
|
-
File.
|
152
|
-
File.
|
149
|
+
allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true)
|
150
|
+
allow(File).to receive(:read).with(ec2_hint_path_nix).and_return('')
|
151
|
+
allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true)
|
152
|
+
allow(File).to receive(:read).with(ec2_hint_path_win).and_return('')
|
153
153
|
end
|
154
154
|
|
155
155
|
it_should_behave_like "!linode"
|
@@ -22,9 +22,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "Linux cpu plugin" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("linux/cpu")
|
25
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
26
26
|
@double_file = double("/proc/cpuinfo")
|
27
|
-
@double_file.
|
27
|
+
allow(@double_file).to receive(:each).
|
28
28
|
and_yield("processor : 0").
|
29
29
|
and_yield("vendor_id : GenuineIntel").
|
30
30
|
and_yield("cpu family : 6").
|
@@ -44,84 +44,84 @@ describe Ohai::System, "Linux cpu plugin" do
|
|
44
44
|
and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov").
|
45
45
|
and_yield("bogomips : 2575.86").
|
46
46
|
and_yield("clflush size : 32")
|
47
|
-
File.
|
47
|
+
allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should set cpu[:total] to 1" do
|
51
51
|
@plugin.run
|
52
|
-
@plugin[:cpu][:total].
|
52
|
+
expect(@plugin[:cpu][:total]).to eq(1)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should set cpu[:real] to 0" do
|
56
56
|
@plugin.run
|
57
|
-
@plugin[:cpu][:real].
|
57
|
+
expect(@plugin[:cpu][:real]).to eq(0)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should have a cpu 0" do
|
61
61
|
@plugin.run
|
62
|
-
@plugin[:cpu].
|
62
|
+
expect(@plugin[:cpu]).to have_key("0")
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should have a vendor_id for cpu 0" do
|
66
66
|
@plugin.run
|
67
|
-
@plugin[:cpu]["0"].
|
68
|
-
@plugin[:cpu]["0"]["vendor_id"].
|
67
|
+
expect(@plugin[:cpu]["0"]).to have_key("vendor_id")
|
68
|
+
expect(@plugin[:cpu]["0"]["vendor_id"]).to eql("GenuineIntel")
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should have a family for cpu 0" do
|
72
72
|
@plugin.run
|
73
|
-
@plugin[:cpu]["0"].
|
74
|
-
@plugin[:cpu]["0"]["family"].
|
73
|
+
expect(@plugin[:cpu]["0"]).to have_key("family")
|
74
|
+
expect(@plugin[:cpu]["0"]["family"]).to eql("6")
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should have a model for cpu 0" do
|
78
78
|
@plugin.run
|
79
|
-
@plugin[:cpu]["0"].
|
80
|
-
@plugin[:cpu]["0"]["model"].
|
79
|
+
expect(@plugin[:cpu]["0"]).to have_key("model")
|
80
|
+
expect(@plugin[:cpu]["0"]["model"]).to eql("23")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should have a stepping for cpu 0" do
|
84
84
|
@plugin.run
|
85
|
-
@plugin[:cpu]["0"].
|
86
|
-
@plugin[:cpu]["0"]["stepping"].
|
85
|
+
expect(@plugin[:cpu]["0"]).to have_key("stepping")
|
86
|
+
expect(@plugin[:cpu]["0"]["stepping"]).to eql("6")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should not have a phyiscal_id for cpu 0" do
|
90
90
|
@plugin.run
|
91
|
-
@plugin[:cpu]["0"].
|
91
|
+
expect(@plugin[:cpu]["0"]).not_to have_key("physical_id")
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should not have a core_id for cpu 0" do
|
95
95
|
@plugin.run
|
96
|
-
@plugin[:cpu]["0"].
|
96
|
+
expect(@plugin[:cpu]["0"]).not_to have_key("core_id")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should not have a cores for cpu 0" do
|
100
100
|
@plugin.run
|
101
|
-
@plugin[:cpu]["0"].
|
101
|
+
expect(@plugin[:cpu]["0"]).not_to have_key("cores")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should have a model name for cpu 0" do
|
105
105
|
@plugin.run
|
106
|
-
@plugin[:cpu]["0"].
|
107
|
-
@plugin[:cpu]["0"]["model_name"].
|
106
|
+
expect(@plugin[:cpu]["0"]).to have_key("model_name")
|
107
|
+
expect(@plugin[:cpu]["0"]["model_name"]).to eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should have a mhz for cpu 0" do
|
111
111
|
@plugin.run
|
112
|
-
@plugin[:cpu]["0"].
|
113
|
-
@plugin[:cpu]["0"]["mhz"].
|
112
|
+
expect(@plugin[:cpu]["0"]).to have_key("mhz")
|
113
|
+
expect(@plugin[:cpu]["0"]["mhz"]).to eql("1968.770")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should have a cache_size for cpu 0" do
|
117
117
|
@plugin.run
|
118
|
-
@plugin[:cpu]["0"].
|
119
|
-
@plugin[:cpu]["0"]["cache_size"].
|
118
|
+
expect(@plugin[:cpu]["0"]).to have_key("cache_size")
|
119
|
+
expect(@plugin[:cpu]["0"]["cache_size"]).to eql("64 KB")
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should have flags for cpu 0" do
|
123
123
|
@plugin.run
|
124
|
-
@plugin[:cpu]["0"].
|
125
|
-
@plugin[:cpu]["0"]["flags"].
|
124
|
+
expect(@plugin[:cpu]["0"]).to have_key("flags")
|
125
|
+
expect(@plugin[:cpu]["0"]["flags"]).to eq(%w{fpu pse tsc msr mce cx8 sep mtrr pge cmov})
|
126
126
|
end
|
127
127
|
end
|
@@ -21,27 +21,27 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
describe Ohai::System, "Linux filesystem plugin" do
|
22
22
|
before(:each) do
|
23
23
|
@plugin = get_plugin("linux/filesystem")
|
24
|
-
@plugin.
|
24
|
+
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
|
26
|
-
@plugin.
|
27
|
-
@plugin.
|
28
|
-
@plugin.
|
29
|
-
File.
|
30
|
-
@plugin.
|
31
|
-
@plugin.
|
32
|
-
@plugin.
|
26
|
+
allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
|
27
|
+
allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
|
28
|
+
allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
29
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
|
30
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
|
31
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
|
32
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
|
33
33
|
|
34
|
-
@plugin.
|
34
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
|
35
35
|
and_return(mock_shell_out(0, "", ""))
|
36
|
-
@plugin.
|
36
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
|
37
37
|
and_return(mock_shell_out(0, "", ""))
|
38
|
-
@plugin.
|
38
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
|
39
39
|
and_return(mock_shell_out(0, "", ""))
|
40
40
|
|
41
|
-
File.
|
41
|
+
allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
|
42
42
|
|
43
43
|
%w{sdb1 sdb2 sda1 sda2 md0 md1 md2}.each do |name|
|
44
|
-
File.
|
44
|
+
allow(File).to receive(:exist?).with("/dev/#{name}").and_return(true)
|
45
45
|
end
|
46
46
|
%w{
|
47
47
|
sys.vg-root.lv
|
@@ -51,8 +51,8 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
51
51
|
sys.vg-var.lv
|
52
52
|
sys.vg-home.lv
|
53
53
|
}.each do |name|
|
54
|
-
File.
|
55
|
-
File.
|
54
|
+
allow(File).to receive(:exist?).with("/dev/#{name}").and_return(false)
|
55
|
+
allow(File).to receive(:exist?).with("/dev/mapper/#{name}").and_return(true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -71,7 +71,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm
|
|
71
71
|
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
|
72
72
|
/dev/md0 960492 36388 875312 4% /boot
|
73
73
|
DF
|
74
|
-
@plugin.
|
74
|
+
allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
|
75
75
|
|
76
76
|
@inode_stdout = <<-DFi
|
77
77
|
Filesystem Inodes IUsed IFree IUse% Mounted on
|
@@ -81,53 +81,53 @@ tmpfs 126922 273 126649 1% /run
|
|
81
81
|
none 126922 1 126921 1% /run/lock
|
82
82
|
none 126922 1 126921 1% /run/shm
|
83
83
|
DFi
|
84
|
-
@plugin.
|
84
|
+
allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should run df -P and df -i" do
|
88
|
-
@plugin.
|
89
|
-
@plugin.
|
88
|
+
expect(@plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
|
89
|
+
expect(@plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
|
90
90
|
@plugin.run
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should set kb_size to value from df -P" do
|
94
94
|
@plugin.run
|
95
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size].
|
95
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057")
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should set kb_used to value from df -P" do
|
99
99
|
@plugin.run
|
100
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used].
|
100
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should set kb_available to value from df -P" do
|
104
104
|
@plugin.run
|
105
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available].
|
105
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should set percent_used to value from df -P" do
|
109
109
|
@plugin.run
|
110
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used].
|
110
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should set mount to value from df -P" do
|
114
114
|
@plugin.run
|
115
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].
|
115
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should set total_inodes to value from df -i" do
|
119
119
|
@plugin.run
|
120
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes].
|
120
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should set inodes_used to value from df -i" do
|
124
124
|
@plugin.run
|
125
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used].
|
125
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380")
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should set inodes_available to value from df -i" do
|
129
129
|
@plugin.run
|
130
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available].
|
130
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485")
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -150,27 +150,27 @@ devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
|
|
150
150
|
fusectl on /sys/fs/fuse/connections type fusectl (rw)
|
151
151
|
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
|
152
152
|
MOUNT
|
153
|
-
@plugin.
|
153
|
+
allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should run mount" do
|
157
|
-
@plugin.
|
157
|
+
expect(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
|
158
158
|
@plugin.run
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should set mount to value from mount" do
|
162
162
|
@plugin.run
|
163
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].
|
163
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should set fs_type to value from mount" do
|
167
167
|
@plugin.run
|
168
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].
|
168
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should set mount_options to an array of values from mount" do
|
172
172
|
@plugin.run
|
173
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].
|
173
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime" ])
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -190,23 +190,23 @@ MOUNT
|
|
190
190
|
/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\"
|
191
191
|
/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\"
|
192
192
|
BLKID_TYPE
|
193
|
-
@plugin.
|
193
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should run blkid -s TYPE" do
|
197
|
-
@plugin.
|
197
|
+
expect(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
|
198
198
|
@plugin.run
|
199
199
|
end
|
200
200
|
|
201
201
|
it "should set kb_size to value from blkid -s TYPE" do
|
202
202
|
@plugin.run
|
203
|
-
@plugin[:filesystem]["/dev/md1"][:fs_type].
|
203
|
+
expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
207
|
describe "when gathering filesystem type data from lsblk" do
|
208
208
|
before(:each) do
|
209
|
-
File.
|
209
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
210
210
|
@stdout = <<-BLKID_TYPE
|
211
211
|
sdb1 linux_raid_member
|
212
212
|
sdb2 linux_raid_member
|
@@ -221,19 +221,19 @@ sys.vg-usr.lv ext4
|
|
221
221
|
sys.vg-var.lv ext4
|
222
222
|
sys.vg-home.lv xfs
|
223
223
|
BLKID_TYPE
|
224
|
-
@plugin.
|
224
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
|
225
225
|
and_return(mock_shell_out(0, @stdout, ""))
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should run lsblk -r -n -o NAME,FSTYPE" do
|
229
|
-
@plugin.
|
229
|
+
expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
|
230
230
|
and_return(mock_shell_out(0, @stdout, ""))
|
231
231
|
@plugin.run
|
232
232
|
end
|
233
233
|
|
234
234
|
it "should set kb_size to value from lsblk -r -n -o NAME,FSTYPE" do
|
235
235
|
@plugin.run
|
236
|
-
@plugin[:filesystem]["/dev/md1"][:fs_type].
|
236
|
+
expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
@@ -253,23 +253,23 @@ BLKID_TYPE
|
|
253
253
|
/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\"
|
254
254
|
/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\"
|
255
255
|
BLKID_UUID
|
256
|
-
@plugin.
|
256
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should run blkid -s UUID" do
|
260
|
-
@plugin.
|
260
|
+
expect(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
261
261
|
@plugin.run
|
262
262
|
end
|
263
263
|
|
264
264
|
it "should set kb_size to value from blkid -s UUID" do
|
265
265
|
@plugin.run
|
266
|
-
@plugin[:filesystem]["/dev/sda2"][:uuid].
|
266
|
+
expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
270
|
describe "when gathering filesystem uuid data from lsblk" do
|
271
271
|
before(:each) do
|
272
|
-
File.
|
272
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
273
273
|
@stdout = <<-BLKID_UUID
|
274
274
|
sdb1 bd1197e0-6997-1f3a-e27e-7801388308b5
|
275
275
|
sdb2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa
|
@@ -284,20 +284,21 @@ sys.vg-usr.lv 26ec33c5-d00b-4f88-a550-492def013bbc
|
|
284
284
|
sys.vg-var.lv 6b559c35-7847-4ae2-b512-c99012d3f5b3
|
285
285
|
sys.vg-home.lv d6efda02-1b73-453c-8c74-7d8dee78fa5e
|
286
286
|
BLKID_UUID
|
287
|
-
@plugin.
|
287
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
|
288
288
|
and_return(mock_shell_out(0, @stdout, ""))
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should run lsblk -r -n -o NAME,UUID" do
|
292
|
-
@plugin.
|
292
|
+
expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
|
293
293
|
and_return(mock_shell_out(0, @stdout, ""))
|
294
294
|
@plugin.run
|
295
295
|
end
|
296
296
|
|
297
297
|
it "should set kb_size to value from lsblk -r -n -o NAME,UUID" do
|
298
298
|
@plugin.run
|
299
|
-
@plugin[:filesystem]["/dev/sda2"][:uuid].
|
299
|
+
expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq(
|
300
300
|
"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
|
301
|
+
)
|
301
302
|
end
|
302
303
|
end
|
303
304
|
|
@@ -315,23 +316,23 @@ BLKID_UUID
|
|
315
316
|
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\"
|
316
317
|
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\"
|
317
318
|
BLKID_LABEL
|
318
|
-
@plugin.
|
319
|
+
allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
319
320
|
end
|
320
321
|
|
321
322
|
it "should run blkid -s LABEL" do
|
322
|
-
@plugin.
|
323
|
+
expect(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
323
324
|
@plugin.run
|
324
325
|
end
|
325
326
|
|
326
327
|
it "should set kb_size to value from blkid -s LABEL" do
|
327
328
|
@plugin.run
|
328
|
-
@plugin[:filesystem]["/dev/md0"][:label].
|
329
|
+
expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
|
329
330
|
end
|
330
331
|
end
|
331
332
|
|
332
333
|
describe "when gathering filesystem label data from lsblk" do
|
333
334
|
before(:each) do
|
334
|
-
File.
|
335
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
335
336
|
@stdout = <<-BLKID_LABEL
|
336
337
|
sda1 fuego:0
|
337
338
|
sda2 fuego:1
|
@@ -344,26 +345,26 @@ sys.vg-usr.lv /usr
|
|
344
345
|
sys.vg-var.lv /var
|
345
346
|
sys.vg-home.lv /home
|
346
347
|
BLKID_LABEL
|
347
|
-
@plugin.
|
348
|
+
allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
|
348
349
|
and_return(mock_shell_out(0, @stdout, ""))
|
349
350
|
end
|
350
351
|
|
351
352
|
it "should run blkid -s LABEL" do
|
352
|
-
@plugin.
|
353
|
+
expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
|
353
354
|
and_return(mock_shell_out(0, @stdout, ""))
|
354
355
|
@plugin.run
|
355
356
|
end
|
356
357
|
|
357
358
|
it "should set kb_size to value from blkid -s LABEL" do
|
358
359
|
@plugin.run
|
359
|
-
@plugin[:filesystem]["/dev/md0"][:label].
|
360
|
+
expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
|
360
361
|
end
|
361
362
|
end
|
362
363
|
|
363
364
|
|
364
365
|
describe "when gathering data from /proc/mounts" do
|
365
366
|
before(:each) do
|
366
|
-
File.
|
367
|
+
allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
|
367
368
|
@double_file = double("/proc/mounts")
|
368
369
|
@mounts = <<-MOUNTS
|
369
370
|
rootfs / rootfs rw 0 0
|
@@ -384,28 +385,28 @@ fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
|
|
384
385
|
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
|
385
386
|
MOUNTS
|
386
387
|
@counter = 0
|
387
|
-
@double_file.
|
388
|
+
allow(@double_file).to receive(:read_nonblock) do
|
388
389
|
@counter += 1
|
389
390
|
raise EOFError if @counter == 2
|
390
391
|
@mounts
|
391
392
|
end
|
392
|
-
@double_file.
|
393
|
-
File.
|
393
|
+
allow(@double_file).to receive(:close)
|
394
|
+
allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file)
|
394
395
|
end
|
395
396
|
|
396
397
|
it "should set mount to value from /proc/mounts" do
|
397
398
|
@plugin.run
|
398
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].
|
399
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
399
400
|
end
|
400
401
|
|
401
402
|
it "should set fs_type to value from /proc/mounts" do
|
402
403
|
@plugin.run
|
403
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].
|
404
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
|
404
405
|
end
|
405
406
|
|
406
407
|
it "should set mount_options to an array of values from /proc/mounts" do
|
407
408
|
@plugin.run
|
408
|
-
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].
|
409
|
+
expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ])
|
409
410
|
end
|
410
411
|
end
|
411
412
|
|