summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-27 13:49:05 -0600
committerLuke Kanies <luke@madstop.com>2007-11-27 13:49:05 -0600
commit7ff8ea5a1a913cfc8b8044f19d6c214d8437cfdf (patch)
treeab63d923d61b400d90ea9ab196f81fa20496c453 /lib
parent18b4c3a4646d353a59996292e8f3822682b4a9d7 (diff)
downloadpuppet-7ff8ea5a1a913cfc8b8044f19d6c214d8437cfdf.tar.gz
puppet-7ff8ea5a1a913cfc8b8044f19d6c214d8437cfdf.tar.xz
puppet-7ff8ea5a1a913cfc8b8044f19d6c214d8437cfdf.zip
Fixing the persistent and periodic schedule test failures
by rewriting the schedule tests entirely.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/schedule.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb
index 46cff10f5..3fdc008b6 100755
--- a/lib/puppet/type/schedule.rb
+++ b/lib/puppet/type/schedule.rb
@@ -241,7 +241,7 @@ module Puppet
:daily => :day,
:monthly => :month,
:weekly => proc do |prev, now|
- prev.strftime("%U") == now.strftime("%U")
+ prev.strftime("%U") != now.strftime("%U")
end
}
@@ -256,8 +256,7 @@ module Puppet
return method.call(previous, now)
else
# We negate it, because if they're equal we don't run
- val = now.send(method) != previous.send(method)
- return val
+ return now.send(method) != previous.send(method)
end
when :distance
scale = @@scale[value]
@@ -266,6 +265,9 @@ module Puppet
# than the unit of time, we match. We divide the scale
# by the repeat, so that we'll repeat that often within
# the scale.
+ diff = (now.to_i - previous.to_i)
+ comparison = (scale / @resource[:repeat])
+
return (now.to_i - previous.to_i) >= (scale / @resource[:repeat])
end
end
@@ -312,25 +314,27 @@ module Puppet
end
def self.mkdefaultschedules
- # Create our default schedule
- unless self["puppet"]
- Puppet.debug "Creating default schedules"
- self.create(
- :name => "puppet",
- :period => :hourly,
- :repeat => "2"
- )
- end
+ return [] if self["puppet"]
+
+ result = []
+ Puppet.debug "Creating default schedules"
+ result << self.create(
+ :name => "puppet",
+ :period => :hourly,
+ :repeat => "2"
+ )
# And then one for every period
@parameters.find { |p| p.name == :period }.values.each { |value|
unless self[value.to_s]
- self.create(
+ result << self.create(
:name => value.to_s,
:period => value
)
end
}
+
+ result
end
def match?(previous = nil, now = nil)
@@ -346,7 +350,7 @@ module Puppet
self.class.allattrs.each { |param|
if @parameters.include?(param) and
@parameters[param].respond_to?(:match?)
- #self.notice "Trying to match %s" % param
+ self.notice "Trying to match %s" % param
return false unless @parameters[param].match?(previous, now)
end
}