summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-07 23:33:38 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-07 23:33:38 +0000
commit23f982ecda3fd74867d404b5e784f072db9a1cde (patch)
tree18a122eec695455c794caa554012fe1ee721ffa6 /test
parent1d739731b20a5dd10a190d783556d5c5a0275137 (diff)
downloadpuppet-23f982ecda3fd74867d404b5e784f072db9a1cde.tar.gz
puppet-23f982ecda3fd74867d404b5e784f072db9a1cde.tar.xz
puppet-23f982ecda3fd74867d404b5e784f072db9a1cde.zip
Undoing the merge that happened in 785
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@786 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/puppetbin.rb4
-rwxr-xr-xtest/executables/puppetmodule.rb7
-rwxr-xr-xtest/language/snippets.rb4
-rwxr-xr-xtest/other/events.rb18
-rw-r--r--test/other/log.rb11
-rw-r--r--test/other/metrics.rb2
-rwxr-xr-xtest/other/overrides.rb8
-rwxr-xr-xtest/other/relationships.rb2
-rw-r--r--test/other/state.rb2
-rw-r--r--test/other/transactions.rb35
-rw-r--r--test/puppettest.rb64
-rwxr-xr-xtest/server/fileserver.rb2
-rw-r--r--test/server/logger.rb12
-rw-r--r--test/types/basic.rb6
-rwxr-xr-xtest/types/component.rb26
-rwxr-xr-xtest/types/cron.rb52
-rwxr-xr-xtest/types/exec.rb44
-rw-r--r--test/types/file.rb159
-rwxr-xr-xtest/types/filebucket.rb11
-rw-r--r--test/types/fileignoresource.rb12
-rwxr-xr-xtest/types/filesources.rb27
-rw-r--r--test/types/filetype.rb12
-rwxr-xr-xtest/types/group.rb20
-rw-r--r--test/types/package.rb24
-rw-r--r--test/types/query.rb14
-rw-r--r--test/types/service.rb47
-rwxr-xr-xtest/types/symlink.rb6
-rwxr-xr-xtest/types/tidy.rb4
-rw-r--r--test/types/type.rb16
-rwxr-xr-xtest/types/user.rb38
30 files changed, 325 insertions, 364 deletions
diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb
index f16ccbbf2..d075d8431 100755
--- a/test/executables/puppetbin.rb
+++ b/test/executables/puppetbin.rb
@@ -35,9 +35,7 @@ class TestPuppetBin < Test::Unit::TestCase
output = nil
cmd = "puppet"
- if Puppet[:debug]
- cmd += " --debug"
- end
+ cmd += " --verbose"
#cmd += " --fqdn %s" % fqdn
cmd += " --confdir %s" % Puppet[:puppetconf]
cmd += " --vardir %s" % Puppet[:puppetvar]
diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb
index 429e29e36..2e97a963a 100755
--- a/test/executables/puppetmodule.rb
+++ b/test/executables/puppetmodule.rb
@@ -19,15 +19,11 @@ libdirs = $:.find_all { |dir|
}
ENV["RUBYLIB"] = libdirs.join(":")
-$module = File.join($puppetbase, "ext", "module_puppet")
+$module = File.join($puppetbase, "ext", "module:puppet")
class TestPuppetModule < Test::Unit::TestCase
include ServerTest
- def test_existence
- assert(FileTest.exists?($module), "Module does not exist")
- end
-
def test_execution
file = tempfile()
@@ -45,7 +41,6 @@ class TestPuppetModule < Test::Unit::TestCase
cmd += " --vardir %s" % Puppet[:puppetvar]
if Puppet[:debug]
cmd += " --logdest %s" % "console"
- cmd += " --debug"
else
cmd += " --logdest %s" % "/dev/null"
end
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index a213d554f..f7cf21548 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -159,7 +159,7 @@ class TestSnippets < Test::Unit::TestCase
%w{a b c d}.each { |letter|
file = "/tmp/create%stest" % letter
Puppet.info "testing %s" % file
- assert(Puppet.type(:file)[file], "File %s does not exist" % file)
+ assert(Puppet::Type::PFile[file], "File %s does not exist" % file)
assert(FileTest.exists?(file))
@@tmpfiles << file
}
@@ -217,7 +217,7 @@ class TestSnippets < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
- obj = Puppet.type(:file)[file]
+ obj = Puppet::Type::PFile[file]
}
assert_nothing_raised {
diff --git a/test/other/events.rb b/test/other/events.rb
index 911180b28..f295608f1 100755
--- a/test/other/events.rb
+++ b/test/other/events.rb
@@ -19,11 +19,11 @@ class TestEvents < Test::Unit::TestCase
def test_simplesubscribe
name = tempfile()
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => name,
:create => true
)
- exec = Puppet.type(:exec).create(
+ exec = Puppet::Type::Exec.create(
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
@@ -32,18 +32,18 @@ class TestEvents < Test::Unit::TestCase
comp = newcomp("eventtesting", file, exec)
- trans = assert_events([:file_created], comp)
+ trans = assert_events(comp, [:file_created], "events")
assert_equal(1, trans.triggered?(exec, :refresh))
end
def test_simplerequire
name = tempfile()
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => name,
:create => true
)
- exec = Puppet.type(:exec).create(
+ exec = Puppet::Type::Exec.create(
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
@@ -51,7 +51,7 @@ class TestEvents < Test::Unit::TestCase
)
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "eventtesting"
)
comp.push exec
@@ -74,13 +74,13 @@ class TestEvents < Test::Unit::TestCase
case l
when :a
name = tempfile() + l.to_s
- objects[l] = Puppet.type(:file).create(
+ objects[l] = Puppet::Type::PFile.create(
:name => name,
:create => true
)
@@tmpfiles << name
when :b
- objects[l] = Puppet.type(:exec).create(
+ objects[l] = Puppet::Type::Exec.create(
:name => "touch %s" % fname,
:path => "/usr/bin:/bin",
:refreshonly => true
@@ -89,7 +89,7 @@ class TestEvents < Test::Unit::TestCase
end
- comps[l] = Puppet.type(:component).create(
+ comps[l] = Puppet::Type::Component.create(
:name => "eventtesting%s" % l
)
diff --git a/test/other/log.rb b/test/other/log.rb
index 0bc2656ea..f082be6ad 100644
--- a/test/other/log.rb
+++ b/test/other/log.rb
@@ -44,8 +44,6 @@ class TestLog < Test::Unit::TestCase
def test_logfile
fact = nil
levels = nil
- oldlevel = Puppet[:loglevel]
- Puppet[:loglevel] = :debug
levels = getlevels
logfile = tempfile()
assert_nothing_raised() {
@@ -61,7 +59,6 @@ class TestLog < Test::Unit::TestCase
}
}
assert(count == levels.length)
- Puppet[:loglevel] = oldlevel
end
def test_syslog
@@ -103,14 +100,12 @@ class TestLog < Test::Unit::TestCase
end
def test_output
- olddebug = Puppet[:debug]
Puppet[:debug] = false
assert(Puppet.err("This is an error").is_a?(Puppet::Log))
assert(Puppet.debug("This is debugging").nil?)
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
@@ -126,7 +121,7 @@ class TestLog < Test::Unit::TestCase
path = tempfile
File.open(path, "w") { |f| f.puts "yayness" }
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => path,
:check => [:owner, :group, :mode, :checksum]
)
@@ -162,7 +157,7 @@ class TestLog < Test::Unit::TestCase
# Verify that the error and source are always strings
def test_argsAreStrings
msg = nil
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tempfile(),
:check => %w{owner group}
)
@@ -180,7 +175,7 @@ class TestLog < Test::Unit::TestCase
# Verify that loglevel behaves as one expects
def test_loglevel
path = tempfile()
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => path,
:create => true
)
diff --git a/test/other/metrics.rb b/test/other/metrics.rb
index 36a12eb1f..dbae3cf54 100644
--- a/test/other/metrics.rb
+++ b/test/other/metrics.rb
@@ -25,7 +25,7 @@ if $haverrd
eventmax = 10
maxdiff = 10
- types = [Puppet.type(:file), Puppet.type(:package), Puppet.type(:package)]
+ types = [Puppet::Type::PFile, Puppet::Type::Package, Puppet::Type::Service]
data = [:total, :managed, :outofsync, :changed, :totalchanges]
events = [:file_changed, :package_installed, :service_started]
diff --git a/test/other/overrides.rb b/test/other/overrides.rb
index d9220264e..be9ccd2ce 100755
--- a/test/other/overrides.rb
+++ b/test/other/overrides.rb
@@ -29,7 +29,7 @@ class TestOverrides < Test::Unit::TestCase
baseobj = nil
basefile = File.join(basedir, "file")
assert_nothing_raised("Could not create base obj") {
- baseobj = Puppet.type(:file).create(
+ baseobj = Puppet::Type::PFile.create(
:path => basedir,
:recurse => true,
:mode => "755"
@@ -40,7 +40,7 @@ class TestOverrides < Test::Unit::TestCase
subdir = File.join(basedir, "0")
subfile = File.join(subdir, "file")
assert_nothing_raised("Could not create sub obj") {
- subobj = Puppet.type(:file).create(
+ subobj = Puppet::Type::PFile.create(
:path => subdir,
:recurse => true,
:mode => "644"
@@ -63,7 +63,7 @@ class TestOverrides < Test::Unit::TestCase
baseobj = nil
assert_nothing_raised("Could not create base obj") {
- baseobj = Puppet.type(:file).create(
+ baseobj = Puppet::Type::PFile.create(
:path => basedir,
:recurse => true,
:mode => "755"
@@ -87,7 +87,7 @@ class TestOverrides < Test::Unit::TestCase
end
assert_nothing_raised("Could not create sub obj") {
- children << Puppet.type(:file).create(
+ children << Puppet::Type::PFile.create(
:path => subdir,
:recurse => true,
:mode => mode
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index f2764c639..04cbd73dc 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -12,7 +12,7 @@ class TestRelationships < Test::Unit::TestCase
include TestPuppet
def newfile
assert_nothing_raised() {
- return Puppet.type(:file).create(
+ return Puppet::Type::PFile.create(
:path => tempfile,
:check => [:mode, :owner, :group]
)
diff --git a/test/other/state.rb b/test/other/state.rb
index 15512f6fe..c53829311 100644
--- a/test/other/state.rb
+++ b/test/other/state.rb
@@ -48,7 +48,7 @@ class TestStorage < Test::Unit::TestCase
file = nil
state = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => "/etc/passwd"
)
}
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 5a00fbe09..f1897e0e5 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -34,7 +34,10 @@ class TestTransactions < Test::Unit::TestCase
end
def teardown
- stopservices
+ Puppet::Type::Service.each { |serv|
+ serv[:running] = false
+ serv.sync
+ }
#print "\n\n" if Puppet[:debug]
super
end
@@ -63,13 +66,13 @@ class TestTransactions < Test::Unit::TestCase
@@tmpfiles.push tmpfile
hash[:name] = tmpfile
assert_nothing_raised() {
- return Puppet.type(:file).create(hash)
+ return Puppet::Type::PFile.create(hash)
}
end
def newservice
assert_nothing_raised() {
- return Puppet.type(:service).create(
+ return Puppet::Type::Service.create(
:name => "sleeper",
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
@@ -81,7 +84,7 @@ class TestTransactions < Test::Unit::TestCase
def newexec(file)
assert_nothing_raised() {
- return Puppet.type(:exec).create(
+ return Puppet::Type::Exec.create(
:name => "touch %s" % file,
:path => "/bin:/usr/bin:/sbin:/usr/sbin",
:returns => 0
@@ -123,7 +126,7 @@ class TestTransactions < Test::Unit::TestCase
file[:mode] = "755"
}
- trans = assert_events([:inode_changed, :inode_changed], component)
+ trans = assert_events(component, [:inode_changed, :inode_changed], "file")
assert_rollback_events(trans, [:inode_changed, :inode_changed], "file")
@@ -138,8 +141,7 @@ class TestTransactions < Test::Unit::TestCase
end
# start a service, and then roll the modification back
- # Disabled, because it wasn't really worth the effort.
- def disabled_test_servicetrans
+ def test_servicetrans
transaction = nil
service = newservice()
@@ -148,13 +150,9 @@ class TestTransactions < Test::Unit::TestCase
assert_nothing_raised() {
service[:running] = 1
}
- service.retrieve
- assert(service.insync?, "Service did not start")
- system("ps -ef | grep ruby")
- trans = assert_events([:service_started], component)
- service.retrieve
+ trans = assert_events(component, [:service_started], "file")
- assert_rollback_events(trans, [:service_stopped], "service")
+ assert_rollback_events(trans, [:service_stopped], "file")
end
# test that services are correctly restarted and that work is done
@@ -188,7 +186,8 @@ class TestTransactions < Test::Unit::TestCase
file[:mode] = "755"
}
- trans = assert_events( [:inode_changed], component)
+ trans = assert_events(component,
+ [:inode_changed], "testboth")
assert(FileTest.exists?(execfile), "Execfile does not exist")
File.unlink(execfile)
@@ -196,7 +195,8 @@ class TestTransactions < Test::Unit::TestCase
file[:group] = @groups[1]
}
- trans = assert_events([:inode_changed], component)
+ trans = assert_events(component,
+ [:inode_changed], "testboth")
assert(FileTest.exists?(execfile), "Execfile does not exist")
end
@@ -220,14 +220,15 @@ class TestTransactions < Test::Unit::TestCase
ecomp[:subscribe] = [[fcomp.class.name,fcomp.name]]
exec[:refreshonly] = true
- trans = assert_events([], component)
+ trans = assert_events(component, [], "subscribe1")
assert_nothing_raised() {
file[:group] = @groups[1]
file[:mode] = "755"
}
- trans = assert_events([:inode_changed, :inode_changed], component)
+ trans = assert_events(component, [:inode_changed, :inode_changed],
+ "subscribe2")
end
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 382bfbc56..0871b5c13 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -7,15 +7,12 @@ require 'puppet'
require 'test/unit'
module TestPuppet
- def newcomp(*ary)
- name = nil
- if ary[0].is_a?(String)
- name = ary.shift
- else
- name = ary[0].name
+ def newcomp(name,*ary)
+ if name.is_a?(Puppet::Type)
+ ary.unshift name
+ name = name.name
end
-
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => name
)
ary.each { |item| comp.push item }
@@ -81,7 +78,7 @@ module TestPuppet
if stype = Puppet::Type.type(:service)
stype.each { |service|
service[:running] = false
- service.evaluate
+ service.sync
}
end
end
@@ -106,9 +103,6 @@ module TestPuppet
# reset all of the logs
Puppet::Log.close
-
- # Just in case there are processes waiting to die...
- Process.waitall
end
def tempfile
@@ -142,7 +136,6 @@ module TestPuppet
"/tmp"
end
-
@tmpdir = File.join(@tmpdir, "puppettesting")
unless File.exists?(@tmpdir)
@@ -153,57 +146,18 @@ module TestPuppet
@tmpdir
end
- def assert_rollback_events(events, trans, msg = nil)
- run_events(:rollback, events, trans, msg)
+ def assert_rollback_events(trans, events, msg)
+ run_events(:rollback, trans, events, msg)
end
- def assert_events(events, *items)
+ def assert_events(comp, events, msg = nil)
trans = nil
- comp = nil
- msg = nil
-
- unless events.is_a? Array
- raise Puppet::DevError, "Incorrect call of assert_events"
- end
- if items[-1].is_a? String
- msg = items.pop
- end
-
- remove_comp = false
- # They either passed a comp or a list of items.
- if items[0].is_a? Puppet.type(:component)
- comp = items.shift
- else
- comp = newcomp(items[0].name, *items)
- remove_comp = true
- end
msg ||= comp.name
assert_nothing_raised("Component %s failed" % [msg]) {
trans = comp.evaluate
}
run_events(:evaluate, trans, events, msg)
-
- if remove_comp
- Puppet.type(:component).delete(comp)
- end
-
- return trans
- end
-
- # A simpler method that just applies what we have.
- def assert_apply(*objects)
- comp = newcomp(*objects)
- trans = nil
-
- assert_nothing_raised("Failed to create transaction") {
- trans = comp.evaluate
- }
-
- assert_nothing_raised("Failed to evaluate transaction") {
- trans.evaluate
- }
- Puppet.type(:component).delete(comp)
end
def run_events(type, trans, events, msg)
diff --git a/test/server/fileserver.rb b/test/server/fileserver.rb
index d1cdd696b..98c0c4cb4 100755
--- a/test/server/fileserver.rb
+++ b/test/server/fileserver.rb
@@ -151,7 +151,7 @@ class TestFileServer < Test::Unit::TestCase
}
assert_nothing_raised {
- file = Puppet.type(:file)[tmpfile]
+ file = Puppet::Type::PFile[tmpfile]
}
output = "/\tfile"
diff --git a/test/server/logger.rb b/test/server/logger.rb
index dfaf50438..6dc5dec48 100644
--- a/test/server/logger.rb
+++ b/test/server/logger.rb
@@ -13,12 +13,6 @@ require 'cgi'
class TestLogger < Test::Unit::TestCase
include ServerTest
- def setup
- super
- #Puppet[:debug] = true
- Puppet[:logdest] = :console
- end
-
# Test the log driver manually
def test_localaddlog
logger = nil
@@ -29,7 +23,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
msg = Puppet::Log.create(
- :level => :warning,
+ :level => :info,
:message => "This is a message"
)
}
@@ -49,7 +43,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
msg = Puppet::Log.create(
- :level => :warning,
+ :level => :info,
:message => "This is a remote message"
)
}
@@ -72,7 +66,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
msg = Puppet::Log.create(
- :level => :warning,
+ :level => :info,
:message => "This is a logclient message"
)
}
diff --git a/test/types/basic.rb b/test/types/basic.rb
index edc6bc66d..8cc5e406c 100644
--- a/test/types/basic.rb
+++ b/test/types/basic.rb
@@ -22,7 +22,7 @@ class TestBasic < Test::Unit::TestCase
Puppet[:loglevel] = :debug if __FILE__ == $0
assert_nothing_raised() {
- @component = Puppet.type(:component).create(
+ @component = Puppet::Type::Component.create(
:name => "yaytest",
:type => "testing"
)
@@ -31,14 +31,14 @@ class TestBasic < Test::Unit::TestCase
assert_nothing_raised() {
@filepath = tempfile()
@@tmpfiles << @filepath
- @configfile = Puppet.type(:file).create(
+ @configfile = Puppet::Type::PFile.create(
:path => @filepath,
:create => true,
:checksum => "md5"
)
}
assert_nothing_raised() {
- @sleeper = Puppet.type(:service).create(
+ @sleeper = Puppet::Type::Service.create(
:name => "sleeper",
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
diff --git a/test/types/component.rb b/test/types/component.rb
index b97695f9f..7243ed2fc 100755
--- a/test/types/component.rb
+++ b/test/types/component.rb
@@ -42,7 +42,7 @@ class TestComponent < Test::Unit::TestCase
end
name = tempfile() + num.to_s
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => name,
:checksum => "md5"
)
@@ -51,7 +51,7 @@ class TestComponent < Test::Unit::TestCase
end
def mkcomp
- Puppet.type(:component).create(:name => "component_" + randnum(1000).to_s)
+ Puppet::Type::Component.create(:name => "component_" + randnum(1000).to_s)
end
def mkrandcomp(numfiles, numdivs)
@@ -114,12 +114,12 @@ class TestComponent < Test::Unit::TestCase
File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
of.puts rand(100)
}
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tmpfile,
:checksum => "md5"
)
assert_nothing_raised {
- cmd = Puppet.type(:exec).create(
+ cmd = Puppet::Type::Exec.create(
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:subscribe => [[file.class.name,file.name]],
@@ -129,7 +129,7 @@ class TestComponent < Test::Unit::TestCase
order = nil
assert_nothing_raised {
- order = Puppet.type(:component).sort([file, cmd])
+ order = Puppet::Type::Component.sort([file, cmd])
}
[cmd, file].each { |obj|
@@ -145,12 +145,12 @@ class TestComponent < Test::Unit::TestCase
File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
of.puts rand(100)
}
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tmpfile,
:checksum => "md5"
)
assert_nothing_raised {
- cmd = Puppet.type(:exec).create(
+ cmd = Puppet::Type::Exec.create(
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:subscribe => [[file.class.name,file.name]],
@@ -158,7 +158,7 @@ class TestComponent < Test::Unit::TestCase
)
}
- comp = Puppet.type(:component).create(:name => "RefreshTest")
+ comp = Puppet::Type::Component.create(:name => "RefreshTest")
[cmd, file].each { |obj|
comp.push obj
}
@@ -183,12 +183,12 @@ class TestComponent < Test::Unit::TestCase
File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
of.puts rand(100)
}
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tmpfile,
:checksum => "md5"
)
assert_nothing_raised {
- cmd = Puppet.type(:exec).create(
+ cmd = Puppet::Type::Exec.create(
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:refreshonly => true
@@ -224,12 +224,12 @@ class TestComponent < Test::Unit::TestCase
File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
of.puts rand(100)
}
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tmpfile,
:checksum => "md5"
)
assert_nothing_raised {
- cmd = Puppet.type(:exec).create(
+ cmd = Puppet::Type::Exec.create(
:command => "pwd",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:refreshonly => true
@@ -238,7 +238,7 @@ class TestComponent < Test::Unit::TestCase
ocmd = nil
assert_nothing_raised {
- ocmd = Puppet.type(:exec).create(
+ ocmd = Puppet::Type::Exec.create(
:command => "echo true",
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:refreshonly => true
diff --git a/test/types/cron.rb b/test/types/cron.rb
index 3ff1dbd18..1a60eecd3 100755
--- a/test/types/cron.rb
+++ b/test/types/cron.rb
@@ -34,9 +34,8 @@ class TestCron < Test::Unit::TestCase
unless defined? @me
raise "Could not retrieve user name; 'id' did not work"
end
-
# god i'm lazy
- @crontype = Puppet.type(:cron)
+ @crontype = Puppet::Type::Cron
# Here we just create a fake cron type that answers to all of the methods
# but does not modify our actual system.
@@ -75,7 +74,7 @@ class TestCron < Test::Unit::TestCase
def cronback
tab = nil
assert_nothing_raised {
- tab = Puppet.type(:cron).crontype.read(@me)
+ tab = Puppet::Type::Cron.crontype.read(@me)
}
if $? == 0
@@ -119,14 +118,14 @@ class TestCron < Test::Unit::TestCase
name = cron.name
comp = newcomp(name, cron)
- trans = assert_events([:cron_created], comp)
+ trans = assert_events(comp, [:cron_created], name)
cron.retrieve
assert(cron.insync?)
- trans = assert_events([], comp)
+ trans = assert_events(comp, [], name)
cron[:command] = :notfound
- trans = assert_events([:cron_deleted], comp)
+ trans = assert_events(comp, [:cron_deleted], name)
# the cron should no longer exist, not even in the comp
- trans = assert_events([], comp)
+ trans = assert_events(comp, [], name)
assert(!comp.include?(cron),
"Cron is still a member of comp, after being deleted")
@@ -176,14 +175,15 @@ class TestCron < Test::Unit::TestCase
:user => @me
)
}
- comp = newcomp(cron)
- assert_events([:cron_created], comp)
-
+ assert_nothing_raised {
+ cron.sync
+ }
assert_nothing_raised {
cron[:month] = "June"
}
+ comp = newcomp(cron)
- assert_events([:cron_changed], comp)
+ assert_events(comp, [:cron_changed], "did not change cron job")
end
# Test that a cron job with spaces at the end doesn't get rewritten
@@ -201,8 +201,8 @@ class TestCron < Test::Unit::TestCase
}
comp = newcomp(cron)
- assert_events([:cron_created], comp, "did not create cron job")
- assert_events([], comp, "cron job got rewritten")
+ assert_events(comp, [:cron_created], "did not create cron job")
+ assert_events(comp, [], "cron job got rewritten")
end
# Test that comments are correctly retained
@@ -247,15 +247,15 @@ class TestCron < Test::Unit::TestCase
# Test adding a cron when there is currently no file.
def test_mkcronwithnotab
- Puppet.type(:cron).crontype.remove(@me)
+ Puppet::Type::Cron.crontype.remove(@me)
cron = mkcron("testwithnotab")
cyclecron(cron)
end
def test_mkcronwithtab
- Puppet.type(:cron).crontype.remove(@me)
- Puppet.type(:cron).crontype.write(@me,
+ Puppet::Type::Cron.crontype.remove(@me)
+ Puppet::Type::Cron.crontype.write(@me,
"1 1 1 1 * date > %s/crontesting\n" % testdir()
)
@@ -264,20 +264,20 @@ class TestCron < Test::Unit::TestCase
end
def test_makeandretrievecron
- Puppet.type(:cron).crontype.remove(@me)
+ Puppet::Type::Cron.crontype.remove(@me)
name = "storeandretrieve"
cron = mkcron(name)
comp = newcomp(name, cron)
- trans = assert_events([:cron_created], comp, name)
+ trans = assert_events(comp, [:cron_created], name)
cron = nil
- Puppet.type(:cron).clear
- Puppet.type(:cron).retrieve(@me)
+ Puppet::Type::Cron.clear
+ Puppet::Type::Cron.retrieve(@me)
- assert(cron = Puppet.type(:cron)[name], "Could not retrieve named cron")
- assert_instance_of(Puppet.type(:cron), cron)
+ assert(cron = Puppet::Type::Cron[name], "Could not retrieve named cron")
+ assert_instance_of(Puppet::Type::Cron, cron)
end
# Do input validation testing on all of the parameters.
@@ -302,16 +302,14 @@ class TestCron < Test::Unit::TestCase
},
:month => {
:valid => [ 1, 11, 12, "mar", "March", "apr", "October", "DeCeMbEr" ],
- :invalid => [ -1, 0, 13, "marc", "sept" ]
+ :invalid => [ 0, 13, "marc", "sept" ]
}
}
cron = mkcron("valtesting")
values.each { |param, hash|
- # We have to test the valid ones first, because otherwise the
- # state will fail to create at all.
- [:valid, :invalid].each { |type|
- hash[type].each { |value|
+ hash.each { |type, values|
+ values.each { |value|
case type
when :valid:
assert_nothing_raised {
diff --git a/test/types/exec.rb b/test/types/exec.rb
index 931d649bc..2da818755 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -24,11 +24,13 @@ class TestExec < Test::Unit::TestCase
assert_nothing_raised {
command.evaluate
}
- assert_events([:executed_command], command)
+ assert_nothing_raised {
+ output = command.sync
+ }
+ assert_equal([:executed_command],output)
end
def test_numvsstring
-<<<<<<< .working
command = nil
output = nil
assert_nothing_raised {
@@ -36,22 +38,7 @@ class TestExec < Test::Unit::TestCase
:command => "/bin/echo",
:returns => 0
)
-=======
- [0, "0"].each { |val|
- Puppet.type(:exec).clear
- Puppet.type(:component).clear
- command = nil
- output = nil
- assert_nothing_raised {
- command = Puppet.type(:exec).create(
- :command => "/bin/echo",
- :returns => val
- )
- }
- assert_events([:executed_command], command)
->>>>>>> .merge-right.r784
}
-<<<<<<< .working
assert_nothing_raised {
command.evaluate
}
@@ -71,8 +58,6 @@ class TestExec < Test::Unit::TestCase
assert_nothing_raised {
output = command.sync
}
-=======
->>>>>>> .merge-right.r784
end
def test_path_or_qualified
@@ -144,7 +129,12 @@ class TestExec < Test::Unit::TestCase
:returns => 0
)
}
- assert_events([:executed_command], command)
+ assert_nothing_raised {
+ command.evaluate
+ }
+ assert_nothing_raised {
+ command.sync
+ }
assert_equal(wd,command.output.chomp)
end
@@ -157,11 +147,10 @@ class TestExec < Test::Unit::TestCase
File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
of.puts rand(100)
}
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => tmpfile,
:checksum => "md5"
)
- assert_instance_of(Puppet.type(:file), file)
assert_nothing_raised {
cmd = Puppet::Type::Exec.create(
:command => "pwd",
@@ -171,9 +160,7 @@ class TestExec < Test::Unit::TestCase
)
}
- assert_instance_of(Puppet.type(:exec), cmd)
-
- comp = Puppet.type(:component).create(:name => "RefreshTest")
+ comp = Puppet::Type::Component.create(:name => "RefreshTest")
[file,cmd].each { |obj|
comp.push obj
}
@@ -211,7 +198,6 @@ class TestExec < Test::Unit::TestCase
def test_creates
file = tempfile()
exec = nil
- assert(! FileTest.exists?(file), "File already exists")
assert_nothing_raised {
exec = Puppet::Type::Exec.create(
:command => "touch %s" % file,
@@ -221,8 +207,8 @@ class TestExec < Test::Unit::TestCase
}
comp = newcomp("createstest", exec)
- assert_events([:executed_command], comp, "creates")
- assert_events([], comp, "creates")
+ assert_events(comp, [:executed_command], "creates")
+ assert_events(comp, [], "creates")
end
if Process.uid == 0
@@ -257,7 +243,7 @@ class TestExec < Test::Unit::TestCase
}
comp = newcomp("usertest", exec)
- assert_events([:executed_command], comp, "usertest")
+ assert_events(comp, [:executed_command], "usertest")
assert(FileTest.exists?(file), "File does not exist")
if user
diff --git a/test/types/file.rb b/test/types/file.rb
index 599dc9630..f01440903 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -17,7 +17,7 @@ class TestFile < Test::Unit::TestCase
def mkfile(hash)
file = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(hash)
+ file = Puppet::Type::PFile.create(hash)
}
return file
end
@@ -88,14 +88,19 @@ class TestFile < Test::Unit::TestCase
us = {}
us[uid] = name
users.each { |uid, name|
- assert_apply(file)
+ # just make sure we don't try to manage users
+ assert_nothing_raised() {
+ file.sync
+ }
assert_nothing_raised() {
file[:owner] = name
}
assert_nothing_raised() {
file.retrieve
}
- assert_apply(file)
+ assert_nothing_raised() {
+ file.sync
+ }
}
end
@@ -120,7 +125,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => path,
:owner => user.name,
:create => true,
@@ -130,7 +135,7 @@ class TestFile < Test::Unit::TestCase
comp = newcomp("createusertest", file)
- assert_events([:file_created], comp)
+ assert_events(comp, [:file_created])
end
def test_ownerasroot
@@ -170,14 +175,19 @@ class TestFile < Test::Unit::TestCase
changes << file.evaluate
}
assert(changes.length > 0)
- assert_apply(file)
- file.retrieve
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.evaluate
+ }
assert(file.insync?())
assert_nothing_raised() {
file[:owner] = uid
}
- assert_apply(file)
- file.retrieve
+ assert_nothing_raised() {
+ file.evaluate
+ }
# make sure changing to number doesn't cause a sync
assert(file.insync?())
}
@@ -201,8 +211,15 @@ class TestFile < Test::Unit::TestCase
}
assert(file.state(:group))
assert(file.state(:group).should)
- assert_apply(file)
- file.retrieve
+ assert_nothing_raised() {
+ file.evaluate
+ }
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.evaluate
+ }
assert(file.insync?())
assert_nothing_raised() {
file.delete(:group)
@@ -217,15 +234,22 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path|
file =nil
assert_nothing_raised() {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => path,
:create => true
)
}
- assert_events([:file_created], file)
- assert_events([], file)
- assert(FileTest.file?(path), "File does not exist")
+ assert_nothing_raised() {
+ file.evaluate
+ }
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.evaluate
+ }
assert(file.insync?())
+ assert(FileTest.file?(path))
@@tmpfiles.push path
}
end
@@ -234,13 +258,20 @@ class TestFile < Test::Unit::TestCase
%w{a b c d}.collect { |name| "/tmp/createst%s" % name }.each { |path|
file = nil
assert_nothing_raised() {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => path,
:create => "directory"
)
}
- assert_events([:directory_created], file)
- assert_events([], file)
+ assert_nothing_raised() {
+ file.evaluate
+ }
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.evaluate
+ }
assert(file.insync?())
assert(FileTest.directory?(path))
@@tmpfiles.push path
@@ -249,17 +280,20 @@ class TestFile < Test::Unit::TestCase
def test_modes
file = mktestfile
- # Set it to something else initially
- File.chmod(0775, file.name)
[0644,0755,0777,0641].each { |mode|
assert_nothing_raised() {
file[:mode] = mode
}
- assert_events([:inode_changed], file)
- assert_events([], file)
-
+ assert_nothing_raised() {
+ file.evaluate
+ }
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.evaluate
+ }
assert(file.insync?())
-
assert_nothing_raised() {
file.delete(:mode)
}
@@ -291,13 +325,13 @@ class TestFile < Test::Unit::TestCase
events = nil
# okay, we now know that we have a file...
assert_nothing_raised() {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => path,
:create => true,
:checksum => type
)
}
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "componentfile"
)
comp.push file
@@ -325,28 +359,38 @@ class TestFile < Test::Unit::TestCase
of.puts rand(100)
}
}
- Puppet.type(:file).clear
- Puppet.type(:component).clear
+ Puppet::Type::PFile.clear
+ Puppet::Type::Component.clear
sleep 1
# now recreate the file
assert_nothing_raised() {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => path,
:checksum => type
)
}
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "componentfile"
)
comp.push file
trans = nil
- assert_events([:file_modified], comp)
+ assert_nothing_raised() {
+ trans = comp.evaluate
+ }
+ assert_nothing_raised() {
+ events = trans.evaluate.collect { |e| e.event }
+ }
+
+ sum = file.state(:checksum)
# verify that we're actually getting notified when a file changes
+ assert(
+ events.include?(:file_modified)
+ )
assert_nothing_raised() {
- Puppet.type(:file).clear
- Puppet.type(:component).clear
+ Puppet::Type::PFile.clear
+ Puppet::Type::Component.clear
}
}
}
@@ -362,13 +406,13 @@ class TestFile < Test::Unit::TestCase
initstorage
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
param => path,
:recurse => true,
:checksum => "md5"
)
}
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push file
@@ -378,6 +422,9 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised {
trans.evaluate
}
+ #assert_nothing_raised {
+ # file.sync
+ #}
clearstorage
Puppet::Type.allclear
}
@@ -391,7 +438,7 @@ class TestFile < Test::Unit::TestCase
dir = nil
assert_nothing_raised {
- dir = Puppet.type(:file).create(
+ dir = Puppet::Type::PFile.create(
:path => basedir,
:recurse => true,
:check => %w{owner mode group}
@@ -404,7 +451,7 @@ class TestFile < Test::Unit::TestCase
subobj = nil
assert_nothing_raised {
- subobj = Puppet.type(:file)[subdir]
+ subobj = Puppet::Type::PFile[subdir]
}
assert(subobj, "Could not retrieve subdir object")
@@ -415,7 +462,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet.type(:file)[tmpfile]
+ file = Puppet::Type::PFile[tmpfile]
}
assert(file, "Could not retrieve file object")
@@ -459,9 +506,8 @@ class TestFile < Test::Unit::TestCase
def test_filetype_retrieval
file = nil
- # Verify it retrieves files of type directory
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => tmpdir(),
:check => :type
)
@@ -473,27 +519,28 @@ class TestFile < Test::Unit::TestCase
assert_equal("directory", file.state(:type).is)
- # And then check files
assert_nothing_raised {
- file = Puppet.type(:file).create(
- :name => tempfile(),
- :create => true
+ file = Puppet::Type::PFile.create(
+ :name => "/etc/passwd",
+ :check => :type
)
}
- assert_apply(file)
- file[:check] = "type"
- assert_apply(file)
+ assert_nothing_raised {
+ file.evaluate
+ }
assert_equal("file", file.state(:type).is)
- file[:type] = "directory"
-
- assert_nothing_raised { file.retrieve }
+ assert_raise(Puppet::Error) {
+ file[:type] = "directory"
+ }
- # The 'retrieve' method sets @should to @is, so they're never
- # out of sync. It's a read-only class.
assert(file.insync?)
+
+ assert_raise(Puppet::Error) {
+ file.sync
+ }
end
def test_remove
@@ -503,7 +550,7 @@ class TestFile < Test::Unit::TestCase
dir = nil
assert_nothing_raised {
- dir = Puppet.type(:file).create(
+ dir = Puppet::Type::PFile.create(
:path => basedir,
:recurse => true,
:check => %w{owner mode group}
@@ -516,7 +563,7 @@ class TestFile < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
- obj = Puppet.type(:file)[subdir]
+ obj = Puppet::Type::PFile[subdir]
}
assert(obj, "Could not retrieve subdir object")
@@ -526,7 +573,7 @@ class TestFile < Test::Unit::TestCase
}
assert_nothing_raised {
- obj = Puppet.type(:file)[subdir]
+ obj = Puppet::Type::PFile[subdir]
}
assert_nil(obj, "Retrieved removed object")
@@ -545,7 +592,7 @@ class TestFile < Test::Unit::TestCase
file = nil
dirobj = nil
assert_nothing_raised("Could not make file object") {
- dirobj = Puppet.type(:file).create(
+ dirobj = Puppet::Type::PFile.create(
:path => dir,
:recurse => true,
:check => %w{mode owner group}
diff --git a/test/types/filebucket.rb b/test/types/filebucket.rb
index 909170f77..884492c41 100755
--- a/test/types/filebucket.rb
+++ b/test/types/filebucket.rb
@@ -19,7 +19,7 @@ class TestFileBucket < Test::Unit::TestCase
def mkfile(hash)
file = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(hash)
+ file = Puppet::Type::PFile.create(hash)
}
return file
end
@@ -27,7 +27,7 @@ class TestFileBucket < Test::Unit::TestCase
def mkbucket(name,path)
bucket = nil
assert_nothing_raised {
- bucket = Puppet.type(:filebucket).create(
+ bucket = Puppet::Type::PFileBucket.create(
:name => name,
:path => path
)
@@ -77,7 +77,7 @@ class TestFileBucket < Test::Unit::TestCase
bucket = nil
assert_nothing_raised {
- bucket = Puppet.type(:filebucket).bucket(name)
+ bucket = Puppet::Type::PFileBucket.bucket(name)
}
assert_instance_of(Puppet::Client::Dipper, bucket)
@@ -94,8 +94,6 @@ class TestFileBucket < Test::Unit::TestCase
newmd5 = nil
- # Just in case the file isn't writable
- File.chmod(0644, newpath)
File.open(newpath, "w") { |f| f.puts ";lkjasdf;lkjasdflkjwerlkj134lkj" }
assert_nothing_raised {
@@ -119,7 +117,7 @@ class TestFileBucket < Test::Unit::TestCase
bucket = nil
assert_nothing_raised {
- bucket = Puppet.type(:filebucket).bucket(name)
+ bucket = Puppet::Type::PFileBucket.bucket(name)
}
file = mktestfile()
@@ -155,7 +153,6 @@ class TestFileBucket < Test::Unit::TestCase
File.open(file.name) { |f| newmd5 = Digest::MD5.hexdigest(f.read) }
)
- #File.chmod(0644, file.name)
assert_nothing_raised {
bucket.restore(file.name, origmd5)
}
diff --git a/test/types/fileignoresource.rb b/test/types/fileignoresource.rb
index 688b57845..747fbcfed 100644
--- a/test/types/fileignoresource.rb
+++ b/test/types/fileignoresource.rb
@@ -76,7 +76,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
- tofile = Puppet.type(:file).create(
+ tofile = Puppet::Type::PFile.create(
:name => topath,
:source => frompath,
:recurse => true,
@@ -85,7 +85,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
}
#make a component and adds the file
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push tofile
@@ -153,7 +153,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
- tofile = Puppet.type(:file).create(
+ tofile = Puppet::Type::PFile.create(
:name => topath,
:source => frompath,
:recurse => true,
@@ -162,7 +162,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
}
#make a component and adds the file
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push tofile
@@ -237,7 +237,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#makes Puppet file Object
assert_nothing_raised {
- tofile = Puppet.type(:file).create(
+ tofile = Puppet::Type::PFile.create(
:name => topath,
:source => frompath,
:recurse => true,
@@ -247,7 +247,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase
}
#make a component and adds the file
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push tofile
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index 8dd0ca6b5..b6c8c1b3c 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -54,7 +54,7 @@ class TestFileSources < Test::Unit::TestCase
comp = nil
trans = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => path
)
}
@@ -82,12 +82,12 @@ class TestFileSources < Test::Unit::TestCase
of.puts "yayness"
}
assert_nothing_raised {
- tofile = Puppet.type(:file).create(
+ tofile = Puppet::Type::PFile.create(
:name => topath,
:source => frompath
)
}
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push tofile
@@ -97,6 +97,9 @@ class TestFileSources < Test::Unit::TestCase
assert_nothing_raised {
trans.evaluate
}
+ # assert_nothing_raised {
+ # comp.sync
+ # }
assert(FileTest.exists?(topath))
from = File.open(frompath) { |o| o.read }
@@ -112,14 +115,14 @@ class TestFileSources < Test::Unit::TestCase
trans = nil
assert_nothing_raised {
- tofile = Puppet.type(:file).create(
+ tofile = Puppet::Type::PFile.create(
:name => todir,
"recurse" => true,
"backup" => false,
"source" => fromdir
)
}
- comp = Puppet.type(:component).create(
+ comp = Puppet::Type::Component.create(
:name => "component"
)
comp.push tofile
@@ -243,7 +246,7 @@ class TestFileSources < Test::Unit::TestCase
File.open(file1, "w") { |f| 3.times { f.print rand(100) } }
rootobj = nil
assert_nothing_raised {
- rootobj = Puppet.type(:file).create(
+ rootobj = Puppet::Type::PFile.create(
:name => basedir,
:recurse => true,
:check => %w{type owner}
@@ -252,7 +255,7 @@ class TestFileSources < Test::Unit::TestCase
rootobj.evaluate
}
- klass = Puppet.type(:file)
+ klass = Puppet::Type::PFile
assert(klass[basedir])
assert(klass[file1])
assert_nil(klass[file2])
@@ -451,7 +454,7 @@ class TestFileSources < Test::Unit::TestCase
sleep(1)
name = File.join(tmpdir(), "nosourcefile")
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:source => "puppet://localhost/dist/file",
:name => name
)
@@ -507,7 +510,7 @@ class TestFileSources < Test::Unit::TestCase
sleep(1)
name = File.join(tmpdir(), "nosourcefile")
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:source => "puppet://localhost/noexist/file",
:name => name
)
@@ -537,7 +540,7 @@ class TestFileSources < Test::Unit::TestCase
# Now the files should be exactly the same, so we should not see attempts
# at copying
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => to,
:source => from
)
@@ -563,14 +566,14 @@ class TestFileSources < Test::Unit::TestCase
file = nil
assert_nothing_raised {
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:name => to,
:source => files
)
}
comp = newcomp(file)
- assert_events([:file_changed], comp)
+ assert_events(comp, [:file_changed])
assert(File.exists?(to), "File does not exist")
diff --git a/test/types/filetype.rb b/test/types/filetype.rb
index b3ebf15ff..fe0e4e316 100644
--- a/test/types/filetype.rb
+++ b/test/types/filetype.rb
@@ -14,10 +14,10 @@ class TestFileType
def disabled_setup
Puppet[:loglevel] = :debug if __FILE__ == $0
- @passwdtype = Puppet.type(:filetype)["passwd"]
+ @passwdtype = Puppet::Type::FileType["passwd"]
if @passwdtype.nil?
assert_nothing_raised() {
- @passwdtype = Puppet.type(:filetype).createtype(
+ @passwdtype = Puppet::Type::FileType.createtype(
:name => "passwd"
)
@passwdtype.addrecord(
@@ -28,10 +28,10 @@ class TestFileType
}
end
- @syslogtype = Puppet.type(:filetype)["syslog"]
+ @syslogtype = Puppet::Type::FileType["syslog"]
if @syslogtype.nil?
assert_nothing_raised() {
- @syslogtype = Puppet.type(:filetype).createtype(
+ @syslogtype = Puppet::Type::FileType.createtype(
:escapednewlines => true,
:name => "syslog"
)
@@ -113,7 +113,7 @@ class TestFileType
assert(!file.insync?)
assert_nothing_raised() {
- file.evaluate
+ file.sync
}
assert(file.insync?)
@@ -125,7 +125,7 @@ class TestFileType
assert(!file.insync?)
assert_nothing_raised() {
- file.evaluate
+ file.sync
}
assert(file.insync?)
diff --git a/test/types/group.rb b/test/types/group.rb
index f28685ef7..215229063 100755
--- a/test/types/group.rb
+++ b/test/types/group.rb
@@ -19,7 +19,7 @@ class TestGroup < Test::Unit::TestCase
end
def teardown
- Puppet.type(:group).clear
+ Puppet::Type::Group.clear
@@tmpgroups.each { |group|
unless missing?(group)
remove(group)
@@ -99,7 +99,7 @@ class TestGroup < Test::Unit::TestCase
group[:gid] = old
- trans = assert_events([], comp, "group")
+ trans = assert_events(comp, [], "group")
newgid = old
while true
@@ -120,7 +120,7 @@ class TestGroup < Test::Unit::TestCase
group[:gid] = newgid
}
- trans = assert_events([:group_modified], comp, "group")
+ trans = assert_events(comp, [:group_modified], "group")
curgid = nil
assert_nothing_raised {
@@ -144,7 +144,7 @@ class TestGroup < Test::Unit::TestCase
assert(obj, "Could not retrieve test group object")
- Puppet.type(:group).validstates.each { |name, state|
+ Puppet::Type::Group.validstates.each { |name, state|
assert_nothing_raised {
method = state.infomethod
assert(method, "State %s has no infomethod" % name)
@@ -170,7 +170,7 @@ class TestGroup < Test::Unit::TestCase
gobj = nil
comp = nil
assert_nothing_raised {
- gobj = Puppet.type(:group).create(
+ gobj = Puppet::Type::Group.create(
:name => group,
:check => [:gid]
)
@@ -198,8 +198,8 @@ class TestGroup < Test::Unit::TestCase
}
user = nil
assert_nothing_raised {
- checks = Puppet.type(:group).validstates
- user = Puppet.type(:group).create(
+ checks = Puppet::Type::Group.validstates
+ user = Puppet::Type::Group.create(
:name => name,
:check => checks
)
@@ -234,7 +234,7 @@ class TestGroup < Test::Unit::TestCase
assert(missing?(name), "Group %s is still present" % name)
assert_nothing_raised {
- gobj = Puppet.type(:group).create(
+ gobj = Puppet::Type::Group.create(
:name => name
)
@@ -242,7 +242,7 @@ class TestGroup < Test::Unit::TestCase
}
@@tmpgroups << name
- trans = assert_events([:group_created], comp, "group")
+ trans = assert_events(comp, [:group_created], "group")
obj = nil
assert_nothing_raised {
@@ -250,7 +250,7 @@ class TestGroup < Test::Unit::TestCase
}
assert(!missing?(name), "Group %s is missing" % name)
- tests = Puppet.type(:group).validstates
+ tests = Puppet::Type::Group.validstates
gobj.retrieve
tests.each { |test|
diff --git a/test/types/package.rb b/test/types/package.rb
index 625763d80..c5f781859 100644
--- a/test/types/package.rb
+++ b/test/types/package.rb
@@ -11,7 +11,7 @@ require 'facter'
$platform = Facter["operatingsystem"].value
-unless Puppet.type(:package).default
+unless Puppet::Type::Package.default
puts "No default package type for %s; skipping package tests" % $platform
else
@@ -31,8 +31,8 @@ class TestPackages < Test::Unit::TestCase
include FileTesting
def setup
super
- #@list = Puppet.type(:package).getpkglist
- Puppet.type(:package).clear
+ #@list = Puppet::Type::Package.getpkglist
+ Puppet::Type::Package.clear
end
# These are packages that we're sure will be installed
@@ -81,7 +81,7 @@ class TestPackages < Test::Unit::TestCase
def mkpkgcomp(pkg)
assert_nothing_raised {
- pkg = Puppet.type(:package).create(:name => pkg, :install => true)
+ pkg = Puppet::Type::Package.create(:name => pkg, :install => true)
}
assert_nothing_raised {
pkg.retrieve
@@ -96,7 +96,7 @@ class TestPackages < Test::Unit::TestCase
installedpkgs().each { |pkg|
obj = nil
assert_nothing_raised {
- obj = Puppet.type(:package).create(
+ obj = Puppet::Type::Package.create(
:name => pkg
)
}
@@ -114,7 +114,7 @@ class TestPackages < Test::Unit::TestCase
def test_nosuchpkg
obj = nil
assert_nothing_raised {
- obj = Puppet.type(:package).create(
+ obj = Puppet::Type::Package.create(
:name => "thispackagedoesnotexist"
)
}
@@ -131,7 +131,7 @@ class TestPackages < Test::Unit::TestCase
pkgs = tstpkg || return
pkgs.each { |name|
- pkg = Puppet.type(:package).create(:name => name)
+ pkg = Puppet::Type::Package.create(:name => name)
assert_nothing_raised {
assert(pkg.latest, "Package did not return value for 'latest'")
}
@@ -147,7 +147,7 @@ class TestPackages < Test::Unit::TestCase
# we first set install to 'true', and make sure something gets
# installed
assert_nothing_raised {
- pkg = Puppet.type(:package).create(:name => pkg, :install => true)
+ pkg = Puppet::Type::Package.create(:name => pkg, :install => true)
}
assert_nothing_raised {
pkg.retrieve
@@ -160,7 +160,7 @@ class TestPackages < Test::Unit::TestCase
comp = newcomp("package", pkg)
- assert_events([:package_installed], comp, "package")
+ assert_events(comp, [:package_installed], "package")
# then uninstall it
assert_nothing_raised {
@@ -172,7 +172,7 @@ class TestPackages < Test::Unit::TestCase
assert(! pkg.insync?, "Package is insync")
- assert_events([:package_removed], comp, "package")
+ assert_events(comp, [:package_removed], "package")
# and now set install to 'latest' and verify it installs
# FIXME this isn't really a very good test -- we should install
@@ -181,7 +181,7 @@ class TestPackages < Test::Unit::TestCase
pkg[:install] = "latest"
}
- assert_events([:package_installed], comp, "package")
+ assert_events(comp, [:package_installed], "package")
pkg.retrieve
assert(pkg.insync?, "After install, package is not insync")
@@ -195,7 +195,7 @@ class TestPackages < Test::Unit::TestCase
assert(! pkg.insync?, "Package is insync")
- assert_events([:package_removed], comp, "package")
+ assert_events(comp, [:package_removed], "package")
}
end
end
diff --git a/test/types/query.rb b/test/types/query.rb
index f535686cb..86aadf678 100644
--- a/test/types/query.rb
+++ b/test/types/query.rb
@@ -18,21 +18,21 @@ class TestQuery < Test::Unit::TestCase
def file
assert_nothing_raised() {
cfile = File.join($puppetbase,"examples/root/etc/configfile")
- unless Puppet.type(:file).has_key?(cfile)
- Puppet.type(:file).create(
+ unless Puppet::Type::PFile.has_key?(cfile)
+ Puppet::Type::PFile.create(
:path => cfile,
:check => [:mode, :owner, :checksum]
)
end
- @configfile = Puppet.type(:file)[cfile]
+ @configfile = Puppet::Type::PFile[cfile]
}
return @configfile
end
def service
assert_nothing_raised() {
- unless Puppet.type(:service).has_key?("sleeper")
- Puppet.type(:service).create(
+ unless Puppet::Type::Service.has_key?("sleeper")
+ Puppet::Type::Service.create(
:name => "sleeper",
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
@@ -40,7 +40,7 @@ class TestQuery < Test::Unit::TestCase
:check => [:running]
)
end
- @sleeper = Puppet.type(:service)["sleeper"]
+ @sleeper = Puppet::Type::Service["sleeper"]
}
return @sleeper
@@ -48,7 +48,7 @@ class TestQuery < Test::Unit::TestCase
def component(name,*args)
assert_nothing_raised() {
- @component = Puppet.type(:component).create(:name => name)
+ @component = Puppet::Type::Component.create(:name => name)
}
args.each { |arg|
diff --git a/test/types/service.rb b/test/types/service.rb
index 30543ea12..99384cf0b 100644
--- a/test/types/service.rb
+++ b/test/types/service.rb
@@ -17,7 +17,6 @@ class TestService < Test::Unit::TestCase
super
sleeper = nil
script = File.join($puppetbase,"examples/root/etc/init.d/sleeper")
- @init = File.join($puppetbase,"examples/root/etc/init.d")
@status = script + " status"
end
@@ -30,10 +29,9 @@ class TestService < Test::Unit::TestCase
hash[:name] = "sleeper"
hash[:path] = File.join($puppetbase,"examples/root/etc/init.d")
hash[:running] = true
- hash[:hasstatus] = true
- #hash[:type] = "init"
+ hash[:type] = "init"
assert_nothing_raised() {
- return Puppet.type(:service).create(hash)
+ return Puppet::Type::Service.create(hash)
}
end
@@ -42,10 +40,9 @@ class TestService < Test::Unit::TestCase
sleeper.retrieve
}
assert(!sleeper.insync?())
-
- comp = newcomp(sleeper)
-
- assert_events([:service_started], comp)
+ assert_nothing_raised() {
+ sleeper.sync
+ }
assert_nothing_raised() {
sleeper.retrieve
}
@@ -66,7 +63,9 @@ class TestService < Test::Unit::TestCase
sleeper.retrieve
}
assert(!sleeper.insync?())
- assert_events([:service_stopped], comp)
+ assert_nothing_raised() {
+ sleeper.sync
+ }
assert_nothing_raised() {
sleeper.retrieve
}
@@ -84,26 +83,18 @@ class TestService < Test::Unit::TestCase
cyclesleeper(sleeper)
end
- def test_invalidpathsremoved
- sleeper = mksleeper()
- fakedir = [@init, "/thisdirnoexist"]
- sleeper[:path] = fakedir
-
- assert(! sleeper[:path].include?(fakedir))
+ unless Process.uid == 0
+ puts "run as root to test service enable/disable"
+ else
+ case Puppet::Type::Service.defaulttype
+ when Puppet::ServiceTypes::InitSvc
+ when Puppet::ServiceTypes::SMFSvc
+ # yay
+ else
+ Puppet.notice "Not testing service type %s" %
+ Puppet::Type::Service.defaulttype
+ end
end
-
- #unless Process.uid == 0
- # puts "run as root to test service enable/disable"
- #else
- # case Puppet.type(:service).defaulttype
- # when Puppet::ServiceTypes::InitSvc
- # when Puppet::ServiceTypes::SMFSvc
- # # yay
- # else
- # Puppet.notice "Not testing service type %s" %
- # Puppet.type(:service).defaulttype
- # end
- #end
end
# $Id$
diff --git a/test/types/symlink.rb b/test/types/symlink.rb
index ecaf8d3ae..3d288bc0a 100755
--- a/test/types/symlink.rb
+++ b/test/types/symlink.rb
@@ -41,7 +41,7 @@ class TestSymlink < Test::Unit::TestCase
unless hash.include?(:target)
hash[:target] = mktmpfile()
end
- link = Puppet.type(:symlink).create(hash)
+ link = Puppet::Type::Symlink.create(hash)
return link
end
@@ -56,7 +56,9 @@ class TestSymlink < Test::Unit::TestCase
}
# we might already be in sync
assert(!link.insync?())
- assert_apply(link)
+ assert_nothing_raised() {
+ link.sync
+ }
assert_nothing_raised() {
link.retrieve
}
diff --git a/test/types/tidy.rb b/test/types/tidy.rb
index b61c68b14..02068b6ff 100755
--- a/test/types/tidy.rb
+++ b/test/types/tidy.rb
@@ -37,7 +37,7 @@ class TestTidy < Test::Unit::TestCase
f.puts rand(100)
}
- tidy = Puppet.type(:tidy).create(
+ tidy = Puppet::Type::Tidy.create(
:name => dir,
:size => "1b",
:recurse => true
@@ -67,7 +67,7 @@ class TestTidy < Test::Unit::TestCase
f.puts rand(100)
}
- tidy = Puppet.type(:tidy).create(
+ tidy = Puppet::Type::Tidy.create(
:name => dir,
:size => "1b",
:age => "1s",
diff --git a/test/types/type.rb b/test/types/type.rb
index ecb623123..87ca8077a 100644
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -52,7 +52,7 @@ class TestType < Test::Unit::TestCase
path = tempfile()
assert_nothing_raised() {
system("rm -f %s" % path)
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
:path => path,
:create => true,
:recurse => true,
@@ -63,12 +63,12 @@ class TestType < Test::Unit::TestCase
file.retrieve
}
assert_nothing_raised() {
- file.evaluate
+ file.sync
}
- Puppet.type(:file).clear
+ Puppet::Type::PFile.clear
assert_nothing_raised() {
system("rm -f %s" % path)
- file = Puppet.type(:file).create(
+ file = Puppet::Type::PFile.create(
"path" => path,
"create" => true,
"recurse" => true,
@@ -91,7 +91,7 @@ class TestType < Test::Unit::TestCase
file["recurse"]
}
assert_nothing_raised() {
- file.evaluate
+ file.sync
}
end
@@ -102,7 +102,7 @@ class TestType < Test::Unit::TestCase
# currently groups are the only objects with the namevar as a state
group = nil
assert_nothing_raised {
- group = Puppet.type(:group).create(
+ group = Puppet::Type::Group.create(
:name => "testing"
)
}
@@ -116,7 +116,7 @@ class TestType < Test::Unit::TestCase
# Create the first version
assert_nothing_raised {
- Puppet.type(:file).create(
+ Puppet::Type::PFile.create(
:path => file,
:owner => ["root", "bin"]
)
@@ -124,7 +124,7 @@ class TestType < Test::Unit::TestCase
# Make sure no other statements are allowed
assert_raise(Puppet::Error) {
- Puppet.type(:file).create(
+ Puppet::Type::PFile.create(
:path => file,
:group => "root"
)
diff --git a/test/types/user.rb b/test/types/user.rb
index db2acf52a..4408cfa4b 100755
--- a/test/types/user.rb
+++ b/test/types/user.rb
@@ -42,7 +42,7 @@ class TestUser < Test::Unit::TestCase
end
def current?(param, name)
- state = Puppet.type(:user).states.find { |st|
+ state = Puppet::Type::User.states.find { |st|
st.name == param
}
@@ -80,7 +80,7 @@ class TestUser < Test::Unit::TestCase
end
def current?(param, name)
- state = Puppet.type(:user).states.find { |st|
+ state = Puppet::Type::User.states.find { |st|
st.name == param
}
@@ -112,7 +112,7 @@ class TestUser < Test::Unit::TestCase
def mkuser(name)
user = nil
assert_nothing_raised {
- user = Puppet.type(:user).create(
+ user = Puppet::Type::User.create(
:name => name,
:comment => "Puppet Testing User",
:gid => Process.gid,
@@ -130,7 +130,7 @@ class TestUser < Test::Unit::TestCase
comp = newcomp("commenttest", user)
- trans = assert_events([:user_modified], comp, "user")
+ trans = assert_events(comp, [:user_modified], "user")
assert_equal("A different comment", current?(:comment, user[:name]),
"Comment was not changed")
@@ -148,11 +148,11 @@ class TestUser < Test::Unit::TestCase
old = current?(:home, user[:name])
user[:home] = old
- trans = assert_events([], comp, "user")
+ trans = assert_events(comp, [], "user")
user[:home] = "/tmp"
- trans = assert_events([:user_modified], comp, "user")
+ trans = assert_events(comp, [:user_modified], "user")
assert_equal("/tmp", current?(:home, user[:name]), "Home was not changed")
@@ -167,7 +167,7 @@ class TestUser < Test::Unit::TestCase
user[:shell] = old
- trans = assert_events([], comp, "user")
+ trans = assert_events(comp, [], "user")
newshell = findshell(old)
@@ -178,7 +178,7 @@ class TestUser < Test::Unit::TestCase
user[:shell] = newshell
- trans = assert_events([:user_modified], comp, "user")
+ trans = assert_events(comp, [:user_modified], "user")
assert_equal(newshell, current?(:shell, user[:name]),
"Shell was not changed")
@@ -197,7 +197,7 @@ class TestUser < Test::Unit::TestCase
user[:gid] = old
- trans = assert_events([], comp, "user")
+ trans = assert_events(comp, [], "user")
newgid = %w{nogroup nobody staff users daemon}.find { |gid|
begin
@@ -218,7 +218,7 @@ class TestUser < Test::Unit::TestCase
user[:gid] = newgid
}
- trans = assert_events([:user_modified], comp, "user")
+ trans = assert_events(comp, [:user_modified], "user")
# then by id
newgid = Etc.getgrnam(newgid).gid
@@ -229,7 +229,7 @@ class TestUser < Test::Unit::TestCase
user.retrieve
- assert_events([], comp, "user")
+ assert_events(comp, [], "user")
assert_equal(newgid, current?(:gid,user[:name]), "GID was not changed")
@@ -245,7 +245,7 @@ class TestUser < Test::Unit::TestCase
old = current?(:uid, user[:name])
user[:uid] = old
- trans = assert_events([], comp, "user")
+ trans = assert_events(comp, [], "user")
newuid = old
while true
@@ -266,7 +266,7 @@ class TestUser < Test::Unit::TestCase
user[:uid] = newuid
}
- trans = assert_events([:user_modified], comp, "user")
+ trans = assert_events(comp, [:user_modified], "user")
assert_equal(newuid, current?(:uid, user[:name]), "UID was not changed")
@@ -281,7 +281,7 @@ class TestUser < Test::Unit::TestCase
assert(obj, "Could not retrieve test group object")
- Puppet.type(:user).validstates.each { |name|
+ Puppet::Type::User.validstates.each { |name|
assert_nothing_raised {
method = state.posixmethod
assert(method, "State %s has no infomethod" % name)
@@ -301,8 +301,8 @@ class TestUser < Test::Unit::TestCase
}
user = nil
assert_nothing_raised {
- checks = Puppet.type(:user).validstates
- user = Puppet.type(:user).create(
+ checks = Puppet::Type::User.validstates
+ user = Puppet::Type::User.create(
:name => name,
:check => checks
)
@@ -327,7 +327,7 @@ class TestUser < Test::Unit::TestCase
comp = newcomp("usercomp", user)
- trans = assert_events([:user_created], comp, "user")
+ trans = assert_events(comp, [:user_created], "user")
assert_equal("Puppet Testing User", current?(:comment, user[:name]),
"Comment was not set")
@@ -349,12 +349,12 @@ class TestUser < Test::Unit::TestCase
comp = newcomp("usercomp", user)
- trans = assert_events([:user_created], comp, "user")
+ trans = assert_events(comp, [:user_created], "user")
assert_equal("Puppet Testing User", current?(:comment, user[:name]),
"Comment was not set")
- tests = Puppet.type(:user).validstates
+ tests = Puppet::Type::User.validstates
user.retrieve
tests.each { |test|