Permalink
Browse files

Fixing a few testing bugs that have crept in, and fixing a self-refer…

…ence problem when configuring, graphing, and setting graphdir manually.

git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2052 980ebf18-57e1-0310-9a29-db15c13687c0
  • Loading branch information...
luke
luke committed Jan 5, 2007
1 parent e756711 commit 704bd761057f075a0754bf6880bbb5c3b6014695
View
@@ -187,7 +187,7 @@ begin
client.apply
rescue => detail
$stderr.puts detail
if Puppet[:debug]
if Puppet[:trace]
puts detail.backtrace
end
exit(1)
@@ -139,12 +139,8 @@ def apply(tags = nil, ignoreschedules = false)
# Cache the config
def cache(text)
Puppet.config.use(:puppet, :sslcertificates, :puppetd)
Puppet.info "Caching configuration at %s" % self.cachefile
confdir = File.dirname(Puppet[:localconfig])
#unless FileTest.exists?(confdir)
# Puppet.recmkdir(confdir, 0770)
#end
File.open(self.cachefile + ".tmp", "w", 0660) { |f|
f.print text
}
@@ -167,7 +163,6 @@ def clear
# Initialize and load storage
def dostorage
begin
Puppet::Storage.init
Puppet::Storage.load
rescue => detail
if Puppet[:trace]
@@ -276,6 +271,7 @@ def getplugins
# Just so we can specify that we are "the" instance.
def initialize(*args)
Puppet.config.use(:puppet, :sslcertificates, :puppetd)
super
@configtime = Time.now
View
@@ -610,6 +610,7 @@ def use(*sections)
end
trans = objects.evaluate
trans.ignoretags = true
trans.configurator = true
trans.evaluate
if tags
Puppet[:tags] = tags
@@ -46,7 +46,10 @@ def install
should = @model.should(:ensure)
# Seems like you can always say 'upgrade'
port "upgrade", @model[:name]
output = port "upgrade", @model[:name]
if output =~ /^Error: No port/
raise Puppet::ExecutionFailure, "Could not find package %s" % @model[:name]
end
end
def query
View
@@ -45,9 +45,6 @@ def self.init
self.init
def self.load
if Puppet[:statefile].nil?
raise Puppet::DevError, "Somehow the statefile is nil"
end
Puppet.config.use(:puppet)
unless File.exists?(Puppet[:statefile])
View
@@ -7,7 +7,7 @@
module Puppet
class Transaction
attr_accessor :component, :resources, :ignoreschedules, :ignoretags
attr_accessor :relgraph, :sorted_resources
attr_accessor :relgraph, :sorted_resources, :configurator
attr_writer :tags
@@ -134,8 +134,10 @@ def changed?
# Do any necessary cleanup. If we don't get rid of the graphs, the
# contained resources might never get cleaned up.
def cleanup
@generated.each do |resource|
resource.remove
if defined? @generated
@generated.each do |resource|
resource.remove
end
end
if defined? @relgraph
@relgraph.clear
@@ -248,6 +250,8 @@ def eval_resource(resource, checkskip = true)
def evaluate
@count = 0
graph(@resources, :resources)
# Start logging.
Puppet::Log.newdestination(@report)
@@ -342,11 +346,14 @@ def generate
# Produce the graph files if requested.
def graph(gr, name)
# We don't want to graph the configuration process.
return if self.configurator
return unless Puppet[:graph]
file = File.join(Puppet[:graphdir], "%s.dot" % name.to_s)
File.open(file, "w") { |f|
f.puts gr.to_dot
f.puts gr.to_dot("name" => name.to_s.capitalize)
}
end
@@ -359,8 +366,6 @@ def initialize(resources)
@resources = resources.to_graph
end
graph(@resources, :resources)
@resourcemetrics = {
:total => @resources.vertices.length,
:out_of_sync => 0, # The number of resources that had changes
View
@@ -357,7 +357,7 @@ def title
# convert to a string
def to_s
self.title
self.ref
end
# Convert to a transportable object
@@ -147,7 +147,11 @@ def to_graph
end
def to_s
return "component(%s)" % self.title
if self.title =~ /\[/
return self.title
else
return "component(%s)" % self.title
end
end
end
end
View
@@ -593,10 +593,6 @@ def run(command, check = false)
return output, status
end
def to_s
"exec(%s)" % self.name
end
def validatecmd(cmd)
# if we're not fully qualified, require a path
if cmd !~ /^\//
View
@@ -8,6 +8,10 @@ def get_posix_field(space, field, id)
end
prefix = "get" + space.to_s
if id.is_a?(Integer)
if id > 1000000
Puppet.err "Tried to get %s field for silly id %s" % [field, id]
return nil
end
method = (prefix + idfield(space).to_s).intern
else
method = (prefix + "nam").intern
@@ -967,6 +967,7 @@ def gennode(name, args)
end
end
mapper = mk_node_mapper
# Make sure it gives the right response
assert_equal("bpple\napple1 apple2 apple3\n",
%x{#{mapper} apple})
@@ -976,8 +977,6 @@ def gennode(name, args)
assert_nil(interp.nodesearch_external("apple"),
"Interp#nodesearch_external defaulted to a non-nil response")
}
mapper = mk_node_mapper
assert_nothing_raised { Puppet[:external_nodes] = mapper }
node = nil
View
@@ -339,6 +339,10 @@ def test_argadding
end
def test_usesection
# We want to make sure that config processes do not result in graphing.
Puppet[:graphdir] = tempfile()
Puppet[:graph] = true
Dir.mkdir(Puppet[:graphdir])
c = mkconfig
dir = tempfile()
@@ -365,6 +369,10 @@ def test_usesection
assert_nothing_raised("Could not reuse a section") {
c.use(section)
}
# Make sure it didn't graph anything, which is the only real way
# to test that the transaction was marked as a configurator.
assert(Dir.entries(Puppet[:graphdir]).reject { |f| f =~ /^\.\.?$/ }.empty?, "Graphed config process")
assert(FileTest.directory?(dir), "Did not create directory")
assert(FileTest.exists?(otherfile), "Did not create file")

0 comments on commit 704bd76

Please sign in to comment.