diff options
| author | Luke Kanies <luke@madstop.com> | 2007-11-19 01:36:48 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-11-19 01:36:48 -0600 |
| commit | 2b14f627aca1d5be69cf6606044df4d6e67f6eba (patch) | |
| tree | a20db3a608af483f598f482e743868413da8fd8f /test/network | |
| parent | 9cf477b6cc771eab7bd29d18c49128571e877987 (diff) | |
| download | puppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.tar.gz puppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.tar.xz puppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.zip | |
Reverting the changes I'd made toward removing the global
resources. These are commits:
c19835ce9f8a5138b30a1a32ca741c996b0916d2
9290cc89a2206fb5204578f8e91208857a48b147
ffb4c2dbc7314b364d25e4f7be599ef05b767b44
Diffstat (limited to 'test/network')
| -rwxr-xr-x | test/network/client/client.rb | 29 | ||||
| -rwxr-xr-x | test/network/client/master.rb | 51 | ||||
| -rwxr-xr-x | test/network/handler/fileserver.rb | 19 | ||||
| -rwxr-xr-x | test/network/handler/resource.rb | 5 |
4 files changed, 90 insertions, 14 deletions
diff --git a/test/network/client/client.rb b/test/network/client/client.rb index 8d08bd3d7..4a7e9cdb6 100755 --- a/test/network/client/client.rb +++ b/test/network/client/client.rb @@ -140,6 +140,35 @@ class TestClient < Test::Unit::TestCase } end + def test_classfile + Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest" + + Puppet::Node::Facts.indirection.stubs(:save) + + master = client = nil + assert_nothing_raised() { + master = Puppet::Network::Handler.master.new( + :Local => false + ) + } + assert_nothing_raised() { + client = Puppet::Network::Client.master.new( + :Master => master + ) + } + + # Fake that it's local, so it creates the class file + client.local = false + + # We can't guarantee class ordering + client.expects(:setclasses).with do |array| + array.length == 2 and array.include?("yaytest") and array.include?("bootest") + end + assert_nothing_raised { + client.getconfig + } + end + def test_client_loading # Make sure we don't get a failure but that we also get nothing back assert_nothing_raised do diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 0caba4bd2..7216af936 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -332,6 +332,39 @@ end assert(FileTest.exists?(file), "file was not created on second run") end + def test_default_objects + # Make sure they start out missing + assert_nil(Puppet::Type.type(:filebucket)["puppet"], + "default filebucket already exists") + assert_nil(Puppet::Type.type(:schedule)["daily"], + "default schedules already exists") + + master = mkclient() + + # Now make sure they got created + assert(Puppet::Type.type(:filebucket)["puppet"], + "default filebucket not found") + assert(Puppet::Type.type(:schedule)["daily"], + "default schedules not found") + + # clear everything, and make sure we can recreate them + Puppet::Type.allclear + assert_nil(Puppet::Type.type(:filebucket)["puppet"], + "default filebucket not removed") + assert_nil(Puppet::Type.type(:schedule)["daily"], + "default schedules not removed") + assert_nothing_raised { master.mkdefault_objects } + assert(Puppet::Type.type(:filebucket)["puppet"], + "default filebucket not found") + assert(Puppet::Type.type(:schedule)["daily"], + "default schedules not found") + + + # Make sure we've got schedules + assert(Puppet::Type.type(:schedule)["hourly"], "Could not retrieve hourly schedule") + assert(Puppet::Type.type(:filebucket)["puppet"], "Could not retrieve default bucket") + end + # #540 - make sure downloads aren't affected by noop def test_download_in_noop source = tempfile @@ -517,6 +550,24 @@ 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::Configuration.new + config.add_resource(file) + + config.expects :apply + + client.configuration = 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/handler/fileserver.rb b/test/network/handler/fileserver.rb index 8703700ea..3539169dc 100755 --- a/test/network/handler/fileserver.rb +++ b/test/network/handler/fileserver.rb @@ -8,11 +8,6 @@ require 'puppet/network/handler/fileserver' class TestFileServer < Test::Unit::TestCase include PuppetTest - def setup - super - Facter.stubs(:to_hash).returns({}) - end - def mkmount(path = nil) mount = nil name = "yaytest" @@ -151,6 +146,10 @@ class TestFileServer < Test::Unit::TestCase list = server.list(sfile, :ignore, true, false) } + assert_nothing_raised { + file = Puppet.type(:file)[tmpfile] + } + output = "/\tfile" # verify it got listed as a file @@ -944,11 +943,10 @@ allow * end # Now, check that they use Facter info - Facter.stubs(:value).with("hostname").returns("myhost") - Facter.stubs(:value).with("domain").returns("mydomain") - local = "myhost" - domain = "mydomain" + Puppet.notice "The following messages are normal" client = nil + local = Facter["hostname"].value + domain = Facter["domain"].value fqdn = [local, domain].join(".") {"%h" => local, # Short name "%H" => fqdn, # Full name @@ -956,7 +954,6 @@ allow * "%%" => "%", # escape "%o" => "%o" # other }.each do |pat, repl| - Puppet.expects(:notice) check.call(client, pat, repl) end @@ -1135,8 +1132,6 @@ allow * def test_failures # create a server with the file server = nil - Facter.stubs(:[]).with("hostname").returns("myhost") - Facter.stubs(:[]).with("domain").returns("mydomain") config = tempfile [ diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb index 247014a47..0d6373160 100755 --- a/test/network/handler/resource.rb +++ b/test/network/handler/resource.rb @@ -3,12 +3,10 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/utils' require 'base64' require 'cgi' class TestResourceServer < Test::Unit::TestCase - include PuppetTest include PuppetTest::ServerTest def verify_described(type, described) @@ -181,6 +179,9 @@ class TestResourceServer < Test::Unit::TestCase require 'etc' + # Make the example schedules, for testing + Puppet::Type.type(:schedule).mkdefaultschedules + Puppet::Type.eachtype do |type| unless type.respond_to? :instances Puppet.warning "%s does not respond to :instances" % type.name |
