facter 2.2.0 → 2.3.0

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.

Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +4 -0
  3. data/Gemfile +2 -1
  4. data/LICENSE +1 -1
  5. data/ext/project_data.yaml +2 -2
  6. data/lib/facter/ec2.rb +2 -2
  7. data/lib/facter/gid.rb +10 -1
  8. data/lib/facter/interfaces.rb +2 -0
  9. data/lib/facter/ipaddress6.rb +1 -1
  10. data/lib/facter/ldom.rb +4 -1
  11. data/lib/facter/macosx.rb +2 -2
  12. data/lib/facter/operatingsystem/linux.rb +13 -1
  13. data/lib/facter/operatingsystem/sunos.rb +1 -1
  14. data/lib/facter/operatingsystem/windows.rb +7 -0
  15. data/lib/facter/physicalprocessorcount.rb +1 -1
  16. data/lib/facter/processor.rb +3 -3
  17. data/lib/facter/processors/os.rb +11 -1
  18. data/lib/facter/rackspace.rb +8 -5
  19. data/lib/facter/rubyplatform.rb +12 -0
  20. data/lib/facter/selinux.rb +9 -9
  21. data/lib/facter/system32.rb +21 -0
  22. data/lib/facter/util/macosx.rb +1 -1
  23. data/lib/facter/util/parser.rb +12 -2
  24. data/lib/facter/util/uptime.rb +1 -1
  25. data/lib/facter/util/virtual.rb +13 -2
  26. data/lib/facter/version.rb +1 -1
  27. data/lib/facter/virtual.rb +5 -3
  28. data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_fe80 +19 -0
  29. data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_no_public_ipv6 +18 -0
  30. data/spec/schema/validate_facter_schema.rb +18 -0
  31. data/spec/unit/ec2_spec.rb +18 -6
  32. data/spec/unit/gid_spec.rb +22 -2
  33. data/spec/unit/interfaces_spec.rb +2 -2
  34. data/spec/unit/ipaddress6_spec.rb +24 -6
  35. data/spec/unit/ldom_spec.rb +13 -0
  36. data/spec/unit/operatingsystem/linux_spec.rb +22 -10
  37. data/spec/unit/operatingsystem/sunos_spec.rb +3 -3
  38. data/spec/unit/operatingsystem/windows_spec.rb +21 -0
  39. data/spec/unit/physicalprocessorcount_spec.rb +1 -1
  40. data/spec/unit/processor_spec.rb +1 -1
  41. data/spec/unit/processors/os_spec.rb +15 -1
  42. data/spec/unit/rackspace_spec.rb +3 -3
  43. data/spec/unit/rubyplatform_spec.rb +7 -0
  44. data/spec/unit/selinux_spec.rb +5 -5
  45. data/spec/unit/system32_spec.rb +28 -0
  46. data/spec/unit/util/macosx_spec.rb +1 -1
  47. data/spec/unit/util/parser_spec.rb +36 -3
  48. data/spec/unit/util/uptime_spec.rb +2 -2
  49. data/spec/unit/virtual_spec.rb +52 -26
  50. metadata +645 -635
@@ -29,7 +29,15 @@ module Facter::Util::Virtual
29
29
  ##
30
30
  # lspci is a delegating helper method intended to make it easier to stub the
31
31
  # system call without affecting other calls to Facter::Core::Execution.exec
32
- def self.lspci(command = "lspci 2>/dev/null")
32
+ def self.lspci(command = nil)
33
+ if command.nil?
34
+ if ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel)
35
+ command = "pciconf -lv 2>/dev/null"
36
+ else
37
+ command = "lspci 2>/dev/null"
38
+ end
39
+ end
40
+
33
41
  Facter::Core::Execution.exec command
34
42
  end
35
43
 
@@ -176,7 +184,10 @@ module Facter::Util::Virtual
176
184
  # @return [String] or nil if the path does not exist or is unreadable
177
185
  def self.read_sysfs_dmi_entries(path="/sys/firmware/dmi/entries/1-0/raw")
178
186
  if File.readable?(path)
179
- Facter::Util::FileRead.read_binary(path)
187
+ begin
188
+ Facter::Util::FileRead.read_binary(path)
189
+ rescue Errno::EINVAL
190
+ end
180
191
  end
181
192
  end
182
193
  end
@@ -1,6 +1,6 @@
1
1
  module Facter
2
2
  if not defined? FACTERVERSION then
3
- FACTERVERSION = '2.2.0'
3
+ FACTERVERSION = '2.3.0'
4
4
  end
5
5
 
6
6
  # Returns the running version of Facter.
@@ -78,7 +78,7 @@ Facter.add("virtual") do
78
78
  setcode do
79
79
  next "zone" if Facter::Util::Virtual.zone?
80
80
 
81
- output = Facter::Core::Execution.exec('prtdiag')
81
+ output = Facter::Core::Execution.exec('prtdiag 2>/dev/null')
82
82
  if output
83
83
  lines = output.split("\n")
84
84
  next "parallels" if lines.any? {|l| l =~ /Parallels/ }
@@ -149,6 +149,7 @@ Facter.add("virtual") do
149
149
  next "xenhvm" if lines.any? {|l| l =~ /XenSource/ }
150
150
  next "hyperv" if lines.any? {|l| l =~ /Microsoft Corporation Hyper-V/ }
151
151
  next "gce" if lines.any? {|l| l =~ /Class 8007: Google, Inc/ }
152
+ next "kvm" if lines.any? {|l| l =~ /virtio/ }
152
153
  end
153
154
 
154
155
  # Parse dmidecode
@@ -162,6 +163,7 @@ Facter.add("virtual") do
162
163
  next "hyperv" if lines.any? {|l| l =~ /Product Name: Virtual Machine/ }
163
164
  next "rhev" if lines.any? {|l| l =~ /Product Name: RHEV Hypervisor/ }
164
165
  next "ovirt" if lines.any? {|l| l =~ /Product Name: oVirt Node/ }
166
+ next "bochs" if lines.any? {|l| l =~ /Bochs/ }
165
167
  end
166
168
 
167
169
  # Default to 'physical'
@@ -304,9 +306,9 @@ Facter.add("is_virtual") do
304
306
  physical_types = %w{physical xen0 vmware_server vmware_workstation openvzhn vserver_host}
305
307
 
306
308
  if physical_types.include? Facter.value(:virtual)
307
- "false"
309
+ false
308
310
  else
309
- "true"
311
+ true
310
312
  end
311
313
  end
312
314
  end
@@ -0,0 +1,19 @@
1
+ eth0 Link encap:Ethernet HWaddr 00:12:3f:be:22:01
2
+ inet addr:131.252.209.153 Bcast:131.252.209.255 Mask:255.255.255.0
3
+ inet6 addr: 2610:10:20:209:212:3fff:fe80:2201/64 Scope:Global
4
+ inet6 addr: fe80::212:3fff:febe:2201/64 Scope:Link
5
+ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
6
+ RX packets:20793317 errors:0 dropped:0 overruns:0 frame:0
7
+ TX packets:19583281 errors:0 dropped:0 overruns:0 carrier:0
8
+ collisions:0 txqueuelen:1000
9
+ RX bytes:1723593481 (1.7 GB) TX bytes:283377282 (283.3 MB)
10
+ Interrupt:16
11
+
12
+ lo Link encap:Local Loopback
13
+ inet addr:127.0.0.1 Mask:255.0.0.0
14
+ inet6 addr: ::1/128 Scope:Host
15
+ UP LOOPBACK RUNNING MTU:16436 Metric:1
16
+ RX packets:31809 errors:0 dropped:0 overruns:0 frame:0
17
+ TX packets:31809 errors:0 dropped:0 overruns:0 carrier:0
18
+ collisions:0 txqueuelen:0
19
+ RX bytes:2075836 (2.0 MB) TX bytes:2075836 (2.0 MB)
@@ -0,0 +1,18 @@
1
+ eth0 Link encap:Ethernet HWaddr 00:12:3f:be:22:01
2
+ inet addr:131.252.209.153 Bcast:131.252.209.255 Mask:255.255.255.0
3
+ inet6 addr: fe80::212:3fff:febe:2201/64 Scope:Link
4
+ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
5
+ RX packets:20793317 errors:0 dropped:0 overruns:0 frame:0
6
+ TX packets:19583281 errors:0 dropped:0 overruns:0 carrier:0
7
+ collisions:0 txqueuelen:1000
8
+ RX bytes:1723593481 (1.7 GB) TX bytes:283377282 (283.3 MB)
9
+ Interrupt:16
10
+
11
+ lo Link encap:Local Loopback
12
+ inet addr:127.0.0.1 Mask:255.0.0.0
13
+ inet6 addr: ::1/128 Scope:Host
14
+ UP LOOPBACK RUNNING MTU:16436 Metric:1
15
+ RX packets:31809 errors:0 dropped:0 overruns:0 frame:0
16
+ TX packets:31809 errors:0 dropped:0 overruns:0 carrier:0
17
+ collisions:0 txqueuelen:0
18
+ RX bytes:2075836 (2.0 MB) TX bytes:2075836 (2.0 MB)
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'facter/util/config'
3
+
4
+ if !Facter::Util::Config.is_windows?
5
+ require 'json'
6
+ require 'json-schema'
7
+
8
+ describe 'facter.json schema' do
9
+ it 'should be valid' do
10
+ # Read in both the json meta-schema and the facter schema
11
+ JSON_META_SCHEMA = JSON.parse(File.read('schema/json-meta-schema.json'))
12
+ FACTER_SCHEMA = JSON.parse(File.read('schema/facter.json'))
13
+
14
+ # Validate that the facter schema itself is valid json
15
+ JSON::Validator.validate!(JSON_META_SCHEMA, FACTER_SCHEMA)
16
+ end
17
+ end
18
+ end
@@ -15,14 +15,14 @@ describe "ec2_metadata" do
15
15
 
16
16
  subject { Facter.fact(:ec2_metadata).resolution(:rest) }
17
17
 
18
- it "is unsuitable if the virtual fact is not xen" do
18
+ it "is unsuitable if the virtual fact is not xen,xenu or kvm" do
19
19
  querier.stubs(:reachable?).returns false
20
- Facter.fact(:virtual).stubs(:value).returns "kvm"
20
+ Facter.fact(:virtual).stubs(:value).returns("Not kvm","Not xen","Not xenu")
21
21
  expect(subject).to_not be_suitable
22
22
  end
23
23
 
24
24
  it "is unsuitable if ec2 endpoint is not reachable" do
25
- Facter.fact(:virtual).stubs(:value).returns "xen"
25
+ Facter.fact(:virtual).stubs(:value).returns("xen","kvm")
26
26
  querier.stubs(:reachable?).returns false
27
27
  expect(subject).to_not be_suitable
28
28
  end
@@ -39,6 +39,13 @@ describe "ec2_metadata" do
39
39
  expect(subject).to be_suitable
40
40
  end
41
41
 
42
+ it "is suitable if the virtual fact is kvm" do
43
+ Facter.fact(:virtual).stubs(:value).returns "kvm"
44
+ subject.suitable?
45
+
46
+ expect(subject).to be_suitable
47
+ end
48
+
42
49
  it "is suitable if the virtual fact is xenu" do
43
50
  Facter.fact(:virtual).stubs(:value).returns "xenu"
44
51
  expect(subject).to be_suitable
@@ -65,14 +72,14 @@ describe "ec2_userdata" do
65
72
 
66
73
  subject { Facter.fact(:ec2_userdata).resolution(:rest) }
67
74
 
68
- it "is unsuitable if the virtual fact is not xen" do
75
+ it "is unsuitable if the virtual fact is not xen,xenu or kvm" do
69
76
  querier.stubs(:reachable?).returns(true)
70
- Facter.fact(:virtual).stubs(:value).returns "kvm"
77
+ Facter.fact(:virtual).stubs(:value).returns("Not kvm","Not xen","Not xenu")
71
78
  expect(subject).to_not be_suitable
72
79
  end
73
80
 
74
81
  it "is unsuitable if ec2 endpoint is not reachable" do
75
- Facter.fact(:virtual).stubs(:value).returns "xen"
82
+ Facter.fact(:virtual).stubs(:value).returns("xen","kvm")
76
83
  querier.stubs(:reachable?).returns false
77
84
  expect(subject).to_not be_suitable
78
85
  end
@@ -87,6 +94,11 @@ describe "ec2_userdata" do
87
94
  expect(subject).to be_suitable
88
95
  end
89
96
 
97
+ it "is suitable if the virtual fact is kvm" do
98
+ Facter.fact(:virtual).stubs(:value).returns "kvm"
99
+ expect(subject).to be_suitable
100
+ end
101
+
90
102
  it "is suitable if the virtual fact is xenu" do
91
103
  Facter.fact(:virtual).stubs(:value).returns "xenu"
92
104
  expect(subject).to be_suitable
@@ -2,8 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe "gid fact" do
4
4
 
5
- describe "on systems with id" do
5
+ describe "on non-SunOS systems with id" do
6
6
  it "should return the current group" do
7
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
7
8
  Facter::Core::Execution.expects(:which).with('id').returns(true)
8
9
  Facter::Core::Execution.expects(:exec).once.with('id -ng').returns 'bar'
9
10
 
@@ -11,12 +12,31 @@ describe "gid fact" do
11
12
  end
12
13
  end
13
14
 
14
- describe "on systems without id" do
15
+ describe "on non-SunOS systems without id" do
15
16
  it "is not supported" do
17
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
16
18
  Facter::Core::Execution.expects(:which).with('id').returns(false)
17
19
 
18
20
  Facter.fact(:gid).value.should == nil
19
21
  end
20
22
  end
21
23
 
24
+ describe "on SunOS systems with /usr/xpg4/bin/id" do
25
+ it "should return the current group" do
26
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
27
+ File.expects(:exist?).with('/usr/xpg4/bin/id').returns true
28
+ Facter::Core::Execution.expects(:exec).with('/usr/xpg4/bin/id -ng').returns 'bar'
29
+
30
+ Facter.fact(:gid).value.should == 'bar'
31
+ end
32
+ end
33
+
34
+ describe "on SunOS systems without /usr/xpg4/bin/id" do
35
+ it "is not supported" do
36
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
37
+ File.expects(:exist?).with('/usr/xpg4/bin/id').returns false
38
+
39
+ Facter.fact(:gid).value.should == nil
40
+ end
41
+ end
22
42
  end
@@ -50,8 +50,8 @@ describe "Netmask and MTU handling on Linux" do
50
50
 
51
51
  example_behavior_for "interface netmask and mtu from ifconfig output",
52
52
  "Archlinux (net-tools 1.60)", "em1",
53
- "255.255.255.0", "1500", "ifconfig_net_tools_1.60.txt"
53
+ "255.255.255.0", 1500, "ifconfig_net_tools_1.60.txt"
54
54
  example_behavior_for "interface netmask and mtu from ifconfig output",
55
55
  "Archlinux (net-tools 1.60)", "lo",
56
- "255.0.0.0", "16436", "ifconfig_net_tools_1.60.txt"
56
+ "255.0.0.0", 16436, "ifconfig_net_tools_1.60.txt"
57
57
  end
@@ -33,13 +33,31 @@ 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::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
37
- Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
38
- Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
39
- returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt'))
36
+ Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
37
+ Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
38
+ Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
39
+ returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt'))
40
40
 
41
- Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
42
- end
41
+ Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
42
+ end
43
+
44
+ it "should return ipaddress6 with fe80 in any other octet than the first for Linux" do
45
+ Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
46
+ Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
47
+ Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
48
+ returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces_and_fe80'))
49
+
50
+ Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:fe80:2201"
51
+ end
52
+
53
+ it "should not return ipaddress6 link-local address for Linux" do
54
+ Facter::Core::Execution.stubs(:exec).with('uname -s').returns('Linux')
55
+ Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig")
56
+ Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]).
57
+ returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces_and_no_public_ipv6'))
58
+
59
+ Facter.value(:ipaddress6).should be_false
60
+ end
43
61
 
44
62
  it "should return ipaddress6 information for Solaris" do
45
63
  Facter::Core::Execution.stubs(:exec).with('uname -s').returns('SunOS')
@@ -15,6 +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.fact(:hardwareisa).stubs(:value).returns("sparc")
18
19
  Facter::Core::Execution.stubs(:which).with("virtinfo").returns 'virtinfo'
19
20
  Facter::Core::Execution.stubs(:exec).with("virtinfo -ap").
20
21
  returns(ldom_fixtures('ldom_v1'))
@@ -64,6 +65,7 @@ describe "ldom fact" do
64
65
 
65
66
  describe "when running on non ldom hardware" do
66
67
  before :each do
68
+ Facter.fact(:hardwareisa).stubs(:value).returns("sparc")
67
69
  Facter::Core::Execution.stubs(:which).with("virtinfo").returns(nil)
68
70
  Facter.collection.internal_loader.load(:ldom)
69
71
  end
@@ -72,4 +74,15 @@ describe "ldom fact" do
72
74
  Facter.fact(:ldom_domainrole_impl).should == nil
73
75
  end
74
76
  end
77
+
78
+ describe "when running on non-sparc hardware" do
79
+ before :each do
80
+ Facter.fact(:hardwareisa).stubs(:value).returns("i386")
81
+ Facter::Core::Execution.stubs(:which).with("virtinfo").returns 'virtinfo'
82
+ end
83
+
84
+ it "should not try to resolve the ldom facts" do
85
+ Facter.fact(:ldom_domainrole_impl).should == nil
86
+ end
87
+ end
75
88
  end
@@ -29,6 +29,7 @@ describe Facter::Operatingsystem::Linux do
29
29
 
30
30
  describe "When lsbdistid is not available" do
31
31
  {
32
+ "AristaEOS" => "/etc/Eos-release",
32
33
  "Debian" => "/etc/debian_version",
33
34
  "Gentoo" => "/etc/gentoo-release",
34
35
  "Fedora" => "/etc/fedora-release",
@@ -37,6 +38,7 @@ describe Facter::Operatingsystem::Linux do
37
38
  "Mandrake" => "/etc/mandrake-release",
38
39
  "MeeGo" => "/etc/meego-release",
39
40
  "Archlinux" => "/etc/arch-release",
41
+ "Manjarolinux"=> "/etc/manjaro-release",
40
42
  "OracleLinux" => "/etc/oracle-release",
41
43
  "OpenWrt" => "/etc/openwrt_release",
42
44
  "Alpine" => "/etc/alpine-release",
@@ -152,6 +154,7 @@ describe Facter::Operatingsystem::Linux do
152
154
  describe "Osfamily fact" do
153
155
  {
154
156
  'Archlinux' => 'Archlinux',
157
+ "Manjarolinux" => "Archlinux",
155
158
  'Ubuntu' => 'Debian',
156
159
  'Debian' => 'Debian',
157
160
  'LinuxMint' => 'Debian',
@@ -191,6 +194,7 @@ describe Facter::Operatingsystem::Linux do
191
194
  'Slamd64',
192
195
  'Slackware',
193
196
  'Alpine',
197
+ 'AristaEOS',
194
198
  ].each do |os|
195
199
  it "should return the kernel fact on operatingsystem #{os}" do
196
200
  Facter.expects(:value).with("kernel").returns "Linux"
@@ -210,17 +214,18 @@ describe Facter::Operatingsystem::Linux do
210
214
 
211
215
  describe "Operatingsystemrelease fact" do
212
216
  test_cases = {
213
- "OpenWrt" => "/etc/openwrt_version",
214
- "CentOS" => "/etc/redhat-release",
215
- "RedHat" => "/etc/redhat-release",
217
+ "AristaEOS" => "/etc/Eos-release",
218
+ "OpenWrt" => "/etc/openwrt_version",
219
+ "CentOS" => "/etc/redhat-release",
220
+ "RedHat" => "/etc/redhat-release",
216
221
  "LinuxMint" => "/etc/linuxmint/info",
217
222
  "Scientific" => "/etc/redhat-release",
218
- "Fedora" => "/etc/fedora-release",
219
- "MeeGo" => "/etc/meego-release",
220
- "OEL" => "/etc/enterprise-release",
221
- "oel" => "/etc/enterprise-release",
222
- "OVS" => "/etc/ovs-release",
223
- "ovs" => "/etc/ovs-release",
223
+ "Fedora" => "/etc/fedora-release",
224
+ "MeeGo" => "/etc/meego-release",
225
+ "OEL" => "/etc/enterprise-release",
226
+ "oel" => "/etc/enterprise-release",
227
+ "OVS" => "/etc/ovs-release",
228
+ "ovs" => "/etc/ovs-release",
224
229
  "OracleLinux" => "/etc/oracle-release",
225
230
  "Ascendos" => "/etc/redhat-release",
226
231
  }
@@ -258,6 +263,13 @@ describe Facter::Operatingsystem::Linux do
258
263
  expect(release).to eq "foo"
259
264
  end
260
265
 
266
+ it "should use the contents of /etc/Eos-release in AristaEOS" do
267
+ subject.expects(:get_operatingsystem).returns("AristaEOS")
268
+ File.expects(:read).with("/etc/Eos-release").returns("Arista Networks EOS 4.13.7M")
269
+ release = subject.get_operatingsystemrelease
270
+ expect(release).to eq "4.13.7M"
271
+ end
272
+
261
273
  it "should fall back to parsing /etc/system-release if lsb facts are not available in Amazon" do
262
274
  subject.expects(:get_operatingsystem).returns("Amazon")
263
275
  subject.expects(:get_lsbdistrelease).returns(nil)
@@ -286,7 +298,7 @@ describe Facter::Operatingsystem::Linux do
286
298
  end
287
299
 
288
300
  describe "Operatingsystemmajrelease key" do
289
- ['Amazon','CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux'].each do |operatingsystem|
301
+ ['Amazon' 'AristaEOS', 'CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux'].each do |operatingsystem|
290
302
  describe "on #{operatingsystem} operatingsystems" do
291
303
  it "should be derived from operatingsystemrelease" do
292
304
  subject.stubs(:get_operatingsystem).returns(operatingsystem)
@@ -125,19 +125,19 @@ describe Facter::Operatingsystem::SunOS do
125
125
 
126
126
  it "should correctly derive from operatingsystemrelease on solaris 10" do
127
127
  subject.expects(:get_operatingsystemrelease).returns("10_u8")
128
- release = subject.get_operatingsystemmajrelease
128
+ release = subject.get_operatingsystemmajorrelease
129
129
  expect(release).to eq "10"
130
130
  end
131
131
 
132
132
  it "should correctly derive from operatingsystemrelease on solaris 11 (old version scheme)" do
133
133
  subject.expects(:get_operatingsystemrelease).returns("11 11/11")
134
- release = subject.get_operatingsystemmajrelease
134
+ release = subject.get_operatingsystemmajorrelease
135
135
  expect(release).to eq "11"
136
136
  end
137
137
 
138
138
  it "should correctly derive from operatingsystemrelease on solaris 11 (new version scheme)" do
139
139
  subject.expects(:get_operatingsystemrelease).returns("11.1")
140
- release = subject.get_operatingsystemmajrelease
140
+ release = subject.get_operatingsystemmajorrelease
141
141
  expect(release).to eq "11"
142
142
  end
143
143
  end
@@ -21,6 +21,10 @@ describe Facter::Operatingsystem::Windows do
21
21
  ['6.2.9200', 1] => "8",
22
22
  ['6.2.9200', 2] => "2012",
23
23
  ['6.2.9200', 3] => "2012",
24
+ ['6.3.9600', 1] => "8.1",
25
+ ['6.3.9600', 2] => "2012 R2",
26
+ ['6.3.9600', 3] => "2012 R2",
27
+ ['6.4.9841', 1] => "10", # Kernel version for Windows 10 preview. Subject to change.
24
28
  }.each do |os_values, expected_output|
25
29
  it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]}" do
26
30
  os = mock('os', :version => os_values[0], :producttype => os_values[1])
@@ -30,6 +34,23 @@ describe Facter::Operatingsystem::Windows do
30
34
  end
31
35
  end
32
36
 
37
+ {
38
+ # Note: this is the kernel version for the Windows 10 technical preview,
39
+ # which is subject to change. These tests cover any future Windows server
40
+ # releases with a kernel version of 6.4.x, none of which have been released
41
+ # as of October 2014.
42
+ ['6.4.9841', 2] => "6.4.9841",
43
+ ['6.4.9841', 3] => "6.4.9841",
44
+ }.each do |os_values, expected_output|
45
+ it "should be the kernel release for unknown future server releases" do
46
+ Facter.fact(:kernelrelease).stubs(:value).returns("6.4.9841")
47
+ os = mock('os', :version => os_values[0], :producttype => os_values[1])
48
+ Facter::Util::WMI.expects(:execquery).returns([os])
49
+ release = subject.get_operatingsystemrelease
50
+ expect(release).to eq expected_output
51
+ end
52
+ end
53
+
33
54
  {
34
55
  ['5.2.3790', 2, ""] => "2003",
35
56
  ['5.2.3790', 2, "R2"] => "2003 R2",