diff options
| author | Luke Kanies <luke@madstop.com> | 2007-10-05 00:07:38 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-10-05 00:07:38 -0500 |
| commit | 0e336bf62b818aaa31fcc323ab5d31e5eb92eb46 (patch) | |
| tree | 2f29d3e668aad2cade6059c74cbba60d60873561 /test | |
| parent | 1fa591287a4ab921cec628aa0c5bf58d61fbdef2 (diff) | |
| download | puppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.tar.gz puppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.tar.xz puppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.zip | |
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.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/compile.rb | 14 | ||||
| -rwxr-xr-x | test/language/snippets.rb | 45 | ||||
| -rwxr-xr-x | test/rails/configuration.rb | 1 |
3 files changed, 18 insertions, 42 deletions
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 diff --git a/test/rails/configuration.rb b/test/rails/configuration.rb index 752ea5375..07665d576 100755 --- a/test/rails/configuration.rb +++ b/test/rails/configuration.rb @@ -25,7 +25,6 @@ class ConfigurationRailsTests < PuppetTest::TestCase def test_finish_before_store railsinit compile = mkcompile - compile.ast_nodes = true parser = compile.parser node = parser.newnode [compile.node.name], :code => AST::ASTArray.new(:children => [ |
