From d812840a89092ccd04c2ad81a3bd80a6cc2f7882 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 20 Jun 2006 18:31:54 +0000 Subject: Fixing #182. Added a retry section to try reconnecting to ldap. Only one reconnect is attempted in a given search, and LDAP produces bad enough error messages that we reconnect regardless of the error thrown. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1305 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/language/interpreter.rb | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test') diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 4ce35d48e..8dc3f0b83 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -18,6 +18,7 @@ require 'puppettest' class TestInterpreter < Test::Unit::TestCase include TestPuppet + include ServerTest AST = Puppet::Parser::AST # create a simple manifest that uses nodes to create a file @@ -207,6 +208,48 @@ class TestInterpreter < Test::Unit::TestCase assert(FileTest.exists?(cfile), "Did not make %s" % cfile) } end + + if Process.uid == 0 and Facter["hostname"].value == "culain" + def test_ldapreconnect + Puppet[:ldapbase] = "ou=hosts, dc=madstop, dc=com" + Puppet[:ldapnodes] = true + + interp = nil + assert_nothing_raised { + interp = Puppet::Parser::Interpreter.new( + :Manifest => mktestmanifest() + ) + } + hostname = "culain.madstop.com" + + # look for our host + assert_nothing_raised { + parent, classes = interp.nodesearch_ldap(hostname) + } + + # Now restart ldap + system("/etc/init.d/slapd restart 2>/dev/null >/dev/null") + sleep(1) + + # and look again + assert_nothing_raised { + parent, classes = interp.nodesearch_ldap(hostname) + } + + # Now stop ldap + system("/etc/init.d/slapd stop 2>/dev/null >/dev/null") + cleanup do + system("/etc/init.d/slapd start 2>/dev/null >/dev/null") + end + + # And make sure we actually fail here + assert_raise(Puppet::Error) { + parent, classes = interp.nodesearch_ldap(hostname) + } + end + else + $stderr.puts "Run as root for ldap reconnect tests" + end end else $stderr.puts "Not in madstop.com; skipping ldap tests" -- cgit