diff options
author | Daniel Pittman <daniel@rimspace.net> | 2011-02-01 17:48:54 -0800 |
---|---|---|
committer | Daniel Pittman <daniel@rimspace.net> | 2011-02-17 14:34:34 -0800 |
commit | cb25119b130337e5a9fff0c142ba18c55ebf6059 (patch) | |
tree | 931ebfb5740c0d92af17a0dae7bf9389a91ee7af /spec | |
parent | ea2948395e4eed1a33f767df60ae28133c94442e (diff) | |
download | facter-cb25119b130337e5a9fff0c142ba18c55ebf6059.tar.gz facter-cb25119b130337e5a9fff0c142ba18c55ebf6059.tar.xz facter-cb25119b130337e5a9fff0c142ba18c55ebf6059.zip |
(#2270) add testing for the new ipaddress6 feature
This stubs out the platform side of the code, and uses fixtures emitting the
right output from the interface configuration tools.
Paired-With: Matt Robinson <matt@puppetlabs.com>
Paired-With: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'spec')
5 files changed, 106 insertions, 0 deletions
diff --git a/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces b/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces new file mode 100644 index 0000000..d5bff49 --- /dev/null +++ b/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces @@ -0,0 +1,18 @@ +bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM> + ether 00:0b:db:93:09:67 + inet 131.252.208.203 netmask 0xffffff00 broadcast 131.252.208.255 + inet6 fe80::20b:dbff:fe93:967%bge0 prefixlen 64 scopeid 0x1 + inet6 2610:10:20:208:20b:dbff:fe93:967 prefixlen 64 autoconf + media: Ethernet autoselect (1000baseT <full-duplex>) + status: active +bge1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 + options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM> + ether 00:0b:db:93:09:68 + media: Ethernet autoselect (none) + status: no carrier +lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 + options=3<RXCSUM,TXCSUM> + inet 127.0.0.1 netmask 0xff000000 + inet6 ::1 prefixlen 128 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 diff --git a/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces b/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces new file mode 100644 index 0000000..a55999c --- /dev/null +++ b/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces @@ -0,0 +1,23 @@ +lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 + inet6 ::1 prefixlen 128 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 + inet 127.0.0.1 netmask 0xff000000 +gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 +stf0: flags=0<> mtu 1280 +en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 + ether 00:23:32:d5:ee:34 + inet6 fe80::223:32ff:fed5:ee34%en0 prefixlen 64 scopeid 0x4 + inet6 2610:10:20:209:223:32ff:fed5:ee34 prefixlen 64 autoconf + inet 131.252.209.140 netmask 0xffffff00 broadcast 131.252.209.255 + media: autoselect (100baseTX <full-duplex>) + status: active +en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 + ether 00:11:33:22:55:44 + inet6 fe80::211:33ff:fe22:5544%en1 prefixlen 64 scopeid 0x5 + inet 131.252.246.129 netmask 0xfffffe00 broadcast 131.252.247.255 + media: autoselect + status: active +fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078 + lladdr 00:23:32:ff:fe:d5:ee:34 + media: autoselect <full-duplex> + status: inactive diff --git a/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces b/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces new file mode 100644 index 0000000..d944694 --- /dev/null +++ b/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces @@ -0,0 +1,19 @@ +eth0 Link encap:Ethernet HWaddr 00:12:3f:be:22:01 + inet addr:131.252.209.153 Bcast:131.252.209.255 Mask:255.255.255.0 + inet6 addr: 2610:10:20:209:212:3fff:febe:2201/64 Scope:Global + inet6 addr: fe80::212:3fff:febe:2201/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:20793317 errors:0 dropped:0 overruns:0 frame:0 + TX packets:19583281 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:1723593481 (1.7 GB) TX bytes:283377282 (283.3 MB) + Interrupt:16 + +lo Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + inet6 addr: ::1/128 Scope:Host + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:31809 errors:0 dropped:0 overruns:0 frame:0 + TX packets:31809 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:2075836 (2.0 MB) TX bytes:2075836 (2.0 MB) diff --git a/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces b/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces new file mode 100644 index 0000000..c30efe0 --- /dev/null +++ b/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces @@ -0,0 +1,10 @@ +lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 + inet 127.0.0.1 netmask ff000000 +bge0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 + inet 131.252.209.59 netmask ffffff00 broadcast 131.252.209.255 +lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 + inet6 ::1/128 +bge0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2 + inet6 fe80::203:baff:fe27:a7c/10 +bge0:1: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2 + inet6 2610:10:20:209:203:baff:fe27:a7c/64 diff --git a/spec/unit/ipaddress6_spec.rb b/spec/unit/ipaddress6_spec.rb new file mode 100755 index 0000000..d507023 --- /dev/null +++ b/spec/unit/ipaddress6_spec.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +$basedir = File.expand_path(File.dirname(__FILE__) + '/..') +require File.join($basedir, 'spec_helper') + +require 'facter' + +def ifconfig_fixture(filename) + ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read +end + +describe "IPv6 address fact" do + it "should return ipaddress6 information for Darwin" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Darwin') + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). + returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:223:32ff:fed5:ee34" + end + + it "should return ipaddress6 information for Linux" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux') + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig'). + returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201" + end + + it "should return ipaddress6 information for Solaris" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/ifconfig -a'). + returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:203:baff:fe27:a7c" + end +end |