facter 1.7.6 → 2.0.1.rc1
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 +7 -0
- data/COMMITTERS.md +194 -0
- data/CONTRIBUTING.md +63 -235
- data/Gemfile +12 -8
- data/README.md +1 -2
- data/Rakefile +1 -1
- data/bin/facter +0 -4
- data/ext/build_defaults.yaml +2 -2
- data/ext/project_data.yaml +18 -0
- data/install.rb +1 -16
- data/lib/facter.rb +171 -171
- data/lib/facter/application.rb +65 -54
- data/lib/facter/core/aggregate.rb +220 -0
- data/lib/facter/core/directed_graph.rb +46 -0
- data/lib/facter/core/execution.rb +100 -0
- data/lib/facter/core/execution/base.rb +73 -0
- data/lib/facter/core/execution/posix.rb +50 -0
- data/lib/facter/core/execution/windows.rb +57 -0
- data/lib/facter/core/logging.rb +169 -0
- data/lib/facter/core/resolvable.rb +94 -0
- data/lib/facter/core/suitable.rb +117 -0
- data/lib/facter/domain.rb +15 -9
- data/lib/facter/filesystems.rb +1 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/hostname.rb +3 -3
- data/lib/facter/interfaces.rb +6 -1
- data/lib/facter/ipaddress.rb +2 -2
- data/lib/facter/kernel.rb +1 -1
- data/lib/facter/kernelrelease.rb +1 -1
- data/lib/facter/ldom.rb +1 -1
- data/lib/facter/lsbdistcodename.rb +1 -1
- data/lib/facter/lsbdistdescription.rb +1 -1
- data/lib/facter/lsbdistid.rb +1 -1
- data/lib/facter/lsbdistrelease.rb +1 -1
- data/lib/facter/lsbrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -14
- data/lib/facter/macosx.rb +2 -2
- data/lib/facter/memory.rb +8 -19
- data/lib/facter/operatingsystem.rb +1 -1
- data/lib/facter/operatingsystemrelease.rb +34 -1
- data/lib/facter/physicalprocessorcount.rb +6 -6
- data/lib/facter/processor.rb +11 -10
- data/lib/facter/selinux.rb +4 -15
- data/lib/facter/ssh.rb +5 -2
- data/lib/facter/util/architecture.rb +2 -2
- data/lib/facter/util/collection.rb +42 -38
- data/lib/facter/util/config.rb +19 -9
- data/lib/facter/util/confine.rb +34 -4
- data/lib/facter/util/ec2.rb +1 -1
- data/lib/facter/util/fact.rb +108 -36
- data/lib/facter/util/file_read.rb +7 -6
- data/lib/facter/util/formatter.rb +38 -0
- data/lib/facter/util/ip.rb +3 -3
- data/lib/facter/util/loader.rb +62 -42
- data/lib/facter/util/macosx.rb +7 -8
- data/lib/facter/util/manufacturer.rb +3 -3
- data/lib/facter/util/memory.rb +13 -13
- data/lib/facter/util/monkey_patches.rb +0 -31
- data/lib/facter/util/netmask.rb +3 -3
- data/lib/facter/util/normalization.rb +94 -0
- data/lib/facter/util/nothing_loader.rb +3 -6
- data/lib/facter/util/parser.rb +3 -5
- data/lib/facter/util/plist/generator.rb +1 -1
- data/lib/facter/util/processor.rb +15 -15
- data/lib/facter/util/resolution.rb +112 -289
- data/lib/facter/util/solaris_zones.rb +4 -4
- data/lib/facter/util/uptime.rb +8 -3
- data/lib/facter/util/values.rb +67 -1
- data/lib/facter/util/virtual.rb +10 -10
- data/lib/facter/util/xendomains.rb +1 -1
- data/lib/facter/version.rb +42 -39
- data/lib/facter/virtual.rb +6 -7
- data/lib/facter/zfs_version.rb +3 -3
- data/lib/facter/zpool_version.rb +3 -3
- data/spec/fixtures/unit/netmask/darwin_10_8_5.txt +30 -0
- data/spec/unit/application_spec.rb +46 -1
- data/spec/unit/core/aggregate_spec.rb +125 -0
- data/spec/unit/core/directed_graph_spec.rb +79 -0
- data/spec/unit/core/execution/base_spec.rb +119 -0
- data/spec/unit/core/execution/posix_spec.rb +86 -0
- data/spec/unit/core/execution/windows_spec.rb +106 -0
- data/spec/unit/core/execution_spec.rb +37 -0
- data/spec/unit/core/logging_spec.rb +104 -0
- data/spec/unit/core/resolvable_spec.rb +81 -0
- data/spec/unit/core/suitable_spec.rb +96 -0
- data/spec/unit/domain_spec.rb +5 -5
- data/spec/unit/facter_spec.rb +61 -222
- data/spec/unit/filesystems_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +5 -5
- data/spec/unit/hardwaremodel_spec.rb +1 -1
- data/spec/unit/hostname_spec.rb +4 -4
- data/spec/unit/id_spec.rb +3 -3
- data/spec/unit/interfaces_spec.rb +10 -0
- data/spec/unit/ipaddress6_spec.rb +4 -4
- data/spec/unit/ipaddress_spec.rb +1 -1
- data/spec/unit/kernel_spec.rb +2 -2
- data/spec/unit/kernelmajversion_spec.rb +1 -1
- data/spec/unit/kernelrelease_spec.rb +4 -4
- data/spec/unit/kernelversion_spec.rb +2 -2
- data/spec/unit/ldom_spec.rb +2 -2
- data/spec/unit/lsbdistcodename_spec.rb +2 -2
- data/spec/unit/lsbdistdescription_spec.rb +2 -2
- data/spec/unit/lsbdistid_spec.rb +2 -2
- data/spec/unit/lsbdistrelease_spec.rb +2 -2
- data/spec/unit/lsbrelease_spec.rb +2 -2
- data/spec/unit/manufacturer_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +24 -31
- data/spec/unit/netmask_spec.rb +9 -0
- data/spec/unit/operatingsystem_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +62 -4
- data/spec/unit/physicalprocessorcount_spec.rb +10 -10
- data/spec/unit/processor_spec.rb +11 -11
- data/spec/unit/selinux_spec.rb +2 -8
- data/spec/unit/ssh_spec.rb +3 -2
- data/spec/unit/uniqueid_spec.rb +3 -3
- data/spec/unit/util/collection_spec.rb +37 -35
- data/spec/unit/util/config_spec.rb +20 -0
- data/spec/unit/util/confine_spec.rb +21 -0
- data/spec/unit/util/directory_loader_spec.rb +1 -0
- data/spec/unit/util/ec2_spec.rb +6 -6
- data/spec/unit/util/fact_spec.rb +92 -90
- data/spec/unit/util/ip_spec.rb +2 -2
- data/spec/unit/util/loader_spec.rb +127 -186
- data/spec/unit/util/macaddress_spec.rb +2 -2
- data/spec/unit/util/macosx_spec.rb +8 -8
- data/spec/unit/util/manufacturer_spec.rb +3 -3
- data/spec/unit/util/normalization_spec.rb +113 -0
- data/spec/unit/util/parser_spec.rb +25 -3
- data/spec/unit/util/processor_spec.rb +2 -2
- data/spec/unit/util/resolution_spec.rb +60 -631
- data/spec/unit/util/solaris_zones_spec.rb +5 -5
- data/spec/unit/util/uptime_spec.rb +1 -1
- data/spec/unit/util/values_spec.rb +131 -0
- data/spec/unit/util/virtual_spec.rb +16 -16
- data/spec/unit/util/xendomains_spec.rb +2 -2
- data/spec/unit/virtual_spec.rb +39 -39
- data/spec/unit/zfs_version_spec.rb +11 -11
- data/spec/unit/zonename_spec.rb +2 -2
- data/spec/unit/zones_spec.rb +1 -1
- data/spec/unit/zpool_version_spec.rb +11 -11
- metadata +466 -447
- data/lib/facter/util/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/LICENSE +0 -19
- data/lib/facter/util/cfpropertylist/README +0 -44
- data/lib/facter/util/cfpropertylist/Rakefile +0 -44
- data/lib/facter/util/cfpropertylist/THANKS +0 -7
- data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +0 -562
- data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +0 -26
- data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +0 -407
- data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +0 -244
- data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +0 -135
- data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +0 -140
- data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +0 -136
- data/spec/unit/util/monkey_patches_spec.rb +0 -42
@@ -1,4 +1,4 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -14,7 +14,7 @@ describe 'Filesystem facts' do
|
|
14
14
|
before :each do
|
15
15
|
Facter.fact(:kernel).stubs(:value).returns('Linux')
|
16
16
|
fixture_data = my_fixture_read('linux')
|
17
|
-
Facter::
|
17
|
+
Facter::Core::Execution.expects(:exec) \
|
18
18
|
.with('cat /proc/filesystems 2> /dev/null').returns(fixture_data)
|
19
19
|
Facter.collection.internal_loader.load(:filesystems)
|
20
20
|
end
|
@@ -6,35 +6,35 @@ require 'facter'
|
|
6
6
|
describe "Hardwareisa fact" do
|
7
7
|
it "should match uname -p on Linux" do
|
8
8
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
9
|
-
Facter::
|
9
|
+
Facter::Core::Execution.stubs(:exec).with("uname -p").returns("Inky")
|
10
10
|
|
11
11
|
Facter.fact(:hardwareisa).value.should == "Inky"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should match uname -p on Darwin" do
|
15
15
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
16
|
-
Facter::
|
16
|
+
Facter::Core::Execution.stubs(:exec).with("uname -p").returns("Blinky")
|
17
17
|
|
18
18
|
Facter.fact(:hardwareisa).value.should == "Blinky"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should match uname -p on SunOS" do
|
22
22
|
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
23
|
-
Facter::
|
23
|
+
Facter::Core::Execution.stubs(:exec).with("uname -p").returns("Pinky")
|
24
24
|
|
25
25
|
Facter.fact(:hardwareisa).value.should == "Pinky"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should match uname -p on FreeBSD" do
|
29
29
|
Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
|
30
|
-
Facter::
|
30
|
+
Facter::Core::Execution.stubs(:exec).with("uname -p").returns("Clyde")
|
31
31
|
|
32
32
|
Facter.fact(:hardwareisa).value.should == "Clyde"
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should match uname -m on HP-UX" do
|
36
36
|
Facter.fact(:kernel).stubs(:value).returns("HP-UX")
|
37
|
-
Facter::
|
37
|
+
Facter::Core::Execution.stubs(:exec).with("uname -m").returns("Pac-Man")
|
38
38
|
|
39
39
|
Facter.fact(:hardwareisa).value.should == "Pac-Man"
|
40
40
|
end
|
@@ -6,7 +6,7 @@ require 'facter'
|
|
6
6
|
describe "Hardwaremodel fact" do
|
7
7
|
it "should match uname -m by default" do
|
8
8
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
9
|
-
Facter::
|
9
|
+
Facter::Core::Execution.stubs(:exec).with("uname -m").returns("Inky")
|
10
10
|
|
11
11
|
Facter.fact(:hardwaremodel).value.should == "Inky"
|
12
12
|
end
|
data/spec/unit/hostname_spec.rb
CHANGED
@@ -11,17 +11,17 @@ describe "Hostname facts" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should use the hostname command" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.expects(:exec).with('hostname').at_least_once
|
15
15
|
Facter.fact(:hostname).value.should be_nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should use hostname as the fact if unqualified" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1')
|
20
20
|
Facter.fact(:hostname).value.should == "host1"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should truncate the domain name if qualified" do
|
24
|
-
Facter::
|
24
|
+
Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1.example.com')
|
25
25
|
Facter.fact(:hostname).value.should == "host1"
|
26
26
|
end
|
27
27
|
end
|
@@ -33,7 +33,7 @@ describe "Hostname facts" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should use scutil to get the hostname" do
|
36
|
-
Facter::
|
36
|
+
Facter::Core::Execution.expects(:exec).with('/usr/sbin/scutil --get LocalHostName').returns("host1")
|
37
37
|
Facter.fact(:hostname).value.should == "host1"
|
38
38
|
end
|
39
39
|
end
|
data/spec/unit/id_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe "id fact" do
|
|
12
12
|
it "should return the current user" do
|
13
13
|
given_a_configuration_of(:is_windows => k == 'windows')
|
14
14
|
Facter.fact(:kernel).stubs(:value).returns(k)
|
15
|
-
Facter::
|
15
|
+
Facter::Core::Execution.expects(:exec).once.with('whoami').returns 'bar'
|
16
16
|
|
17
17
|
Facter.fact(:id).value.should == 'bar'
|
18
18
|
end
|
@@ -21,8 +21,8 @@ describe "id fact" do
|
|
21
21
|
|
22
22
|
it "should return the current user on Solaris" do
|
23
23
|
given_a_configuration_of(:is_windows => false)
|
24
|
-
Facter::
|
25
|
-
Facter::
|
24
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns('SunOS')
|
25
|
+
Facter::Core::Execution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar'
|
26
26
|
|
27
27
|
Facter.fact(:id).value.should == 'bar'
|
28
28
|
end
|
@@ -31,6 +31,16 @@ describe "Per Interface IP facts" do
|
|
31
31
|
Facter::Util::IP.stubs(:get_interfaces).returns ["Local Area Connection", "Loopback \"Pseudo-Interface\" (#1)"]
|
32
32
|
Facter.fact(:interfaces).value.should == %{Local_Area_Connection,Loopback__Pseudo_Interface____1_}
|
33
33
|
end
|
34
|
+
|
35
|
+
it "should properly format a mac address" do
|
36
|
+
Facter::Util::IP.stubs(:get_interfaces).returns ["net0"]
|
37
|
+
Facter::Util::IP.stubs(:get_interface_value).returns "0:12:34:56:78:90"
|
38
|
+
|
39
|
+
Facter.collection.internal_loader.load(:interfaces)
|
40
|
+
|
41
|
+
fact = Facter.fact("macaddress_net0".intern)
|
42
|
+
fact.value.should eq("00:12:34:56:78:90")
|
43
|
+
end
|
34
44
|
end
|
35
45
|
|
36
46
|
describe "Netmask handling on Linux" do
|
@@ -15,7 +15,7 @@ describe "The IPv6 address fact" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return ipaddress6 information for Darwin" do
|
18
|
-
Facter::
|
18
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Darwin')
|
19
19
|
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
20
20
|
Facter::Util::IP.stubs(:exec_ifconfig).with(["-a"]).
|
21
21
|
returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces'))
|
@@ -24,7 +24,7 @@ describe "The IPv6 address fact" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should return ipaddress6 information for Linux" do
|
27
|
-
Facter::
|
27
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
|
28
28
|
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
29
29
|
Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
|
30
30
|
returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces'))
|
@@ -33,7 +33,7 @@ describe "The IPv6 address fact" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return ipaddress6 information for Linux with recent net-tools" do
|
36
|
-
Facter::
|
36
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
|
37
37
|
Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
|
38
38
|
Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
|
39
39
|
returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt'))
|
@@ -42,7 +42,7 @@ describe "The IPv6 address fact" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should return ipaddress6 information for Solaris" do
|
45
|
-
Facter::
|
45
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns('SunOS')
|
46
46
|
Facter::Util::IP.stubs(:get_ifconfig).returns("/usr/sbin/ifconfig")
|
47
47
|
Facter::Util::IP.stubs(:exec_ifconfig).with(["-a"]).
|
48
48
|
returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces'))
|
data/spec/unit/ipaddress_spec.rb
CHANGED
@@ -60,7 +60,7 @@ describe "ipaddress fact" do
|
|
60
60
|
context "when you have no active network adapter" do
|
61
61
|
it "should return nil if there are no active (or any) network adapters" do
|
62
62
|
Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).returns([])
|
63
|
-
Facter::
|
63
|
+
Facter::Core::Execution.stubs(:exec)
|
64
64
|
|
65
65
|
Facter.value(:ipaddress).should == nil
|
66
66
|
end
|
data/spec/unit/kernel_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -16,7 +16,7 @@ describe "Kernel fact" do
|
|
16
16
|
describe "on everything else" do
|
17
17
|
it "should return the kernel using 'uname -s'" do
|
18
18
|
given_a_configuration_of(:is_windows => false)
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('uname -s').returns("test_kernel")
|
20
20
|
|
21
21
|
Facter.fact(:kernel).value.should == 'test_kernel'
|
22
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -21,7 +21,7 @@ describe "Kernel release fact" do
|
|
21
21
|
describe "on AIX" do
|
22
22
|
before do
|
23
23
|
Facter.fact(:kernel).stubs(:value).returns("aix")
|
24
|
-
Facter::
|
24
|
+
Facter::Core::Execution.stubs(:exec).with('oslevel -s').returns("test_kernel")
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should return the kernel release" do
|
@@ -32,7 +32,7 @@ describe "Kernel release fact" do
|
|
32
32
|
describe "on HP-UX" do
|
33
33
|
before do
|
34
34
|
Facter.fact(:kernel).stubs(:value).returns("hp-ux")
|
35
|
-
Facter::
|
35
|
+
Facter::Core::Execution.stubs(:exec).with('uname -r').returns("B.11.31")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should remove preceding letters" do
|
@@ -43,7 +43,7 @@ describe "Kernel release fact" do
|
|
43
43
|
describe "on everything else" do
|
44
44
|
before do
|
45
45
|
Facter.fact(:kernel).stubs(:value).returns("linux")
|
46
|
-
Facter::
|
46
|
+
Facter::Core::Execution.stubs(:exec).with('uname -r').returns("test_kernel")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return the kernel release" do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -7,7 +7,7 @@ describe "Kernel version fact" do
|
|
7
7
|
describe "on Solaris/Sun OS" do
|
8
8
|
before do
|
9
9
|
Facter.fact(:kernel).stubs(:value).returns('sunos')
|
10
|
-
Facter::
|
10
|
+
Facter::Core::Execution.stubs(:exec).with('uname -v').returns("1.234.5")
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the kernel version using 'uname -v'" do
|
data/spec/unit/ldom_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe "ldom fact" do
|
|
15
15
|
before :each do
|
16
16
|
# For virtinfo documentation:
|
17
17
|
# http://docs.oracle.com/cd/E23824_01/html/821-1462/virtinfo-1m.html
|
18
|
-
Facter::
|
18
|
+
Facter::Core::Execution.stubs(:exec).with("virtinfo -ap").
|
19
19
|
returns(ldom_fixtures('ldom_v1'))
|
20
20
|
Facter.collection.internal_loader.load(:ldom)
|
21
21
|
end
|
@@ -63,7 +63,7 @@ describe "ldom fact" do
|
|
63
63
|
|
64
64
|
describe "when running on non ldom hardware" do
|
65
65
|
before :each do
|
66
|
-
Facter::
|
66
|
+
Facter::Core::Execution.stubs(:exec).with("virtinfo -ap").returns(nil)
|
67
67
|
Facter.collection.internal_loader.load(:ldom)
|
68
68
|
end
|
69
69
|
|
@@ -11,12 +11,12 @@ describe "lsbdistcodename fact" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the codename through lsb_release -c -s 2>/dev/null" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns 'n/a'
|
15
15
|
Facter.fact(:lsbdistcodename).value.should == 'n/a'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if lsb_release is not installed" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns nil
|
20
20
|
Facter.fact(:lsbdistcodename).value.should be_nil
|
21
21
|
end
|
22
22
|
end
|
@@ -11,12 +11,12 @@ describe "lsbdistdescription fact" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the description through lsb_release -d -s 2>/dev/null" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns '"Gentoo Base System release 2.1"'
|
15
15
|
Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if lsb_release is not installed" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns nil
|
20
20
|
Facter.fact(:lsbdistdescription).value.should be_nil
|
21
21
|
end
|
22
22
|
end
|
data/spec/unit/lsbdistid_spec.rb
CHANGED
@@ -11,12 +11,12 @@ describe "lsbdistid fact" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the id through lsb_release -i -s 2>/dev/null" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns 'Gentoo'
|
15
15
|
Facter.fact(:lsbdistid).value.should == 'Gentoo'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if lsb_release is not installed 2>/dev/null" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns nil
|
20
20
|
Facter.fact(:lsbdistid).value.should be_nil
|
21
21
|
end
|
22
22
|
end
|
@@ -11,12 +11,12 @@ describe "lsbdistrelease fact" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the release through lsb_release -r -s 2>/dev/null" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns '2.1'
|
15
15
|
Facter.fact(:lsbdistrelease).value.should == '2.1'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if lsb_release is not installed" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns nil
|
20
20
|
Facter.fact(:lsbdistrelease).value.should be_nil
|
21
21
|
end
|
22
22
|
end
|
@@ -11,12 +11,12 @@ describe "lsbrelease fact" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the release through lsb_release -v -s 2>/dev/null" do
|
14
|
-
Facter::
|
14
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns 'n/a'
|
15
15
|
Facter.fact(:lsbrelease).value.should == 'n/a'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if lsb_release is not installed" do
|
19
|
-
Facter::
|
19
|
+
Facter::Core::Execution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns nil
|
20
20
|
Facter.fact(:lsbrelease).value.should be_nil
|
21
21
|
end
|
22
22
|
end
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -48,7 +48,7 @@ describe "Memory facts" do
|
|
48
48
|
before(:each) do
|
49
49
|
Facter.clear
|
50
50
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
51
|
-
Facter::
|
51
|
+
Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.memsize').returns('8589934592')
|
52
52
|
sample_vm_stat = <<VMSTAT
|
53
53
|
Mach Virtual Memory Statistics: (page size of 4096 bytes)
|
54
54
|
Pages free: 28430.
|
@@ -64,8 +64,8 @@ Pageins: 13862917.
|
|
64
64
|
Pageouts: 1384383.
|
65
65
|
Object cache: 14 hits of 2619925 lookups (0% hit rate)
|
66
66
|
VMSTAT
|
67
|
-
Facter::
|
68
|
-
Facter::
|
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)")
|
69
69
|
|
70
70
|
Facter.collection.internal_loader.load(:memory)
|
71
71
|
end
|
@@ -154,7 +154,7 @@ device maj,min total free
|
|
154
154
|
/dev/hd6 10, 2 512MB 508MB
|
155
155
|
SWAP
|
156
156
|
|
157
|
-
Facter::
|
157
|
+
Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
|
158
158
|
|
159
159
|
svmon = <<SVMON
|
160
160
|
Unit: KB
|
@@ -168,7 +168,7 @@ pin 1478228 0 0 953852
|
|
168
168
|
in use 4448928 0 5499480
|
169
169
|
SVMON
|
170
170
|
|
171
|
-
Facter::
|
171
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon)
|
172
172
|
|
173
173
|
Facter.collection.internal_loader.load(:memory)
|
174
174
|
end
|
@@ -222,16 +222,16 @@ SVMON
|
|
222
222
|
Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
|
223
223
|
|
224
224
|
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
225
|
-
Facter::
|
225
|
+
Facter::Core::Execution.stubs(:exec).with('swapctl -s').returns(swapusage)
|
226
226
|
|
227
227
|
vmstat = <<EOS
|
228
228
|
procs memory page disks traps cpu
|
229
229
|
r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id
|
230
230
|
0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100
|
231
231
|
EOS
|
232
|
-
Facter::
|
232
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
233
233
|
|
234
|
-
Facter::
|
234
|
+
Facter::Core::Execution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344')
|
235
235
|
|
236
236
|
Facter.collection.internal_loader.load(:memory)
|
237
237
|
end
|
@@ -267,14 +267,14 @@ Memory size: 2048 Megabytes
|
|
267
267
|
System Peripherals (Software Nodes):
|
268
268
|
|
269
269
|
PRTCONF
|
270
|
-
Facter::
|
270
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns sample_prtconf
|
271
271
|
|
272
272
|
vmstat_lines = <<VMSTAT
|
273
273
|
kthr memory page disk faults cpu
|
274
274
|
r b w swap free re mf pi po fr de sr s0 s3 -- -- in sy cs us sy id
|
275
275
|
0 0 0 1154552 476224 8 19 0 0 0 0 0 0 0 0 0 460 294 236 1 2 97
|
276
276
|
VMSTAT
|
277
|
-
Facter::
|
277
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat_lines)
|
278
278
|
end
|
279
279
|
|
280
280
|
after(:each) do
|
@@ -287,7 +287,7 @@ VMSTAT
|
|
287
287
|
swapfile dev swaplo blocks free
|
288
288
|
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
289
289
|
SWAP
|
290
|
-
Facter::
|
290
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
291
291
|
|
292
292
|
Facter.collection.internal_loader.load(:memory)
|
293
293
|
end
|
@@ -316,7 +316,7 @@ swapfile dev swaplo blocks free
|
|
316
316
|
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
317
317
|
/dev/swap2 4294967295,4294967295 16 2097136 2097136
|
318
318
|
SWAP
|
319
|
-
Facter::
|
319
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
320
320
|
Facter.collection.internal_loader.load(:memory)
|
321
321
|
end
|
322
322
|
|
@@ -339,7 +339,7 @@ SWAP
|
|
339
339
|
|
340
340
|
describe "when no swap exists" do
|
341
341
|
before(:each) do
|
342
|
-
Facter::
|
342
|
+
Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns ""
|
343
343
|
|
344
344
|
Facter.collection.internal_loader.load(:memory)
|
345
345
|
end
|
@@ -368,19 +368,19 @@ SWAP
|
|
368
368
|
Facter.fact(:kernel).stubs(:value).returns("dragonfly")
|
369
369
|
|
370
370
|
swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
|
371
|
-
Facter::
|
372
|
-
Facter::
|
373
|
-
Facter::
|
374
|
-
Facter::
|
371
|
+
Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096")
|
372
|
+
Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461")
|
373
|
+
Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635")
|
374
|
+
Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0")
|
375
375
|
|
376
376
|
vmstat = <<EOS
|
377
377
|
procs memory page disks faults cpu
|
378
378
|
r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id
|
379
379
|
0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9
|
380
380
|
EOS
|
381
|
-
Facter::
|
381
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
|
382
382
|
|
383
|
-
Facter::
|
383
|
+
Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512')
|
384
384
|
|
385
385
|
Facter.collection.internal_loader.load(:memory)
|
386
386
|
end
|
@@ -416,11 +416,11 @@ EOS
|
|
416
416
|
r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id
|
417
417
|
1 0 0 207600 656640 10 0 0 0 13 0 0 0 51 164 257 0 1 99
|
418
418
|
VM_STAT
|
419
|
-
Facter::
|
419
|
+
Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns sample_vmstat
|
420
420
|
sample_physmem = <<PHYSMEM
|
421
421
|
1056276480
|
422
422
|
PHYSMEM
|
423
|
-
Facter::
|
423
|
+
Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns sample_physmem
|
424
424
|
end
|
425
425
|
|
426
426
|
after(:each) do
|
@@ -432,7 +432,7 @@ PHYSMEM
|
|
432
432
|
sample_swapinfo = <<SWAP
|
433
433
|
Device 1K-blocks Used Avail Capacity
|
434
434
|
SWAP
|
435
|
-
Facter::
|
435
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
436
436
|
|
437
437
|
Facter.collection.internal_loader.load(:memory)
|
438
438
|
end
|
@@ -460,7 +460,7 @@ SWAP
|
|
460
460
|
Device 1K-blocks Used Avail Capacity
|
461
461
|
/dev/da0p3 2048540 0 1048540 0%
|
462
462
|
SWAP
|
463
|
-
Facter::
|
463
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
464
464
|
|
465
465
|
Facter.collection.internal_loader.load(:memory)
|
466
466
|
end
|
@@ -489,7 +489,7 @@ Device 1K-blocks Used Avail Capacity
|
|
489
489
|
/dev/da0p3 2048540 0 1048540 0%
|
490
490
|
/dev/da0p4 3048540 0 1048540 0%
|
491
491
|
SWAP
|
492
|
-
Facter::
|
492
|
+
Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
|
493
493
|
|
494
494
|
Facter.collection.internal_loader.load(:memory)
|
495
495
|
end
|
@@ -534,13 +534,6 @@ SWAP
|
|
534
534
|
Facter::Util::WMI.stubs(:execquery).returns([computer])
|
535
535
|
|
536
536
|
Facter.fact(:memorysize_mb).value.should == '3999.55'
|
537
|
-
Facter.fact(:MemoryTotal).value.should == '3.91 GB'
|
538
537
|
end
|
539
538
|
end
|
540
|
-
|
541
|
-
it "should use the memorysize fact for the memorytotal fact" do
|
542
|
-
Facter.fact("memorysize").expects(:value).once.returns "16.00 GB"
|
543
|
-
Facter::Util::Resolution.expects(:exec).never
|
544
|
-
Facter.fact(:memorytotal).value.should == "16.00 GB"
|
545
|
-
end
|
546
539
|
end
|