diff options
| author | Luke Kanies <luke@madstop.com> | 2007-10-08 19:12:39 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-10-08 19:12:39 -0500 |
| commit | d24c1ccc56b912e0ff69f7572dd36912c8c739c2 (patch) | |
| tree | f86a02ae5845f1b7cb8327247356268a70e0948e /test/network | |
| parent | fc9c850414baff17dc97b0184f34e58b4bec5785 (diff) | |
| download | puppet-d24c1ccc56b912e0ff69f7572dd36912c8c739c2.tar.gz puppet-d24c1ccc56b912e0ff69f7572dd36912c8c739c2.tar.xz puppet-d24c1ccc56b912e0ff69f7572dd36912c8c739c2.zip | |
All tests should now pass again.
This is the first real pass towards using caching. The `puppet`
executable actually uses the indirection work, instead of
handlers and such (and man! is it cleaner).
Most of this work was a result of trying to get the client-side
story working, with correct yaml caching of configurations, which
means this commit also covers converting configurations to yaml,
which was a much bigger PITA than it needed to be.
I still need to write integration tests, and I also need to cover
the server-side story of a normal configuration retrieval.
Diffstat (limited to 'test/network')
| -rwxr-xr-x | test/network/client/client.rb | 2 | ||||
| -rwxr-xr-x | test/network/client/master.rb | 8 | ||||
| -rwxr-xr-x | test/network/handler/configuration.rb | 27 | ||||
| -rwxr-xr-x | test/network/handler/master.rb | 3 |
4 files changed, 17 insertions, 23 deletions
diff --git a/test/network/client/client.rb b/test/network/client/client.rb index e08da357c..a297a87e1 100755 --- a/test/network/client/client.rb +++ b/test/network/client/client.rb @@ -143,6 +143,8 @@ class TestClient < Test::Unit::TestCase def test_classfile Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest" + Puppet::Node::Facts.indirection.stubs(:save) + master = client = nil assert_nothing_raised() { master = Puppet::Network::Handler.master.new( diff --git a/test/network/client/master.rb b/test/network/client/master.rb index aaa38b223..4ae77abc2 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -397,6 +397,8 @@ end manifest = tempfile() File.open(manifest, "w") { |f| f.puts "file { '#{file}': content => yay }" } + Puppet::Node::Facts.indirection.stubs(:save) + driver = mkmaster(:Manifest => manifest) driver.local = false master = mkclient(driver) @@ -406,7 +408,7 @@ end assert(! master.fresh?(master.class.facts), "Considered fresh with no compile at all") - + assert_nothing_raised { master.run } assert(master.fresh?(master.class.facts), "not considered fresh after compile") @@ -481,7 +483,9 @@ end master.local = false driver = master.send(:instance_variable_get, "@driver") driver.local = false + Puppet::Node::Facts.indirection.stubs(:save) # Retrieve the configuration + master.getconfig # Now the config is up to date, so get rid of the @objects var and @@ -509,6 +513,8 @@ end driver = master.send(:instance_variable_get, "@driver") driver.local = false + Puppet::Node::Facts.indirection.stubs(:save) + assert_nothing_raised("Could not compile config") do master.getconfig end diff --git a/test/network/handler/configuration.rb b/test/network/handler/configuration.rb index 29a393769..1c08fd196 100755 --- a/test/network/handler/configuration.rb +++ b/test/network/handler/configuration.rb @@ -25,9 +25,7 @@ class TestHandlerConfiguration < Test::Unit::TestCase config = Config.new # First test the defaults - args = {} - config.instance_variable_set("@options", args) - config.expects(:create_interpreter).with(args).returns(:interp) + config.expects(:create_interpreter).returns(:interp) assert_equal(:interp, config.send(:interpreter), "Did not return the interpreter") # Now run it again and make sure we get the same thing @@ -39,20 +37,8 @@ class TestHandlerConfiguration < Test::Unit::TestCase args = {} # Try it first with defaults. - Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?).returns(:interp) - assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter") - - # Now reset it and make sure a specified manifest passes through - file = tempfile - args[:Manifest] = file - Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?, :Manifest => file).returns(:interp) - assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter") - - # And make sure the code does, too - args.delete(:Manifest) - args[:Code] = "yay" - Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?, :Code => "yay").returns(:interp) - assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter") + Puppet::Parser::Interpreter.expects(:new).returns(:interp) + assert_equal(:interp, config.send(:create_interpreter), "Did not return the interpreter") end # Make sure node objects get appropriate data added to them. @@ -67,7 +53,7 @@ class TestHandlerConfiguration < Test::Unit::TestCase config.send(:add_node_data, fakenode) # Now try it with classes. - config.instance_variable_set("@options", {:Classes => %w{a b}}) + config.classes = %w{a b} list = [] fakenode = Object.new fakenode.expects(:merge).with(:facts) @@ -126,8 +112,9 @@ class TestHandlerConfiguration < Test::Unit::TestCase # Now a non-local config = Config.new(:Local => false) - obj = Object.new - yamld = Object.new + assert(! config.local?, "Config wrongly thinks it's local") + obj = mock 'dumpee' + yamld = mock 'yaml' obj.expects(:to_yaml).with(:UseBlock => true).returns(yamld) CGI.expects(:escape).with(yamld).returns(:translated) assert_equal(:translated, config.send(:translate, obj), "Did not return translated config") diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 42c4d22c9..6c4451d06 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -56,11 +56,10 @@ class TestMaster < Test::Unit::TestCase @@tmpfiles << file2 client = master = nil + Puppet[:manifest] = manifest assert_nothing_raised() { # this is the default server setup master = Puppet::Network::Handler.master.new( - :Manifest => manifest, - :UseNodes => false, :Local => true ) } |
