facter 2.0.2-x86-mingw32 → 2.1.0-x86-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile +14 -0
- data/ext/project_data.yaml +9 -6
- data/lib/facter/core/execution/base.rb +3 -3
- data/lib/facter/core/suitable.rb +1 -5
- data/lib/facter/dhcp_servers.rb +39 -0
- data/lib/facter/ec2.rb +33 -26
- data/lib/facter/ec2/rest.rb +130 -0
- data/lib/facter/fqdn.rb +2 -0
- data/lib/facter/gce.rb +16 -0
- data/lib/facter/gce/metadata.rb +87 -0
- data/lib/facter/kernelmajversion.rb +8 -0
- data/lib/facter/kernelrelease.rb +8 -0
- data/lib/facter/memory.rb +21 -15
- data/lib/facter/netmask.rb +1 -1
- data/lib/facter/operatingsystem.rb +20 -0
- data/lib/facter/operatingsystemmajrelease.rb +2 -1
- data/lib/facter/operatingsystemrelease.rb +19 -0
- data/lib/facter/osfamily.rb +3 -1
- data/lib/facter/partitions.rb +35 -0
- data/lib/facter/physicalprocessorcount.rb +9 -0
- data/lib/facter/processor.rb +25 -25
- data/lib/facter/util/config.rb +3 -1
- data/lib/facter/util/dhcp_servers.rb +43 -0
- data/lib/facter/util/ec2.rb +5 -0
- data/lib/facter/util/formatter.rb +2 -1
- data/lib/facter/util/ip.rb +1 -1
- data/lib/facter/util/loader.rb +10 -1
- data/lib/facter/util/manufacturer.rb +15 -16
- data/lib/facter/util/memory.rb +12 -12
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/operatingsystem.rb +21 -0
- data/lib/facter/util/partitions.rb +41 -0
- data/lib/facter/util/partitions/linux.rb +65 -0
- data/lib/facter/util/posix.rb +16 -0
- data/lib/facter/util/processor.rb +8 -10
- data/lib/facter/util/resolution.rb +4 -0
- data/lib/facter/util/values.rb +29 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/util/windows_root.rb +2 -32
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +53 -12
- data/spec/fixtures/ifconfig/openbsd_bridge_rules +11 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected +4 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp +36 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static +24 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp +49 -0
- data/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static +37 -0
- data/spec/fixtures/unit/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/ec2/rest/meta-data/root +20 -0
- data/spec/fixtures/unit/gce/metadata/metadata.json +69 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3 +2 -0
- data/spec/fixtures/unit/kernelrelease/openbsd-5.3-current +3 -0
- data/spec/fixtures/unit/memory/aix-svmon +9 -0
- data/spec/fixtures/unit/memory/aix-swap_l +2 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-multiple +3 -0
- data/spec/fixtures/unit/memory/darwin-swapinfo-single +2 -0
- data/spec/fixtures/unit/memory/darwin-vm_stat +13 -0
- data/spec/fixtures/unit/memory/dragonfly-vmstat +3 -0
- data/spec/fixtures/unit/memory/freebsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/linux-proc_meminfo +10 -0
- data/spec/fixtures/unit/memory/openbsd-vmstat +3 -0
- data/spec/fixtures/unit/memory/smartos_zone_swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-prtconf +4 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-multiple +3 -0
- data/spec/fixtures/unit/memory/solaris-swap_l-single +2 -0
- data/spec/fixtures/unit/memory/solaris-vmstat +3 -0
- data/spec/fixtures/unit/netmask/ifconfig_aix_7.txt +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route +3 -0
- data/spec/fixtures/unit/util/dhcp_servers/route_nogw +1 -0
- data/spec/fixtures/unit/util/manufacturer/smartos_smbios +533 -0
- data/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt +8 -0
- data/spec/fixtures/unit/util/operatingsystem/redhat-7.txt +12 -0
- data/spec/fixtures/unit/util/operatingsystem/sabayon.txt +7 -0
- data/spec/fixtures/unit/util/operatingsystem/wheezy.txt +9 -0
- data/spec/fixtures/unit/util/partitions/partitions/mount +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_container +9 -0
- data/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container +8 -0
- data/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container +9 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/core/execution/base_spec.rb +3 -5
- data/spec/unit/core/execution/posix_spec.rb +2 -2
- data/spec/unit/core/suitable_spec.rb +10 -0
- data/spec/unit/dhcp_servers_spec.rb +152 -0
- data/spec/unit/ec2/rest_spec.rb +145 -0
- data/spec/unit/ec2_spec.rb +87 -147
- data/spec/unit/fqdn_spec.rb +16 -0
- data/spec/unit/gce/metadata_spec.rb +49 -0
- data/spec/unit/gce_spec.rb +34 -0
- data/spec/unit/interfaces_spec.rb +9 -9
- data/spec/unit/kernelmajversion_spec.rb +14 -9
- data/spec/unit/kernelrelease_spec.rb +16 -0
- data/spec/unit/macaddress_spec.rb +12 -0
- data/spec/unit/memory_spec.rb +53 -122
- data/spec/unit/netmask_spec.rb +11 -0
- data/spec/unit/operatingsystem_spec.rb +19 -0
- data/spec/unit/operatingsystemmajrelease_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +8 -0
- data/spec/unit/osfamily_spec.rb +62 -0
- data/spec/unit/partitions_spec.rb +48 -0
- data/spec/unit/physicalprocessorcount_spec.rb +9 -0
- data/spec/unit/processor_spec.rb +15 -7
- data/spec/unit/util/config_spec.rb +13 -0
- data/spec/unit/util/dhcp_servers_spec.rb +63 -0
- data/spec/unit/util/ec2_spec.rb +4 -0
- data/spec/unit/util/formatter_spec.rb +50 -0
- data/spec/unit/util/loader_spec.rb +4 -4
- data/spec/unit/util/macosx_spec.rb +3 -2
- data/spec/unit/util/manufacturer_spec.rb +44 -0
- data/spec/unit/util/operatingsystem_spec.rb +92 -0
- data/spec/unit/util/partitions/partitions_spec.rb +67 -0
- data/spec/unit/util/partitions_spec.rb +19 -0
- data/spec/unit/util/posix_spec.rb +11 -0
- data/spec/unit/util/values_spec.rb +40 -0
- data/spec/unit/util/virtual_spec.rb +72 -2
- data/spec/unit/virtual_spec.rb +67 -18
- metadata +124 -54
- data/spec/fixtures/unit/util/loader/nosuchfact.rb +0 -1
@@ -0,0 +1,16 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "fqdn fact" do
|
6
|
+
it "should concatenate hostname and domain" do
|
7
|
+
Facter.fact(:hostname).stubs(:value).returns("foo")
|
8
|
+
Facter.fact(:domain).stubs(:value).returns("bar")
|
9
|
+
Facter.fact(:fqdn).value.should == "foo.bar"
|
10
|
+
end
|
11
|
+
it "should return hostname when domain is nil" do
|
12
|
+
Facter.fact(:hostname).stubs(:value).returns("foo")
|
13
|
+
Facter.fact(:domain).stubs(:value).returns(nil)
|
14
|
+
Facter.fact(:fqdn).value.should == "foo"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'facter/gce/metadata'
|
3
|
+
|
4
|
+
describe Facter::GCE::Metadata, :if => Facter.json? do
|
5
|
+
|
6
|
+
describe "contacting the metadata server" do
|
7
|
+
it "retries the request when a connection error is thrown" do
|
8
|
+
subject.stubs(:open).returns(stub(:read => '{"hello": "world"}'))
|
9
|
+
seq = sequence('open-uri seq')
|
10
|
+
Timeout.expects(:timeout).with(0.05).twice.in_sequence(seq).raises(Timeout::Error)
|
11
|
+
Timeout.expects(:timeout).with(0.05).once.in_sequence(seq).yields
|
12
|
+
expect(subject.fetch).to eq({'hello' => 'world'})
|
13
|
+
end
|
14
|
+
|
15
|
+
it "logs the exception when all retries failed" do
|
16
|
+
Timeout.expects(:timeout).with(0.05).times(3).raises(Timeout::Error)
|
17
|
+
Facter.expects(:log_exception).with(instance_of(Timeout::Error), instance_of(String))
|
18
|
+
expect(subject.fetch).to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "parsing the metadata response" do
|
23
|
+
let(:body) { my_fixture_read('metadata.json') }
|
24
|
+
before do
|
25
|
+
subject.stubs(:open).returns(stub(:read => body))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "transforms hash values with the 'image' key" do
|
29
|
+
expect(subject.fetch['instance']['image']).to eq 'centos6'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "transforms hash values with the 'machineType' key" do
|
33
|
+
expect(subject.fetch['instance']['machineType']).to eq 'n1-standard-1'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "transforms hash values with the 'zone' key" do
|
37
|
+
expect(subject.fetch['instance']['zone']).to eq 'us-central1-b'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "transforms hash values with the 'network' key" do
|
41
|
+
expect(subject.fetch['instance']['networkInterfaces'][0]['network']).to eq 'default'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "splits up the elements of the 'sshKeys' value into an array" do
|
45
|
+
expect(subject.fetch['project']['attributes']['sshKeys'][0]).to match(/justin:ssh-rsa/)
|
46
|
+
expect(subject.fetch['project']['attributes']['sshKeys'][1]).to match(/adrien:ssh-rsa/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'facter/gce/metadata'
|
3
|
+
|
4
|
+
describe "gce_metadata" do
|
5
|
+
let(:querier) { stub('GCE metadata querier') }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Facter::GCE::Metadata.stubs(:new).returns querier
|
9
|
+
Facter.collection.internal_loader.load(:ec2)
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { Facter.fact(:gce).resolution(:rest) }
|
13
|
+
|
14
|
+
it "is unsuitable when the virtual type is not gce" do
|
15
|
+
Facter.fact(:virtual).stubs(:value).returns 'kvm'
|
16
|
+
expect(subject).to_not be_suitable
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is unsuitable when JSON is not available" do
|
20
|
+
Facter.stubs(:json?).returns false
|
21
|
+
expect(subject).to_not be_suitable
|
22
|
+
end
|
23
|
+
|
24
|
+
it "is suitable when both the virtual type is gce and JSON is available" do
|
25
|
+
Facter.fact(:virtual).stubs(:value).returns 'gce'
|
26
|
+
Facter.stubs(:json?).returns true
|
27
|
+
expect(subject).to be_suitable
|
28
|
+
end
|
29
|
+
|
30
|
+
it "resolves the fact by querying GCE metadata API" do
|
31
|
+
querier.expects(:fetch).returns({'hello' => 'world'})
|
32
|
+
expect(subject.value).to eq({'hello' => 'world'})
|
33
|
+
end
|
34
|
+
end
|
@@ -4,15 +4,15 @@ require 'spec_helper'
|
|
4
4
|
require 'shared_formats/parses'
|
5
5
|
require 'facter/util/ip'
|
6
6
|
|
7
|
-
shared_examples_for "
|
8
|
-
it "
|
7
|
+
shared_examples_for "interface netmask and mtu from ifconfig output" do |platform, interface, netmask, mtu, fixture|
|
8
|
+
it "should be correct on #{platform} for interface #{interface}" do
|
9
9
|
Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
|
10
10
|
Facter::Util::IP.stubs(:get_output_for_interface_and_label).
|
11
11
|
returns(my_fixture_read("#{fixture}.#{interface}"))
|
12
12
|
Facter.collection.internal_loader.load(:interfaces)
|
13
13
|
|
14
|
-
|
15
|
-
fact.value.should eq(
|
14
|
+
Facter.fact("netmask_#{interface}".intern).value.should eq(netmask)
|
15
|
+
Facter.fact("mtu_#{interface}".intern).value.should eq(mtu)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -43,15 +43,15 @@ describe "Per Interface IP facts" do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe "Netmask handling on Linux" do
|
46
|
+
describe "Netmask and MTU handling on Linux" do
|
47
47
|
before :each do
|
48
48
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
49
49
|
end
|
50
50
|
|
51
|
-
example_behavior_for "
|
51
|
+
example_behavior_for "interface netmask and mtu from ifconfig output",
|
52
52
|
"Archlinux (net-tools 1.60)", "em1",
|
53
|
-
"255.255.255.0", "ifconfig_net_tools_1.60.txt"
|
54
|
-
example_behavior_for "
|
53
|
+
"255.255.255.0", "1500", "ifconfig_net_tools_1.60.txt"
|
54
|
+
example_behavior_for "interface netmask and mtu from ifconfig output",
|
55
55
|
"Archlinux (net-tools 1.60)", "lo",
|
56
|
-
"255.0.0.0", "ifconfig_net_tools_1.60.txt"
|
56
|
+
"255.0.0.0", "16436", "ifconfig_net_tools_1.60.txt"
|
57
57
|
end
|
@@ -3,15 +3,20 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe "Kernel major version fact" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return the kernel major release using the kernel release" do
|
12
|
-
Facter.fact(:kernelmajversion).value.should == "12.34"
|
13
|
-
end
|
14
|
-
end
|
6
|
+
context "when the kernelrelease fact contains three components" do
|
7
|
+
it "returns the first two components" do
|
8
|
+
Facter.fact(:kernelversion).stubs(:value).returns("12.34.56")
|
15
9
|
|
10
|
+
Facter.fact(:kernelmajversion).value.should == "12.34"
|
11
|
+
end
|
12
|
+
end
|
16
13
|
|
14
|
+
context "when the kernelrelease fact only contains two components" do
|
15
|
+
it "returns the first component" do
|
16
|
+
Facter.fact(:kernel).stubs(:value).returns('FreeBSD')
|
17
|
+
Facter.fact(:kernelversion).stubs(:value).returns("9.2")
|
17
18
|
|
19
|
+
Facter.fact(:kernelmajversion).value.should == "9"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -50,4 +50,20 @@ describe "Kernel release fact" do
|
|
50
50
|
Facter.fact(:kernelrelease).value.should == "test_kernel"
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
describe 'on OpenBSD' do
|
55
|
+
before do
|
56
|
+
Facter.fact(:kernel).stubs(:value).returns :openbsd
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'parses 5.3-current sysctl output' do
|
60
|
+
Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3-current'))
|
61
|
+
Facter.value(:kernelrelease).should == '5.3-current'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'parses 5.3 sysctl output' do
|
65
|
+
Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3'))
|
66
|
+
Facter.value(:kernelrelease).should == '5.3'
|
67
|
+
end
|
68
|
+
end
|
53
69
|
end
|
@@ -58,4 +58,16 @@ describe "macaddress fact" do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
describe "when run on OpenBSD with bridge(4) rules" do
|
62
|
+
it "should return macaddress information" do
|
63
|
+
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
64
|
+
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
65
|
+
Facter::Util::IP.stubs(:exec_ifconfig).
|
66
|
+
returns(ifconfig_fixture('openbsd_bridge_rules'))
|
67
|
+
|
68
|
+
proc { Facter.value(:macaddress) }.should_not raise_error
|
69
|
+
Facter.value(:macaddress).should be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
end
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -48,24 +48,9 @@ describe "Memory facts" do
|
|
48
48
|
before(:each) do
|
49
49
|
Facter.clear
|
50
50
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
51
|
-
Facter::
|
52
|
-
|
53
|
-
|
54
|
-
Pages free: 28430.
|
55
|
-
Pages active: 1152576.
|
56
|
-
Pages inactive: 489054.
|
57
|
-
Pages speculative: 7076.
|
58
|
-
Pages wired down: 418217.
|
59
|
-
"Translation faults": 1340091228.
|
60
|
-
Pages copy-on-write: 16851357.
|
61
|
-
Pages zero filled: 665168768.
|
62
|
-
Pages reactivated: 3082708.
|
63
|
-
Pageins: 13862917.
|
64
|
-
Pageouts: 1384383.
|
65
|
-
Object cache: 14 hits of 2619925 lookups (0% hit rate)
|
66
|
-
VMSTAT
|
67
|
-
Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(sample_vm_stat)
|
68
|
-
Facter::Core::Execution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 1.00M free = 63.00M (encrypted)")
|
51
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.memsize').returns('8589934592')
|
52
|
+
Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(my_fixture_read('darwin-vm_stat'))
|
53
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swapusage').returns("vm.swapusage: total = 64.00M used = 1.00M free = 63.00M (encrypted)")
|
69
54
|
|
70
55
|
Facter.collection.internal_loader.load(:memory)
|
71
56
|
end
|
@@ -104,20 +89,10 @@ VMSTAT
|
|
104
89
|
before(:each) do
|
105
90
|
Facter.clear
|
106
91
|
Facter.fact(:kernel).stubs(:value).returns(kernel)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Cached: 115124 kB
|
112
|
-
SwapCached: 0 kB
|
113
|
-
Active: 92700 kB
|
114
|
-
Inactive: 63792 kB
|
115
|
-
SwapTotal: 524280 kB
|
116
|
-
SwapFree: 524280 kB
|
117
|
-
Dirty: 4 kB
|
118
|
-
INFO
|
119
|
-
|
120
|
-
File.stubs(:readlines).with("/proc/meminfo").returns(meminfo.split("\n"))
|
92
|
+
|
93
|
+
meminfo_contents = my_fixture_read('linux-proc_meminfo').split("\n")
|
94
|
+
|
95
|
+
File.stubs(:readlines).with("/proc/meminfo").returns(meminfo_contents)
|
121
96
|
|
122
97
|
Facter.collection.internal_loader.load(:memory)
|
123
98
|
end
|
@@ -149,26 +124,8 @@ INFO
|
|
149
124
|
Facter.clear
|
150
125
|
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
151
126
|
|
152
|
-
|
153
|
-
|
154
|
-
/dev/hd6 10, 2 512MB 508MB
|
155
|
-
SWAP
|
156
|
-
|
157
|
-
Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
|
158
|
-
|
159
|
-
svmon = <<SVMON
|
160
|
-
Unit: KB
|
161
|
-
--------------------------------------------------------------------------------------
|
162
|
-
size inuse free pin virtual available mmode
|
163
|
-
memory 32768000 9948408 22819592 2432080 4448928 27231828 Ded
|
164
|
-
pg space 34078720 15000
|
165
|
-
|
166
|
-
work pers clnt other
|
167
|
-
pin 1478228 0 0 953852
|
168
|
-
in use 4448928 0 5499480
|
169
|
-
SVMON
|
170
|
-
|
171
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon)
|
127
|
+
Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(my_fixture_read('aix-swap_l'))
|
128
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(my_fixture_read('aix-svmon'))
|
172
129
|
|
173
130
|
Facter.collection.internal_loader.load(:memory)
|
174
131
|
end
|
@@ -221,17 +178,13 @@ SVMON
|
|
221
178
|
Facter.clear
|
222
179
|
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
223
180
|
|
224
|
-
swapusage = "total:
|
181
|
+
swapusage = "total: 4080510 512-blocks allocated, 461832 used, 3618678 available"
|
225
182
|
Facter::Core::Execution.stubs(:exec).with('swapctl -s').returns(swapusage)
|
226
183
|
|
227
|
-
vmstat
|
228
|
-
procs memory page disks traps cpu
|
229
|
-
r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id
|
230
|
-
0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100
|
231
|
-
EOS
|
232
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
184
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('openbsd-vmstat'))
|
233
185
|
|
234
|
-
Facter::
|
186
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns('267321344')
|
187
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swapencrypt.enable').returns('1')
|
235
188
|
|
236
189
|
Facter.collection.internal_loader.load(:memory)
|
237
190
|
end
|
@@ -241,11 +194,11 @@ EOS
|
|
241
194
|
end
|
242
195
|
|
243
196
|
it "should return the current swap free in MB" do
|
244
|
-
Facter.fact(:swapfree_mb).value.should == "
|
197
|
+
Facter.fact(:swapfree_mb).value.should == "1766.93"
|
245
198
|
end
|
246
199
|
|
247
200
|
it "should return the current swap size in MB" do
|
248
|
-
Facter.fact(:swapsize_mb).value.should == "
|
201
|
+
Facter.fact(:swapsize_mb).value.should == "1992.44"
|
249
202
|
end
|
250
203
|
|
251
204
|
it "should return the current memory free in MB" do
|
@@ -255,26 +208,20 @@ EOS
|
|
255
208
|
it "should return the current memory size in MB" do
|
256
209
|
Facter.fact(:memorysize_mb).value.should == "254.94"
|
257
210
|
end
|
211
|
+
|
212
|
+
it "should return whether swap is encrypted" do
|
213
|
+
Facter.fact(:swapencrypted).value.should == true
|
214
|
+
end
|
258
215
|
end
|
259
216
|
|
217
|
+
|
260
218
|
describe "on Solaris" do
|
261
219
|
before(:each) do
|
262
220
|
Facter.clear
|
263
221
|
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
264
|
-
sample_prtconf = <<PRTCONF
|
265
|
-
System Configuration: Sun Microsystems sun4u
|
266
|
-
Memory size: 2048 Megabytes
|
267
|
-
System Peripherals (Software Nodes):
|
268
|
-
|
269
|
-
PRTCONF
|
270
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns sample_prtconf
|
271
222
|
|
272
|
-
|
273
|
-
|
274
|
-
r b w swap free re mf pi po fr de sr s0 s3 -- -- in sy cs us sy id
|
275
|
-
0 0 0 1154552 476224 8 19 0 0 0 0 0 0 0 0 0 460 294 236 1 2 97
|
276
|
-
VMSTAT
|
277
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat_lines)
|
223
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns(my_fixture_read('solaris-prtconf'))
|
224
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('solaris-vmstat'))
|
278
225
|
end
|
279
226
|
|
280
227
|
after(:each) do
|
@@ -283,11 +230,7 @@ VMSTAT
|
|
283
230
|
|
284
231
|
describe "when single swap exists" do
|
285
232
|
before(:each) do
|
286
|
-
|
287
|
-
swapfile dev swaplo blocks free
|
288
|
-
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
289
|
-
SWAP
|
290
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
233
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-single')
|
291
234
|
|
292
235
|
Facter.collection.internal_loader.load(:memory)
|
293
236
|
end
|
@@ -307,16 +250,12 @@ SWAP
|
|
307
250
|
it "should return the current swap size in MB" do
|
308
251
|
Facter.fact(:swapsize_mb).value.should == "1023.99"
|
309
252
|
end
|
253
|
+
|
310
254
|
end
|
311
255
|
|
312
256
|
describe "when multiple swaps exist" do
|
313
257
|
before(:each) do
|
314
|
-
|
315
|
-
swapfile dev swaplo blocks free
|
316
|
-
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
317
|
-
/dev/swap2 4294967295,4294967295 16 2097136 2097136
|
318
|
-
SWAP
|
319
|
-
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
258
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-multiple')
|
320
259
|
Facter.collection.internal_loader.load(:memory)
|
321
260
|
end
|
322
261
|
|
@@ -360,6 +299,22 @@ SWAP
|
|
360
299
|
Facter.fact(:swapsize_mb).value.should == "0.00"
|
361
300
|
end
|
362
301
|
end
|
302
|
+
|
303
|
+
describe "when in a SmartOS zone" do
|
304
|
+
before(:each) do
|
305
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('smartos_zone_swap_l-single')
|
306
|
+
Facter.collection.internal_loader.load(:memory)
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should return the current swap size in MB" do
|
310
|
+
Facter.fact(:swapsize_mb).value.should == "49152.00"
|
311
|
+
end
|
312
|
+
|
313
|
+
it "should return the current swap free in MB" do
|
314
|
+
Facter.fact(:swapfree_mb).value.should == "33676.06"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
363
318
|
end
|
364
319
|
|
365
320
|
describe "on DragonFly BSD" do
|
@@ -368,19 +323,14 @@ SWAP
|
|
368
323
|
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
369
324
|
|
370
325
|
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
371
|
-
Facter::
|
372
|
-
Facter::
|
373
|
-
Facter::
|
374
|
-
Facter::
|
326
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.pagesize').returns("4096")
|
327
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_size').returns("128461")
|
328
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_anon_use').returns("2635")
|
329
|
+
Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_cache_use').returns("0")
|
375
330
|
|
376
|
-
vmstat
|
377
|
-
procs memory page disks faults cpu
|
378
|
-
r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id
|
379
|
-
0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9
|
380
|
-
EOS
|
381
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
331
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns my_fixture_read('dragonfly-vmstat')
|
382
332
|
|
383
|
-
Facter::
|
333
|
+
Facter::Util::POSIX.stubs(:sysctl).with("hw.physmem").returns('248512512')
|
384
334
|
|
385
335
|
Facter.collection.internal_loader.load(:memory)
|
386
336
|
end
|
@@ -411,16 +361,8 @@ EOS
|
|
411
361
|
Facter.clear
|
412
362
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
413
363
|
|
414
|
-
|
415
|
-
|
416
|
-
r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id
|
417
|
-
1 0 0 207600 656640 10 0 0 0 13 0 0 0 51 164 257 0 1 99
|
418
|
-
VM_STAT
|
419
|
-
Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns sample_vmstat
|
420
|
-
sample_physmem = <<PHYSMEM
|
421
|
-
1056276480
|
422
|
-
PHYSMEM
|
423
|
-
Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns sample_physmem
|
364
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns my_fixture_read('freebsd-vmstat')
|
365
|
+
Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns '1056276480'
|
424
366
|
end
|
425
367
|
|
426
368
|
after(:each) do
|
@@ -429,11 +371,9 @@ PHYSMEM
|
|
429
371
|
|
430
372
|
describe "with no swap" do
|
431
373
|
before(:each) do
|
432
|
-
sample_swapinfo =
|
433
|
-
Device 1K-blocks Used Avail Capacity
|
434
|
-
SWAP
|
435
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
374
|
+
sample_swapinfo = 'Device 1K-blocks Used Avail Capacity'
|
436
375
|
|
376
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
437
377
|
Facter.collection.internal_loader.load(:memory)
|
438
378
|
end
|
439
379
|
|
@@ -456,11 +396,7 @@ SWAP
|
|
456
396
|
|
457
397
|
describe "with one swap" do
|
458
398
|
before(:each) do
|
459
|
-
|
460
|
-
Device 1K-blocks Used Avail Capacity
|
461
|
-
/dev/da0p3 2048540 0 1048540 0%
|
462
|
-
SWAP
|
463
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
399
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-single')
|
464
400
|
|
465
401
|
Facter.collection.internal_loader.load(:memory)
|
466
402
|
end
|
@@ -484,12 +420,7 @@ SWAP
|
|
484
420
|
|
485
421
|
describe "with multiple swaps" do
|
486
422
|
before(:each) do
|
487
|
-
|
488
|
-
Device 1K-blocks Used Avail Capacity
|
489
|
-
/dev/da0p3 2048540 0 1048540 0%
|
490
|
-
/dev/da0p4 3048540 0 1048540 0%
|
491
|
-
SWAP
|
492
|
-
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
423
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-multiple')
|
493
424
|
|
494
425
|
Facter.collection.internal_loader.load(:memory)
|
495
426
|
end
|