facter 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +31 -0
- data/Rakefile +41 -36
- data/conf/redhat/facter.spec +11 -4
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +286 -286
- data/lib/facter.rb +211 -211
- data/lib/facter/Cfkey.rb +24 -24
- data/lib/facter/application.rb +1 -0
- data/lib/facter/architecture.rb +21 -29
- data/lib/facter/domain.rb +34 -34
- data/lib/facter/facterversion.rb +1 -1
- data/lib/facter/fqdn.rb +8 -8
- data/lib/facter/hardwareisa.rb +2 -2
- data/lib/facter/hardwaremodel.rb +12 -12
- data/lib/facter/hostname.rb +14 -14
- data/lib/facter/id.rb +3 -3
- data/lib/facter/interfaces.rb +13 -13
- data/lib/facter/ipaddress.rb +101 -101
- data/lib/facter/iphostnumber.rb +12 -12
- data/lib/facter/kernel.rb +7 -7
- data/lib/facter/kernelmajversion.rb +3 -3
- data/lib/facter/kernelrelease.rb +12 -12
- data/lib/facter/kernelversion.rb +5 -5
- data/lib/facter/lsb.rb +14 -14
- data/lib/facter/lsbmajdistrelease.rb +8 -8
- data/lib/facter/macaddress.rb +44 -44
- data/lib/facter/macosx.rb +21 -21
- data/lib/facter/manufacturer.rb +28 -28
- data/lib/facter/memory.rb +143 -115
- data/lib/facter/netmask.rb +4 -4
- data/lib/facter/network.rb +4 -4
- data/lib/facter/operatingsystem.rb +73 -69
- data/lib/facter/operatingsystemrelease.rb +85 -79
- data/lib/facter/osfamily.rb +31 -0
- data/lib/facter/path.rb +3 -3
- data/lib/facter/physicalprocessorcount.rb +8 -0
- data/lib/facter/processor.rb +91 -72
- data/lib/facter/ps.rb +3 -3
- data/lib/facter/puppetversion.rb +7 -7
- data/lib/facter/rubysitedir.rb +5 -5
- data/lib/facter/rubyversion.rb +1 -1
- data/lib/facter/ssh.rb +16 -16
- data/lib/facter/timezone.rb +3 -3
- data/lib/facter/uniqueid.rb +2 -2
- data/lib/facter/util/collection.rb +96 -96
- data/lib/facter/util/confine.rb +30 -30
- data/lib/facter/util/fact.rb +95 -95
- data/lib/facter/util/ip.rb +173 -173
- data/lib/facter/util/loader.rb +88 -88
- data/lib/facter/util/macosx.rb +46 -46
- data/lib/facter/util/manufacturer.rb +78 -78
- data/lib/facter/util/memory.rb +63 -63
- data/lib/facter/util/netmask.rb +34 -34
- data/lib/facter/util/plist.rb +1 -1
- data/lib/facter/util/plist/generator.rb +177 -177
- data/lib/facter/util/plist/parser.rb +166 -166
- data/lib/facter/util/processor.rb +88 -0
- data/lib/facter/util/resolution.rb +154 -154
- data/lib/facter/util/uptime.rb +42 -42
- data/lib/facter/util/values.rb +9 -9
- data/lib/facter/util/virtual.rb +68 -58
- data/lib/facter/util/vlans.rb +17 -17
- data/lib/facter/virtual.rb +105 -110
- data/lib/facter/vlans.rb +6 -6
- data/spec/fixtures/cpuinfo/amd64dual +57 -0
- data/spec/fixtures/cpuinfo/amd64quad +79 -0
- data/spec/fixtures/cpuinfo/amd64solo +23 -0
- data/spec/fixtures/cpuinfo/amd64tri +86 -0
- data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
- data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
- data/spec/fixtures/cpuinfo/panda-armel +17 -0
- data/spec/fixtures/cpuinfo/ppc64 +19 -0
- data/spec/fixtures/cpuinfo/sparc +10 -0
- data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
- data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
- data/spec/integration/facter_spec.rb +18 -18
- data/spec/spec_helper.rb +10 -1
- data/spec/unit/architecture_spec.rb +54 -0
- data/spec/unit/domain_spec.rb +23 -0
- data/spec/unit/memory_spec.rb +78 -1
- data/spec/unit/physicalprocessorcount_spec.rb +41 -35
- data/spec/unit/processor_spec.rb +183 -2
- data/spec/unit/util/processor_spec.rb +62 -0
- data/spec/unit/util/uptime_spec.rb +4 -4
- data/spec/unit/util/virtual_spec.rb +26 -5
- data/spec/unit/virtual_spec.rb +47 -2
- data/spec/watchr.rb +125 -0
- metadata +20 -4
@@ -0,0 +1,225 @@
|
|
1
|
+
module: cpu_info instance: 0
|
2
|
+
name: cpu_info0 class: misc
|
3
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
4
|
+
cache_id 0
|
5
|
+
chip_id 0
|
6
|
+
clock_MHz 2300
|
7
|
+
clog_id 0
|
8
|
+
core_id 0
|
9
|
+
cpu_type i386
|
10
|
+
crtime 150.118972763
|
11
|
+
current_clock_Hz 2300000000
|
12
|
+
current_cstate 0
|
13
|
+
family 16
|
14
|
+
fpu_type i387 compatible
|
15
|
+
implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
16
|
+
model 2
|
17
|
+
ncore_per_chip 4
|
18
|
+
ncpu_per_chip 4
|
19
|
+
pg_id 2
|
20
|
+
pkg_core_id 0
|
21
|
+
snaptime 1964970.24919915
|
22
|
+
state on-line
|
23
|
+
state_begin 1315115687
|
24
|
+
stepping 3
|
25
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
26
|
+
supported_max_cstates 0
|
27
|
+
vendor_id AuthenticAMD
|
28
|
+
|
29
|
+
module: cpu_info instance: 1
|
30
|
+
name: cpu_info1 class: misc
|
31
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
32
|
+
cache_id 1
|
33
|
+
chip_id 0
|
34
|
+
clock_MHz 2300
|
35
|
+
clog_id 1
|
36
|
+
core_id 1
|
37
|
+
cpu_type i386
|
38
|
+
crtime 153.090853556
|
39
|
+
current_clock_Hz 1200000000
|
40
|
+
current_cstate 1
|
41
|
+
family 16
|
42
|
+
fpu_type i387 compatible
|
43
|
+
implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
44
|
+
model 2
|
45
|
+
ncore_per_chip 4
|
46
|
+
ncpu_per_chip 4
|
47
|
+
pg_id 3
|
48
|
+
pkg_core_id 1
|
49
|
+
snaptime 1964970.24965225
|
50
|
+
state on-line
|
51
|
+
state_begin 1315115690
|
52
|
+
stepping 3
|
53
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
54
|
+
supported_max_cstates 0
|
55
|
+
vendor_id AuthenticAMD
|
56
|
+
|
57
|
+
module: cpu_info instance: 2
|
58
|
+
name: cpu_info2 class: misc
|
59
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
60
|
+
cache_id 2
|
61
|
+
chip_id 0
|
62
|
+
clock_MHz 2300
|
63
|
+
clog_id 2
|
64
|
+
core_id 2
|
65
|
+
cpu_type i386
|
66
|
+
crtime 153.160162766
|
67
|
+
current_clock_Hz 1200000000
|
68
|
+
current_cstate 1
|
69
|
+
family 16
|
70
|
+
fpu_type i387 compatible
|
71
|
+
implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
72
|
+
model 2
|
73
|
+
ncore_per_chip 4
|
74
|
+
ncpu_per_chip 4
|
75
|
+
pg_id 4
|
76
|
+
pkg_core_id 2
|
77
|
+
snaptime 1964970.24997443
|
78
|
+
state on-line
|
79
|
+
state_begin 1315115690
|
80
|
+
stepping 3
|
81
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
82
|
+
supported_max_cstates 0
|
83
|
+
vendor_id AuthenticAMD
|
84
|
+
|
85
|
+
module: cpu_info instance: 3
|
86
|
+
name: cpu_info3 class: misc
|
87
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
88
|
+
cache_id 3
|
89
|
+
chip_id 0
|
90
|
+
clock_MHz 2300
|
91
|
+
clog_id 3
|
92
|
+
core_id 3
|
93
|
+
cpu_type i386
|
94
|
+
crtime 153.190177596
|
95
|
+
current_clock_Hz 1200000000
|
96
|
+
current_cstate 1
|
97
|
+
family 16
|
98
|
+
fpu_type i387 compatible
|
99
|
+
implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
100
|
+
model 2
|
101
|
+
ncore_per_chip 4
|
102
|
+
ncpu_per_chip 4
|
103
|
+
pg_id 5
|
104
|
+
pkg_core_id 3
|
105
|
+
snaptime 1964970.2502919
|
106
|
+
state on-line
|
107
|
+
state_begin 1315115690
|
108
|
+
stepping 3
|
109
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
110
|
+
supported_max_cstates 0
|
111
|
+
vendor_id AuthenticAMD
|
112
|
+
|
113
|
+
module: cpu_info instance: 4
|
114
|
+
name: cpu_info4 class: misc
|
115
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
116
|
+
cache_id 4
|
117
|
+
chip_id 1
|
118
|
+
clock_MHz 2300
|
119
|
+
clog_id 0
|
120
|
+
core_id 4
|
121
|
+
cpu_type i386
|
122
|
+
crtime 153.2201642
|
123
|
+
current_clock_Hz 1200000000
|
124
|
+
current_cstate 1
|
125
|
+
family 16
|
126
|
+
fpu_type i387 compatible
|
127
|
+
implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
128
|
+
model 2
|
129
|
+
ncore_per_chip 4
|
130
|
+
ncpu_per_chip 4
|
131
|
+
pg_id 7
|
132
|
+
pkg_core_id 0
|
133
|
+
snaptime 1964970.2505907
|
134
|
+
state on-line
|
135
|
+
state_begin 1315115690
|
136
|
+
stepping 3
|
137
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
138
|
+
supported_max_cstates 0
|
139
|
+
vendor_id AuthenticAMD
|
140
|
+
|
141
|
+
module: cpu_info instance: 5
|
142
|
+
name: cpu_info5 class: misc
|
143
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
144
|
+
cache_id 5
|
145
|
+
chip_id 1
|
146
|
+
clock_MHz 2300
|
147
|
+
clog_id 1
|
148
|
+
core_id 5
|
149
|
+
cpu_type i386
|
150
|
+
crtime 153.250190916
|
151
|
+
current_clock_Hz 1200000000
|
152
|
+
current_cstate 1
|
153
|
+
family 16
|
154
|
+
fpu_type i387 compatible
|
155
|
+
implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
156
|
+
model 2
|
157
|
+
ncore_per_chip 4
|
158
|
+
ncpu_per_chip 4
|
159
|
+
pg_id 8
|
160
|
+
pkg_core_id 1
|
161
|
+
snaptime 1964970.25087316
|
162
|
+
state on-line
|
163
|
+
state_begin 1315115690
|
164
|
+
stepping 3
|
165
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
166
|
+
supported_max_cstates 0
|
167
|
+
vendor_id AuthenticAMD
|
168
|
+
|
169
|
+
module: cpu_info instance: 6
|
170
|
+
name: cpu_info6 class: misc
|
171
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
172
|
+
cache_id 6
|
173
|
+
chip_id 1
|
174
|
+
clock_MHz 2300
|
175
|
+
clog_id 2
|
176
|
+
core_id 6
|
177
|
+
cpu_type i386
|
178
|
+
crtime 153.280185962
|
179
|
+
current_clock_Hz 1200000000
|
180
|
+
current_cstate 1
|
181
|
+
family 16
|
182
|
+
fpu_type i387 compatible
|
183
|
+
implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
184
|
+
model 2
|
185
|
+
ncore_per_chip 4
|
186
|
+
ncpu_per_chip 4
|
187
|
+
pg_id 9
|
188
|
+
pkg_core_id 2
|
189
|
+
snaptime 1964970.25117252
|
190
|
+
state on-line
|
191
|
+
state_begin 1315115690
|
192
|
+
stepping 3
|
193
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
194
|
+
supported_max_cstates 0
|
195
|
+
vendor_id AuthenticAMD
|
196
|
+
|
197
|
+
module: cpu_info instance: 7
|
198
|
+
name: cpu_info7 class: misc
|
199
|
+
brand Quad-Core AMD Opteron(tm) Processor 2356
|
200
|
+
cache_id 7
|
201
|
+
chip_id 1
|
202
|
+
clock_MHz 2300
|
203
|
+
clog_id 3
|
204
|
+
core_id 7
|
205
|
+
cpu_type i386
|
206
|
+
crtime 153.310206904
|
207
|
+
current_clock_Hz 2300000000
|
208
|
+
current_cstate 1
|
209
|
+
family 16
|
210
|
+
fpu_type i387 compatible
|
211
|
+
implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz)
|
212
|
+
model 2
|
213
|
+
ncore_per_chip 4
|
214
|
+
ncpu_per_chip 4
|
215
|
+
pg_id 10
|
216
|
+
pkg_core_id 3
|
217
|
+
snaptime 1964970.25143389
|
218
|
+
state on-line
|
219
|
+
state_begin 1315115690
|
220
|
+
stepping 3
|
221
|
+
supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000
|
222
|
+
supported_max_cstates 0
|
223
|
+
vendor_id AuthenticAMD
|
224
|
+
|
225
|
+
|
@@ -3,25 +3,25 @@
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
4
|
|
5
5
|
describe Facter do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
before do
|
7
|
+
Facter.reset
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
after do
|
11
|
+
Facter.reset
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
it "should create a new collection if one does not exist" do
|
15
|
+
Facter.reset
|
16
|
+
coll = mock('coll')
|
17
|
+
Facter::Util::Collection.stubs(:new).returns coll
|
18
|
+
Facter.collection.should equal(coll)
|
19
|
+
Facter.reset
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
it "should remove the collection when reset" do
|
23
|
+
old = Facter.collection
|
24
|
+
Facter.reset
|
25
|
+
Facter.collection.should_not equal(old)
|
26
|
+
end
|
27
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,10 +16,19 @@ Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file }
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.mock_with :mocha
|
18
18
|
|
19
|
-
# Ensure that we don't accidentally cache
|
19
|
+
# Ensure that we don't accidentally cache facts and environment
|
20
|
+
# between test cases.
|
20
21
|
config.before :each do
|
21
22
|
Facter::Util::Loader.any_instance.stubs(:load_all)
|
22
23
|
Facter.clear
|
23
24
|
Facter.clear_messages
|
25
|
+
@old_env = {}
|
26
|
+
ENV.each_key {|k| @old_env[k] = ENV[k]}
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after :each do
|
30
|
+
@old_env.each_pair {|k, v| ENV[k] = v}
|
31
|
+
to_remove = ENV.keys.reject {|key| @old_env.include? key }
|
32
|
+
to_remove.each {|key| ENV.delete key }
|
24
33
|
end
|
25
34
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
require 'facter'
|
6
|
+
|
7
|
+
describe "Architecture fact" do
|
8
|
+
|
9
|
+
it "should default to the hardware model" do
|
10
|
+
Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW")
|
11
|
+
|
12
|
+
Facter.fact(:architecture).value.should == "NonSpecialCasedHW"
|
13
|
+
end
|
14
|
+
|
15
|
+
os_archs = Hash.new
|
16
|
+
os_archs = {
|
17
|
+
["Debian","x86_64"] => "amd64",
|
18
|
+
["Gentoo","x86_64"] => "amd64",
|
19
|
+
["GNU/kFreeBSD","x86_64"] => "amd64",
|
20
|
+
["Ubuntu","x86_64"] => "amd64",
|
21
|
+
["Gentoo","i386"] => "x86",
|
22
|
+
["Gentoo","i486"] => "x86",
|
23
|
+
["Gentoo","i586"] => "x86",
|
24
|
+
["Gentoo","i686"] => "x86",
|
25
|
+
["Gentoo","pentium"] => "x86",
|
26
|
+
}
|
27
|
+
generic_archs = Hash.new
|
28
|
+
generic_archs = {
|
29
|
+
"i386" => "i386",
|
30
|
+
"i486" => "i386",
|
31
|
+
"i586" => "i386",
|
32
|
+
"i686" => "i386",
|
33
|
+
"pentium" => "i386",
|
34
|
+
}
|
35
|
+
|
36
|
+
os_archs.each do |pair, result|
|
37
|
+
it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do
|
38
|
+
Facter.fact(:operatingsystem).stubs(:value).returns(pair[0])
|
39
|
+
Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1])
|
40
|
+
|
41
|
+
Facter.fact(:architecture).value.should == result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
generic_archs.each do |hw, result|
|
46
|
+
it "should be #{result} if hardwaremodel is #{hw}" do
|
47
|
+
Facter.fact(:hardwaremodel).stubs(:value).returns(hw)
|
48
|
+
Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS")
|
49
|
+
|
50
|
+
Facter.fact(:architecture).value.should == result
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/spec/unit/domain_spec.rb
CHANGED
@@ -69,6 +69,29 @@ describe "Domain name facts" do
|
|
69
69
|
@mock_file.expects(:each).multiple_yields(*lines)
|
70
70
|
Facter.fact(:domain).value.should == 'example.org'
|
71
71
|
end
|
72
|
+
|
73
|
+
# Test permutations of domain and search
|
74
|
+
[
|
75
|
+
["domain domain", "domain"],
|
76
|
+
["domain search", "search"],
|
77
|
+
["search domain", "domain"],
|
78
|
+
["search search", "search"],
|
79
|
+
["search domain notdomain", "domain"],
|
80
|
+
[["#search notdomain","search search"], "search"],
|
81
|
+
[["# search notdomain","search search"], "search"],
|
82
|
+
[["#domain notdomain","domain domain"], "domain"],
|
83
|
+
[["# domain notdomain","domain domain"], "domain"],
|
84
|
+
].each do |tuple|
|
85
|
+
field = tuple[0]
|
86
|
+
expect = tuple[1]
|
87
|
+
it "should return #{expect} from \"#{field}\"" do
|
88
|
+
lines = [
|
89
|
+
field
|
90
|
+
].flatten
|
91
|
+
@mock_file.expects(:each).multiple_yields(*lines)
|
92
|
+
Facter.fact(:domain).value.should == expect
|
93
|
+
end
|
94
|
+
end
|
72
95
|
end
|
73
96
|
end
|
74
97
|
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -42,7 +42,84 @@ describe "Memory facts" do
|
|
42
42
|
swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)"
|
43
43
|
|
44
44
|
swapusage =~ /\(encrypted\)/
|
45
|
-
|
45
|
+
Facter.fact(:swapencrypted).value.should == true
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "on OpenBSD" do
|
49
|
+
before :each do
|
50
|
+
Facter.clear
|
51
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
52
|
+
|
53
|
+
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
54
|
+
Facter::Util::Resolution.stubs(:exec).with('swapctl -s').returns(swapusage)
|
55
|
+
|
56
|
+
vmstat = <<EOS
|
57
|
+
procs memory page disks traps cpu
|
58
|
+
r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id
|
59
|
+
0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100
|
60
|
+
EOS
|
61
|
+
Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat)
|
62
|
+
|
63
|
+
Facter::Util::Resolution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344')
|
64
|
+
|
65
|
+
Facter.collection.loader.load(:memory)
|
66
|
+
end
|
67
|
+
|
68
|
+
after :each do
|
69
|
+
Facter.clear
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should return the current swap free" do
|
73
|
+
Facter.fact(:swapfree).value.should == "144.87 MB"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return the current swap size" do
|
77
|
+
Facter.fact(:swapsize).value.should == "144.87 MB"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return the current memorysize" do
|
81
|
+
Facter.fact(:memorytotal).value.should == "254.94 MB"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "on DragonFly BSD" do
|
86
|
+
before :each do
|
87
|
+
Facter.clear
|
88
|
+
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
89
|
+
|
90
|
+
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
91
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096")
|
92
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461")
|
93
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635")
|
94
|
+
Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0")
|
95
|
+
|
96
|
+
vmstat = <<EOS
|
97
|
+
procs memory page disks faults cpu
|
98
|
+
r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id
|
99
|
+
0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9
|
100
|
+
EOS
|
101
|
+
Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat)
|
102
|
+
|
103
|
+
Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512')
|
104
|
+
|
105
|
+
Facter.collection.loader.load(:memory)
|
106
|
+
end
|
107
|
+
|
108
|
+
after :each do
|
109
|
+
Facter.clear
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return the current swap free" do
|
113
|
+
Facter.fact(:swapfree).value.should == "491.51 MB"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return the current swap size" do
|
117
|
+
Facter.fact(:swapsize).value.should == "501.80 MB"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return the current memorysize" do
|
121
|
+
Facter.fact(:memorytotal).value.should == "237.00 MB"
|
122
|
+
end
|
46
123
|
end
|
47
124
|
|
48
125
|
describe "on Windows" do
|