summaryrefslogtreecommitdiff
path: root/spec/integration/provider/cron/crontab_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-06-24(maint) use compiler in crontab integration specFelix Frank1-148/+137
2014-03-26Merge pull request #2331 from ticket/master/PUP-1587-catch-empty-cron-entriesCharlie Sharpsteen1-0/+24
(PUP-1587) crontab: make sure that invalid crontabs aren't written out (PUP-1586) remove obsolete unit test (PUP-1586) allow managing existing cronjobs without caring for command Signed-off-by: Charlie Sharpsteen <Charlie Sharpsteen chuck@puppetlabs.com>
2014-03-03(PUP-1585) cron: fix resource duplication in crontab providerFelix Frank1-0/+11
The regression fix for #19876 caused yet another regression in cron resources that manage the target property, but not the user property. The earlier fix made sure that a cron resource would not try and manage a matching record from another user's crontab. It did so by comparing the record's target to the resource's user property. When the user is unmanaged, but the target is specified instead, this would cause puppet to ignore the record on disk and add it once more. This is fixed by comparing the record's target to either the user property or the target property. If there is a should-value for the user, it is used, otherwise the provider falls back to the target should-value.
2014-02-21(PUP-1587) crontab: make sure that invalid crontabs aren't written outFelix Frank1-0/+24
It is permissible to manage cron entries and not manage the command property. However, if the entry doesn't exist on the target system yet, puppet should not try to create it. In other words, a cron resource without a should value for the command property can only be synced to a valid state if the corresponding resource on the target system has a valid command value already. cron { "foo": minute => 1 } is alright with an existing crontab of # Puppet Name: foo * * * * * /some/command but not with a crontab not yet containing the entry named 'foo'. This change prevents the sync operation in the error scenario.
2014-02-11(#3220) crontab: allow purging unmanaged resourcesFelix Frank1-0/+21
The problem was that unmanaged cronjobs would be parsed, but not implicitly named. Workaround: Pick an implicit name. It's derived from the command. The provider will never put this implicit name into a crontab file when writing it back to disk. The names are not unique if several unmanaged jobs execute the same command. That's a wrinkle and not mission critical, but it can be surprising for users, because the "duplicates" will not be purged during the first run.
2013-11-05(maint) Remove an unimplemented test and fix up some comments.Kylo Ginsberg1-5/+3
2013-04-04(#3010) cron: allow the absent value for the "special" propertyFelix Frank1-0/+11
The crontab provider fails to apply the change to a cronjob if the schedule has been a special schedule such as @daily. Paraphrasing from the bug report, assuming this crontab: @reboot /bin/true this manifest won't work correctly: cron{ "test": minute => 50 } even though puppet will correctly detect that the 'minute' property needs changing from "absent". The special schedule will remain. The fix allows this workaround: cron{ "test": minute => 50, special => absent }
2013-04-03(#2251) Make the crontab integration spec match the behavior againFelix Frank1-1/+2
The previous final cron test was Very Bad. It relied on an edge case that sidestepped #2251. Assume user1 and user2 and a cronjob X that moves from user1 to user2. Normally, this will trigger #2251 and fill user2's crontab with duplicates until at some point, another cronjob of user1's needs changing and the provider behaves as tested. In many real life scenarios, it can be months or weeks before this happens. Testing for the behaviour agreed upon in the redmine ticket makes more sense, because we can now make sure that the edge case will not hide unwanted behavior that emerges in the average case.
2013-03-21(maint) Exclude crontab integration specs on windowsAdrien Thebo1-1/+1
Since windows doesn't have a functional crontab provider, it doesn't make sense to run integration tests for cron on windows.
2013-03-13(#16809) Use only one record_type in cron providerStefan Schulte1-0/+186
The cronprovider defines two record_types :crontab and :freebsd_special to handle the following crontab records: @daily /bin/my_daily_command 0 0 * * * /bin/my_daily_command This has a few issues: a) The merging of the name (the comment before the cronentry itself) and the environment variables only happens for the :crontab record_type but not for the :freebsd_special record_type so information may get lost (#16809) b) When parsing an existing record the record_type can be automatically determined (depending on which regex matched) but when creating a new entry the record_type is undefined and the default :crontab is used. So if a new cronentry is created with the :special property set it is still treated as a crontab entry (so the to_line hook of the :crontab record_type is used and not of the :freebsd_special record_type) which is kind of confusing. c) It is really hard to change the time of a cronentry from the special format to a normal format (or vise versa) e.g. if we already have the following cronentry # Puppet Name: foo * * * * * /bin/foo and we have defined the following resource cron { "foo": special => daily, } the resource is treatd as in sync because the existing cronentry is parsed as a :crontab record_type and this record_type doesn't define a :special field that could be out of sync This patch now only uses one record_type that internally parses the timefield as either the old format (minute,hour,monthday,month,weekday) or the special format. This way the above issues go away (but the different to_line, post_parse hooks get a bit more difficult to handle both entries)