summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/puppetca.rb115
-rwxr-xr-xtest/executables/puppetmasterd.rb147
-rwxr-xr-xtest/language/parser.rb11
-rwxr-xr-xtest/language/snippets.rb33
-rwxr-xr-xtest/lib/puppettest.rb4
-rw-r--r--test/lib/puppettest/exetest.rb1
-rw-r--r--test/lib/puppettest/support/utils.rb6
-rwxr-xr-xtest/network/client/ca.rb1
-rwxr-xr-xtest/network/client/master.rb18
-rwxr-xr-xtest/network/client/resource.rb5
-rwxr-xr-xtest/network/handler/fileserver.rb4
-rwxr-xr-xtest/network/handler/master.rb2
-rwxr-xr-xtest/network/handler/resource.rb98
-rwxr-xr-xtest/network/server/webrick.rb5
-rwxr-xr-xtest/other/relationships.rb11
-rwxr-xr-xtest/other/transactions.rb30
-rwxr-xr-xtest/ral/manager/instances.rb16
-rwxr-xr-xtest/ral/manager/type.rb161
-rwxr-xr-xtest/ral/providers/group.rb1
-rwxr-xr-xtest/ral/type/basic.rb85
-rwxr-xr-xtest/ral/type/cron.rb13
-rwxr-xr-xtest/ral/type/exec.rb6
-rwxr-xr-xtest/ral/type/file.rb128
-rwxr-xr-xtest/ral/type/file/target.rb24
-rwxr-xr-xtest/ral/type/filebucket.rb51
-rwxr-xr-xtest/ral/type/fileignoresource.rb11
-rwxr-xr-xtest/ral/type/filesources.rb166
-rwxr-xr-xtest/ral/type/group.rb1
-rwxr-xr-xtest/ral/type/host.rb13
-rwxr-xr-xtest/ral/type/parameter.rb2
-rwxr-xr-xtest/ral/type/sshkey.rb53
-rwxr-xr-xtest/ral/type/tidy.rb2
-rwxr-xr-xtest/ral/type/user.rb1
-rwxr-xr-xtest/ral/type/yumrepo.rb17
-rwxr-xr-xtest/util/filetype.rb4
-rwxr-xr-xtest/util/posixtest.rb10
-rwxr-xr-xtest/util/settings.rb63
-rwxr-xr-xtest/util/utiltest.rb19
38 files changed, 216 insertions, 1122 deletions
diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb
deleted file mode 100755
index cdc827079..000000000
--- a/test/executables/puppetca.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppettest'
-require 'mocha'
-
-class TestPuppetCA < Test::Unit::TestCase
- include PuppetTest::ExeTest
-
- def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
- end
-
- def gen_cert(ca, host)
- runca("-g #{host}")
- ca.getclientcert(host)[0]
- end
-
- def mkca
- Puppet::Network::Handler.ca.new()
- end
-
- def mkcert(hostname)
- cert = nil
- assert_nothing_raised {
- cert = Puppet::SSLCertificates::Certificate.new(
- :name => hostname
- )
- cert.mkcsr
- }
-
- return cert
- end
-
- def runca(args)
- debug = ""
- if Puppet[:debug]
- debug = "-d "
- end
- return %x{puppetca --user=#{Puppet[:user]} #{debug} --group=#{Puppet[:group]} --confdir=#{Puppet[:confdir]} --vardir=#{Puppet[:vardir]} #{args} 2>&1}
- end
-
- def test_signing
- ca = mkca
- Puppet[:autosign] = false
-
- %w{host.test.com Other.Testing.Com}.each do |host|
- cert = mkcert(host)
- resp = nil
- assert_nothing_raised {
- # We need to use a fake name so it doesn't think the cert is from
- # itself. Strangely, getcert stores the csr, because it's a server-side
- # method, not client.
- resp = ca.getcert(cert.csr.to_pem, host, "127.0.0.1")
- }
- assert_equal(["",""], resp)
-
- output = nil
- assert_nothing_raised {
- output = runca("--list").chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb
- }
- assert_equal($?,0)
- assert_equal([host.downcase], output)
- assert_nothing_raised {
- output = runca("--sign -a").chomp.split("\n")
- }
-
-
- assert_equal($?,0)
- assert_equal(["Signed #{host.downcase}"], output)
-
-
- signedfile = ca.ca.host2certfile(host)
- assert(FileTest.exists?(signedfile), "cert does not exist")
- assert(! FileTest.executable?(signedfile), "cert is executable")
-
- uid = Puppet::Util.uid(Puppet[:user])
-
- if Puppet::Util::SUIDManager.uid == 0
- assert(! FileTest.owned?(signedfile), "cert is owned by root")
- end
- assert_nothing_raised {
- output = runca("--list").chomp.split("\n")
- }
- assert_equal($?,0)
- assert_equal(["No certificates to sign"], output)
- end
- end
-
- # This method takes a long time to run because of all of the external
- # executable calls.
- def test_revocation
- ca = Puppet::SSLCertificates::CA.new()
- host1 = gen_cert(ca, "host1.example.com")
- host2 = gen_cert(ca, "host2.example.com")
- host3 = gen_cert(ca, "host3.example.com")
- runca("-r host1.example.com")
- runca("-r #{host2.serial}")
- runca("-r 0x#{host3.serial.to_s(16)}")
- runca("-r 0xff")
-
- # Recreate CA to force reading of CRL
- ca = Puppet::SSLCertificates::CA.new()
- crl = ca.crl
- revoked = crl.revoked.collect { |r| r.serial }
- exp = [host1.serial, host2.serial, host3.serial, 255]
- assert_equal(exp, revoked)
- end
-
- def test_case_insensitive_sign
- end
-end
-
diff --git a/test/executables/puppetmasterd.rb b/test/executables/puppetmasterd.rb
deleted file mode 100755
index 6d4ddf56f..000000000
--- a/test/executables/puppetmasterd.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppet'
-require 'puppet/network/client'
-require 'puppettest'
-require 'socket'
-
-class TestPuppetMasterD < Test::Unit::TestCase
- include PuppetTest::ExeTest
- def setup
- super
- Puppet[:certdnsnames] = "localhost"
- end
-
- def getcerts
- include Puppet::Daemon
- if self.readcerts
- return [@cert, @key, @cacert, @cacertfile]
- else
- raise "Couldn't read certs"
- end
- end
-
- # start the daemon and verify it responds and such
- def test_normalstart
- startmasterd
-
- pidfile = File.join(Puppet[:vardir], "run", "puppetmasterd.pid")
- assert(FileTest.exists?(pidfile), "PID file does not exist")
-
- sleep(1)
- assert_nothing_raised {
- socket = TCPSocket.new("127.0.0.1", @@port)
- socket.close
- }
-
- client = nil
- assert_nothing_raised() {
- client = Puppet::Network::Client.status.new(
- :Server => "localhost",
- :Port => @@port
- )
- }
-
- # set our client up to auto-sign
- assert(Puppet[:autosign] =~ /^#{File::SEPARATOR}/,
- "Autosign is set to %s, not a file" % Puppet[:autosign])
-
- FileUtils.mkdir_p(File.dirname(Puppet[:autosign]))
- File.open(Puppet[:autosign], "w") { |f|
- f.puts Puppet[:certname]
- }
-
- retval = nil
-
- # init the client certs
- assert_nothing_raised() {
- client.cert
- }
-
- # call status
- assert_nothing_raised() {
- retval = client.status
- }
- assert_equal(1, retval, "Status.status return value was %s" % retval)
-
- # this client shoulduse the same certs
- assert_nothing_raised() {
- client = Puppet::Network::Client.master.new(
- :Server => "localhost",
- :Port => @@port
- )
- }
- assert_nothing_raised() {
- retval = client.getconfig
- }
-
- objects = nil
- end
-
- # verify that we can run puppetmasterd in parse-only mode
- def test_parseonly
- startmasterd("--parseonly > /dev/null")
- sleep(1)
-
- pid = nil
- ps = Facter["ps"].value || "ps -ef"
- %x{#{ps}}.chomp.split(/\n/).each { |line|
- next if line =~ /^puppet/ # skip normal master procs
- if line =~ /puppetmasterd.+--manifest/
- ary = line.split(" ")
- pid = ary[1].to_i
- end
- }
-
- assert($? == 0, "Puppetmasterd ended with non-zero exit status")
-
- assert_nil(pid, "Puppetmasterd is still running after parseonly")
- end
-
- def disabled_test_sslconnection
- #file = File.join(exampledir, "code", "head")
- #startmasterd("--manifest #{file}")
-
- #assert_nothing_raised {
- # socket = TCPSocket.new("127.0.0.1", Puppet[:masterport])
- # socket.close
- #}
-
- client = nil
- cert, key, cacert, cacertfile = getcerts()
-
- assert_nothing_raised() {
- client = Net::HTTP.new("localhost", Puppet[:masterport])
- client.cert = cert
- client.key = key
- client.ca_file = cacertfile
- client.use_ssl = true
- client.start_immediately = true
- }
- retval = nil
-
- assert_nothing_raised() {
- retval = client.nothing
- }
- assert_equal(1, retval, "return value was %s" % retval)
- facts = {}
- Facter.each { |p,v|
- facts[p] = v
- }
- textfacts = CGI.escape(YAML.dump(facts))
- assert_nothing_raised() {
- #Puppet.notice "calling status"
- #retval = client.call("status.status", "")
- retval = client.call("puppetmaster.getconfig", textfacts, "yaml")
- }
-
- objects = nil
- assert_nothing_raised {
- YAML.load(CGI.unescape(retval))
- }
- #stopmasterd
- end
-end
-
diff --git a/test/language/parser.rb b/test/language/parser.rb
index cdd13297a..effb2d40c 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -26,15 +26,6 @@ class TestParser < Test::Unit::TestCase
parser.file = file
parser.parse
}
-
- Puppet::Type.eachtype { |type|
- type.each { |obj|
- assert(obj.file, "File is not set on %s" % obj.ref)
- assert(obj.name, "Name is not set on %s" % obj.ref)
- assert(obj.line, "Line is not set on %s" % obj.ref)
- }
- }
- Puppet::Type.allclear
}
end
@@ -49,7 +40,6 @@ class TestParser < Test::Unit::TestCase
config.compile
#ast.classes[""].evaluate config.topscope
}
- Puppet::Type.allclear
}
end
@@ -680,7 +670,6 @@ file { "/tmp/yayness":
manifest = File.join(modpath, "manifest.pp")
manifest_texts.each do |txt|
- Puppet::Type.allclear
File.open(manifest, "w") { |f| f.puts txt }
assert_nothing_raised {
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 982ddfec4..95a518388 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -24,14 +24,14 @@ class TestSnippets < Test::Unit::TestCase
end
def assert_file(path, msg = nil)
- unless file = @file[path]
+ unless file = @catalog.resource(:file, path)
msg ||= "Could not find file %s" % path
raise msg
end
end
def assert_mode_equal(mode, path)
- unless file = @file[path]
+ unless file = @catalog.resource(:file, path)
raise "Could not find file %s" % path
end
@@ -213,8 +213,8 @@ class TestSnippets < Test::Unit::TestCase
path1 = "/tmp/argumenttest1"
path2 = "/tmp/argumenttest2"
- file1 = @file[path1]
- file2 = @file[path2]
+ file1 = @catalog.resource(:file, path1)
+ file2 = @catalog.resource(:file, path2)
assert_file(path1)
assert_mode_equal(0755, path1)
@@ -233,7 +233,7 @@ class TestSnippets < Test::Unit::TestCase
}
paths.each { |path|
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert(file, "File %s is missing" % path)
assert_mode_equal(0755, path)
}
@@ -243,7 +243,7 @@ class TestSnippets < Test::Unit::TestCase
paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l }
paths.each { |path|
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert_file(path)
assert_mode_equal(0755, path)
}
@@ -264,7 +264,7 @@ class TestSnippets < Test::Unit::TestCase
dir = "/tmp/testdirtest"
assert_file(file)
assert_file(dir)
- assert_equal(:directory, @file[dir].should(:ensure), "Directory is not set to be a directory")
+ assert_equal(:directory, @catalog.resource(:file, dir).should(:ensure), "Directory is not set to be a directory")
end
def snippet_scopetest
@@ -351,7 +351,7 @@ class TestSnippets < Test::Unit::TestCase
}.each { |count, str|
path = "/tmp/singlequote%s" % count
assert_file(path)
- assert_equal(str, @file[path].should(:content))
+ assert_equal(str, @catalog.resource(:file, path).should(:content))
}
end
@@ -389,21 +389,20 @@ class TestSnippets < Test::Unit::TestCase
end
def snippet_emptyexec
- assert(Puppet::Type.type(:exec)["touch /tmp/emptyexectest"],
- "Did not create exec")
+ assert(@catalog.resource(:exec, "touch /tmp/emptyexectest"), "Did not create exec")
end
def snippet_multisubs
path = "/tmp/multisubtest"
assert_file(path)
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert_equal("sub2", file.should(:content), "sub2 did not override content")
assert_mode_equal(0755, path)
end
def snippet_collection
assert_file("/tmp/colltest1")
- assert_nil(@file["/tmp/colltest2"], "Incorrectly collected file")
+ assert_nil(@catalog.resource(:file, "/tmp/colltest2"), "Incorrectly collected file")
end
def snippet_virtualresources
@@ -476,16 +475,6 @@ class TestSnippets < Test::Unit::TestCase
catalog = catalog.to_ral
}
- Puppet::Type.eachtype { |type|
- type.each { |obj|
- # don't worry about this for now
- #unless obj.name == "puppet[top]" or
- # obj.is_a?(Puppet.type(:schedule))
- # assert(obj.parent, "%s has no parent" % obj.name)
- #end
- assert(obj.name)
- }
- }
@catalog = catalog
assert_nothing_raised {
self.send(mname)
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 63f8121b5..1f4432d00 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -233,6 +233,7 @@ module PuppetTest
end
f = File.join(self.tmpdir(), "tempfile_" + @@tmpfilenum.to_s)
+ @@tmpfiles ||= []
@@tmpfiles << f
return f
end
@@ -298,11 +299,10 @@ module PuppetTest
@@tmppids.clear
- Puppet::Type.allclear
Puppet::Util::Storage.clear
Puppet.clear
Puppet.settings.clear
- Puppet::Indirector::Indirection.clear_cache
+ Puppet::Util::Cacher.invalidate
@memoryatend = Puppet::Util.memory
diff = @memoryatend - @memoryatstart
diff --git a/test/lib/puppettest/exetest.rb b/test/lib/puppettest/exetest.rb
index 05de56c0f..0d66c5a07 100644
--- a/test/lib/puppettest/exetest.rb
+++ b/test/lib/puppettest/exetest.rb
@@ -58,7 +58,6 @@ module PuppetTest::ExeTest
args += " --masterport %s" % @@port
args += " --user %s" % Puppet::Util::SUIDManager.uid
args += " --group %s" % Puppet::Util::SUIDManager.gid
- args += " --nonodes"
args += " --autosign true"
#if Puppet[:debug]
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index cb4a6924c..b749c7931 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -42,12 +42,6 @@ module PuppetTest::Support::Utils
# stop any services that might be hanging around
def stopservices
- if stype = Puppet::Type.type(:service)
- stype.each { |service|
- service[:ensure] = :stopped
- service.evaluate
- }
- end
end
# TODO: rewrite this to use the 'etc' module.
diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb
index 56419b645..1741c850a 100755
--- a/test/network/client/ca.rb
+++ b/test/network/client/ca.rb
@@ -36,6 +36,7 @@ class TestClientCA < Test::Unit::TestCase
Puppet.settings.stubs(:value).with(:http_proxy_host).returns(nil)
Puppet.settings.stubs(:value).with(:http_proxy_port).returns(nil)
Puppet.settings.stubs(:value).with(:http_keepalive).returns(false)
+ Puppet.settings.stubs(:value).with(:configtimeout).returns(180)
# Just throw an error; the important thing is the values, not what happens next.
Net::HTTP.stubs(:new).with("myca", 321, nil, nil).raises(ArgumentError)
diff --git a/test/network/client/master.rb b/test/network/client/master.rb
index 9f71247fa..5399fca13 100755
--- a/test/network/client/master.rb
+++ b/test/network/client/master.rb
@@ -421,24 +421,6 @@ end
assert_equal(facts["environment"], Puppet[:environment], "Did not add environment to client facts")
end
- # This is partially to fix #532, but also to save on memory.
- def test_remove_objects_after_every_run
- client = mkclient
-
- ftype = Puppet::Type.type(:file)
- file = ftype.create :title => "/what/ever", :ensure => :present
- config = Puppet::Node::Catalog.new
- config.add_resource(file)
-
- config.expects :apply
-
- client.catalog = config
- client.expects(:getconfig)
- client.run
-
- assert_nil(ftype[@createdfile], "file object was not removed from memory")
- end
-
# #685
def test_http_failures_do_not_kill_puppetd
client = mkclient
diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb
index eb8e829eb..f3c564d9d 100755
--- a/test/network/client/resource.rb
+++ b/test/network/client/resource.rb
@@ -38,7 +38,6 @@ class TestResourceClient < Test::Unit::TestCase
assert_instance_of(Puppet::TransObject, tobj)
- Puppet::Type.allclear
obj = nil
assert_nothing_raised {
obj = tobj.to_type
@@ -49,7 +48,6 @@ class TestResourceClient < Test::Unit::TestCase
File.unlink(file)
# Now test applying
- Puppet::Type.allclear
result = nil
assert_nothing_raised {
result = client.apply(tobj)
@@ -57,7 +55,6 @@ class TestResourceClient < Test::Unit::TestCase
assert(FileTest.exists?(file), "File was not created on apply")
# Lastly, test "list"
- Puppet::Type.allclear
list = nil
assert_nothing_raised {
list = client.list("user")
@@ -70,14 +67,12 @@ class TestResourceClient < Test::Unit::TestCase
break if count > 3
assert_instance_of(Puppet::TransObject, tobj)
- Puppet::Type.allclear
tobj2 = nil
assert_nothing_raised {
tobj2 = client.describe(tobj.type, tobj.name)
}
obj = nil
- Puppet::Type.allclear
assert_nothing_raised {
obj = tobj2.to_type
}
diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb
index a705dbf4b..b3a9aef2b 100755
--- a/test/network/handler/fileserver.rb
+++ b/test/network/handler/fileserver.rb
@@ -146,10 +146,6 @@ class TestFileServer < Test::Unit::TestCase
list = server.list(sfile, :manage, true, false)
}
- assert_nothing_raised {
- file = Puppet.type(:file)[tmpfile]
- }
-
output = "/\tfile"
# verify it got listed as a file
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 448667b73..17bf1b3cc 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -18,7 +18,7 @@ class TestMaster < Test::Unit::TestCase
def teardown
super
- Puppet::Indirector::Indirection.clear_cache
+ Puppet::Util::Cacher.invalidate
end
def test_freshness_is_always_now
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
index 00a88b57f..269c9571c 100755
--- a/test/network/handler/resource.rb
+++ b/test/network/handler/resource.rb
@@ -13,7 +13,6 @@ class TestResourceServer < Test::Unit::TestCase
def verify_described(type, described)
described.each do |name, trans|
- type.clear
obj = nil
assert_nothing_raised do
obj = trans.to_type
@@ -28,7 +27,6 @@ class TestResourceServer < Test::Unit::TestCase
assert_equal(Puppet::Type.type(:package).defaultprovider.name, obj[:provider])
end
end
- type.clear
end
def test_describe_file
@@ -42,71 +40,38 @@ class TestResourceServer < Test::Unit::TestCase
server = Puppet::Network::Handler.resource.new()
end
- # The first run we create the file on the copy, the second run
- # the file is already there so the object should be in sync
- 2.times do |i|
- [ [nil],
- [[:content, :mode], []],
- [[], [:content]],
- [[:content], [:mode]]
- ].each do |ary|
- retrieve = ary[0] || []
- ignore = ary[1] || []
-
- File.open(file, "w") { |f| f.print str }
-
- result = nil
- assert_nothing_raised do
- result = server.describe("file", file, *ary)
- end
-
- assert(result, "Could not retrieve file information")
-
- assert_instance_of(Puppet::TransObject, result)
+ [ [nil],
+ [[:content, :mode], []],
+ [[], [:content]],
+ [[:content], [:mode]]
+ ].each do |ary|
+ retrieve = ary[0] || []
+ ignore = ary[1] || []
- # Now we have to clear, so that the server's object gets removed
- Puppet::Type.type(:file).clear
+ File.open(file, "w") { |f| f.print str }
- # And remove the file, so we can verify it gets recreated
- if i == 0
- File.unlink(file)
- end
-
- object = nil
- assert_nothing_raised do
- object = result.to_type
- end
+ result = nil
+ assert_nothing_raised do
+ result = server.describe("file", file, *ary)
+ end
- assert(object, "Could not create type")
+ assert(result, "Could not retrieve file information")
- retrieve.each do |property|
- assert(object.should(property), "Did not retrieve %s" % property)
- end
+ assert_instance_of(Puppet::TransObject, result)
- ignore.each do |property|
- assert(! object.should(property), "Incorrectly retrieved %s" % property)
- end
+ object = nil
+ assert_nothing_raised do
+ object = result.to_type
+ end
- if i == 0
- assert_events([:file_created], object)
- else
- assert_nothing_raised {
- assert(object.insync?(object.retrieve), "Object was not in sync")
- }
- end
+ assert(object, "Could not create type")
- assert(FileTest.exists?(file), "File did not get recreated")
+ retrieve.each do |property|
+ assert(object.should(property), "Did not retrieve %s" % property)
+ end
- if i == 0
- if object.should(:content)
- assert_equal(str, File.read(file), "File contents are not the same")
- else
- assert_equal("", File.read(file), "File content was incorrectly made")
- end
- end
- if FileTest.exists? file
- File.unlink(file)
- end
+ ignore.each do |property|
+ assert(! object.should(property), "Incorrectly retrieved %s" % property)
end
end
end
@@ -140,9 +105,6 @@ class TestResourceServer < Test::Unit::TestCase
assert_instance_of(Puppet::TransObject, result)
- # Now we have to clear, so that the server's object gets removed
- Puppet::Type.type(:file).clear
-
# And remove the file, so we can verify it gets recreated
Dir.rmdir(file)
@@ -151,6 +113,8 @@ class TestResourceServer < Test::Unit::TestCase
object = result.to_type
end
+ catalog = mk_catalog(object)
+
assert(object, "Could not create type")
retrieve.each do |property|
@@ -160,11 +124,6 @@ class TestResourceServer < Test::Unit::TestCase
ignore.each do |property|
assert(! object.should(property), "Incorrectly retrieved %s" % property)
end
-
- #assert_apply(object)
- assert_events([:directory_created], object)
- assert(FileTest.directory?(file), "Directory did not get recreated")
- Dir.rmdir(file)
end
end
@@ -198,8 +157,6 @@ class TestResourceServer < Test::Unit::TestCase
bucket = server.list(type.name)
}
- #type.clear
-
count = 0
described = {}
bucket.each do |obj|
@@ -251,8 +208,6 @@ class TestResourceServer < Test::Unit::TestCase
filetrans = server.describe("file", file)
}
- Puppet::Type.type(:file).clear
-
bucket = Puppet::TransBucket.new
bucket.type = "file"
bucket.name = "test"
@@ -273,7 +228,6 @@ class TestResourceServer < Test::Unit::TestCase
yaml = Base64.encode64(YAML::dump(bucket))
}
- Puppet::Type.type(:file).clear
File.unlink(file)
if Base64.decode64(yaml) =~ /(.{20}Loglevel.{20})/
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index fe6d69ade..0cdade4ba 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -67,7 +67,7 @@ class TestWebrickServer < Test::Unit::TestCase
end
# Test that a client whose cert has been revoked really can't connect
- def test_certificate_revocation
+ def test_xcertificate_revocation
Puppet[:autosign] = true
serverpid, server = mk_status_server
@@ -101,9 +101,6 @@ class TestWebrickServer < Test::Unit::TestCase
def mk_status_client
client = nil
- # Otherwise, the client initalization will trip over itself
- # since elements created in the last run are still around
- Puppet::Type::allclear
assert_nothing_raised() {
client = Puppet::Network::Client.status.new(
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index bf83caf4a..4e666450e 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -81,6 +81,9 @@ class TestRelationships < Test::Unit::TestCase
)
end
+ catalog = mk_catalog(*files)
+ catalog.add_resource(*execs)
+
# Add our first relationship
if out[param]
files[0][param] = execs[0]
@@ -106,8 +109,6 @@ class TestRelationships < Test::Unit::TestCase
execs[0][param], "Incorrect source list")
end
check_relationship(sources, targets, out[param], refreshers.include?(param))
-
- Puppet::Type.allclear
end
end
@@ -166,6 +167,7 @@ class TestRelationships < Test::Unit::TestCase
exec = Puppet::Type.newexec(:title => "myexec", :cwd => path,
:command => "/bin/echo")
+ catalog = mk_catalog(file, exec)
reqs = nil
assert_nothing_raised do
reqs = exec.autorequire
@@ -176,9 +178,8 @@ class TestRelationships < Test::Unit::TestCase
# Now make sure that these relationships are added to the
# relationship graph
- config = mk_catalog(file, exec)
- config.apply do |trans|
- assert(config.relationship_graph.edge?(file, exec), "autorequire edge was not created")
+ catalog.apply do |trans|
+ assert(catalog.relationship_graph.edge?(file, exec), "autorequire edge was not created")
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index a517ac731..28f0d2940 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -598,15 +598,15 @@ class TestTransactions < Test::Unit::TestCase
yay = Puppet::Type.newgenerator :title => "yay"
rah = Puppet::Type.newgenerator :title => "rah"
- config = mk_catalog(yay, rah)
- trans = Puppet::Transaction.new(config)
+ catalog = mk_catalog(yay, rah)
+ trans = Puppet::Transaction.new(catalog)
assert_nothing_raised do
trans.generate
end
%w{ya ra y r}.each do |name|
- assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
+ assert(catalog.resource(:generator, name),
"Generated %s was not a vertex" % name)
assert($finished.include?(name), "%s was not finished" % name)
end
@@ -617,10 +617,8 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(!trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
+ assert(! catalog.resource(:generator, name),
"Generated vertex %s was not removed from graph" % name)
- assert_nil(Puppet::Type.type(:generator)[name],
- "Generated vertex %s was not removed from class" % name)
end
end
@@ -637,8 +635,8 @@ class TestTransactions < Test::Unit::TestCase
yay = Puppet::Type.newgenerator :title => "yay"
rah = Puppet::Type.newgenerator :title => "rah", :subscribe => yay
- config = mk_catalog(yay, rah)
- trans = Puppet::Transaction.new(config)
+ catalog = mk_catalog(yay, rah)
+ trans = Puppet::Transaction.new(catalog)
trans.prepare
@@ -647,7 +645,7 @@ class TestTransactions < Test::Unit::TestCase
assert_nothing_raised("failed to apply yay") do
trans.eval_resource(yay)
end
- ya = type["ya"]
+ ya = catalog.resource(type.name, "ya")
assert(ya, "Did not generate ya")
assert(trans.relationship_graph.vertex?(ya),
"Did not add ya to rel_graph")
@@ -660,11 +658,11 @@ class TestTransactions < Test::Unit::TestCase
# Now make sure it in turn eval_generates appropriately
assert_nothing_raised("failed to apply yay") do
- trans.eval_resource(type["ya"])
+ trans.eval_resource(catalog.resource(type.name, "ya"))
end
%w{y}.each do |name|
- res = type[name]
+ res = catalog.resource(type.name, "ya")
assert(res, "Did not generate %s" % name)
assert(trans.relationship_graph.vertex?(res),
"Did not add %s to rel_graph" % name)
@@ -672,7 +670,7 @@ class TestTransactions < Test::Unit::TestCase
end
assert_nothing_raised("failed to eval_generate with nil response") do
- trans.eval_resource(type["y"])
+ trans.eval_resource(catalog.resource(type.name, "y"))
end
assert(trans.relationship_graph.edge?(yay, ya), "no edge was created for ya => yay")
@@ -680,7 +678,7 @@ class TestTransactions < Test::Unit::TestCase
trans.eval_resource(rah)
end
- ra = type["ra"]
+ ra = catalog.resource(type.name, "ra")
assert(ra, "Did not generate ra")
assert(trans.relationship_graph.vertex?(ra),
"Did not add ra to rel_graph" % name)
@@ -699,14 +697,12 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(!trans.relationship_graph.vertex?(type[name]),
+ assert(!trans.relationship_graph.vertex?(catalog.resource(type.name, name)),
"Generated vertex %s was not removed from graph" % name)
- assert_nil(type[name],
- "Generated vertex %s was not removed from class" % name)
end
# Now, start over and make sure that everything gets evaluated.
- trans = Puppet::Transaction.new(config)
+ trans = Puppet::Transaction.new(catalog)
$evaluated.clear
assert_nothing_raised do
trans.evaluate
diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb
index a50ecb213..5305b3ff3 100755
--- a/test/ral/manager/instances.rb
+++ b/test/ral/manager/instances.rb
@@ -89,21 +89,5 @@ class TestTypeInstances < Test::Unit::TestCase
# Now make sure the resources have an 'ensure' property to go with the value in the provider
assert(resources[:one].send(:instance_variable_get, "@parameters").include?(:ensure), "Did not create ensure property")
end
-
- # Make sure resources are entirely deleted.
- def test_delete
- aliases = %w{one}
- catalog = mk_catalog
- obj = @type.create(:name => "testing", :alias => "two", :catalog => catalog)
- aliases << "two"
-
- @type.alias("two", obj)
-
- obj.remove
- assert_nil(@type["testing"], "Object was not removed from objects hash")
- assert_nil(@type["one"], "Object's alias was not removed")
- assert_nil(@type["two"], "Object's second alias was not removed")
-
- end
end
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index c6efe4f00..f3a116f6f 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -65,7 +65,6 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised() {
file.evaluate
}
- Puppet.type(:file).clear
assert_nothing_raised() {
system("rm -f %s" % path)
file = Puppet.type(:file).create(
@@ -110,47 +109,7 @@ class TestType < Test::Unit::TestCase
assert_equal("testing", group.name, "Could not retrieve name")
end
- # Verify that values get merged correctly
- def test_mergepropertyvalues
- file = tempfile()
-
- # Create the first version
- assert_nothing_raised {
- Puppet.type(:file).create(
- :path => file,
- :owner => ["root", "bin"]
- )
- }
-
- # Make sure no other statements are allowed
- assert_raise(Puppet::Error) {
- Puppet.type(:file).create(
- :path => file,
- :group => "root"
- )
- }
- end
-
- def test_aliases_to_self_are_not_failures
- resource = Puppet.type(:file).create(
- :name => "/path/to/some/missing/file",
- :ensure => "file"
- )
- resource.stubs(:path).returns("")
-
- catalog = stub 'catalog'
- catalog.expects(:resource).with(:file, "/path/to/some/missing/file").returns(resource)
- resource.catalog = catalog
-
- # Verify our adding ourselves as an alias isn't an error.
- assert_nothing_raised("Could not add alias") {
- resource[:alias] = "/path/to/some/missing/file"
- }
-
- assert_equal(resource.object_id, Puppet.type(:file)["/path/to/some/missing/file"].object_id, "Could not retrieve alias to self")
- end
-
- def test_aliases_are_added_to_class_and_catalog
+ def test_aliases_are_added_to_catalog
resource = Puppet.type(:file).create(
:name => "/path/to/some/missing/file",
:ensure => "file"
@@ -165,8 +124,6 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised("Could not add alias") {
resource[:alias] = "funtest"
}
-
- assert_equal(resource.object_id, Puppet.type(:file)["funtest"].object_id, "Could not retrieve alias")
end
def test_aliasing_fails_without_a_catalog
@@ -182,7 +139,7 @@ class TestType < Test::Unit::TestCase
def test_catalogs_are_set_during_initialization_if_present_on_the_transobject
trans = Puppet::TransObject.new("/path/to/some/file", :file)
- trans.catalog = :my_config
+ trans.catalog = stub 'catalog', :resource => nil
resource = trans.to_type
assert_equal(resource.catalog, trans.catalog, "Did not set catalog on initialization")
end
@@ -217,37 +174,6 @@ class TestType < Test::Unit::TestCase
assert(twoobj.requires?(oneobj), "Requirement was not created")
end
- # Verify that names are aliases, not equivalents
- def test_nameasalias
- file = nil
- # Create the parent dir, so we make sure autorequiring the parent dir works
- parentdir = tempfile()
- dir = Puppet.type(:file).create(
- :name => parentdir,
- :ensure => "directory"
- )
- assert_apply(dir)
- path = File.join(parentdir, "subdir")
- name = "a test file"
- transport = Puppet::TransObject.new(name, "file")
- transport[:path] = path
- transport[:ensure] = "file"
- assert_nothing_raised {
- file = transport.to_type
- }
-
- assert_equal(path, file[:path])
- assert_equal(name, file.title)
-
- assert_nothing_raised {
- file.retrieve
- }
-
- assert_apply(file)
-
- assert(Puppet.type(:file)[name], "Could not look up object by name")
- end
-
def test_ensuredefault
user = nil
assert_nothing_raised {
@@ -434,7 +360,6 @@ class TestType < Test::Unit::TestCase
assert_equal(path, file[:name], "Did not get correct name")
file = nil
- Puppet::Type.type(:file).clear
# Now make sure we can specify both and still get the right answers
assert_nothing_raised do
@@ -475,7 +400,6 @@ class TestType < Test::Unit::TestCase
# Now try it using the class method on Type
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
assert_nothing_raised {
obj = Puppet::Type.create(trans)
@@ -487,7 +411,6 @@ class TestType < Test::Unit::TestCase
# Now try the same things with hashes instead of a transobject
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
hash = {
:type => :file,
:title => "Myfile",
@@ -510,7 +433,6 @@ class TestType < Test::Unit::TestCase
# Now try it using the class method on Type
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
assert_nothing_raised {
obj = Puppet::Type.create(hash)
@@ -533,25 +455,6 @@ class TestType < Test::Unit::TestCase
end
end
- def test_title_and_name
- obj = nil
- path = tempfile()
- fileobj = Puppet::Type.type(:file)
-
- assert_nothing_raised do
- obj = fileobj.create(
- :title => "myfile",
- :path => path
- )
- end
-
- assert_equal(obj, fileobj["myfile"],
- "Could not retrieve obj by title")
-
- assert_equal(obj, fileobj[path],
- "Could not retrieve obj by name")
- end
-
# Make sure default providers behave correctly
def test_defaultproviders
# Make a fake type
@@ -577,6 +480,7 @@ class TestType < Test::Unit::TestCase
# Make sure that we can have multiple non-isomorphic objects with the same name,
# but not with isomorphic objects.
def test_isomorphic_names
+ catalog = mk_catalog
# First do execs, since they're not isomorphic.
echo = Puppet::Util.binary "echo"
exec1 = exec2 = nil
@@ -586,37 +490,31 @@ class TestType < Test::Unit::TestCase
:command => "#{echo} funtest"
)
end
+ catalog.add_resource(exec1)
assert_nothing_raised do
exec2 = Puppet::Type.type(:exec).create(
:title => "exec2",
:command => "#{echo} funtest"
)
end
-
- assert_apply(exec1, exec2)
+ catalog.add_resource(exec2)
# Now do files, since they are. This should fail.
file1 = file2 = nil
path = tempfile()
- assert_nothing_raised do
- file1 = Puppet::Type.type(:file).create(
- :title => "file1",
- :path => path,
- :content => "yayness"
- )
- end
-
- # This will fail, but earlier systems will catch it.
- assert_raise(Puppet::Error) do
- file2 = Puppet::Type.type(:file).create(
- :title => "file2",
- :path => path,
- :content => "rahness"
- )
- end
+ file1 = Puppet::Type.type(:file).create(
+ :title => "file1",
+ :path => path,
+ :content => "yayness"
+ )
+ catalog.add_resource(file1)
- assert(file1, "Did not create first file")
- assert_nil(file2, "Incorrectly created second file")
+ file2 = Puppet::Type.type(:file).create(
+ :title => "file2",
+ :path => path,
+ :content => "rahness"
+ )
+ assert_raise(ArgumentError) { catalog.add_resource(file2) }
end
def test_tags
@@ -654,20 +552,6 @@ class TestType < Test::Unit::TestCase
end
end
- # Make sure that classes behave like hashes.
- def test_class_hash_behaviour
- path = tempfile()
-
- filetype = Puppet::Type.type(:file)
- one = Puppet::Type.newfile :path => path
-
- assert_equal(one, filetype[path], "Did not get file back")
-
- assert_raise(Puppet::Error) do
- filetype[path] = one
- end
- end
-
def test_ref
path = tempfile()
Puppet::Type.type(:exec) # uggh, the methods need to load the types
@@ -685,7 +569,7 @@ class TestType < Test::Unit::TestCase
type = Puppet::Type.type(:exec)
mk = Proc.new do |i, hash|
hash[:title] = "exec%s" % i
- hash[:command] = "/bin/echo"
+ hash[:command] = "/bin/echo %s" % i
if parent = hash[:parent]
hash.delete(:parent)
end
@@ -753,7 +637,8 @@ class TestType < Test::Unit::TestCase
# Partially test #704, but also cover the rest of the schedule management bases.
def test_schedule
- Puppet::Type.type(:schedule).create(:name => "maint")
+ schedule = Puppet::Type.type(:schedule).create(:name => "maint")
+ catalog = mk_catalog(schedule)
{"maint" => true, nil => false, :fail => :fail}.each do |name, should|
args = {:name => tempfile, :ensure => :file}
@@ -761,21 +646,27 @@ class TestType < Test::Unit::TestCase
args[:schedule] = name
end
resource = Puppet::Type.type(:file).create(args)
+ catalog.add_resource(resource)
if should == :fail
assert_raise(Puppet::Error, "Did not fail on missing schedule") do
resource.schedule
end
+ elsif should == false
+ assert_nil(resource.schedule, "Set the schedule tho it is set to nil")
else
sched = nil
assert_nothing_raised("Failed when schedule was %s" % sched) do
sched = resource.schedule
end
+ assert(sched, "Did not find schedule %s" % sched.inspect)
+
if should
assert_equal(name, sched.name, "did not get correct schedule back")
end
end
+ catalog.remove_resource(resource)
end
end
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index 18b0866b9..f912ec51a 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -21,7 +21,6 @@ class TestGroupProvider < Test::Unit::TestCase
def teardown
super
- Puppet.type(:group).clear
@@tmpgroups.each { |group|
unless missing?(group)
remove(group)
diff --git a/test/ral/type/basic.rb b/test/ral/type/basic.rb
deleted file mode 100755
index 3c5faeee0..000000000
--- a/test/ral/type/basic.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../lib/puppettest'
-
-require 'puppettest'
-
-class TestBasic < Test::Unit::TestCase
- include PuppetTest
-
- def setup
- super
- @component = nil
- @configfile = nil
- @command = nil
-
- assert_nothing_raised() {
- @component = Puppet.type(:component).create(
- :name => "yaytest",
- :type => "testing"
- )
- }
-
- assert_nothing_raised() {
- @filepath = tempfile()
- @configfile = Puppet.type(:file).create(
- :path => @filepath,
- :ensure => "file",
- :checksum => "md5"
- )
- }
- assert_nothing_raised() {
- @command = Puppet.type(:exec).create(
- :title => "echo",
- :command => "echo yay",
- :path => ENV["PATH"]
- )
- }
- @config = mk_catalog(@component, @configfile, @command)
- @config.add_edge @component, @configfile
- @config.add_edge @component, @command
- end
-
- def teardown
- super
- stopservices
- end
-
- def test_values
- [:ensure, :checksum].each do |param|
- prop = @configfile.property(param)
- assert(prop, "got no property for %s" % param)
- assert(prop.value, "got no value for %s" % param)
- end
- end
-
- def test_name_calls
- [@command, @configfile].each { |obj|
- Puppet.debug "obj is %s" % obj
- assert_nothing_raised(){
- obj.name
- }
- }
- end
-
- def test_name_equality
- assert_equal(@filepath, @configfile.title)
-
- assert_equal("echo", @command.title)
- end
-
- def test_object_retrieval
- [@command, @configfile].each { |obj|
- assert_equal(obj.class[obj.name].object_id, obj.object_id,
- "%s did not match class version" % obj.ref)
- }
- end
-
- def test_paths
- [@configfile, @command, @component].each { |obj|
- assert_nothing_raised {
- assert_instance_of(String, obj.path)
- }
- }
- end
-end
diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb
index 73e941894..8e3d25350 100755
--- a/test/ral/type/cron.rb
+++ b/test/ral/type/cron.rb
@@ -25,7 +25,6 @@ class TestCron < Test::Unit::TestCase
def teardown
super
@crontype.defaultprovider = nil
- Puppet::Util::FileType.filetype(:ram).clear
end
def eachprovider
@@ -145,21 +144,19 @@ class TestCron < Test::Unit::TestCase
next unless prop.name.to_s == "command"
assert(prop.insync?(value), "Property %s is not considered in sync with value %s" % [prop.name, value.inspect])
end
-
- @crontype.clear
end
end
def test_makeandretrievecron
%w{storeandretrieve a-name another-name more_naming SomeName}.each do |name|
cron = mkcron(name)
- comp = mk_catalog(name, cron)
- trans = assert_events([:cron_created], comp, name)
+ catalog = mk_catalog(name, cron)
+ trans = assert_events([:cron_created], catalog, name)
cron.provider.class.prefetch
cron = nil
- assert(cron = Puppet.type(:cron)[name], "Could not retrieve named cron")
+ assert(cron = catalog.resource(:cron, name), "Could not retrieve named cron")
assert_instance_of(Puppet.type(:cron), cron)
end
end
@@ -247,7 +244,6 @@ class TestCron < Test::Unit::TestCase
next unless prop.name.to_s == "minute"
assert(prop.insync?(value), "Property %s is not considered in sync with value %s" % [prop.name, value.inspect])
end
- @crontype.clear
end
end
@@ -294,8 +290,6 @@ class TestCron < Test::Unit::TestCase
# Write it to our file
assert_apply(cron)
- @crontype.clear
-
crons = []
assert_nothing_raised {
@crontype.instances.each do |cron|
@@ -484,7 +478,6 @@ class TestCron < Test::Unit::TestCase
cron = @crontype.create(:name => "space testing", :command => string)
assert_apply(cron)
- cron.class.clear
cron = @crontype.create(:name => "space testing", :command => string)
# Now make sure that it's correctly in sync
diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb
index e2a3dd9ed..8c7c3f69b 100755
--- a/test/ral/type/exec.rb
+++ b/test/ral/type/exec.rb
@@ -22,8 +22,6 @@ class TestExec < Test::Unit::TestCase
def test_numvsstring
[0, "0"].each { |val|
- Puppet.type(:exec).clear
- Puppet.type(:component).clear
command = nil
output = nil
assert_nothing_raised {
@@ -50,13 +48,11 @@ class TestExec < Test::Unit::TestCase
:path => "/usr/bin:/bin:/usr/sbin:/sbin"
)
}
- Puppet.type(:exec).clear
assert_nothing_raised {
command = Puppet.type(:exec).create(
:command => "/bin/echo"
)
}
- Puppet.type(:exec).clear
assert_nothing_raised {
command = Puppet.type(:exec).create(
:command => "/bin/echo",
@@ -242,6 +238,8 @@ class TestExec < Test::Unit::TestCase
:command => "cat %s %s" % [exe, oexe],
:path => ENV["PATH"]
)
+
+ catalog = mk_catalog(file, baseobj, ofile, exec, cat)
rels = nil
assert_nothing_raised do
diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb
index 5cf989aa3..fc7c39796 100755
--- a/test/ral/type/file.rb
+++ b/test/ral/type/file.rb
@@ -30,10 +30,10 @@ class TestFile < Test::Unit::TestCase
@file = Puppet::Type.type(:file)
$method = @method_name
Puppet[:filetimeout] = -1
+ Facter.stubs(:to_hash).returns({})
end
def teardown
- Puppet::Util::Storage.clear
system("rm -rf %s" % Puppet[:statefile])
super
end
@@ -409,7 +409,6 @@ class TestFile < Test::Unit::TestCase
of.puts "some more text, yo"
}
}
- Puppet.type(:file).clear
# now recreate the file
assert_nothing_raised() {
@@ -445,11 +444,6 @@ class TestFile < Test::Unit::TestCase
}
assert_events([:file_changed], file)
- # verify that we're actually getting notified when a file changes
- assert_nothing_raised() {
- Puppet.type(:file).clear
- }
-
if path =~ /nonexists/
File.unlink(path)
end
@@ -492,7 +486,7 @@ class TestFile < Test::Unit::TestCase
# Create a test directory
path = tempfile()
dir = @file.create :path => path, :mode => 0755, :recurse => true
- config = mk_catalog(dir)
+ catalog = mk_catalog(dir)
Dir.mkdir(path)
@@ -505,7 +499,7 @@ class TestFile < Test::Unit::TestCase
test = File.join(path, "file")
File.open(test, "w") { |f| f.puts "yay" }
assert_nothing_raised() { ret = dir.localrecurse(true) }
- fileobj = @file[test]
+ fileobj = catalog.resource(:file, test)
assert(fileobj, "child object was not created")
assert_equal([fileobj], ret, "child object was not returned")
@@ -549,7 +543,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised() { ret = dir.localrecurse(true) }
assert_equal([bad], ret.collect { |f| f.title }, "purge failed")
- badobj = @file[bad]
+ badobj = catalog.resource(:file, bad)
assert(badobj, "did not create bad object")
end
@@ -700,7 +694,6 @@ class TestFile < Test::Unit::TestCase
"Incorrect generated children when recurse == %s" % value.inspect)
File.unlink(tmpfile)
- Puppet.type(:file).clear
end
end
@@ -745,43 +738,6 @@ class TestFile < Test::Unit::TestCase
assert(file.insync?(currentvalues))
end
- def test_remove
- basedir = tempfile()
- subdir = File.join(basedir, "this")
- FileUtils.mkdir_p(subdir)
-
- dir = nil
- assert_nothing_raised {
- dir = Puppet.type(:file).create(
- :path => basedir,
- :recurse => true,
- :check => %w{owner mode group}
- )
- }
- mk_catalog dir
-
- assert_nothing_raised {
- dir.eval_generate
- }
-
- obj = nil
- assert_nothing_raised {
- obj = Puppet.type(:file)[subdir]
- }
-
- assert(obj, "Could not retrieve subdir object")
-
- assert_nothing_raised {
- obj.remove(true)
- }
-
- assert_nothing_raised {
- obj = Puppet.type(:file)[subdir]
- }
-
- assert_nil(obj, "Retrieved removed object")
- end
-
def test_path
dir = tempfile()
@@ -801,15 +757,13 @@ class TestFile < Test::Unit::TestCase
:check => %w{mode owner group}
)
}
- mk_catalog dirobj
+ catalog = mk_catalog dirobj
assert_nothing_raised {
dirobj.eval_generate
}
- assert_nothing_raised {
- file = dirobj.class[path]
- }
+ file = catalog.resource(:file, path)
assert(file, "Could not retrieve file object")
@@ -829,6 +783,7 @@ class TestFile < Test::Unit::TestCase
:name => subfile,
:ensure => "file"
)
+ catalog = mk_catalog(baseobj, subobj)
edge = nil
assert_nothing_raised do
edge = subobj.autorequire.shift
@@ -1062,14 +1017,11 @@ class TestFile < Test::Unit::TestCase
File.open(file, "w", 0411) { |f| f.puts "yayness" }
- obj = nil
- assert_nothing_raised {
- obj = Puppet::Type.type(:file).create(
- :path => file, :content => "rahness\n", :backup => ".puppet-bak"
- )
- }
-
- assert_apply(obj)
+ obj = Puppet::Type.type(:file).create(
+ :path => file, :content => "rahness\n", :backup => ".puppet-bak"
+ )
+ catalog = mk_catalog(obj)
+ catalog.apply
backupfile = file + obj[:backup]
@@tmpfiles << backupfile
@@ -1079,16 +1031,16 @@ class TestFile < Test::Unit::TestCase
assert_equal(0411, filemode(backupfile),
"File mode is wrong for backupfile")
- bucket = "bucket"
+ name = "bucket"
bpath = tempfile()
Dir.mkdir(bpath)
- Puppet::Type.type(:filebucket).create(
- :title => bucket, :path => bpath
- )
+ bucket = Puppet::Type.type(:filebucket).create(:title => name, :path => bpath)
+ catalog.add_resource(bucket)
- obj[:backup] = bucket
+ obj[:backup] = name
obj[:content] = "New content"
- assert_apply(obj)
+ catalog.finalize
+ catalog.apply
md5 = "18cc17fa3047fcc691fdf49c0a7f539a"
dir, file, pathfile = Puppet::Network::Handler.filebucket.paths(bpath, md5)
@@ -1301,8 +1253,6 @@ class TestFile < Test::Unit::TestCase
end
assert_equal("/my/file/for/testing", file.title)
- assert_equal(file, Puppet::Type.type(:file)["/my/file/for/testing"])
- Puppet::Type.type(:file).clear
end
end
@@ -1319,7 +1269,9 @@ class TestFile < Test::Unit::TestCase
assert_equal(dir, File.readlink(link))
obj = Puppet::Type.newfile :path => link, :ensure => :link, :target => file, :recurse => false, :backup => "main"
- assert_apply(obj)
+ catalog = mk_catalog(bucket, obj)
+
+ catalog.apply
assert_equal(file, File.readlink(link))
end
@@ -1367,6 +1319,8 @@ class TestFile < Test::Unit::TestCase
obj = Puppet::Type.newfile :path => path, :force => true,
:links => :manage
+ catalog = mk_catalog(obj, bucket)
+
Puppet[:trace] = true
["main", false].each do |backup|
obj[:backup] = backup
@@ -1495,8 +1449,11 @@ class TestFile < Test::Unit::TestCase
)
assert(dipper, "did not receive bucket client")
file = Puppet::Type.newfile :path => dest, :source => source, :recurse => true, :backup => "rtest"
+
+ catalog = mk_catalog(bucket, file)
- assert_apply(file)
+ catalog.apply
+
dfiles.each do |f|
assert(FileTest.exists?(f), "destfile %s was not created" % f)
end
@@ -1506,7 +1463,7 @@ class TestFile < Test::Unit::TestCase
f.puts "boo: %s" % File.basename(sf)
} }
- assert_apply(file)
+ catalog.apply
dfiles.each do |f|
assert_equal("boo: %s\n" % File.basename(f), File.read(f),
"file was not copied correctly")
@@ -1532,6 +1489,9 @@ class TestFile < Test::Unit::TestCase
def test_backup
path = tempfile()
file = Puppet::Type.newfile :path => path, :content => "yay"
+
+ catalog = mk_catalog(file)
+ catalog.finalize # adds the default resources.
[false, :false, "false"].each do |val|
assert_nothing_raised do
@@ -1561,6 +1521,7 @@ class TestFile < Test::Unit::TestCase
# And then an existing bucket
obj = Puppet::Type.type(:filebucket).create :name => "testing"
+ catalog.add_resource(obj)
bucket = obj.bucket
assert_nothing_raised do
@@ -1576,12 +1537,12 @@ class TestFile < Test::Unit::TestCase
file = File.join(dir, "file")
File.open(file, "w") { |f| f.puts "" }
obj = Puppet::Type.newfile :path => dir, :recurse => true, :mode => 0755
- mk_catalog obj
+ catalog = mk_catalog obj
assert_equal("/%s" % obj.ref, obj.path)
list = obj.eval_generate
- fileobj = obj.class[file]
+ fileobj = catalog.resource(:file, file)
assert(fileobj, "did not generate file object")
assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path")
end
@@ -1596,14 +1557,6 @@ class TestFile < Test::Unit::TestCase
assert(! FileTest.exists?(path), "File was not removed")
end
- # Testing #434
- def test_stripping_extra_slashes_during_lookup
- file = Puppet::Type.newfile(:path => "/one/two")
- %w{/one/two/ /one/two /one//two //one//two//}.each do |path|
- assert(Puppet::Type.type(:file)[path], "could not look up file via path %s" % path)
- end
- end
-
# Testing #438
def test_creating_properties_conflict
file = tempfile()
@@ -1614,7 +1567,6 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised("%s conflicted with ensure" % [param]) do
Puppet::Type.newfile(:path => file, param => first, :ensure => :file)
end
- Puppet::Type.type(:file).clear
params.each do |other|
next if other == param
assert_raise(Puppet::Error, "%s and %s did not conflict" % [param, other]) do
@@ -1687,20 +1639,20 @@ class TestFile < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yay" }
File.chmod(0644, file)
obj = Puppet::Type.newfile(:path => dir, :mode => 0750, :recurse => "2")
- config = mk_catalog(obj)
+ catalog = mk_catalog(obj)
children = nil
assert_nothing_raised("Failure when recursing") do
children = obj.eval_generate
end
- assert(obj.class[subdir], "did not create subdir object")
+ assert(catalog.resource(:file, subdir), "did not create subdir object")
children.each do |c|
assert_nothing_raised("Failure when recursing on %s" % c) do
- c.catalog = config
+ c.catalog = catalog
others = c.eval_generate
end
end
- oobj = obj.class[other]
+ oobj = catalog.resource(:file, other)
assert(oobj, "did not create other object")
assert_nothing_raised do
@@ -1728,12 +1680,12 @@ class TestFile < Test::Unit::TestCase
obj = Puppet::Type.newfile(:path => dir, :ensure => :directory,
:recurse => true)
- config = mk_catalog(obj)
+ catalog = mk_catalog(obj)
children = nil
assert_nothing_raised do
children = obj.eval_generate
end
- fobj = obj.class[file]
+ fobj = catalog.resource(:file, file)
assert(fobj, "did not create file object")
assert(fobj.should(:ensure) != :directory, "ensure was passed to child")
end
diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb
index 035ea905b..b6c84df99 100755
--- a/test/ral/type/file/target.rb
+++ b/test/ral/type/file/target.rb
@@ -46,7 +46,7 @@ class TestFileTarget < Test::Unit::TestCase
def test_linkrecurse
dest = tempfile()
link = @file.create :path => tempfile(), :recurse => true, :ensure => dest
- mk_catalog link
+ catalog = mk_catalog(link)
ret = nil
@@ -64,7 +64,7 @@ class TestFileTarget < Test::Unit::TestCase
assert_equal(:directory, link.should(:ensure), "ensure was not set to directory")
assert_equal([File.join(link.title, "one")], ret.collect { |f| f.title },
"Did not get linked file")
- oneobj = @file[File.join(link.title, "one")]
+ oneobj = catalog.resource(:file, File.join(link.title, "one"))
assert_equal(one, oneobj.should(:target), "target was not set correctly")
oneobj.remove
@@ -83,7 +83,7 @@ class TestFileTarget < Test::Unit::TestCase
"Did not get links back")
returns.each do |path|
- obj = @file[path]
+ obj = catalog.resource(:file, path)
assert(path, "did not get obj for %s" % path)
sdest = File.join(dest, File.basename(path))
assert_equal(sdest, obj.should(:target),
@@ -100,16 +100,14 @@ class TestFileTarget < Test::Unit::TestCase
system("mkdir -p %s" % subdir)
system("touch %s" % file)
- link = nil
- assert_nothing_raised {
- link = Puppet.type(:file).create(
- :ensure => source,
- :path => path,
- :recurse => true
- )
- }
+ link = Puppet.type(:file).create(
+ :ensure => source,
+ :path => path,
+ :recurse => true
+ )
- assert_apply(link)
+ catalog = mk_catalog(link)
+ catalog.apply
sublink = File.join(path, "subdir")
linkpath = File.join(sublink, "file")
@@ -118,7 +116,7 @@ class TestFileTarget < Test::Unit::TestCase
assert(File.symlink?(linkpath), "path is not a link")
assert_equal(file, File.readlink(linkpath))
- assert_nil(@file[sublink], "objects were not removed")
+ assert_nil(catalog.resource(:file, sublink), "objects were not removed")
assert_equal([], link.evaluate, "Link is not in sync")
end
diff --git a/test/ral/type/filebucket.rb b/test/ral/type/filebucket.rb
index f9706663b..28be67b0c 100755
--- a/test/ral/type/filebucket.rb
+++ b/test/ral/type/filebucket.rb
@@ -65,12 +65,9 @@ class TestFileBucket < Test::Unit::TestCase
def test_simplebucket
name = "yayness"
bucketpath = tempfile()
- mkbucket(name, bucketpath)
+ resource = mkbucket(name, bucketpath)
- bucket = nil
- assert_nothing_raised {
- bucket = Puppet.type(:filebucket).bucket(name)
- }
+ bucket = resource.bucket
assert_instance_of(Puppet::Network::Client.dipper, bucket)
@@ -109,49 +106,5 @@ class TestFileBucket < Test::Unit::TestCase
assert_equal(md5, newmd5)
end
-
- def test_fileswithbuckets
- name = "yayness"
- mkbucket(name, tempfile())
-
- bucket = nil
- assert_nothing_raised {
- bucket = Puppet.type(:filebucket).bucket(name)
- }
-
- file = mktestfile()
- assert_nothing_raised {
- file[:backup] = name
- }
-
- opath = tempfile()
- @@tmpfiles << opath
- File.open(opath, "w") { |f| f.puts "yaytest" }
-
- origmd5 = File.open(file.name) { |f| newmd5 = Digest::MD5.hexdigest(f.read) }
-
- file[:source] = opath
- #assert_nothing_raised {
- # file[:backup] = true
- #}
-
- assert_apply(file)
-
- # so, we've now replaced the file with the opath file
- assert_equal(
- File.open(opath) { |f| newmd5 = Digest::MD5.hexdigest(f.read) },
- File.open(file.name) { |f| newmd5 = Digest::MD5.hexdigest(f.read) }
- )
-
- #File.chmod(0644, file.name)
- assert_nothing_raised {
- bucket.restore(file.name, origmd5)
- }
-
- assert_equal(
- origmd5,
- File.open(file.name) { |f| newmd5 = Digest::MD5.hexdigest(f.read) }
- )
- end
end
diff --git a/test/ral/type/fileignoresource.rb b/test/ral/type/fileignoresource.rb
index ff867c879..996bca424 100755
--- a/test/ral/type/fileignoresource.rb
+++ b/test/ral/type/fileignoresource.rb
@@ -18,6 +18,8 @@ class TestFileIgnoreSources < Test::Unit::TestCase
rescue
system("rm -rf %s" % Puppet[:statefile])
end
+
+ Facter.stubs(:to_hash).returns({})
end
#This is not needed unless using md5 (correct me if I'm wrong)
@@ -86,8 +88,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#This file should not
assert(!(FileTest.exists?(File.join(topath,sourcefile2))))
-
- Puppet::Type.allclear
end
def test_ignore_with_wildcard
@@ -155,8 +155,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase
assert(!(FileTest.exists?(File.join(topath,sourcefile2))))
assert(!(FileTest.exists?(File.join(topath,subdir2))))
assert(!(FileTest.exists?(File.join(File.join(topath,subdir),sourcefile2))))
- Puppet::Type.allclear
-
end
def test_ignore_array
@@ -236,10 +234,5 @@ class TestFileIgnoreSources < Test::Unit::TestCase
assert(!(FileTest.exists?(File.join(topath,subdir2))), "subdir2 in dest")
assert(!(FileTest.exists?(File.join(topath,subdir3))), "anotherdir in dest")
assert(!(FileTest.exists?(File.join(File.join(topath,subdir),sourcefile2))), "file2 in dest/sub")
-
-
- Puppet::Type.allclear
-
end
-
end
diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb
index a7bb6fefa..653db5c7d 100755
--- a/test/ral/type/filesources.rb
+++ b/test/ral/type/filesources.rb
@@ -21,6 +21,7 @@ class TestFileSources < Test::Unit::TestCase
@file = Puppet::Type.type(:file)
Puppet[:filetimeout] = -1
Puppet::Util::SUIDManager.stubs(:asuser).yields
+ Facter.stubs(:to_hash).returns({})
end
def teardown
@@ -69,7 +70,7 @@ class TestFileSources < Test::Unit::TestCase
:name => path
)
}
- config = mk_catalog(file)
+ catalog = mk_catalog(file)
child = nil
assert_nothing_raised {
child = file.newchild("childtest", true)
@@ -84,7 +85,8 @@ class TestFileSources < Test::Unit::TestCase
source = tempfile()
dest = tempfile()
- file = Puppet::Type.newfile :path => dest, :source => source, :title => "copier"
+ file = Puppet::Type.newfile :path => dest, :source => source,
+ :title => "copier"
property = file.property(:source)
@@ -123,10 +125,7 @@ class TestFileSources < Test::Unit::TestCase
File.open(target, "w") { |f| f.puts "yay" }
File.symlink(target, source)
- file[:links] = :manage
- assert_equal("link", property.describe(source)[:type])
-
- # And then make sure links get followed
+ # And then make sure links get followed, otherwise
file[:links] = :follow
assert_equal("file", property.describe(source)[:type])
end
@@ -275,7 +274,7 @@ class TestFileSources < Test::Unit::TestCase
# The sourcerecurse method will only ever get called when we're
# recursing, so we go ahead and set it.
obj = Puppet::Type.newfile :source => source, :path => dest, :recurse => true
- config = mk_catalog(obj)
+ catalog = mk_catalog(obj)
result = nil
sourced = nil
@@ -284,12 +283,12 @@ class TestFileSources < Test::Unit::TestCase
end
assert_equal([destfile], sourced, "Did not get correct list of sourced objects")
- dfileobj = @file[destfile]
+ dfileobj = catalog.resource(:file, destfile)
assert(dfileobj, "Did not create destfile object")
assert_equal([dfileobj], result)
# Clean this up so it can be recreated
- config.remove_resource(dfileobj)
+ catalog.remove_resource(dfileobj)
# Make sure we correctly iterate over the sources
nosource = tempfile()
@@ -300,7 +299,7 @@ class TestFileSources < Test::Unit::TestCase
result, sourced = obj.sourcerecurse(true)
end
assert_equal([destfile], sourced, "Did not get correct list of sourced objects")
- dfileobj = @file[destfile]
+ dfileobj = catalog.resource(:file, destfile)
assert(dfileobj, "Did not create destfile object with a missing source")
assert_equal([dfileobj], result)
dfileobj.remove
@@ -356,23 +355,20 @@ class TestFileSources < Test::Unit::TestCase
end
def recursive_source_test(fromdir, todir)
- Puppet::Type.allclear
initstorage
tofile = nil
trans = nil
- assert_nothing_raised {
- tofile = Puppet.type(:file).create(
- :path => todir,
- :recurse => true,
- :backup => false,
- :source => fromdir
- )
- }
- assert_apply(tofile)
+ tofile = Puppet.type(:file).create(
+ :path => todir,
+ :recurse => true,
+ :backup => false,
+ :source => fromdir
+ )
+ catalog = mk_catalog(tofile)
+ catalog.apply
assert(FileTest.exists?(todir), "Created dir %s does not exist" % todir)
- Puppet::Type.allclear
end
def run_complex_sources(networked = false)
@@ -414,9 +410,6 @@ class TestFileSources < Test::Unit::TestCase
def test_sources_with_deleted_destfiles
fromdir, todir, one, two = run_complex_sources
assert(FileTest.exists?(todir))
-
- # We shouldn't have a 'two' file object in memory
- assert_nil(@file[two], "object for 'two' is still in memory")
# then delete a file
File.unlink(two)
@@ -532,107 +525,6 @@ class TestFileSources < Test::Unit::TestCase
return file
end
- def test_NetworkSources
- server = nil
- mounts = {
- "/" => "root"
- }
-
- fileserverconf = mkfileserverconf(mounts)
-
- Puppet[:autosign] = true
-
- Puppet[:masterport] = 8762
- Puppet[:name] = "puppetmasterd"
- Puppet[:certdnsnames] = "localhost"
-
- serverpid = nil
- assert_nothing_raised() {
- server = Puppet::Network::HTTPServer::WEBrick.new(
- :Handlers => {
- :CA => {}, # so that certs autogenerate
- :FileServer => {
- :Config => fileserverconf
- }
- }
- )
-
- }
- serverpid = fork {
- assert_nothing_raised() {
- #trap(:INT) { server.shutdown; Kernel.exit! }
- trap(:INT) { server.shutdown }
- server.start
- }
- }
- @@tmppids << serverpid
-
- sleep(1)
-
- fromdir, todir = run_complex_sources("root")
- assert_trees_equal(fromdir,todir)
- recursive_source_test(fromdir, todir)
- assert_trees_equal(fromdir,todir)
-
- assert_nothing_raised {
- system("kill -INT %s" % serverpid)
- }
- end
-
- def test_unmountedNetworkSources
- server = nil
- mounts = {
- "/" => "root",
- "/noexistokay" => "noexist"
- }
-
- fileserverconf = mkfileserverconf(mounts)
-
- Puppet[:autosign] = true
- Puppet[:masterport] = @port
- Puppet[:certdnsnames] = "localhost"
-
- serverpid = nil
- assert_nothing_raised("Could not start on port %s" % @port) {
- server = Puppet::Network::HTTPServer::WEBrick.new(
- :Port => @port,
- :Handlers => {
- :CA => {}, # so that certs autogenerate
- :FileServer => {
- :Config => fileserverconf
- }
- }
- )
-
- }
-
- serverpid = fork {
- assert_nothing_raised() {
- #trap(:INT) { server.shutdown; Kernel.exit! }
- trap(:INT) { server.shutdown }
- server.start
- }
- }
- @@tmppids << serverpid
-
- sleep(1)
-
- name = File.join(tmpdir(), "nosourcefile")
- file = Puppet.type(:file).create(
- :source => "puppet://localhost/noexist/file",
- :name => name
- )
-
- assert_nothing_raised {
- file.retrieve
- }
-
- comp = mk_catalog(file)
- comp.apply
-
- assert(!FileTest.exists?(name), "File with no source exists anyway")
- end
-
def test_alwayschecksum
from = tempfile()
to = tempfile()
@@ -741,22 +633,18 @@ class TestFileSources < Test::Unit::TestCase
File.open(source, "w") { |f| f.puts "yay" }
File.symlink(source, link)
- file = nil
- assert_nothing_raised {
- file = Puppet.type(:file).create(
- :name => dest,
- :source => link,
- :links => :follow
- )
- }
+ file = Puppet.type(:file).create(:name => dest, :source => link)
- assert_events([:file_created], file)
- assert(FileTest.file?(dest), "Destination is not a file")
+ catalog = mk_catalog(file)
- # Now copy the links
- file[:links] = :manage
- assert_events([:link_created], file)
- assert(FileTest.symlink?(dest), "Destination is not a link")
+ # Default to managing links
+ catalog.apply
+ assert(FileTest.symlink?(dest), "Did not create link")
+
+ # Now follow the links
+ file[:links] = :follow
+ catalog.apply
+ assert(FileTest.file?(dest), "Destination is not a file")
end
def test_changes
diff --git a/test/ral/type/group.rb b/test/ral/type/group.rb
index d28c8eea5..3c29fe505 100755
--- a/test/ral/type/group.rb
+++ b/test/ral/type/group.rb
@@ -39,7 +39,6 @@ class TestGroup < Test::Unit::TestCase
end
def teardown
- Puppet.type(:group).clear
Puppet::Type.type(:group).defaultprovider = nil
super
end
diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb
index 9b744eeec..df7cc508f 100755
--- a/test/ral/type/host.rb
+++ b/test/ral/type/host.rb
@@ -55,16 +55,12 @@ class TestHost < Test::Unit::TestCase
end
def test_list
+ list = nil
assert_nothing_raised do
- @hosttype.defaultprovider.prefetch
+ list = @hosttype.defaultprovider.instances
end
- count = 0
- @hosttype.each do |h|
- count += 1
- end
-
- assert_equal(0, count, "Found hosts in empty file somehow")
+ assert_equal(0, list.length, "Found hosts in empty file somehow")
end
# Darwin will actually write to netinfo here.
@@ -213,12 +209,13 @@ class TestHost < Test::Unit::TestCase
def test_puppetalias
host = mkhost()
+ catalog = mk_catalog(host)
assert_nothing_raised {
host[:alias] = "testing"
}
- same = host.class["testing"]
+ same = catalog.resource(:host, "testing")
assert(same, "Could not retrieve by alias")
end
end
diff --git a/test/ral/type/parameter.rb b/test/ral/type/parameter.rb
index e1b8e00b3..04c4b0ce1 100755
--- a/test/ral/type/parameter.rb
+++ b/test/ral/type/parameter.rb
@@ -131,7 +131,7 @@ class TestParameter < Test::Unit::TestCase
assert_instance_of(param, obj, "alias is an instance of the wrong class")
# Make sure the alias got created
- assert(type["foo"], "Did not retrieve object by its alias")
+ assert(config.resource(type.name, "foo"), "Did not retrieve object by its alias")
# Now try it during initialization
other = nil
diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb
index b9aed20e8..333bc377d 100755
--- a/test/ral/type/sshkey.rb
+++ b/test/ral/type/sshkey.rb
@@ -49,26 +49,27 @@ class TestSSHKey < Test::Unit::TestCase
@catalog ||= mk_catalog
- assert_nothing_raised {
- key = @sshkeytype.create(
- :name => "host%s.madstop.com" % @kcount,
- :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
- :type => "ssh-dss",
- :alias => ["192.168.0.%s" % @kcount],
- :catalog => @catalog
- )
- }
+ key = @sshkeytype.create(
+ :name => "host%s.madstop.com" % @kcount,
+ :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
+ :type => "ssh-dss",
+ :alias => ["192.168.0.%s" % @kcount],
+ :catalog => @catalog
+ )
+
+ @catalog.add_resource(key)
return key
end
def test_instances
+ list = nil
assert_nothing_raised {
- Puppet.type(:sshkey).instances
+ list = Puppet.type(:sshkey).instances
}
count = 0
- @sshkeytype.each do |h|
+ list.each do |h|
count += 1
end
@@ -90,7 +91,6 @@ class TestSSHKey < Test::Unit::TestCase
# Now create a new key object
name = key.name
key = nil
- @sshkeytype.clear
key = @sshkeytype.create :name => name, :target => file, :provider => :parsed
key.retrieve
@@ -102,19 +102,17 @@ class TestSSHKey < Test::Unit::TestCase
def test_moddingkey
key = mkkey()
- assert_events([:sshkey_created], key)
+ @catalog.apply
key.retrieve
aliases = %w{madstop kirby yayness}
key[:alias] = aliases
- params = key.instance_variable_get("@parameters")
- assert_events([:sshkey_changed], key)
+ @catalog.apply
aliases.each do |name|
- assert_equal(key, key.class[name],
- "alias was not set")
+ assert_equal(key.object_id, @catalog.resource(:sshkey, name).object_id, "alias %s was not set" % name)
end
end
@@ -136,7 +134,9 @@ class TestSSHKey < Test::Unit::TestCase
key[:alias] = "testing"
}
- same = key.class["testing"]
+ key.finish
+
+ same = @catalog.resource(:sshkey, "testing")
assert(same, "Could not retrieve by alias")
end
@@ -170,7 +170,10 @@ class TestSSHKey < Test::Unit::TestCase
}
assert_apply(*keys)
keys.clear
- Puppet.type(:sshkey).clear
+
+ @catalog.clear(true)
+ @catalog = nil
+
newkey = mkkey()
#newkey[:ensure] = :present
names << newkey.name
@@ -178,17 +181,9 @@ class TestSSHKey < Test::Unit::TestCase
# Verify we can retrieve that info
assert_nothing_raised("Could not retrieve after second write") {
- newkey.provider.class.prefetch
- newkey.retrieve
+ newkey.provider.prefetch
}
- # And verify that we have data for everything
- names.each { |name|
- key = Puppet.type(:sshkey)[name] ||
- Puppet.type(:sshkey).create(:name => name)
- assert(key, "Could not retrieve key for %s" % name)
- assert(key.provider.exists?, "key %s is missing" % name)
- }
+ assert(newkey.provider.exists?, "Did not see key in file")
end
end
-
diff --git a/test/ral/type/tidy.rb b/test/ral/type/tidy.rb
index 657ca6e93..a3a3b4b01 100755
--- a/test/ral/type/tidy.rb
+++ b/test/ral/type/tidy.rb
@@ -207,8 +207,6 @@ class TestTidy < Test::Unit::TestCase
assert_apply(tidy)
assert(! FileTest.exists?(path), "file did not get tidied")
- tidy.class.clear
-
# Now try one with just an age attribute.
time = Time.now - 10
stat = stub 'stat', :mtime => time, :atime => time, :ftype => "file"
diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb
index 87d5b6075..1a2de2649 100755
--- a/test/ral/type/user.rb
+++ b/test/ral/type/user.rb
@@ -455,6 +455,7 @@ class TestUser < Test::Unit::TestCase
# Testing #455
def test_autorequire_with_no_group_should
user = Puppet::Type.type(:user).create(:name => "yaytest", :check => :all)
+ catalog = mk_catalog(user)
assert_nothing_raised do
user.autorequire
diff --git a/test/ral/type/yumrepo.rb b/test/ral/type/yumrepo.rb
index 899a02135..273179bc4 100755
--- a/test/ral/type/yumrepo.rb
+++ b/test/ral/type/yumrepo.rb
@@ -17,6 +17,9 @@ class TestYumRepo < Test::Unit::TestCase
f.print "[main]\nreposdir=#{@yumdir} /no/such/dir\n"
end
Puppet.type(:yumrepo).yumconf = @yumconf
+
+ # It needs to be reset each time, otherwise the cache is used.
+ Puppet.type(:yumrepo).inifile = nil
end
# Modify one existing section
@@ -24,19 +27,17 @@ class TestYumRepo < Test::Unit::TestCase
copy_datafiles
devel = make_repo("development", { :descr => "New description" })
current_values = devel.retrieve
+
assert_equal("development", devel[:name])
- assert_equal('Fedora Core $releasever - Development Tree',
- current_values[devel.property(:descr)])
- assert_equal('New description',
- devel.property(:descr).should)
+ assert_equal('Fedora Core $releasever - Development Tree', current_values[devel.property(:descr)])
+ assert_equal('New description', devel.property(:descr).should)
assert_apply(devel)
+
inifile = Puppet.type(:yumrepo).read()
assert_equal('New description', inifile['development']['name'])
- assert_equal('Fedora Core $releasever - $basearch - Base',
- inifile['base']['name'])
+ assert_equal('Fedora Core $releasever - $basearch - Base', inifile['base']['name'])
assert_equal("foo\n bar\n baz", inifile['base']['exclude'])
- assert_equal(['base', 'development', 'main'],
- all_sections(inifile))
+ assert_equal(['base', 'development', 'main'], all_sections(inifile))
end
# Create a new section
diff --git a/test/util/filetype.rb b/test/util/filetype.rb
index 6c7ede07b..24a968552 100755
--- a/test/util/filetype.rb
+++ b/test/util/filetype.rb
@@ -85,7 +85,7 @@ class TestFileType < Test::Unit::TestCase
assert_nothing_raised("Could not call backup with no buckets") do
obj.backup
end
- puppet = type["puppet"]
+ puppet = type.mkdefaultbucket
assert(puppet, "Did not create default filebucket")
assert_equal("one", puppet.bucket.getfile(Digest::MD5.hexdigest(File.read(path))), "Could not get file from backup")
@@ -99,7 +99,7 @@ class TestFileType < Test::Unit::TestCase
assert_equal("two", puppet.bucket.getfile(Digest::MD5.hexdigest(File.read(path))), "Could not get file from backup")
end
- if Facter["operatingsystem"].value == "Darwin"
+ if Facter["operatingsystem"].value == "Darwin" and Facter["operatingsystemrelease"] != "9.1.0"
def test_ninfotoarray
obj = nil
type = nil
diff --git a/test/util/posixtest.rb b/test/util/posixtest.rb
index 34d68e3a2..8fd11b086 100755
--- a/test/util/posixtest.rb
+++ b/test/util/posixtest.rb
@@ -35,16 +35,6 @@ class TestPosixUtil < Test::Unit::TestCase
end
end
- def test_get_provider_value
- user = nonrootuser
- obj = mk_posix_resource(:user, user)
-
- assert_nothing_raised do
- assert_equal(user.uid, get_provider_value(:user, :uid, user.uid))
- assert_equal(user.name, get_provider_value(:user, :name, user.name))
- end
- end
-
def test_gid_and_uid
{:user => nonrootuser, :group => nonrootgroup}.each do |type, obj|
method = idfield(type)
diff --git a/test/util/settings.rb b/test/util/settings.rb
index cf5dca76d..de6fff946 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -256,69 +256,6 @@ yay = /a/path
end
end
- def test_old_parse
- text = %{
-one = this is a test
-two = another test
-owner = root
-group = root
-yay = /a/path
-
-[section1]
- attr = value
- owner = puppet
- group = puppet
- attrdir = /some/dir
- attr3 = $attrdir/other
- }
-
- file = tempfile()
- File.open(file, "w") { |f| f.puts text }
-
- assert_nothing_raised {
- @config.setdefaults("puppet",
- :one => ["a", "one"],
- :two => ["a", "two"],
- :yay => ["/default/path", "boo"],
- :mkusers => [true, "uh, yeah"]
- )
- }
-
- assert_nothing_raised {
- @config.setdefaults("section1",
- :attr => ["a", "one"],
- :attrdir => ["/another/dir", "two"],
- :attr3 => ["$attrdir/maybe", "boo"]
- )
- }
-
- assert_nothing_raised {
- @config.old_parse(file)
- }
-
- assert_equal("value", @config[:attr])
- assert_equal("/some/dir", @config[:attrdir])
- assert_equal(:directory, @config.element(:attrdir).type)
- assert_equal("/some/dir/other", @config[:attr3])
-
- elem = nil
- assert_nothing_raised {
- elem = @config.element(:attr3)
- }
-
- assert(elem)
- assert_equal("puppet", elem.owner)
-
- config = nil
- assert_nothing_raised {
- config = @config.to_config
- }
-
- assert_nothing_raised("Could not create transportable config") {
- @config.to_transportable
- }
- end
-
def test_parse
result = {
:main => {:main => "main", :bad => "invalid", :cliparam => "reset"},
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 35e1446a1..a8dfca9c2 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -264,24 +264,5 @@ class TestPuppetUtil < Test::Unit::TestCase
# Puppet::Util.execute(cmd, 0, 0)
#}
end
-
- # This is mostly to test #380.
- def test_get_provider_value
- group = Puppet::Type.type(:group).create :name => "yayness", :ensure => :present
-
- root = Puppet::Type.type(:user).create :name => "root", :ensure => :present
-
- val = nil
- assert_nothing_raised do
- val = Puppet::Util.get_provider_value(:group, :gid, "yayness")
- end
- assert_nil(val, "returned a value on a missing group")
-
- # Now make sure we get a value for one we know exists
- assert_nothing_raised do
- val = Puppet::Util.get_provider_value(:user, :uid, "root")
- end
- assert_equal(0, val, "got invalid uid for root")
- end
end