diff options
-rw-r--r-- | lib/puppet/gratr/adjacency_graph.rb | 3 | ||||
-rw-r--r-- | lib/puppet/gratr/digraph.rb | 5 | ||||
-rw-r--r-- | lib/puppet/pgraph.rb | 5 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 5 | ||||
-rwxr-xr-x | test/client/master.rb | 16 | ||||
-rwxr-xr-x | test/other/events.rb | 15 | ||||
-rw-r--r-- | test/other/pgraph.rb | 16 | ||||
-rwxr-xr-x | test/other/transactions.rb | 6 |
8 files changed, 67 insertions, 4 deletions
diff --git a/lib/puppet/gratr/adjacency_graph.rb b/lib/puppet/gratr/adjacency_graph.rb index 930e2abac..bea50e8c8 100644 --- a/lib/puppet/gratr/adjacency_graph.rb +++ b/lib/puppet/gratr/adjacency_graph.rb @@ -178,6 +178,9 @@ module GRATR alias graph_adjacent adjacent def adjacent(x, options={}) + unless @vertex_dict.has_key?(x) + raise ArgumentError, "%s is not a vertex" % x + end options[:direction] ||= :out if !x.kind_of?(GRATR::Edge) and (options[:direction] == :out || !directed?) if options[:type] == :edges diff --git a/lib/puppet/gratr/digraph.rb b/lib/puppet/gratr/digraph.rb index 2c4850d43..ae875376d 100644 --- a/lib/puppet/gratr/digraph.rb +++ b/lib/puppet/gratr/digraph.rb @@ -68,7 +68,10 @@ module GRATR # Reverse all edges in a graph def reversal return new(self) unless directed? - edges.inject(self.class.new) {|a,e| a << e.reverse} + result = self.class.new + edges.inject(result) {|a,e| a << e.reverse} + vertices.each { |v| result.add_vertex!(v) unless result.vertex?(v) } + result end # Return true if the Graph is oriented. diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index 58bee8605..bf156ed2d 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -68,7 +68,10 @@ class Puppet::PGraph < GRATR::Digraph next unless vertex.is_a?(type) leaves = other.leaves(vertex) - next if leaves.empty? + if leaves.empty? + remove_vertex!(vertex) + next + end # First create new edges for each of the :in edges adjacent(vertex, :direction => :in, :type => :edges).each do |edge| diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index adb5eb134..d6d1669a1 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -143,6 +143,10 @@ class Transaction def eval_resource(resource) events = [] + if resource.is_a?(Puppet::Type::Component) + raise Puppet::DevError, "Got a component to evaluate" + end + if skip?(resource) @resourcemetrics[:skipped] += 1 else @@ -231,6 +235,7 @@ class Transaction # enough to check the immediate dependencies, which is why we use # a tree from the reversed graph. skip = false + resource.info "checking for failed deps" @relgraph.reversal.tree_from_vertex(resource, :dfs).keys.each do |dep| if fails = failed?(dep) resource.notice "Dependency %s[%s] has %s failures" % diff --git a/test/client/master.rb b/test/client/master.rb index ddbee8467..f89d2cae8 100755 --- a/test/client/master.rb +++ b/test/client/master.rb @@ -128,6 +128,22 @@ class TestMasterClient < Test::Unit::TestCase client.run } end + + def test_download + source = tempfile() + dest = tempfile() + sfile = File.join(source, "file") + Dir.mkdir(source) + File.open(sfile, "w") {|f| f.puts "yay"} + + files = [] + assert_nothing_raised do + + Puppet::Client::Master.download(:dest => dest, :source => source, :name => "testing") do |path| + files << path + end + end + end def test_getplugins Puppet[:pluginsource] = tempfile() diff --git a/test/other/events.rb b/test/other/events.rb index a6d5d0e6c..10099fa46 100755 --- a/test/other/events.rb +++ b/test/other/events.rb @@ -125,27 +125,40 @@ class TestEvents < Test::Unit::TestCase assert(FileTest.exists?(fname), "Exec file did not get created") end + # Make sure refreshing happens mid-transaction, rather than at the end. def test_refreshordering file = tempfile() exec1 = Puppet.type(:exec).create( + :title => "one", :name => "echo one >> %s" % file, :path => "/usr/bin:/bin" ) exec2 = Puppet.type(:exec).create( + :title => "two", :name => "echo two >> %s" % file, :path => "/usr/bin:/bin", :refreshonly => true, - :subscribe => ["exec", exec1.name] + :subscribe => exec1 ) exec3 = Puppet.type(:exec).create( + :title => "three", :name => "echo three >> %s" % file, :path => "/usr/bin:/bin" ) + execs = [exec1, exec2, exec3] comp = newcomp(exec1,exec2,exec3) + + trans = comp.evaluate + execs.each do |e| assert(trans.resources.vertex?(e), "%s is not in graph" % e.title) end + trans.prepare + execs.each do |e| assert(trans.relgraph.vertex?(e), "%s is not in relgraph" % e.title) end + reverse = trans.relgraph.reversal + execs.each do |e| assert(reverse.vertex?(e), "%s is not in reversed graph" % e.title) end + assert_apply(comp) diff --git a/test/other/pgraph.rb b/test/other/pgraph.rb index adf290b34..3dc232670 100644 --- a/test/other/pgraph.rb +++ b/test/other/pgraph.rb @@ -54,6 +54,10 @@ class TestPGraph < Test::Unit::TestCase # Test that we can take a containment graph and rearrange it by dependencies def test_splice one, two, middle, top = build_tree + empty = Container.new("empty", []) + # Also, add an empty container to top + top.push empty + contgraph = top.to_graph # Now add a couple of child files, so that we can test whether all containers @@ -66,7 +70,9 @@ class TestPGraph < Test::Unit::TestCase deps.add_vertex(v) end - {one => two, "f" => "c", "h" => middle}.each do |source, target| + # We have to specify a relationship to our empty container, else it never makes it + # into the dep graph in the first place. + {one => two, "f" => "c", "h" => middle, "c" => empty}.each do |source, target| deps.add_edge!(source, target, :callback => :refresh) end @@ -86,6 +92,10 @@ class TestPGraph < Test::Unit::TestCase end end + # Make sure there are no container objects remaining + c = deps.vertices.find_all { |v| v.is_a?(Container) } + assert(c.empty?, "Still have containers %s" % c.inspect) + nons = deps.vertices.find_all { |v| ! v.is_a?(String) } assert(nons.empty?, "still contain non-strings %s" % nons.inspect) @@ -97,6 +107,10 @@ class TestPGraph < Test::Unit::TestCase "Label was not copied on splice") end end + + # Make sure empty containers are also removed + def test_empty_splice + end end # $Id$
\ No newline at end of file diff --git a/test/other/transactions.rb b/test/other/transactions.rb index 9fc58526a..67a2daea9 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -553,6 +553,12 @@ class TestTransactions < Test::Unit::TestCase assert(graph.vertex?(f(:g)), "Lost vertexes with no relations") + # Now make the reversal graph and make sure all of the vertices made it into that + reverse = graph.reversal + %w{a b c d e f g h}.each do |letter| + file = f(letter) + assert(reverse.vertex?(file), "%s did not make it into reversal" % letter) + end graph.to_jpg("normal_relations") end |