summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-17 16:15:33 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-17 16:15:33 +0000
commitd56870cff9fac4704de91dee9ef3138bf0a80ff4 (patch)
treeb153b1d34e2f8bf1290ff55a393821363725ca5f /test
parent0478f78b2291b9c54b4de9807fd0a0f216eaed53 (diff)
downloadpuppet-d56870cff9fac4704de91dee9ef3138bf0a80ff4.tar.gz
puppet-d56870cff9fac4704de91dee9ef3138bf0a80ff4.tar.xz
puppet-d56870cff9fac4704de91dee9ef3138bf0a80ff4.zip
Fixing a bunch of small bugs, mostly found by testing on solaris, and added a check to the test system that points out memory growth
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1113 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/puppetca.rb9
-rwxr-xr-xtest/language/snippets.rb2
-rw-r--r--test/other/transactions.rb14
-rw-r--r--test/puppettest.rb32
-rw-r--r--test/server/bucket.rb51
-rw-r--r--test/types/basic.rb4
-rwxr-xr-xtest/types/group.rb12
7 files changed, 71 insertions, 53 deletions
diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb
index a38296a54..8a232ab8d 100755
--- a/test/executables/puppetca.rb
+++ b/test/executables/puppetca.rb
@@ -25,7 +25,11 @@ class TestPuppetCA < Test::Unit::TestCase
end
def runca(args)
- return %x{puppetca --confdir=#{Puppet[:confdir]} #{args} 2>&1}
+ debug = ""
+ if Puppet[:debug]
+ debug = "-d "
+ end
+ return %x{puppetca --user=#{Puppet[:user]} #{debug} --group=#{Puppet[:group]} --confdir=#{Puppet[:confdir]} #{args} 2>&1}
end
@@ -68,6 +72,9 @@ class TestPuppetCA < Test::Unit::TestCase
signedfile = File.join(Puppet[:signeddir], "host.test.com.pem")
assert(FileTest.exists?(signedfile), "cert does not exist")
assert(! FileTest.executable?(signedfile), "cert is executable")
+
+ uid = Puppet::Util.uid(Puppet[:user])
+
if Process.uid == 0
assert(! FileTest.owned?(signedfile), "cert is owned by root")
end
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 84ca4d73c..536fab4fd 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -429,7 +429,7 @@ class TestSnippets < Test::Unit::TestCase
# There's no way to actually retrieve the list of classes from the
# transaction.
- def snippet_set(trans)
+ def snippet_tag(trans)
@@tmpfiles << "/tmp/settestingness"
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index c742b682c..34294e6d2 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -33,12 +33,6 @@ class TestTransactions < Test::Unit::TestCase
end
end
- def teardown
- stopservices
- #print "\n\n" if Puppet[:debug]
- super
- end
-
def newfile(hash = {})
tmpfile = tempfile()
File.open(tmpfile, "w") { |f| f.puts rand(100) }
@@ -60,7 +54,6 @@ class TestTransactions < Test::Unit::TestCase
File.chown(nil, firstgr, tmpfile)
end
- @@tmpfiles.push tmpfile
hash[:name] = tmpfile
assert_nothing_raised() {
return Puppet.type(:file).create(hash)
@@ -74,7 +67,7 @@ class TestTransactions < Test::Unit::TestCase
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
:hasstatus => true,
- :check => [:running]
+ :check => [:ensure]
)
}
end
@@ -147,7 +140,7 @@ class TestTransactions < Test::Unit::TestCase
component = newcomp("service",service)
assert_nothing_raised() {
- service[:running] = 1
+ service[:ensure] = 1
}
service.retrieve
assert(service.insync?, "Service did not start")
@@ -281,6 +274,7 @@ class TestTransactions < Test::Unit::TestCase
)
assert_apply(file, svc, exec)
- assert(FileTest.exists?(newfile), "File did not get created")
+ assert(FileTest.exists?(path), "File did not get created")
+ assert(FileTest.exists?(newfile), "Refresh file did not get created")
end
end
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 323da53e6..ffd6d34f1 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -24,6 +24,7 @@ module TestPuppet
end
def setup
+ @memoryatstart = Puppet::Util.memory
if defined? @@testcount
@@testcount += 1
else
@@ -99,7 +100,7 @@ module TestPuppet
def stopservices
if stype = Puppet::Type.type(:service)
stype.each { |service|
- service[:running] = false
+ service[:ensure] = :stopped
service.evaluate
}
end
@@ -131,6 +132,14 @@ module TestPuppet
Puppet::Storage.clear
Puppet.clear
+ @memoryatend = Puppet::Util.memory
+ diff = @memoryatend - @memoryatstart
+
+ if diff > 1000
+ Puppet.info "%s#%s memory growth (%s to %s): %s" %
+ [self.class, @method_name, @memoryatstart, @memoryatend, diff]
+ end
+
# reset all of the logs
Puppet::Log.close
@@ -145,23 +154,24 @@ module TestPuppet
end
def tempfile
- if defined? @tmpfilenum
- @tmpfilenum += 1
+ if defined? @@tmpfilenum
+ @@tmpfilenum += 1
else
- @tmpfilenum = 1
+ @@tmpfilenum = 1
end
- f = File.join(self.tmpdir(), self.class.to_s + "testfile" + @tmpfilenum.to_s)
+
+ f = File.join(self.tmpdir(), self.class.to_s + "testfile" + @@tmpfilenum.to_s)
@@tmpfiles << f
return f
end
def tstdir
- if defined? @testdirnum
- @testdirnum += 1
+ if defined? @@testdirnum
+ @@testdirnum += 1
else
- @testdirnum = 1
+ @@testdirnum = 1
end
- d = File.join(self.tmpdir(), self.class.to_s + "testdir" + @testdirnum.to_s)
+ d = File.join(self.tmpdir(), self.class.to_s + "testdir" + @@testdirnum.to_s)
@@tmpfiles << d
return d
end
@@ -306,6 +316,10 @@ module TestPuppet
def filemode(file)
File.stat(file).mode & 007777
end
+
+ def memory
+ Puppet::Util.memory
+ end
end
diff --git a/test/server/bucket.rb b/test/server/bucket.rb
index d4a2eee37..29d2b4369 100644
--- a/test/server/bucket.rb
+++ b/test/server/bucket.rb
@@ -14,25 +14,36 @@ require 'base64'
class TestBucket < Test::Unit::TestCase
include ServerTest
+
+ def out
+ if defined? @num
+ @num += 1
+ else
+ @num = 1
+ end
+
+ Puppet.err "#{Process.pid}: %s: %s" % [@num, memory()]
+ GC.start
+ end
# run through all of the files and exercise the filebucket methods
def checkfiles(client)
files = filelist()
+ #files = %w{/usr/local/bin/vim /etc/motd /etc/motd /etc/motd /etc/motd}
+ #files = %w{/usr/local/bin/vim}
# iterate across all of the files
files.each { |file|
- spin
+ Puppet.warning file
+ out
tempdir = tempfile()
Dir.mkdir(tempdir)
name = File.basename(file)
tmppath = File.join(tempdir,name)
@@tmpfiles << tmppath
+ out
# copy the files to our tmp directory so we can modify them...
- File.open(tmppath,File::WRONLY|File::TRUNC|File::CREAT) { |wf|
- File.open(file) { |rf|
- wf.print(rf.read)
- }
- }
+ FileUtils.cp(file, tmppath)
# make sure the copy worked
assert(FileTest.exists?(tmppath))
@@ -41,14 +52,15 @@ class TestBucket < Test::Unit::TestCase
osum = nil
tsum = nil
nsum = nil
- spin
+ out
assert_nothing_raised {
osum = client.backup(file)
}
- spin
+ out
assert_nothing_raised {
tsum = client.backup(tmppath)
}
+ out
# verify you got the same sum back for both
assert(tsum == osum)
@@ -57,30 +69,32 @@ class TestBucket < Test::Unit::TestCase
File.open(tmppath,File::WRONLY|File::TRUNC) { |wf|
wf.print "This is some test text\n"
}
+ out
# back it up
- spin
assert_nothing_raised {
#STDERR.puts("backing up %s" % tmppath) if $debug
nsum = client.backup(tmppath)
}
+ out
# and verify the sum changed
assert(tsum != nsum)
# restore the orig
- spin
assert_nothing_raised {
nsum = client.restore(tmppath,tsum)
}
+ out
# and verify it actually got restored
- spin
contents = File.open(tmppath) { |rf|
#STDERR.puts("reading %s" % tmppath) if $debug
rf.read
}
+ out
csum = Digest::MD5.hexdigest(contents)
+ out
assert(tsum == csum)
}
end
@@ -94,8 +108,9 @@ class TestBucket < Test::Unit::TestCase
@files = []
end
+ #who bash vim sh uname /etc/passwd /etc/syslog.conf /etc/hosts
%w{
- who bash vim sh uname /etc/passwd /etc/syslog.conf /etc/hosts
+ vim.ruby
}.each { |file|
# if it's fully qualified, just add it
if file =~ /^\//
@@ -127,6 +142,11 @@ class TestBucket < Test::Unit::TestCase
@@tmpfiles << @bucket
end
+ #def teardown
+ # system("lsof -p %s" % Process.pid)
+ # super
+ #end
+
# test operating against the local filebucket object
# this calls the direct server methods, which are different than the
# Dipper methods
@@ -141,7 +161,6 @@ class TestBucket < Test::Unit::TestCase
# iterate across them...
files.each { |file|
- spin
contents = File.open(file) { |of| of.read }
md5 = nil
@@ -170,10 +189,6 @@ class TestBucket < Test::Unit::TestCase
def test_localboth
files = filelist()
- tmpdir = File.join(tmpdir(),"tmpfiledir")
- @@tmpfiles << tmpdir
- FileUtils.mkdir_p(tmpdir)
-
bucket = nil
client = nil
threads = []
@@ -190,8 +205,8 @@ class TestBucket < Test::Unit::TestCase
)
}
+ #4.times { checkfiles(client) }
checkfiles(client)
-
end
# test that things work over the wire
diff --git a/test/types/basic.rb b/test/types/basic.rb
index 9b01f0447..1c41d37bc 100644
--- a/test/types/basic.rb
+++ b/test/types/basic.rb
@@ -41,7 +41,7 @@ class TestBasic < Test::Unit::TestCase
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
:hasstatus => true,
- :running => 1
+ :ensure => :running
)
}
assert_nothing_raised() {
@@ -95,7 +95,7 @@ class TestBasic < Test::Unit::TestCase
transaction.evaluate
}
assert_nothing_raised() {
- @sleeper[:running] = 0
+ @sleeper[:ensure] = :running
}
assert_nothing_raised() {
transaction = @component.evaluate
diff --git a/test/types/group.rb b/test/types/group.rb
index 372b35cb3..61edeb771 100755
--- a/test/types/group.rb
+++ b/test/types/group.rb
@@ -234,18 +234,6 @@ class TestGroup < Test::Unit::TestCase
assert_equal(Process.gid, user.is(:gid), "Retrieved UID does not match")
end
- def test_ensurevals
- gobj = nil
- assert_nothing_raised {
- gobj = Puppet.type(:group).create(
- :name => name,
- :ensure => :exists
- )
- }
-
- assert_equal(false, gobj.state(:ensure))
- end
-
if Process.uid == 0
def test_mkgroup
gobj = nil