From 0e336bf62b818aaa31fcc323ab5d31e5eb92eb46 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 5 Oct 2007 00:07:38 -0500 Subject: This commit is focused on getting the 'puppet' executable to work. As a result, it involves a lot of integration-level testing, and a lot of small design changes to make the code actually work. In particular, indirections can now have default termini, so that configurations and facts default to their code terminus Also, I've removed the ability to manually control whether ast nodes are used. I might need to add it back in later, but if so it will be in the form of a global setting, rather than the previous system of passing it through 10 different classes. Instead, the parser detects whether there are AST nodes defined and requires them if so or ignores them if not. About 75 tests are still failing in the main set of tests, but it's going to be a long slog to get them working -- there are significant design issues around them, as most of the failures are a result of tests trying to emulate both the client and server sides of a connection, which normally would have different fact termini but in this case must have the same terminus just because they're in the same process and are global. The next step, then, is to figure that process out, thus finding a way to make this all work. --- test/language/compile.rb | 14 +++++++------- test/language/snippets.rb | 45 +++++++++++---------------------------------- 2 files changed, 18 insertions(+), 41 deletions(-) (limited to 'test/language') diff --git a/test/language/compile.rb b/test/language/compile.rb index 5732acba3..7a8a613af 100755 --- a/test/language/compile.rb +++ b/test/language/compile.rb @@ -23,7 +23,7 @@ class TestCompile < Test::Unit::TestCase def mkparser # This should mock an interpreter - @parser = stub 'parser', :version => "1.0" + @parser = stub 'parser', :version => "1.0", :nodes => {} end def mkcompile(options = {}) @@ -38,7 +38,7 @@ class TestCompile < Test::Unit::TestCase def test_initialize compile = nil node = stub 'node', :name => "foo" - parser = stub 'parser', :version => "1.0" + parser = stub 'parser', :version => "1.0", :nodes => {} assert_nothing_raised("Could not init compile with all required options") do compile = Compile.new(node, parser) end @@ -51,7 +51,7 @@ class TestCompile < Test::Unit::TestCase # Now try it with some options assert_nothing_raised("Could not init compile with extra options") do - compile = Compile.new(node, parser, :ast_nodes => false) + compile = Compile.new(node, parser) end assert_equal(false, compile.ast_nodes?, "Did not set ast_nodes? correctly") @@ -188,7 +188,7 @@ class TestCompile < Test::Unit::TestCase # Make sure we either don't look for nodes, or that we find and evaluate the right object. def test_evaluate_ast_node # First try it with ast_nodes disabled - compile = mkcompile :ast_nodes => false + compile = mkcompile name = compile.node.name compile.expects(:ast_nodes?).returns(false) compile.parser.expects(:nodes).never @@ -201,7 +201,7 @@ class TestCompile < Test::Unit::TestCase # Now try it with them enabled, but no node found. nodes = mock 'node_hash' - compile = mkcompile :ast_nodes => true + compile = mkcompile name = compile.node.name compile.expects(:ast_nodes?).returns(true) compile.parser.stubs(:nodes).returns(nodes) @@ -221,7 +221,7 @@ class TestCompile < Test::Unit::TestCase end # Finally, make sure it works dandily when we have a node - compile = mkcompile :ast_nodes => true + compile = mkcompile compile.expects(:ast_nodes?).returns(true) node = stub 'node', :classname => "c" @@ -240,7 +240,7 @@ class TestCompile < Test::Unit::TestCase "Did not create node resource") # Lastly, check when we actually find the default. - compile = mkcompile :ast_nodes => true + compile = mkcompile compile.expects(:ast_nodes?).returns(true) node = stub 'node', :classname => "default" diff --git a/test/language/snippets.rb b/test/language/snippets.rb index 7168a81d8..cc3859552 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -449,45 +449,24 @@ class TestSnippets < Test::Unit::TestCase #eval("alias %s %s" % [testname, mname]) testname = ("test_" + mname).intern self.send(:define_method, testname) { + Puppet[:manifest] = snippet(file) facts = { "hostname" => "testhost", "domain" => "domain.com", "ipaddress" => "127.0.0.1", "fqdn" => "testhost.domain.com" } - Facter.stubs(:each) - facts.each do |name, value| - Facter.stubs(:value).with(name).returns(value) - end - # first parse the file - server = Puppet::Network::Handler.master.new( - :Manifest => snippet(file), - :Local => true - ) - facts = Puppet::Node::Facts.new("testhost", facts) - Puppet::Node::Facts.stubs(:save) - Puppet::Node::Facts.stubs(:find).returns(facts) - client = Puppet::Network::Client.master.new( - :Master => server, - :Cache => false - ) - client.class.stubs(:facts).returns(facts.values) - - assert(client.local) - assert_nothing_raised { - client.getconfig() - } - client = Puppet::Network::Client.master.new( - :Master => server, - :Cache => false - ) + node = Puppet::Node.new("testhost") + node.merge(facts) - assert(client.local) - # Now do it again - Puppet::Type.allclear - assert_nothing_raised { - client.getconfig() + config = nil + assert_nothing_raised("Could not compile configuration") { + config = Puppet::Node::Configuration.find(node) + } + + assert_nothing_raised("Could not convert configuration") { + config = config.extract_to_transportable.to_configuration } Puppet::Type.eachtype { |type| @@ -500,12 +479,10 @@ class TestSnippets < Test::Unit::TestCase assert(obj.name) } } - @configuration = client.configuration + @configuration = config assert_nothing_raised { self.send(mname) } - - client.clear } mname = mname.intern end -- cgit