[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Nick Lewis nick at puppetlabs.com
Thu Mar 17 10:48:41 UTC 2011


The following commit has been merged in the upstream branch:
commit c3baa2899d88fadd4bbe94e008015e33f98132c7
Author: Nick Lewis <nick at puppetlabs.com>
Date:   Thu Mar 3 14:12:44 2011 -0800

    (#6338) Remove inventory indirection, and move to facts indirection
    
    The inventory indirection was just providing the search method for facts.
    Because the route is now facts_search instead of inventory, it can just be
    implemented as the search method for facts.
    
    Reviewed-By: Daniel Pittman

diff --git a/lib/puppet/indirector/facts/yaml.rb b/lib/puppet/indirector/facts/yaml.rb
index 89feaf2..65bd783 100644
--- a/lib/puppet/indirector/facts/yaml.rb
+++ b/lib/puppet/indirector/facts/yaml.rb
@@ -4,4 +4,79 @@ require 'puppet/indirector/yaml'
 class Puppet::Node::Facts::Yaml < Puppet::Indirector::Yaml
   desc "Store client facts as flat files, serialized using YAML, or
     return deserialized facts from disk."
+
+  def search(request)
+    node_names = []
+    Dir.glob(yaml_dir_path).each do |file|
+      facts = YAML.load_file(file)
+      node_names << facts.name if node_matches?(facts, request.options)
+    end
+    node_names
+  end
+
+  private
+
+  # Return the path to a given node's file.
+  def yaml_dir_path
+    base = Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir]
+    File.join(base, 'facts', '*.yaml')
+  end
+
+  def node_matches?(facts, options)
+    options.each do |key, value|
+      type, name, operator = key.to_s.split(".")
+      operator ||= 'eq'
+
+      return false unless node_matches_option?(type, name, operator, value, facts)
+    end
+    return true
+  end
+
+  def node_matches_option?(type, name, operator, value, facts)
+    case type
+    when "meta"
+      case name
+      when "timestamp"
+        compare_timestamp(operator, facts.timestamp, Time.parse(value))
+      end
+    when "facts"
+      compare_facts(operator, facts.values[name], value)
+    end
+  end
+
+  def compare_facts(operator, value1, value2)
+    return false unless value1
+
+    case operator
+    when "eq"
+      value1.to_s == value2.to_s
+    when "le"
+      value1.to_f <= value2.to_f
+    when "ge"
+      value1.to_f >= value2.to_f
+    when "lt"
+      value1.to_f < value2.to_f
+    when "gt"
+      value1.to_f > value2.to_f
+    when "ne"
+      value1.to_s != value2.to_s
+    end
+  end
+
+  def compare_timestamp(operator, value1, value2)
+    case operator
+    when "eq"
+      value1 == value2
+    when "le"
+      value1 <= value2
+    when "ge"
+      value1 >= value2
+    when "lt"
+      value1 < value2
+    when "gt"
+      value1 > value2
+    when "ne"
+      value1 != value2
+    end
+  end
 end
diff --git a/lib/puppet/indirector/inventory/yaml.rb b/lib/puppet/indirector/inventory/yaml.rb
deleted file mode 100644
index fe3489a..0000000
--- a/lib/puppet/indirector/inventory/yaml.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-require 'puppet/node/inventory'
-require 'puppet/indirector/yaml'
-
-class Puppet::Node::Inventory::Yaml < Puppet::Indirector::Yaml
-  desc "Return node names matching the fact query"
-
-  # Return the path to a given node's file.
-  def yaml_dir_path
-    base = Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir]
-    File.join(base, 'facts', '*.yaml')
-  end
-
-  def node_matches?(facts, options)
-    options.each do |key, value|
-      type, name, operator = key.to_s.split(".")
-      operator ||= 'eq'
-
-      return false unless node_matches_option?(type, name, operator, value, facts)
-    end
-    return true
-  end
-
-  def search(request)
-    node_names = []
-    Dir.glob(yaml_dir_path).each do |file|
-      facts = YAML.load_file(file)
-      node_names << facts.name if node_matches?(facts, request.options)
-    end
-    node_names
-  end
-
-  private
-
-  def node_matches_option?(type, name, operator, value, facts)
-    case type
-    when "meta"
-      case name
-      when "timestamp"
-        compare_timestamp(operator, facts.timestamp, Time.parse(value))
-      end
-    when "facts"
-      compare_facts(operator, facts.values[name], value)
-    end
-  end
-
-  def compare_facts(operator, value1, value2)
-    return false unless value1
-
-    case operator
-    when "eq"
-      value1.to_s == value2.to_s
-    when "le"
-      value1.to_f <= value2.to_f
-    when "ge"
-      value1.to_f >= value2.to_f
-    when "lt"
-      value1.to_f < value2.to_f
-    when "gt"
-      value1.to_f > value2.to_f
-    when "ne"
-      value1.to_s != value2.to_s
-    end
-  end
-
-  def compare_timestamp(operator, value1, value2)
-    case operator
-    when "eq"
-      value1 == value2
-    when "le"
-      value1 <= value2
-    when "ge"
-      value1 >= value2
-    when "lt"
-      value1 < value2
-    when "gt"
-      value1 > value2
-    when "ne"
-      value1 != value2
-    end
-  end
-end
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index e8d58e6..2453cd1 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -3,7 +3,6 @@ require 'puppet/indirector'
 # A class for managing nodes, including their facts and environment.
 class Puppet::Node
   require 'puppet/node/facts'
-  require 'puppet/node/inventory'
   require 'puppet/node/environment'
 
   # Set up indirection, so that nodes can be looked for in
diff --git a/lib/puppet/node/inventory.rb b/lib/puppet/node/inventory.rb
deleted file mode 100644
index fd99163..0000000
--- a/lib/puppet/node/inventory.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'puppet/node'
-require 'puppet/indirector'
-
-class Puppet::Node::Inventory
-  extend Puppet::Indirector
-  indirects :inventory, :terminus_setting => :inventory_terminus
-end
diff --git a/spec/unit/indirector/facts/yaml_spec.rb b/spec/unit/indirector/facts/yaml_spec.rb
index 37a1bca..c625c8e 100755
--- a/spec/unit/indirector/facts/yaml_spec.rb
+++ b/spec/unit/indirector/facts/yaml_spec.rb
@@ -23,4 +23,218 @@ describe Puppet::Node::Facts::Yaml do
   it "should have its name set to :yaml" do
     Puppet::Node::Facts::Yaml.name.should == :yaml
   end
+
+  describe "#search" do
+    def assert_search_matches(matching, nonmatching, query)
+      request = Puppet::Indirector::Request.new(:inventory, :search, nil, query)
+
+      Dir.stubs(:glob).returns(matching.keys + nonmatching.keys)
+      [matching, nonmatching].each do |examples|
+        examples.each do |key, value|
+          YAML.stubs(:load_file).with(key).returns value
+        end
+      end
+      Puppet::Node::Facts::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
+    end
+
+    it "should return node names that match the search query options" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386", 'processor_count' => '4'),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "i386", 'processor_count' => '4', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '4'),
+          "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5'),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3",                              'processor_count' => '4'),
+        },
+        {'facts.architecture' => 'i386', 'facts.processor_count' => '4'}
+      )
+    end
+
+    it "should return empty array when no nodes match the search query options" do
+      assert_search_matches({}, {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '10'),
+          "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5'),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3",                              'processor_count' => '4'),
+        },
+        {'facts.processor_count.lt' => '4', 'facts.processor_count.gt' => '4'}
+      )
+    end
+
+
+    it "should return node names that match the search query options with the greater than operator" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '10', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '4'),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '3'),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                       ),
+        },
+        {'facts.processor_count.gt' => '4'}
+      )
+    end
+
+    it "should return node names that match the search query options with the less than operator" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '30', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '50' ),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '100'),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                         ),
+        },
+        {'facts.processor_count.lt' => '50'}
+      )
+    end
+
+    it "should return node names that match the search query options with the less than or equal to operator" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '100' ),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5000'),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                          ),
+        },
+        {'facts.processor_count.le' => '50'}
+      )
+    end
+
+    it "should return node names that match the search query options with the greater than or equal to operator" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '100'),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '40'),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '9' ),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                        ),
+        },
+        {'facts.processor_count.ge' => '50'}
+      )
+    end
+
+    it "should return node names that match the search query options with the not equal operator" do
+      assert_search_matches({
+          '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => 'arm'                           ),
+          '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => 'powerpc', 'randomfact' => 'foo')
+        },
+        {
+          "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "i386"                           ),
+          "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ),
+          "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                     ),
+        },
+        {'facts.architecture.ne' => 'i386'}
+      )
+    end
+
+    def apply_timestamp(facts, timestamp)
+      facts.timestamp = timestamp
+      facts
+    end
+
+    it "should be able to query based on meta.timestamp.gt" do
+      assert_search_matches({
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+        },
+        {
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {'meta.timestamp.gt' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp.le" do
+      assert_search_matches({
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+        },
+        {'meta.timestamp.le' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp.lt" do
+      assert_search_matches({
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+        },
+        {
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {'meta.timestamp.lt' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp.ge" do
+      assert_search_matches({
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+        },
+        {'meta.timestamp.ge' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp.eq" do
+      assert_search_matches({
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+        },
+        {'meta.timestamp.eq' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp" do
+      assert_search_matches({
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+        },
+        {'meta.timestamp' => '2010-10-15'}
+      )
+    end
+
+    it "should be able to query based on meta.timestamp.ne" do
+      assert_search_matches({
+          '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
+          '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
+          '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
+          '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
+        },
+        {
+          '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
+        },
+        {'meta.timestamp.ne' => '2010-10-15'}
+      )
+    end
+  end
 end
diff --git a/spec/unit/indirector/inventory/yaml_spec.rb b/spec/unit/indirector/inventory/yaml_spec.rb
deleted file mode 100644
index 9f0c543..0000000
--- a/spec/unit/indirector/inventory/yaml_spec.rb
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
-
-require 'puppet/node/inventory'
-require 'puppet/indirector/inventory/yaml'
-require 'puppet/indirector/request'
-
-describe Puppet::Node::Inventory::Yaml do
-  def assert_search_matches(matching, nonmatching, query)
-    request = Puppet::Indirector::Request.new(:inventory, :search, nil, query)
-
-    Dir.stubs(:glob).returns(matching.keys + nonmatching.keys)
-    [matching, nonmatching].each do |examples|
-      examples.each do |key, value|
-        YAML.stubs(:load_file).with(key).returns value
-      end
-    end
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
-  end
-
-  it "should return node names that match the search query options" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386", 'processor_count' => '4'),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "i386", 'processor_count' => '4', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '4'),
-        "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5'),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3",                              'processor_count' => '4'),
-      },
-      {'facts.architecture' => 'i386', 'facts.processor_count' => '4'}
-    )
-  end
-
-  it "should return empty array when no nodes match the search query options" do
-    assert_search_matches({}, {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '10'),
-        "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5'),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3",                              'processor_count' => '4'),
-      },
-      {'facts.processor_count.lt' => '4', 'facts.processor_count.gt' => '4'}
-    )
-  end
-
-
-  it "should return node names that match the search query options with the greater than operator" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '10', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '4'),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '3'),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                       ),
-      },
-      {'facts.processor_count.gt' => '4'}
-    )
-  end
-
-  it "should return node names that match the search query options with the less than operator" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '30', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '50' ),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '100'),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                         ),
-      },
-      {'facts.processor_count.lt' => '50'}
-    )
-  end
-
-  it "should return node names that match the search query options with the less than or equal to operator" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '100' ),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5000'),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                          ),
-      },
-      {'facts.processor_count.le' => '50'}
-    )
-  end
-
-  it "should return node names that match the search query options with the greater than or equal to operator" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '100'),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '40'),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '9' ),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                        ),
-      },
-      {'facts.processor_count.ge' => '50'}
-    )
-  end
-
-  it "should return node names that match the search query options with the not equal operator" do
-    assert_search_matches({
-        '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => 'arm'                           ),
-        '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => 'powerpc', 'randomfact' => 'foo')
-      },
-      {
-        "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "i386"                           ),
-        "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ),
-        "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3"                                                     ),
-      },
-      {'facts.architecture.ne' => 'i386'}
-    )
-  end
-
-  def apply_timestamp(facts, timestamp)
-    facts.timestamp = timestamp
-    facts
-  end
-
-  it "should be able to query based on meta.timestamp.gt" do
-    assert_search_matches({
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-      },
-      {
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {'meta.timestamp.gt' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp.le" do
-    assert_search_matches({
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-      },
-      {'meta.timestamp.le' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp.lt" do
-    assert_search_matches({
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-      },
-      {
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {'meta.timestamp.lt' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp.ge" do
-    assert_search_matches({
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-      },
-      {'meta.timestamp.ge' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp.eq" do
-    assert_search_matches({
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-      },
-      {'meta.timestamp.eq' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp" do
-    assert_search_matches({
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-      },
-      {'meta.timestamp' => '2010-10-15'}
-    )
-  end
-
-  it "should be able to query based on meta.timestamp.ne" do
-    assert_search_matches({
-        '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")),
-        '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")),
-        '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")),
-        '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")),
-      },
-      {
-        '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")),
-      },
-      {'meta.timestamp.ne' => '2010-10-15'}
-    )
-  end
-end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list