Skip to content

Commit

Permalink
Fixing #967 -- default resources no longer conflict with
Browse files Browse the repository at this point in the history
managed resources.
  • Loading branch information
lak committed Dec 19, 2007
1 parent c998a25 commit 927cb24
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Default resources like schedules no longer conflict with
managed resources. (#965)

Removing the ability to disable http keep-alive, since
it didn't really work anyway and it should no longer
be necessary.
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/network/client/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def cachefile
def clear
@catalog.clear(true) if @catalog
Puppet::Type.allclear
mkdefault_objects
@catalog = nil
end

Expand Down Expand Up @@ -205,12 +204,10 @@ def initialize(*args)

self.class.instance = self
@running = false

mkdefault_objects
end

# Make the default objects necessary for function.
def mkdefault_objects
def make_default_resources
# First create the default scheduling objects
Puppet::Type.type(:schedule).mkdefaultschedules

Expand Down Expand Up @@ -266,6 +263,9 @@ def run(options = {})
end

if self.catalog
# Make our default schedules and such.
make_default_resources

@catalog.retrieval_duration = duration
Puppet.notice "Starting catalog run" unless @local
benchmark(:notice, "Finished catalog run") do
Expand Down
21 changes: 18 additions & 3 deletions test/network/client/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,16 @@ def test_caching_of_compile_time
assert(FileTest.exists?(file), "file was not created on second run")
end

def test_default_objects
def test_default_resources
client = mkclient()

# 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()
client.make_default_resources

# Now make sure they got created
assert(Puppet::Type.type(:filebucket)["puppet"],
Expand All @@ -354,7 +356,7 @@ def test_default_objects
"default filebucket not removed")
assert_nil(Puppet::Type.type(:schedule)["daily"],
"default schedules not removed")
assert_nothing_raised { master.mkdefault_objects }
assert_nothing_raised { client.make_default_resources }
assert(Puppet::Type.type(:filebucket)["puppet"],
"default filebucket not found")
assert(Puppet::Type.type(:schedule)["daily"],
Expand All @@ -366,6 +368,19 @@ def test_default_objects
assert(Puppet::Type.type(:filebucket)["puppet"], "Could not retrieve default bucket")
end

# #965 - make sure default objects don't conflict with existing
# objects.
def test_default_resources_do_not_conflict_with_managed_resources
# Create some that conflict with our defaults
bucket = Puppet::Type.type(:filebucket).create :name => "puppet"
schedule = Puppet::Type.type(:schedule).create :name => "daily"

client = mkclient()

# Then make sure creating new defaults doesn't throw an exception.
assert_nothing_raised("Default resources conflicted with resources in the catalog") { client.make_default_resources }
end

# #540 - make sure downloads aren't affected by noop
def test_download_in_noop
source = tempfile
Expand Down

0 comments on commit 927cb24

Please sign in to comment.