[Pkg-puppet-devel] [facter] 92/180: (maint) Extract heredoc fixtures from memory spec

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 1b01b17ee6f86395dfb85a656d93c92c0960bc14
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Wed Jun 5 11:15:40 2013 -0700

    (maint) Extract heredoc fixtures from memory spec
    
    Conflicts:
    	spec/unit/memory_spec.rb
---
 spec/fixtures/unit/memory/aix-svmon                |   9 ++
 spec/fixtures/unit/memory/aix-swap_l               |   2 +
 spec/fixtures/unit/memory/darwin-swapinfo-multiple |   3 +
 spec/fixtures/unit/memory/darwin-swapinfo-single   |   2 +
 spec/fixtures/unit/memory/darwin-vm_stat           |  13 ++
 spec/fixtures/unit/memory/dragonfly-vmstat         |   3 +
 spec/fixtures/unit/memory/freebsd-vmstat           |   3 +
 spec/fixtures/unit/memory/linux-proc_meminfo       |  10 ++
 spec/fixtures/unit/memory/openbsd-vmstat           |   3 +
 spec/fixtures/unit/memory/solaris-prtconf          |   4 +
 spec/fixtures/unit/memory/solaris-swap_l-multiple  |   3 +
 spec/fixtures/unit/memory/solaris-swap_l-single    |   2 +
 spec/fixtures/unit/memory/solaris-vmstat           |   3 +
 spec/unit/memory_spec.rb                           | 134 ++++-----------------
 14 files changed, 81 insertions(+), 113 deletions(-)

diff --git a/spec/fixtures/unit/memory/aix-svmon b/spec/fixtures/unit/memory/aix-svmon
new file mode 100644
index 0000000..bb96729
--- /dev/null
+++ b/spec/fixtures/unit/memory/aix-svmon
@@ -0,0 +1,9 @@
+Unit: KB
+--------------------------------------------------------------------------------------
+               size       inuse        free         pin     virtual  available   mmode
+memory     32768000     9948408    22819592     2432080     4448928   27231828     Ded
+pg space   34078720       15000
+
+               work        pers        clnt       other
+pin         1478228           0           0      953852
+in use      4448928           0     5499480
diff --git a/spec/fixtures/unit/memory/aix-swap_l b/spec/fixtures/unit/memory/aix-swap_l
new file mode 100644
index 0000000..1966dbf
--- /dev/null
+++ b/spec/fixtures/unit/memory/aix-swap_l
@@ -0,0 +1,2 @@
+device maj,min total free
+/dev/hd6 10, 2 512MB 508MB
diff --git a/spec/fixtures/unit/memory/darwin-swapinfo-multiple b/spec/fixtures/unit/memory/darwin-swapinfo-multiple
new file mode 100644
index 0000000..f5e9305
--- /dev/null
+++ b/spec/fixtures/unit/memory/darwin-swapinfo-multiple
@@ -0,0 +1,3 @@
+Device          1K-blocks     Used    Avail Capacity
+/dev/da0p3        2048540        0  1048540     0%
+/dev/da0p4        3048540        0  1048540     0%
diff --git a/spec/fixtures/unit/memory/darwin-swapinfo-single b/spec/fixtures/unit/memory/darwin-swapinfo-single
new file mode 100644
index 0000000..8b41560
--- /dev/null
+++ b/spec/fixtures/unit/memory/darwin-swapinfo-single
@@ -0,0 +1,2 @@
+Device          1K-blocks     Used    Avail Capacity
+/dev/da0p3        2048540        0  1048540     0%
diff --git a/spec/fixtures/unit/memory/darwin-vm_stat b/spec/fixtures/unit/memory/darwin-vm_stat
new file mode 100644
index 0000000..300f405
--- /dev/null
+++ b/spec/fixtures/unit/memory/darwin-vm_stat
@@ -0,0 +1,13 @@
+Mach Virtual Memory Statistics: (page size of 4096 bytes)
+Pages free:                          28430.
+Pages active:                      1152576.
+Pages inactive:                     489054.
+Pages speculative:                    7076.
+Pages wired down:                   418217.
+"Translation faults":           1340091228.
+Pages copy-on-write:              16851357.
+Pages zero filled:               665168768.
+Pages reactivated:                 3082708.
+Pageins:                          13862917.
+Pageouts:                          1384383.
+Object cache: 14 hits of 2619925 lookups (0% hit rate)
diff --git a/spec/fixtures/unit/memory/dragonfly-vmstat b/spec/fixtures/unit/memory/dragonfly-vmstat
new file mode 100644
index 0000000..bae884c
--- /dev/null
+++ b/spec/fixtures/unit/memory/dragonfly-vmstat
@@ -0,0 +1,3 @@
+ procs    memory    page          disks   faults    cpu
+ r b w   avm  fre  flt  re  pi  po  fr  sr da0 sg1   in   sy  cs us sy id
+ 0 0 0   33152  13940 1902120 2198 53119 11642 6544597 5460994   0   0 6148243 7087927 3484264  0  1 9
diff --git a/spec/fixtures/unit/memory/freebsd-vmstat b/spec/fixtures/unit/memory/freebsd-vmstat
new file mode 100644
index 0000000..3525abf
--- /dev/null
+++ b/spec/fixtures/unit/memory/freebsd-vmstat
@@ -0,0 +1,3 @@
+ procs      memory      page                    disks     faults         cpu
+ r b w     avm    fre   flt  re  pi  po    fr  sr da0 cd0   in   sy   cs us sy id
+ 1 0 0  207600  656640    10   0   0   0    13   0   0   0   51  164  257  0  1 99
diff --git a/spec/fixtures/unit/memory/linux-proc_meminfo b/spec/fixtures/unit/memory/linux-proc_meminfo
new file mode 100644
index 0000000..bf68aa0
--- /dev/null
+++ b/spec/fixtures/unit/memory/linux-proc_meminfo
@@ -0,0 +1,10 @@
+MemTotal:   255908 kB
+MemFree:     69936 kB
+Buffers:     15812 kB
+Cached:     115124 kB
+SwapCached:      0 kB
+Active:      92700 kB
+Inactive:    63792 kB
+SwapTotal:  524280 kB
+SwapFree:   524280 kB
+Dirty:           4 kB
diff --git a/spec/fixtures/unit/memory/openbsd-vmstat b/spec/fixtures/unit/memory/openbsd-vmstat
new file mode 100644
index 0000000..df57d8e
--- /dev/null
+++ b/spec/fixtures/unit/memory/openbsd-vmstat
@@ -0,0 +1,3 @@
+ procs  memory     page          disks  traps      cpu
+ r b w  avm   fre  flt  re  pi  po  fr  sr cd0 sd0  int   sys   cs us sy id
+ 0 0 0  11048  181028   39   0   0   0   0   0   0   1  3  90   17  0  0 100
diff --git a/spec/fixtures/unit/memory/solaris-prtconf b/spec/fixtures/unit/memory/solaris-prtconf
new file mode 100644
index 0000000..5da9238
--- /dev/null
+++ b/spec/fixtures/unit/memory/solaris-prtconf
@@ -0,0 +1,4 @@
+System Configuration:  Sun Microsystems  sun4u
+Memory size: 2048 Megabytes
+System Peripherals (Software Nodes):
+
diff --git a/spec/fixtures/unit/memory/solaris-swap_l-multiple b/spec/fixtures/unit/memory/solaris-swap_l-multiple
new file mode 100644
index 0000000..843eb73
--- /dev/null
+++ b/spec/fixtures/unit/memory/solaris-swap_l-multiple
@@ -0,0 +1,3 @@
+swapfile             dev  swaplo blocks   free
+/dev/swap           4294967295,4294967295     16 2097136 2097136
+/dev/swap2          4294967295,4294967295     16 2097136 2097136
diff --git a/spec/fixtures/unit/memory/solaris-swap_l-single b/spec/fixtures/unit/memory/solaris-swap_l-single
new file mode 100644
index 0000000..1f4e804
--- /dev/null
+++ b/spec/fixtures/unit/memory/solaris-swap_l-single
@@ -0,0 +1,2 @@
+swapfile             dev  swaplo blocks   free
+/dev/swap           4294967295,4294967295     16 2097136 2097136
diff --git a/spec/fixtures/unit/memory/solaris-vmstat b/spec/fixtures/unit/memory/solaris-vmstat
new file mode 100644
index 0000000..d3c9d11
--- /dev/null
+++ b/spec/fixtures/unit/memory/solaris-vmstat
@@ -0,0 +1,3 @@
+ kthr      memory            page            disk          faults      cpu
+ r b w   swap  free  re  mf pi po fr de sr s0 s3 -- --   in   sy   cs us sy id
+ 0 0 0 1154552 476224 8  19  0  0  0  0  0  0  0  0  0  460  294  236  1  2 97
diff --git a/spec/unit/memory_spec.rb b/spec/unit/memory_spec.rb
index fa92367..bb35111 100755
--- a/spec/unit/memory_spec.rb
+++ b/spec/unit/memory_spec.rb
@@ -49,22 +49,7 @@ describe "Memory facts" do
       Facter.clear
       Facter.fact(:kernel).stubs(:value).returns("Darwin")
       Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.memsize').returns('8589934592')
-      sample_vm_stat = <<VMSTAT
-Mach Virtual Memory Statistics: (page size of 4096 bytes)
-Pages free:                          28430.
-Pages active:                      1152576.
-Pages inactive:                     489054.
-Pages speculative:                    7076.
-Pages wired down:                   418217.
-"Translation faults":           1340091228.
-Pages copy-on-write:              16851357.
-Pages zero filled:               665168768.
-Pages reactivated:                 3082708.
-Pageins:                          13862917.
-Pageouts:                          1384383.
-Object cache: 14 hits of 2619925 lookups (0% hit rate)
-VMSTAT
-      Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(sample_vm_stat)
+      Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(my_fixture_read('darwin-vm_stat'))
       Facter::Core::Execution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M  used = 1.00M  free = 63.00M  (encrypted)")
 
       Facter.collection.internal_loader.load(:memory)
@@ -104,20 +89,10 @@ VMSTAT
       before(:each) do
         Facter.clear
         Facter.fact(:kernel).stubs(:value).returns(kernel)
-        meminfo = <<INFO
-MemTotal:   255908 kB
-MemFree:     69936 kB
-Buffers:     15812 kB
-Cached:     115124 kB
-SwapCached:      0 kB
-Active:      92700 kB
-Inactive:    63792 kB
-SwapTotal:  524280 kB
-SwapFree:   524280 kB
-Dirty:           4 kB
-INFO
-
-        File.stubs(:readlines).with("/proc/meminfo").returns(meminfo.split("\n"))
+
+        meminfo_contents = my_fixture_read('linux-proc_meminfo').split("\n")
+
+        File.stubs(:readlines).with("/proc/meminfo").returns(meminfo_contents)
 
         Facter.collection.internal_loader.load(:memory)
       end
@@ -149,26 +124,8 @@ INFO
       Facter.clear
       Facter.fact(:kernel).stubs(:value).returns("AIX")
 
-      swapusage = <<SWAP
-device maj,min total free
-/dev/hd6 10, 2 512MB 508MB
-SWAP
-
-      Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
-
-      svmon = <<SVMON
-Unit: KB
---------------------------------------------------------------------------------------
-               size       inuse        free         pin     virtual  available   mmode
-memory     32768000     9948408    22819592     2432080     4448928   27231828     Ded
-pg space   34078720       15000
-
-               work        pers        clnt       other
-pin         1478228           0           0      953852
-in use      4448928           0     5499480
-SVMON
-
-      Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon)
+      Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(my_fixture_read('aix-swap_l'))
+      Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(my_fixture_read('aix-svmon'))
 
       Facter.collection.internal_loader.load(:memory)
     end
@@ -224,14 +181,9 @@ SVMON
       swapusage = "total: 148342k bytes allocated = 0k used, 148342k available"
       Facter::Core::Execution.stubs(:exec).with('swapctl -s').returns(swapusage)
 
-      vmstat = <<EOS
- procs  memory     page          disks  traps      cpu
- r b w  avm   fre  flt  re  pi  po  fr  sr cd0 sd0  int   sys   cs us sy id
- 0 0 0  11048  181028   39   0   0   0   0   0   0   1  3  90   17  0  0 100
-EOS
-      Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
-      Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns('267321344')
+      Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('openbsd-vmstat'))
 
+      Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns('267321344')
       Facter::Core::Execution.stubs(:exec).with('sysctl -n vm.swapencrypt.enable').returns('1')
 
       Facter.collection.internal_loader.load(:memory)
@@ -266,20 +218,9 @@ EOS
     before(:each) do
       Facter.clear
       Facter.fact(:kernel).stubs(:value).returns("SunOS")
-      sample_prtconf = <<PRTCONF
-System Configuration:  Sun Microsystems  sun4u
-Memory size: 2048 Megabytes
-System Peripherals (Software Nodes):
-
-PRTCONF
-      Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns sample_prtconf
-
-      vmstat_lines = <<VMSTAT
- kthr      memory            page            disk          faults      cpu
- r b w   swap  free  re  mf pi po fr de sr s0 s3 -- --   in   sy   cs us sy id
- 0 0 0 1154552 476224 8  19  0  0  0  0  0  0  0  0  0  460  294  236  1  2 97
-VMSTAT
-      Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat_lines)
+
+      Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns(my_fixture_read('solaris-prtconf'))
+      Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('solaris-vmstat'))
     end
 
     after(:each) do
@@ -288,11 +229,7 @@ VMSTAT
 
     describe "when single swap exists" do
       before(:each) do
-        sample_swap_line = <<SWAP
-swapfile             dev  swaplo blocks   free
-/dev/swap           4294967295,4294967295     16 2097136 2097136
-SWAP
-        Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
+        Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-single')
 
         Facter.collection.internal_loader.load(:memory)
       end
@@ -316,12 +253,7 @@ SWAP
 
     describe "when multiple swaps exist" do
       before(:each) do
-        sample_swap_line = <<SWAP
-swapfile             dev  swaplo blocks   free
-/dev/swap           4294967295,4294967295     16 2097136 2097136
-/dev/swap2          4294967295,4294967295     16 2097136 2097136
-SWAP
-        Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
+        Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-multiple')
         Facter.collection.internal_loader.load(:memory)
       end
 
@@ -378,12 +310,7 @@ SWAP
         Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635")
         Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0")
 
-        vmstat = <<EOS
- procs    memory    page          disks   faults    cpu
- r b w   avm  fre  flt  re  pi  po  fr  sr da0 sg1   in   sy  cs us sy id
- 0 0 0   33152  13940 1902120 2198 53119 11642 6544597 5460994   0   0 6148243 7087927 3484264  0  1 9
-EOS
-        Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
+        Facter::Core::Execution.stubs(:exec).with('vmstat').returns my_fixture_read('dragonfly-vmstat')
 
         Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512')
 
@@ -416,16 +343,8 @@ EOS
         Facter.clear
         Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
 
-        sample_vmstat = <<VM_STAT
- procs      memory      page                    disks     faults         cpu
- r b w     avm    fre   flt  re  pi  po    fr  sr da0 cd0   in   sy   cs us sy id
- 1 0 0  207600  656640    10   0   0   0    13   0   0   0   51  164  257  0  1 99
-VM_STAT
-        Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns sample_vmstat
-        sample_physmem = <<PHYSMEM
-1056276480
-PHYSMEM
-        Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns sample_physmem
+        Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns my_fixture_read('freebsd-vmstat')
+        Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns '1056276480'
       end
 
       after(:each) do
@@ -434,11 +353,9 @@ PHYSMEM
 
       describe "with no swap" do
         before(:each) do
-          sample_swapinfo = <<SWAP
-Device          1K-blocks     Used    Avail Capacity
-SWAP
-          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
+          sample_swapinfo = 'Device          1K-blocks     Used    Avail Capacity'
 
+          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
           Facter.collection.internal_loader.load(:memory)
         end
 
@@ -461,11 +378,7 @@ SWAP
 
       describe "with one swap" do
         before(:each) do
-          sample_swapinfo = <<SWAP
-Device          1K-blocks     Used    Avail Capacity
-/dev/da0p3        2048540        0  1048540     0%
-SWAP
-          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
+          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-single')
 
           Facter.collection.internal_loader.load(:memory)
         end
@@ -489,12 +402,7 @@ SWAP
 
       describe "with multiple swaps" do
         before(:each) do
-          sample_swapinfo = <<SWAP
-Device          1K-blocks     Used    Avail Capacity
-/dev/da0p3        2048540        0  1048540     0%
-/dev/da0p4        3048540        0  1048540     0%
-SWAP
-          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo
+          Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-multiple')
 
           Facter.collection.internal_loader.load(:memory)
         end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list