summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-17 07:11:50 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-17 07:11:50 +0000
commit3700b37e2386e7dbaabd90b7ba13c3dce06203d2 (patch)
tree28a691598edd5e56332c0d8e254263fb4fe8a9f4 /test
parent92a780a3106f863e442c12897184abbe39fe3310 (diff)
downloadpuppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.tar.gz
puppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.tar.xz
puppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.zip
Adding an "ensure" state where appropriate, and significantly reworking the builtin docs.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@832 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/puppetmodule.rb2
-rwxr-xr-xtest/language/interpreter.rb2
-rwxr-xr-xtest/other/events.rb6
-rw-r--r--test/other/log.rb2
-rwxr-xr-xtest/other/storage.rb10
-rw-r--r--test/other/transactions.rb10
-rw-r--r--test/parser/parser.rb2
-rw-r--r--test/puppettest.rb2
-rw-r--r--test/server/master.rb2
-rw-r--r--test/types/basic.rb2
-rwxr-xr-xtest/types/exec.rb4
-rw-r--r--test/types/file.rb69
-rwxr-xr-xtest/types/filesources.rb2
-rw-r--r--test/types/package.rb3
-rw-r--r--test/types/type.rb6
15 files changed, 81 insertions, 43 deletions
diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb
index c0020779d..56173c4b6 100755
--- a/test/executables/puppetmodule.rb
+++ b/test/executables/puppetmodule.rb
@@ -25,7 +25,7 @@ class TestPuppetModule < Test::Unit::TestCase
createdfile = tempfile()
File.open(file, "w") { |f|
- f.puts "class yaytest { file { \"#{createdfile}\": create => true } }"
+ f.puts "class yaytest { file { \"#{createdfile}\": ensure => file } }"
}
output = nil
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb
index 9dbf8dc99..a9d448a67 100755
--- a/test/language/interpreter.rb
+++ b/test/language/interpreter.rb
@@ -22,7 +22,7 @@ class TestInterpreter < Test::Unit::TestCase
createdfile = tempfile()
File.open(file, "w") { |f|
- f.puts "node %s { file { \"%s\": create => true, mode => 755 } }\n" %
+ f.puts "node %s { file { \"%s\": ensure => file, mode => 755 } }\n" %
[node, createdfile]
}
diff --git a/test/other/events.rb b/test/other/events.rb
index f57fd3272..be319724c 100755
--- a/test/other/events.rb
+++ b/test/other/events.rb
@@ -21,7 +21,7 @@ class TestEvents < Test::Unit::TestCase
name = tempfile()
file = Puppet.type(:file).create(
:name => name,
- :create => true
+ :ensure => "file"
)
exec = Puppet.type(:exec).create(
:name => "echo true",
@@ -41,7 +41,7 @@ class TestEvents < Test::Unit::TestCase
name = tempfile()
file = Puppet.type(:file).create(
:name => name,
- :create => true
+ :ensure => "file"
)
exec = Puppet.type(:exec).create(
:name => "echo true",
@@ -76,7 +76,7 @@ class TestEvents < Test::Unit::TestCase
name = tempfile() + l.to_s
objects[l] = Puppet.type(:file).create(
:name => name,
- :create => true
+ :ensure => "file"
)
@@tmpfiles << name
when :b
diff --git a/test/other/log.rb b/test/other/log.rb
index 0bc2656ea..16f458193 100644
--- a/test/other/log.rb
+++ b/test/other/log.rb
@@ -182,7 +182,7 @@ class TestLog < Test::Unit::TestCase
path = tempfile()
file = Puppet.type(:file).create(
:path => path,
- :create => true
+ :ensure => "file"
)
assert_nothing_raised {
diff --git a/test/other/storage.rb b/test/other/storage.rb
index 0a52196d6..64f08cdc7 100755
--- a/test/other/storage.rb
+++ b/test/other/storage.rb
@@ -62,6 +62,16 @@ class TestParsedFile < Test::Unit::TestCase
}
threads.each { |th| th.join }
end
+
+ def test_emptyrestore
+ Puppet::Storage.load
+ Puppet::Storage.store
+ Puppet::Storage.clear
+ Puppet::Storage.load
+ state = Puppet::Storage.state('newstate')
+ assert_same Hash, state.class
+ assert_equal 0, state.size
+ end
end
# $Id$
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 5a00fbe09..ed6843104 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -123,9 +123,9 @@ class TestTransactions < Test::Unit::TestCase
file[:mode] = "755"
}
- trans = assert_events([:inode_changed, :inode_changed], component)
+ trans = assert_events([:file_changed, :file_changed], component)
- assert_rollback_events(trans, [:inode_changed, :inode_changed], "file")
+ assert_rollback_events(trans, [:file_changed, :file_changed], "file")
assert_nothing_raised() {
file.retrieve
@@ -188,7 +188,7 @@ class TestTransactions < Test::Unit::TestCase
file[:mode] = "755"
}
- trans = assert_events( [:inode_changed], component)
+ trans = assert_events( [:file_changed], component)
assert(FileTest.exists?(execfile), "Execfile does not exist")
File.unlink(execfile)
@@ -196,7 +196,7 @@ class TestTransactions < Test::Unit::TestCase
file[:group] = @groups[1]
}
- trans = assert_events([:inode_changed], component)
+ trans = assert_events([:file_changed], component)
assert(FileTest.exists?(execfile), "Execfile does not exist")
end
@@ -227,7 +227,7 @@ class TestTransactions < Test::Unit::TestCase
file[:mode] = "755"
}
- trans = assert_events([:inode_changed, :inode_changed], component)
+ trans = assert_events([:file_changed, :file_changed], component)
end
diff --git a/test/parser/parser.rb b/test/parser/parser.rb
index 4752ce35e..68209a0d2 100644
--- a/test/parser/parser.rb
+++ b/test/parser/parser.rb
@@ -66,7 +66,7 @@ class TestParser < Test::Unit::TestCase
@@tmpfiles << name
File.open(file, "w") { |f|
- f.puts "file { \"%s\": create => true, mode => 755 }\n" %
+ f.puts "file { \"%s\": ensure => file, mode => 755 }\n" %
name
}
end
diff --git a/test/puppettest.rb b/test/puppettest.rb
index fd966f930..34d48ff52 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -289,7 +289,7 @@ module ServerTest
@createdfile = File.join(tmpdir(), self.class.to_s + "servermanifesttesting")
File.open(file, "w") { |f|
- f.puts "file { \"%s\": create => true, mode => 755 }\n" % @createdfile
+ f.puts "file { \"%s\": ensure => file, mode => 755 }\n" % @createdfile
}
@@tmpfiles << @createdfile
diff --git a/test/server/master.rb b/test/server/master.rb
index 3ccd176f8..a300a18a4 100644
--- a/test/server/master.rb
+++ b/test/server/master.rb
@@ -134,7 +134,7 @@ class TestMaster < Test::Unit::TestCase
Puppet::Type.allclear
File.open(manifest, "w") { |f|
- f.puts "file { \"%s\": create => true }\n" % file2
+ f.puts "file { \"%s\": ensure => file }\n" % file2
}
assert_nothing_raised {
client.getconfig
diff --git a/test/types/basic.rb b/test/types/basic.rb
index edc6bc66d..082a8342f 100644
--- a/test/types/basic.rb
+++ b/test/types/basic.rb
@@ -33,7 +33,7 @@ class TestBasic < Test::Unit::TestCase
@@tmpfiles << @filepath
@configfile = Puppet.type(:file).create(
:path => @filepath,
- :create => true,
+ :ensure => "file",
:checksum => "md5"
)
}
diff --git a/test/types/exec.rb b/test/types/exec.rb
index 370fe380f..7ecf8a26d 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -171,7 +171,7 @@ class TestExec < Test::Unit::TestCase
# verify that only the file_changed event was kicked off, not the
# command_executed
assert_equal(
- [:file_modified],
+ [:file_changed],
events
)
end
@@ -213,7 +213,7 @@ class TestExec < Test::Unit::TestCase
comp = newcomp("Testing", file, exec)
- assert_events([:file_changed, :executed_command], comp)
+ assert_events([:file_created, :executed_command], comp)
end
# Verify that we auto-require any managed scripts.
diff --git a/test/types/file.rb b/test/types/file.rb
index 65d1560cd..b9e85839e 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -124,7 +124,7 @@ class TestFile < Test::Unit::TestCase
file = Puppet.type(:file).create(
:path => path,
:owner => user.name,
- :create => true,
+ :ensure => "file",
:mode => "755"
)
}
@@ -221,7 +221,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised() {
file = Puppet.type(:file).create(
:name => path,
- :create => true
+ :ensure => "file"
)
}
assert_events([:file_created], file)
@@ -240,7 +240,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised() {
file = Puppet.type(:file).create(
:name => path,
- :create => "directory"
+ :ensure => "directory"
)
}
assert(! FileTest.directory?(path), "Directory %s already exists" %
@@ -261,7 +261,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised() {
file[:mode] = mode
}
- assert_events([:inode_changed], file)
+ assert_events([:file_changed], file)
assert_events([], file)
assert(file.insync?())
@@ -283,15 +283,13 @@ class TestFile < Test::Unit::TestCase
# try it both with files that exist and ones that don't
files = [exists, nonexists]
initstorage
- File.open(exists,"w") { |of|
- 10.times {
- of.puts rand(100)
- }
+ File.open(exists,File::CREAT|File::TRUNC|File::WRONLY) { |of|
+ of.puts "initial text"
}
types.each { |type|
files.each { |path|
if Puppet[:debug]
- Puppet.info "Testing %s on %s" % [type,path]
+ Puppet.warning "Testing %s on %s" % [type,path]
end
file = nil
events = nil
@@ -299,12 +297,12 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised() {
file = Puppet.type(:file).create(
:name => path,
- :create => true,
+ :ensure => "file",
:checksum => type
)
}
comp = Puppet.type(:component).create(
- :name => "componentfile"
+ :name => "checksum %s" % type
)
comp.push file
trans = nil
@@ -324,16 +322,19 @@ class TestFile < Test::Unit::TestCase
# we don't want to kick off an event the first time we
# come across a file
assert(
- ! events.include?(:file_modified)
+ ! events.include?(:file_changed)
)
assert_nothing_raised() {
- File.open(path,"w") { |of|
- of.puts rand(100)
+ File.open(path,File::CREAT|File::TRUNC|File::WRONLY) { |of|
+ of.puts "some more text, yo"
}
}
Puppet.type(:file).clear
Puppet.type(:component).clear
- sleep 1
+
+ # We have to sleep because the time resolution of the time-based
+ # mechanisms is greater than one second
+ sleep 1.1
# now recreate the file
assert_nothing_raised() {
@@ -343,17 +344,41 @@ class TestFile < Test::Unit::TestCase
)
}
comp = Puppet.type(:component).create(
- :name => "componentfile"
+ :name => "checksum, take 2, %s" % type
)
comp.push file
trans = nil
- assert_events([:file_modified], comp)
+
+ # If the file was missing, it should not generate an event
+ # when it gets created.
+ if path =~ /nonexists/e
+ assert_events([], comp)
+ else
+ assert_events([:file_changed], comp)
+ end
+ assert_nothing_raised() {
+ File.unlink(path)
+ File.open(path,File::CREAT|File::TRUNC|File::WRONLY) { |of|
+ # We have to put a certain amount of text in here or
+ # the md5-lite test fails
+ 2.times {
+ of.puts rand(100)
+ }
+ of.flush
+ }
+ }
+ #assert_apply(comp)
+ assert_events([:file_changed], comp)
# verify that we're actually getting notified when a file changes
assert_nothing_raised() {
Puppet.type(:file).clear
Puppet.type(:component).clear
}
+
+ if path =~ /nonexists/
+ File.unlink(path)
+ end
}
}
end
@@ -444,7 +469,7 @@ class TestFile < Test::Unit::TestCase
file = mkfile(
:name => path,
:recurse => true,
- :create => true
+ :ensure => "file"
)
}
@@ -483,7 +508,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised {
file = Puppet.type(:file).create(
:name => tempfile(),
- :create => true
+ :ensure => "file"
)
}
@@ -577,12 +602,12 @@ class TestFile < Test::Unit::TestCase
baseobj = Puppet.type(:file).create(
:name => basedir,
- :create => "directory"
+ :ensure => "directory"
)
subobj = Puppet.type(:file).create(
:name => subfile,
- :create => "file"
+ :ensure => "file"
)
Puppet::Type.finalize
@@ -640,7 +665,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised {
file = Puppet.type(:file).create(
:name => subpath,
- :create => "directory",
+ :ensure => "directory",
:recurse => true
)
}
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index 5ae728c81..ba401b446 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -565,7 +565,7 @@ class TestFileSources < Test::Unit::TestCase
}
comp = newcomp(file)
- assert_events([:file_changed], comp)
+ assert_events([:file_created], comp)
assert(File.exists?(to), "File does not exist")
diff --git a/test/types/package.rb b/test/types/package.rb
index 1723f973d..36da3c0cd 100644
--- a/test/types/package.rb
+++ b/test/types/package.rb
@@ -167,6 +167,7 @@ class TestPackages < Test::Unit::TestCase
comp = newcomp("package", pkg)
+ Puppet.err :mark
assert_events([:package_created], comp, "package")
# then uninstall it
@@ -177,6 +178,8 @@ class TestPackages < Test::Unit::TestCase
pkg.retrieve
+ p pkg
+
assert(! pkg.insync?, "Package is in sync")
assert_events([:package_removed], comp, "package")
diff --git a/test/types/type.rb b/test/types/type.rb
index 5426ec669..7d087b30b 100644
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -59,7 +59,7 @@ class TestType < Test::Unit::TestCase
system("rm -f %s" % path)
file = Puppet.type(:file).create(
:path => path,
- :create => true,
+ :ensure => "file",
:recurse => true,
:checksum => "md5"
)
@@ -75,7 +75,7 @@ class TestType < Test::Unit::TestCase
system("rm -f %s" % path)
file = Puppet.type(:file).create(
"path" => path,
- "create" => true,
+ "ensure" => "file",
"recurse" => true,
"checksum" => "md5"
)
@@ -144,7 +144,7 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised {
baseobj = Puppet.type(:file).create(
:name => file,
- :create => true,
+ :ensure => "file",
:alias => ["funtest"]
)
}