diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-09 17:41:36 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-09 17:41:36 +0000 |
| commit | 133c17fa6665256cafdcd1cf76d2ae50233c44f4 (patch) | |
| tree | 1288ceef2c13826fea395a518cdb4fc806ca8ad6 /test | |
| parent | c3cc16274d2a2cc0b394bb7ec7fbb8b45491abcc (diff) | |
| download | puppet-133c17fa6665256cafdcd1cf76d2ae50233c44f4.tar.gz puppet-133c17fa6665256cafdcd1cf76d2ae50233c44f4.tar.xz puppet-133c17fa6665256cafdcd1cf76d2ae50233c44f4.zip | |
Fixing #305 -- logs now reopen when Puppet restarts, and there is also now an autoflush mechanism available so logs will flush to disk immediately. I also now trap USR2 and reopen logs when it is sent, so if you just want to reopen logs you do not have to restart the whole process.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1750 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rw-r--r-- | test/other/log.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/other/log.rb b/test/other/log.rb index cb049b30d..36b1e163f 100644 --- a/test/other/log.rb +++ b/test/other/log.rb @@ -232,4 +232,49 @@ class TestLog < Test::Unit::TestCase assert(dest.match("Yayness"), "Did not match yayness") Puppet::Log.close(dest) end + + def test_autoflush + file = tempfile + Puppet::Log.newdestination(file) + Puppet.info "A test" + assert(File.read(file) !~ /A test/, + "File defualted to autoflush") + Puppet::Log.flush + assert(File.read(file) =~ /A test/, + "File did not flush") + Puppet::Log.close(file) + + # Now try one with autoflush enabled + Puppet[:autoflush] = true + file = tempfile + Puppet::Log.newdestination(file) + Puppet.info "A test" + assert(File.read(file) =~ /A test/, + "File did not autoflush") + Puppet::Log.close(file) + end + + def test_reopen + Puppet[:autoflush] = true + file = tempfile + Puppet::Log.newdestination(file) + Puppet.info "A test" + assert(File.read(file) =~ /A test/, + "File did not flush") + # Rename the file + newfile = file + ".old" + File.rename(file, newfile) + + # Send another log + Puppet.info "Another test" + assert(File.read(newfile) =~ /Another test/, + "File did not rename") + + # Now reopen the log + Puppet::Log.reopen + Puppet.info "Reopen test" + assert(File.read(file) =~ /Reopen test/, + "File did not reopen") + Puppet::Log.close(file) + end end |
