summaryrefslogtreecommitdiff
path: root/spec/unit/provider/cron
AgeCommit message (Collapse)AuthorFilesLines
2014-03-26Merge pull request #2331 from ticket/master/PUP-1587-catch-empty-cron-entriesCharlie Sharpsteen1-0/+15
(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) amend unit test to match corrected behaviorFelix Frank1-0/+1
Just a simple addition to the mock object used for some tests, because the crontab provider will now perform an additional property value lookup to find an on-disk resource.
2014-02-11(PUP-649) Loosen checks for crontab providerAndrew Parker1-31/+27
The tests for the crontab provider exhibited an order dependent failure. If the spec/integration/provider/cron tests were run before the spec/unit/provider/cron tests then the global counter that is used by the crontab provider would not be at the expected value. This isn't really a problem in practice, but the expectations in the tests were for a specific count. This updates the checks so that they are resilient to the exact numbers chosen.
2014-02-11(#3220) uniquify implicit record namesFelix Frank1-2/+2
Adds an numeric suffix to the artifical name that gets generated for unnamed records in crontabs. It will suppress naming collisions for cronjobs that use the exact same command string.
2014-02-11(#3220) make the unit test "generating cron resources" match the new behaviourFelix Frank1-2/+2
To allow purging of unmanaged resources, they are now implicitly named. The unit test must take that into account.
2014-02-05(PUP-1586) allow managing existing cronjobs without caring for commandFelix Frank1-0/+15
When the catalog contains a cron resource that does not specify a value for the command property, the transaction would fail with the cryptic error message 'no command, somehow' under certain conditions. This error is spurious. Generally, it's quite allowable to manage a subset of cron properties that does not include the command. Fixed by removing the devfail invocation. The command property is now handled just like the 'special' property.
2013-04-09(maint) Use stub over puppet type objectAdrien Thebo1-3/+8
Using an object of class Puppet::Type::Cron is too error prone, as instantiation of those objects have a lot of side effects. This replaces the actual object with a stub to minimize the possible side effects.
2013-04-09(#2251) correct crontab matching specsAdrien Thebo1-2/+1
The previous implementation of this spec was exhibiting failures on windows and was testing behavior out of the scope of the unit test. This narrows the scope of the given test.
2013-04-09(#2251) add specs around resource_for_recordAdrien Thebo1-0/+25
2013-04-09(#2251) Rewrite parsedfile method names for clarityAdrien Thebo1-1/+1
This renames the ParsedFile `self.find_resource` method to `self.resource_for_record` and changes the method return to return the resource found. It also adds some yardoc for the methods involved.
2013-04-09Revert "Revert "Merge branch 'pull-1540'""Adrien Thebo1-1/+27
This reverts commit c992fb536d9fd87ad23b2fc0b88592bfe1dea0f5.
2013-04-04Revert "Merge branch 'pull-1540'"Adrien Thebo1-27/+1
This is causing spec failures on windows, and the current implementation of the crontab provider and the parsedfile provider is sufficiently complex that it's not clear how to sanely fix this issue. This is getting reverted until it's in a more understandable state. This reverts commit f85ec37456095c06a7b0d99a752534d0caf9c97e, reversing changes made to 138fc337c36715a7ab40b2b68b86aa71ec3ada64.
2013-04-03(#2251) crontab: avoid duplication of cronjobsFelix Frank1-1/+27
The crontab provider will duplicate resources ad nauseam if another record with the same "puppet name" exists in a different crontab. It was found that entries in different crontabs, even when sharing names, should be treated as independent entities. Therefor, the crontab provider will now ensure that when prefetching crontabs from disk, cronjobs are matched to managed resources only if both the name and the target file match.
2013-03-28(#19876) Fix crontab regression in resource matchingFelix Frank1-0/+28
The logic for matching new resources with exiting unmanaged cronjobs has been reworked during the fix for #16809. Somehow, this lead to a new issue which caused spurious matches, e.g.: 10 * * * * /bin/true and cron { "blank": command => "/bin/true", ensure => present } would now match. At least puppet will not try to change the name of the record (i.e., the 'Puppet Name:' line). But the new entry will not get added either. It still works if there is a non-matching time field, e.g. cron { "blank": command => "/bin/true", hour => 1 } but without such fields, the behaviour is wrong. The match method (in the crontab provider) will expressly ignore named records on disk. This is safe to do; if the resource does have the same name as the on-disk record, the match method will not even get invoked. There is no scenario in which we'd want differently named records to be matched with a resource. If an on-disk record has a name, it either is managed through another resource, or it used to be managed. Either way, the resource in question needs adding or matching to a different record.
2013-03-22(maint) Refactor crontab filetype selectionAdrien Thebo1-5/+11
The previous implementation of the crontab implementation type determined the filetype to use at load time by calling out to Facter before the type was loaded, which was both ugly and made it difficult to test on alternate platforms. This commit overrides the `.filetype` method to do the detection at runtime so the provider encapsulates all its logic and the filetype can be stubbed out.
2013-03-13(#16809) Remove refs to freebsd_special cron typeAdrien Thebo1-1/+0
The legacy test::unit crontab tests contained checks for the freebsd_special record line. Since those were not getting run by the normal rspec coverage it got missed when the freebsd_special line type was removed. This commit removes the outdated references.
2013-03-13(#16809) Use only one record_type in cron providerStefan Schulte1-0/+319
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)
2013-02-15(#593) crontab: drop vixie cron headers when writing crontabsFelix Frank1-6/+14
This makes use of the "native header" of parsed files. Vixie cron headers should never be written back to disk, because cron will insert a new header, regardless of what's found in the temporary input file. The underlying issue is a cron bug, because vixie headers should (probably) not appear in `crontab -l` output. This is indeed fixed in newer versions of cron, so this workaround merely introduces compatibility with older systems.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-03-30Port the crontab Test::Unit tests to RSpec.Daniel Pittman1-0/+116
These tests covered a bunch of content that wasn't already covered, so they should be ported. Includes some fun around enumerators and Ruby 1.8.5. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2010-01-14Revert "Fix #2845 Cron entries using "special" parameter lose their title ↵0.25.4rc1James Turnbull1-21/+0
when changed" This reverts commit c99f394bf8c10d13f3fa7d3ab7ab43ecf454c081. The fix broke cron jobs in 0.25.3 and was reverted for the 0.25.4 release.
2010-01-12Fix #2845 Cron entries using "special" parameter lose their title when changedJesse Wolfe1-0/+21
Merged the "freebsd_special" pattern into the other crontab records, since its definition was incomplete Signed-off-by: Jesse Wolfe <jes5199@gmail.com>