summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
Commit message (Collapse)AuthorAgeFilesLines
* (#7670) Never fail to find a fact that is presentNick Lewis2011-05-311-0/+4
| | | | | | | | | | | | | | | | | | | | | With the previous behavior, any fact which depended on another fact in a file not matching its name would fail to properly load the required fact, resulting in missing, incorrect, or inconsistent values. For instance, the operatingsystem fact depends on the lsbdistid fact found in lsb.rb. The first time the operatingsystem fact is requested, it requires lsb.rb, and so the required fact is loaded first. But if Facter is subsequently cleared and the operatingsystem fact requested again, the require will not occur, and the fact will not be automatically loaded because it doesn't match its filename. Now if a fact is requested and can't be found, we will attempt to load all the facts to find it. Such an approach appears heavy-handed, but in the case where we want a particular fact, this is the only way to make sure we've found it. In the case where we eventually want other facts, we are conveniently eagerly loading them. Paired-With: Jacob Helwig <jacob@puppetlabs.com>
* Merge branch ↵Max Martin2011-04-281-0/+1
|\ | | | | | | | | | | | | | | 'ticket/next/6728-facter_improperly_detects_openvzve_on_cloudlinux_systems' into next * ticket/next/6728-facter_improperly_detects_openvzve_on_cloudlinux_systems: (#6728) Facter improperly detects openvzve on CloudLinux systems (#6883) Update Facter install.rb to be slightly more informative.
| * (#6728) Facter improperly detects openvzve on CloudLinux systemsBen Hughes2011-04-071-0/+1
| | | | | | | | | | | | | | | | Make the openvz check for more than just the vz directory to be sure it's OpenVZ. Update the OpenVZ fact to be slightly more resilient in it's checking of OpenVZ, so it doesn't clash with CloudLinux's LVE container system.
* | (#6612) Changed uptime spec to be endian agnosticAdrien Thebo2011-04-181-1/+6
| | | | | | | | | | The sysctl uptime fixture was little endian, which fails on sparc hardware. Added a big endian fixture and endian detection.
* | refactor the mechanism for allowing for resolution ordering to be influencedRichard Clamp2011-04-062-13/+31
|/ | | | | renames Facter::Util::Resolution#length to weight as a more generic mechanism for allowing resolutions to state their importance
* (#6795) Update tests to reflect changed execJacob Helwig2011-03-211-2/+2
|
* Merge branch 'tickets/next/6716-osx-ipv6-macaddress' into nextJacob Helwig2011-03-171-58/+51
|\ | | | | | | | | | | * tickets/next/6716-osx-ipv6-macaddress: Clean up indentation, and alignment in macaddress_spec.rb (#6716) fix facter issues on OSX with ipv6 in macaddress.rb.
| * Clean up indentation, and alignment in macaddress_spec.rbJacob Helwig2011-03-171-59/+51
| | | | | | | | | | | | | | This changes the spec file from 4-space indentations to 2-space indentations to match the style guide[1]. [1] http://projects.puppetlabs.com/projects/puppet/wiki/Development_Lifecycle#Style
| * (#6716) fix facter issues on OSX with ipv6 in macaddress.rb.Ben Hughes2011-03-171-1/+2
| | | | | | | | | | | | Due to "netstat -rn" returning multiple protocols (IPv4 and IPv6) the "default_interface" can get more than one entry in to it, causing the macaddress resolving to break. This limits it to just one interface.
* | Fixed #2346 - Part 1: Added arp fact for LinuxJames Turnbull2011-03-171-0/+7
| | | | | | | | | | Added facts arp (like the ipaddress etc) facts Added facts arp_interfacename
* | Fix for #6495 - Updated interface detectionJames Turnbull2011-03-091-10/+10
|/ | | | | | | | | | 1. Fixed IP return to not filter lo/localhost and return it as a proper interface 2. Fixed HP-UX netstat return to remove extraneous first line of naming. 3. Updated tests to reflect changes
* (#6615) fix missing stub calls in loader specsRick Bradley2011-03-071-2/+9
| | | | | | | | | | It's not clear to me how these are now needed and apparently weren't when we first checked this in. These stubs will let the specs continue on so we can check the load order, which was the original intent of (#5510) which caused the introduction of these specs. Signed-off-by: Rick Bradley <rick@rickbradley.com>
* Fixed #6525 - Test failures on Ruby 1.9.xJames Turnbull2011-03-021-2/+2
|
* Fix #4755: add support for GNU/kFreeBSD platform where missing.Marc Fournier2011-01-312-3/+33
| | | | | | | | | Merged manually to the current state of the art. Minimal conflicts resolved by adding both Darwin and GNU/KFreeBSD to the confine lines. Author: Marc Fournier <marc.fournier@camptocamp.com> Signed-off-by: Daniel Pittman <daniel@puppetlabs.com> Signed-off-by: Rick Bradley <rick@rickbradley.com>
* (#5510) Facter should load custom fact definitions in filename order.Rick Bradley2011-01-311-0/+43
| | | | | | | | | | | | | | | | Ruby's Dir.entries will return files in different orders depending on the OS and/or filesystem. As a result Facter::Util::Loader will load ruby custom fact definitions in different orders on different platforms. Specs to expose the bugs, and code to ensure that custom fact files are loaded in alphabetical order. Addresses redmine issue #5510 http://projects.puppetlabs.com/issues/5510 Signed-off-by: Rick Bradley <rick@rickbradley.com> Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
* Refactor #6044 -- use _spec.rb as the pattern for spec tests.Daniel Pittman2011-01-2713-0/+0
| | | | | | Rename all the spec tests to follow the rspec convention of *_spec.rb rather than unadorned *.rb; this also makes it easier to work with them consistently without using the Rakefile support that customizes that.
* Refactor #6044 -- require spec_helper with a consistent path.Daniel Pittman2011-01-2713-13/+13
| | | | | | Because we pull in spec_helper in individual tests, we need to use a consistent path or Ruby will evaluate it multiple times. Make the path consistent by expanding it before require.
* Refactor #6044 -- port testing to rspec2Daniel Pittman2011-01-274-12/+12
| | | | We have moved to rspec2 for puppet, and facter should follow suit.
* (#5086) Try using kstat before falling back to 'who -b' to determine uptime.Jacob Helwig2011-01-241-8/+21
| | | | | | | | | 'who -b' doesn't report the year of the last system boot on (at least) Solaris 10, and OpenSolaris 2009.06. Try using 'kstat -p unix:::boot_time', which reports as seconds since the epoch on these systems before falling back to 'who -b'. Reviewed-by: Paul Berry <paul@puppetlabs.com>
* Refactor util/uptime.rb tests to reduce duplication using contextsJacob Helwig2011-01-241-27/+34
| | | | Reviewed-by: Paul Berry <paul@puppetlabs.com>
* (#5325) Add tests for SPARC manufacturer and product nameMatt Robinson2010-11-221-1/+12
| | | | | | | Just tests the regex, won't actually catch problems if prtdiag doesn't return output like our test. Paired-with: Nick Lewis
* maint: Fix spec failures caused by having a space in the path to facter's sourceNick Lewis2010-11-222-6/+6
|
* (#4989) Add xendomains factRein Henrichs2010-11-091-0/+23
| | | | | Parses `/usr/sbin/xm list` and returns a comma-separated list of domains. Based on a patch submitted by Jonas Genannt.
* Merge remote branch 'stschulte/feature/master/5040' into nextPaul Berry2010-11-091-0/+11
|\ | | | | | | | | | | Manually resolved conflicts: lib/facter/virtual.rb spec/unit/virtual.rb
| * (#5040) fact virtual should detect hpvmStefan Schulte2010-11-031-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With HP-UX you can build virtual machines that are often refered to as HP-VMs. This patch detecs HP-VMs by introducing a new function hpvm? that will check the output of /usr/bin/getconf MACHINE_MODEL. This should not depend on any tools that might be not installed. If inside a HP-VM the command will say something like ia64 hp server Integrity Virtual Machine while on real hardware the output could be ia64 hp server rx660 so searching for "Virtual Machine" should work. Currently it only works if the guest is also running HP-UX. (I guess this is the most common usecase).
| |
| \
*-. \ Merge remote branches 'pnasrat/tickets/master/4889' and ↵Rein Henrichs2010-10-181-0/+1
|\ \ \ | | |/ | |/| | | | 'pnasrat/tickets/master/4956' into next
| | * Make sure FreeBSD spec also works on systems that have /proc/cpuinfo.Hans de Graaff2010-09-181-0/+1
| |/
* | Merge branch 'ticket/master/3703-macaddress-on-mac' into nextRein Henrichs2010-08-181-0/+75
|\ \
| * | [#3703] Fix macaddress fact for DarwinRein Henrichs2010-08-111-0/+75
| |/ | | | | | | * With tests for 9.8.0, 10.3.0 and 10.6.4
* / [#2865] Fix reporting of virtual factsRein Henrichs2010-08-181-0/+20
|/ | | | | | | | | Regexp tested the s_context or VxID field if /proc/self/status and returned false for 0 and true for any other number. 0 indicates a host, which is still virtual. Fix changes regexp to correctly report hosts as virtual. Tested against vserver 2.1 and 2.3.
* [#4156] Updating spec to match Kai's changeRein Henrichs2010-08-061-1/+1
| | | | | | | Updating the spec to check for the existence of /proc/vz to match the change in the previously applied patch. Signed-off-by: Rein Henrichs <rein@puppetlabs.com>
* Merge remote branch 'kubicek/ticket/master/4352'Rein Henrichs2010-08-061-0/+16
|\
| * Fix #4352 - Support for detecting KVM virtuals on FreeBSDJiri Kubicek2010-07-261-0/+6
| | | | | | | | | | | | There was no support for detecting FreeBSD running in KVM as a virtual in facter. This patch detects KVM by getting "hw.model" kernel state via sysctl. Jails running in KVM are also correctly detected as "jail" not "kvm". Signed-off-by: Jiri Kubicek <jiri.kubicek@kraxnet.cz>
| * Fix #4352 - Support for detecting virtuals (jails) on FreeBSDJiri Kubicek2010-07-261-0/+10
| | | | | | | | | | | | There was no support for detecting FreeBSD jails as a virtual in facter. This patch detects jail by getting "security.jail.jailed" kernel state via sysctl. Signed-off-by: Jiri Kubicek <jiri.kubicek@kraxnet.cz>
| |
| \
*-. | Merge branches 'ticket/master/2330-uptime', 'ticket/master/4062-meego' and ↵Rein Henrichs2010-08-061-0/+53
|\ \| | | | | | | | | | 'ticket/master/4453-rakefile'
| * | [#2330] Uptime should not make redundant system callsRein Henrichs2010-08-031-0/+53
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rewrite of uptime facts and supporting utility methods. Works on unix, BSD, windows. No longer makes redundant system calls. Uses Facter::Util::Uptime utility methods: * Implemented uptime_seconds_unix using /proc/uptime or who -b on unix, sysctl on BSD. Added unit tests for the behaviors of get_uptime_seconds_unix: read from proc/uptime, read uptime from "sysctl -b kern.boottime", read uptime from "who -b", and return nil if nothing else works. * Implemented uptime_seconds_win using the Win32 API. Facts implemented: * uptime_{seconds,hours,days} Returns the respective integer value. * uptime Returns human readable uptime statistic that preserves original behavior. Examples: 3 days 1 day 5:08 hours 0:35 hours
* | Facter::Manufacturer - sunos test + simplified regexMarc Fournier2010-08-041-0/+12
| | | | | | | | | | | | | | | | | | The 2nd regex (with the 0x\d+) got removed because it appears to never be used, even on SunOS, for which it has been introduced (99833a1b / #1793). The 3dn regex is changed to clearly confine the value between mandatory newlines/whitespaces.
* | Facter::Manufacturer - test for SunOS and FreeBSDMarc Fournier2010-08-041-0/+23
|/ | | | | This test compares a fact made with dmidecode (linux and bsd) with one using smbios (solaris).
* Adding HP-UX support to Facter's IP factsJames Turnbull2010-06-151-2/+59
| | | | Includes Rspec tests
* Fixed #3393 - Updates to Facter for MS WindowsDavid Schmitt2010-06-151-11/+43
| | | | | | | | | | This patch is originally by Daniel Berger <djberg96@gmail.com>, I changed using Facter.value instead of repeatedly testing Config['host_os'], removed Resolution::which, and fixed the specs. Thanks to Paul Nasrat for helping with cross-platform debugging. Signed-off-by: David Schmitt <david@dasz.at>
* Fixed #3403 - Added fact to query vlans; added spec testJonas Genannt2010-06-131-0/+14
|
* Fixed failing test introduced by previous commitMarc Fournier2010-05-071-2/+2
|
* Fixes #3740 - split dmi output on regexMarc Fournier2010-05-071-1/+39
| | | | | | | | Splitting dmi output on the string "/^Handle/" didn't work, and caused the function to match the wrong key if it was found more than once. The intended behaviour of the function is restored by splitting the dmi output on the regex /^Handle/.
* Fixed #3541 - Ruby 1.9: broken unittest, unexpected invocation: ↵James Turnbull2010-04-241-0/+1
| | | | | | Process.waitall() Thanks to Jos Backus for the fix.
* Add kvm support to virtual factJohn Ferlito2010-03-081-0/+7
| | | | Based on initial patch by James Turnbull
* Revert "use popen3 in Resolution.exec"Paul Nasrat2010-02-281-44/+0
| | | | | | | | | | | This reverts commit 33fb7709404e706801683e6c47ab7a0a5a1884b1. This has broken master for some facts (eg OS X facts), it also breaks facter platform support on win32 as popen3 does not work there. I'd like to get master working, backlog of patches applied and revisit exec. Paul
* Fix #2341 - stricter handling of dmidecode splitPaul Nasrat2010-01-301-0/+22
| | | | This adds a test to ensure we are not prematurely splitting on Handle
* Remove whitespace in DMI facts (#3008, #3011)Paul Nasrat2010-01-101-0/+26
| | | | | | | | | In addition to the stripping of the output of these facts this patchset: Refactor - Extracted function to enable easier testing. Tests - data driven tests for the dmidecode/smbios fact. Paul
* use popen3 in Resolution.exec to catch stderrPeter Meier2009-11-081-0/+44
| | | | | | | | | | | | | | | | | | | So far messages to stderr haven't been catched by Facter::Util::Resolution.exec and were insted printed out to stderr. This will cause facter and even puppet to print to stderr themself, which is not very nice when running puppetd by cron, as you might get every run a mail if a command outputs to stderr. We are now wrapping the command execution with Open3.popen3 to catch stderr and passing them to the new introduced Facter.warn method. We are also catching multiline outputs chomping newlines and returning an array if there have been more than one line. Otherwise we return an array containing the different lines. This prevents in general cases as described in #2766 and should handle command execution in a bit saner way.
* Issue #2414 - add unit testPaul Nasrat2009-09-091-0/+6
| | | | This adds a unit test on top of Kurt's patch