diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-07 23:12:33 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-07 23:12:33 +0000 |
| commit | b98e65f1fd858a1d0af415554db49a121a76232c (patch) | |
| tree | 728f94dd17f88902c6bdf21ff6b17486babb08af /test | |
| parent | f1ffc34c0927840beeb21e1e2d864ce14de5d15e (diff) | |
| download | puppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.gz puppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.xz puppet-b98e65f1fd858a1d0af415554db49a121a76232c.zip | |
There is now full support for configuration files, and the entire system has been modified to expect their new behaviour. I have not yet run the test across all test hosts, though.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@873 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/certmgr/certmgr.rb | 1 | ||||
| -rwxr-xr-x | test/executables/puppetbin.rb | 4 | ||||
| -rwxr-xr-x | test/executables/puppetca.rb | 27 | ||||
| -rwxr-xr-x | test/executables/puppetd.rb | 9 | ||||
| -rwxr-xr-x | test/executables/puppetmasterd.rb | 4 | ||||
| -rwxr-xr-x | test/executables/puppetmodule.rb | 4 | ||||
| -rwxr-xr-x | test/other/config.rb | 86 | ||||
| -rw-r--r-- | test/other/log.rb | 15 | ||||
| -rwxr-xr-x | test/puppet/conffiles.rb | 8 | ||||
| -rwxr-xr-x | test/puppet/defaults.rb | 18 | ||||
| -rw-r--r-- | test/puppettest.rb | 24 | ||||
| -rw-r--r-- | test/server/bucket.rb | 2 | ||||
| -rw-r--r-- | test/server/logger.rb | 8 | ||||
| -rw-r--r-- | test/types/basic.rb | 2 | ||||
| -rwxr-xr-x | test/types/filesources.rb | 8 | ||||
| -rw-r--r-- | test/types/filetype.rb | 1 |
16 files changed, 145 insertions, 76 deletions
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb index d9f2c4812..8c88fe4d6 100755 --- a/test/certmgr/certmgr.rb +++ b/test/certmgr/certmgr.rb @@ -26,7 +26,6 @@ class TestCertMgr < Test::Unit::TestCase super #@dir = File.join(Puppet[:certdir], "testing") @dir = File.join(@configpath, "certest") - Puppet.notice @dir system("mkdir -p %s" % @dir) end diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb index 9fb4dbd11..39814769c 100755 --- a/test/executables/puppetbin.rb +++ b/test/executables/puppetbin.rb @@ -30,8 +30,8 @@ class TestPuppetBin < Test::Unit::TestCase cmd += " --debug" end #cmd += " --fqdn %s" % fqdn - cmd += " --confdir %s" % Puppet[:puppetconf] - cmd += " --vardir %s" % Puppet[:puppetvar] + cmd += " --confdir %s" % Puppet[:confdir] + cmd += " --vardir %s" % Puppet[:vardir] cmd += " --logdest %s" % "/dev/null" assert_nothing_raised { diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb index b69edb314..67df0a6b6 100755 --- a/test/executables/puppetca.rb +++ b/test/executables/puppetca.rb @@ -23,17 +23,20 @@ class TestPuppetCA < Test::Unit::TestCase return cert end + + def runca(args) + return %x{puppetca --confdir=#{Puppet[:confdir]} --user #{Process.uid} --group #{Process.gid} #{args} 2>&1} + + end def test_signing ca = nil - Puppet[:ssldir] = tempfile() - @@tmpfiles << Puppet[:ssldir] Puppet[:autosign] = false assert_nothing_raised { ca = Puppet::Server::CA.new() } - #Puppet.warning "SSLDir is %s" % Puppet[:ssldir] - #system("find %s" % Puppet[:ssldir]) + #Puppet.warning "SSLDir is %s" % Puppet[:confdir] + #system("find %s" % Puppet[:confdir]) cert = mkcert("host.test.com") resp = nil @@ -43,24 +46,24 @@ class TestPuppetCA < Test::Unit::TestCase resp = ca.getcert(cert.csr.to_pem, "fakename", "127.0.0.1") } assert_equal(["",""], resp) - #Puppet.warning "SSLDir is %s" % Puppet[:ssldir] - #system("find %s" % Puppet[:ssldir]) + #Puppet.warning "SSLDir is %s" % Puppet[:confdir] + #system("find %s" % Puppet[:confdir]) output = nil assert_nothing_raised { - output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]} 2>&1}.chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb + output = runca("--list").chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb } - #Puppet.warning "SSLDir is %s" % Puppet[:ssldir] - #system("find %s" % Puppet[:ssldir]) + #Puppet.warning "SSLDir is %s" % Puppet[:confdir] + #system("find %s" % Puppet[:confdir]) assert_equal($?,0) assert_equal(%w{host.test.com}, output) assert_nothing_raised { - output = %x{puppetca --sign -a --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n") + output = runca("--sign -a").chomp.split("\n") } assert_equal($?,0) - assert_equal([], output) + assert_equal(["Signed host.test.com"], output) assert_nothing_raised { - output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n") + output = runca("--list").chomp.split("\n") } assert_equal($?,0) assert_equal([], output) diff --git a/test/executables/puppetd.rb b/test/executables/puppetd.rb index 90733ed19..1ac53db16 100755 --- a/test/executables/puppetd.rb +++ b/test/executables/puppetd.rb @@ -27,15 +27,14 @@ class TestPuppetDExe < Test::Unit::TestCase cmd += " --verbose" cmd += " --onetime" #cmd += " --fqdn %s" % fqdn - cmd += " --port %s" % @@port - cmd += " --confdir %s" % Puppet[:puppetconf] - cmd += " --vardir %s" % Puppet[:puppetvar] + cmd += " --masterport %s" % @@port + cmd += " --confdir %s" % Puppet[:confdir] + cmd += " --vardir %s" % Puppet[:vardir] cmd += " --server localhost" # and verify our daemon runs assert_nothing_raised { - output = %x{#{cmd}}.chomp - puts output + system cmd } sleep 1 assert($? == 0, "Puppetd exited with code %s" % $?) diff --git a/test/executables/puppetmasterd.rb b/test/executables/puppetmasterd.rb index e1f48c11b..691e27070 100755 --- a/test/executables/puppetmasterd.rb +++ b/test/executables/puppetmasterd.rb @@ -27,7 +27,7 @@ class TestPuppetMasterD < Test::Unit::TestCase def test_normalstart startmasterd - pidfile = File.join(Puppet[:puppetvar], "run", "puppetmasterd.pid") + pidfile = File.join(Puppet[:vardir], "run", "puppetmasterd.pid") assert(FileTest.exists?(pidfile), "PID file does not exist") sleep(1) @@ -92,7 +92,7 @@ class TestPuppetMasterD < Test::Unit::TestCase pid = nil ps = Facter["ps"].value || "ps -ef" %x{#{ps}}.chomp.split(/\n/).each { |line| - if line =~ /puppetmasterd --manifest/ + if line =~ /puppetmasterd.+--manifest/ ary = line.split(" ") pid = ary[1].to_i end diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb index 56173c4b6..fcd85f42c 100755 --- a/test/executables/puppetmodule.rb +++ b/test/executables/puppetmodule.rb @@ -32,8 +32,8 @@ class TestPuppetModule < Test::Unit::TestCase cmd = $module cmd += " --verbose" #cmd += " --fqdn %s" % fqdn - cmd += " --confdir %s" % Puppet[:puppetconf] - cmd += " --vardir %s" % Puppet[:puppetvar] + cmd += " --confdir %s" % Puppet[:confdir] + cmd += " --vardir %s" % Puppet[:vardir] if Puppet[:debug] cmd += " --logdest %s" % "console" cmd += " --debug" diff --git a/test/other/config.rb b/test/other/config.rb index fba50e66e..60cb01ba7 100755 --- a/test/other/config.rb +++ b/test/other/config.rb @@ -78,7 +78,7 @@ class TestConfig < Test::Unit::TestCase c = mkconfig assert_nothing_raised { - c.setdefaults(:testing, [:booltest, "testing", true]) + c.setdefaults(:testing, [:booltest, true, "testing"]) } assert(c[:booltest]) @@ -181,8 +181,8 @@ yay = /a/path attr = value owner = puppet group = puppet - attr2 = /some/dir - attr3 = $attr2/other + attrdir = /some/dir + attr3 = $attrdir/other } file = tempfile() @@ -200,8 +200,8 @@ yay = /a/path assert_nothing_raised { c.setdefaults("section1", [:attr, "a", "one"], - [:attr2, "/another/dir", "two"], - [:attr3, "$attr2/maybe", "boo"] + [:attrdir, "/another/dir", "two"], + [:attr3, "$attrdir/maybe", "boo"] ) } @@ -210,8 +210,8 @@ yay = /a/path } assert_equal("value", c[:attr]) - assert_equal("/some/dir", c[:attr2]) - assert_equal(:directory, c.element(:attr2).type) + assert_equal("/some/dir", c[:attrdir]) + assert_equal(:directory, c.element(:attrdir).type) assert_equal("/some/dir/other", c[:attr3]) elem = nil @@ -239,6 +239,78 @@ yay = /a/path Puppet::Type.allclear check_to_transportable(c) end + + def test_arghandling + c = mkconfig + + assert_nothing_raised { + c.setdefaults("testing", + [:onboolean, true, "An on bool"], + [:offboolean, false, "An off bool"], + [:string, "a string", "A string arg"], + [:file, "/path/to/file", "A file arg"] + ) + } + + data = { + :onboolean => [true, false], + :offboolean => [true, false], + :string => ["one string", "another string"], + :file => %w{/a/file /another/file} + } + data.each { |param, values| + values.each { |val| + opt = nil + arg = nil + if c.boolean?(param) + if val + opt = "--%s" % param + else + opt = "--no-%s" % param + end + else + opt = "--%s" % param + arg = val + end + + assert_nothing_raised("Could not handle arg %s with value %s" % + [opt, val]) { + + c.handlearg(opt, arg) + } + } + } + end + + def test_argadding + c = mkconfig + + assert_nothing_raised { + c.setdefaults("testing", + [:onboolean, true, "An on bool"], + [:offboolean, false, "An off bool"], + [:string, "a string", "A string arg"], + [:file, "/path/to/file", "A file arg"] + ) + } + options = [] + + c.addargs(options) + + c.each { |param, obj| + opt = "--%s" % param + assert(options.find { |ary| + ary[0] == opt + }, "Argument %s was not added" % opt) + + if c.boolean?(param) + o = "--no-%s" % param + assert(options.find { |ary| + ary[0] == o + }, "Boolean off %s was not added" % o) + end + } + end end # $Id$ diff --git a/test/other/log.rb b/test/other/log.rb index 16f458193..ad13b15bf 100644 --- a/test/other/log.rb +++ b/test/other/log.rb @@ -44,8 +44,7 @@ class TestLog < Test::Unit::TestCase def test_logfile fact = nil levels = nil - oldlevel = Puppet[:loglevel] - Puppet[:loglevel] = :debug + Puppet::Log.level = :debug levels = getlevels logfile = tempfile() assert_nothing_raised() { @@ -61,7 +60,6 @@ class TestLog < Test::Unit::TestCase } } assert(count == levels.length) - Puppet[:loglevel] = oldlevel end def test_syslog @@ -80,7 +78,6 @@ class TestLog < Test::Unit::TestCase end def test_consolelog - Puppet[:debug] = true if __FILE__ == $0 fact = nil levels = getlevels assert_nothing_raised() { @@ -103,20 +100,18 @@ class TestLog < Test::Unit::TestCase end def test_output - olddebug = Puppet[:debug] - Puppet[:debug] = false + Puppet.debug = false assert(Puppet.err("This is an error").is_a?(Puppet::Log)) assert(Puppet.debug("This is debugging").nil?) - Puppet[:debug] = true + Puppet.debug = true assert(Puppet.err("This is an error").is_a?(Puppet::Log)) assert(Puppet.debug("This is debugging").is_a?(Puppet::Log)) - Puppet[:debug] = olddebug end def test_creatingdirs dir = tempfile() file = File.join(dir, "logfile") - Puppet[:logdest] = file + Puppet::Log.newdestination file Puppet.info "testing logs" assert(FileTest.directory?(dir)) assert(FileTest.file?(file)) @@ -149,7 +144,7 @@ class TestLog < Test::Unit::TestCase # Verify that we can pass strings that match printf args def test_percentlogs - Puppet[:logdest] = :syslog + Puppet::Log.newdestination :syslog assert_nothing_raised { Puppet::Log.new( diff --git a/test/puppet/conffiles.rb b/test/puppet/conffiles.rb index 49da5fa46..b63886488 100755 --- a/test/puppet/conffiles.rb +++ b/test/puppet/conffiles.rb @@ -76,11 +76,15 @@ class TestConfFiles < Test::Unit::TestCase path = tempfile() sampledata { |data| + config = Puppet::Config.new + data.each { |section, hash| + hash.each { |param, value| + config.setdefaults(section, [param, value, value]) + } + } # Write it out as a config file File.open(path, "w") { |f| f.print data2config(data) } - config = nil assert_nothing_raised { - config = Puppet::Config.new config.parse(path) } diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb index 2fbd4fe46..73759ca6b 100755 --- a/test/puppet/defaults.rb +++ b/test/puppet/defaults.rb @@ -12,8 +12,8 @@ require 'test/unit' class TestPuppetDefaults < Test::Unit::TestCase include TestPuppet - @@dirs = %w{rrddir puppetconf puppetvar logdir statedir} - @@files = %w{logfile statefile manifest masterlog} + @@dirs = %w{rrddir confdir vardir logdir statedir} + @@files = %w{statefile manifest masterlog} @@normals = %w{puppetport masterport server} @@booleans = %w{rrdgraph noop} @@ -43,8 +43,8 @@ class TestPuppetDefaults < Test::Unit::TestCase if __FILE__ == $0 def disabled_testContained - confdir = Regexp.new(Puppet[:puppetconf]) - vardir = Regexp.new(Puppet[:puppetvar]) + confdir = Regexp.new(Puppet[:confdir]) + vardir = Regexp.new(Puppet[:vardir]) [@@dirs,@@files].flatten.each { |param| value = Puppet[param] @@ -62,8 +62,8 @@ class TestPuppetDefaults < Test::Unit::TestCase end def testFailOnBogusArgs - [0, "ashoweklj", ";", :thisisafakesymbol].each { |param| - assert_raise(ArgumentError) { Puppet[param] } + [0, "ashoweklj", ";"].each { |param| + assert_raise(ArgumentError, "No error on %s" % param) { Puppet[param] } } end @@ -87,15 +87,15 @@ class TestPuppetDefaults < Test::Unit::TestCase def test_settingdefaults testvals = { - :fakeparam => [:puppetconf, "yaytest"], - :anotherparam => proc { File.join(Puppet[:puppetvar], "goodtest") }, + :fakeparam => "$confdir/yaytest", + :anotherparam => "$vardir/goodtest", :string => "a yay string", :boolean => true } testvals.each { |param, default| assert_nothing_raised { - Puppet.setdefault(param,default) + Puppet.setdefaults("testing", [param, default, "a value"]) } } end diff --git a/test/puppettest.rb b/test/puppettest.rb index 439e5b085..012279d4a 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -31,11 +31,11 @@ module TestPuppet end @configpath = File.join(tmpdir, - self.class.to_s + "configdir" + @@testcount.to_s + self.class.to_s + "configdir" + @@testcount.to_s + "/" ) - Puppet[:puppetconf] = @configpath - Puppet[:puppetvar] = @configpath + Puppet[:confdir] = @configpath + Puppet[:vardir] = @configpath unless File.exists?(@configpath) Dir.mkdir(@configpath) @@ -45,12 +45,12 @@ module TestPuppet @@tmppids = [] if $0 =~ /.+\.rb/ or Puppet[:debug] - Puppet[:logdest] = :console - Puppet[:loglevel] = :debug + Puppet::Log.newdestination :console + Puppet::Log.level = :debug $VERBOSE = 1 else Puppet::Log.close - Puppet[:logdest] = "/dev/null" + Puppet::Log.newdestination "/dev/null" Puppet[:httplog] = "/dev/null" end @@ -288,7 +288,7 @@ module ServerTest # create a simple manifest that just creates a file def mktestmanifest - file = File.join(Puppet[:puppetconf], "%ssite.pp" % (self.class.to_s + "test")) + file = File.join(Puppet[:confdir], "%ssite.pp" % (self.class.to_s + "test")) @createdfile = File.join(tmpdir(), self.class.to_s + "servermanifesttesting") File.open(file, "w") { |f| @@ -383,13 +383,13 @@ module ExeTest manifest = mktestmanifest() args += " --manifest %s" % manifest - args += " --confdir %s" % Puppet[:puppetconf] - args += " --vardir %s" % Puppet[:puppetvar] - args += " --port %s" % @@port + args += " --confdir %s" % Puppet[:confdir] + args += " --vardir %s" % Puppet[:vardir] + args += " --masterport %s" % @@port args += " --user %s" % Process.uid args += " --group %s" % Process.gid args += " --nonodes" - args += " --autosign" + args += " --autosign true" #if Puppet[:debug] # args += " --debug" @@ -411,7 +411,7 @@ module ExeTest def stopmasterd(running = true) ps = Facter["ps"].value || "ps -ef" - pidfile = File.join(Puppet[:puppetvar], "run", "puppetmasterd.pid") + pidfile = File.join(Puppet[:vardir], "run", "puppetmasterd.pid") pid = nil if FileTest.exists?(pidfile) diff --git a/test/server/bucket.rb b/test/server/bucket.rb index ac418484e..d4a2eee37 100644 --- a/test/server/bucket.rb +++ b/test/server/bucket.rb @@ -122,7 +122,7 @@ class TestBucket < Test::Unit::TestCase def setup super - @bucket = File.join(Puppet[:puppetconf], "buckettesting") + @bucket = File.join(Puppet[:confdir], "buckettesting") @@tmpfiles << @bucket end diff --git a/test/server/logger.rb b/test/server/logger.rb index 7872ed172..e0a03417e 100644 --- a/test/server/logger.rb +++ b/test/server/logger.rb @@ -16,7 +16,7 @@ class TestLogger < Test::Unit::TestCase def setup super #Puppet[:debug] = true - Puppet[:logdest] = :console + Puppet::Log.newdestination :console end # Test the log driver manually @@ -92,7 +92,7 @@ class TestLogger < Test::Unit::TestCase clientlog = tempfile() serverlog = tempfile() Puppet.warning "serverlog is %s" % serverlog - Puppet[:logdest] = clientlog + Puppet::Log.newdestination clientlog Puppet::Log.close(:syslog) # For testing @@ -113,7 +113,7 @@ class TestLogger < Test::Unit::TestCase # Start our server serverpid = fork { Puppet::Log.close(clientlog) - Puppet[:logdest] = serverlog + Puppet::Log.newdestination serverlog assert_nothing_raised() { trap(:INT) { logger.shutdown } logger.start @@ -152,7 +152,7 @@ class TestLogger < Test::Unit::TestCase # and now use the normal client action # Set the log destination to be the server - Puppet[:logdest] = "localhost:%s" % @@port + Puppet::Log.newdestination "localhost:%s" % @@port # And now do some logging assert_nothing_raised { diff --git a/test/types/basic.rb b/test/types/basic.rb index 082a8342f..9b01f0447 100644 --- a/test/types/basic.rb +++ b/test/types/basic.rb @@ -19,8 +19,6 @@ class TestBasic < Test::Unit::TestCase @configfile = nil @sleeper = nil - Puppet[:loglevel] = :debug if __FILE__ == $0 - assert_nothing_raised() { @component = Puppet.type(:component).create( :name => "yaytest", diff --git a/test/types/filesources.rb b/test/types/filesources.rb index 3d020d628..a3fb358a6 100755 --- a/test/types/filesources.rb +++ b/test/types/filesources.rb @@ -290,8 +290,8 @@ class TestFileSources < Test::Unit::TestCase end Dir.mkdir(basedir) - Puppet[:puppetconf] = basedir - Puppet[:puppetvar] = basedir + Puppet[:confdir] = basedir + Puppet[:vardir] = basedir Puppet[:autosign] = true tmpname = "yaytesting" @@ -368,8 +368,8 @@ class TestFileSources < Test::Unit::TestCase fileserverconf = mkfileserverconf(mounts) - Puppet[:puppetconf] = basedir - Puppet[:puppetvar] = basedir + Puppet[:confdir] = basedir + Puppet[:vardir] = basedir Puppet[:autosign] = true Puppet[:masterport] = 8762 diff --git a/test/types/filetype.rb b/test/types/filetype.rb index b3ebf15ff..7c5e4583c 100644 --- a/test/types/filetype.rb +++ b/test/types/filetype.rb @@ -12,7 +12,6 @@ require 'test/unit' #class TestFileType < Test::Unit::TestCase class TestFileType def disabled_setup - Puppet[:loglevel] = :debug if __FILE__ == $0 @passwdtype = Puppet.type(:filetype)["passwd"] if @passwdtype.nil? |
