summaryrefslogtreecommitdiff
path: root/spec/unit/agent
AgeCommit message (Collapse)AuthorFilesLines
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune2-2/+2
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-09-18(Maint) Improve error message when catalog run is in progressJeff McCune1-0/+6
When a catalog run is currently in progress, or the `puppet agent --configprint agent_catalog_run_lockfile` is stale, the error message looks like this: Run of Puppet configuration client already in progress; skipping This is a problem because if the system is deadlocked from a stale file, it's not clear what file needs to be removed. This patch improves the error message to be: Run of Puppet configuration client already in progress; skipping \ (/var/lib/puppet/state/agent_catalog_run.lock exists) A new method has been added to make it easy to print out the file being referenced by the `running?` method.
2012-09-18(#3757) Rename agent_pidfile to agent_catalog_run_lockfileJeff McCune1-2/+2
Without this patch it is very confusing what the intended purpose of the agent_pidfile setting is. This confusion may lead to people thinking this file is intended to be used my monitoring systems or service management frameworks to determine the PID of a running puppet agent process. This thinking is incorrect, the `pidfile` setting is intended for this purpose. The `agent_pidfile` setting is intended to provide mutual exclusion of configuration catalog runs. This patch reduces confusion by more closely matching the name and description to the intent. In addition, the prose in the descriptions and comments have been augmented to make it clear "running agent" refers to an agent performing a configuration catalog run and not simply the running agent process.
2012-07-23Reduce stubs and expectations on settingsPatrick Carlisle2-13/+10
Many tests set stubs or expectations on configuration values. This is unnecessary, as settings are reset before each test. Because creating a stub stubs out the entire value method on settings, stubbing any individual setting interferes with retrieving any other setting. This makes for weird errors and fragile tests. This commit changes most cases to just set each setting directly. Expectations on settings were often used to verify that a setting is used. This is not a good way of testing this, since it checks that the value is accessed but not that it is actually used correctly. Most expecations on settings are better expressed by changing the setting and then verifying a returned value.
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune2-2/+2
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-04-17(#3757) cleanup and docsChris Price2-8/+8
2012-04-17(#3757) Implement json-based lockfilesChris Price2-10/+8
This commit does the following: 1. Refactors our main lockfile class to accept a data object as an argument to the #lock method. This data can then be retrieved at any time while the lock is held; the implementation is to write the hash as JSON to the lockfile. This will allow external tools to read it without calling into puppet code. 2. Refactor pidlock to use the above--but only serializing a String (the pid) to the file. 3. Refactor disabler to use the above, with a Hash containing a key/value pair identifying the "disabled" message. 4. Fix and clean up spec tests.
2012-04-17(#3757) rename AnonymousFilelock to JsonFilelockChris Price1-6/+6
This commit simply renames AnonymousFilelock to JsonFilelock. The behavior hasn't changed at all yet, so this is a bit of a suspect commit but I wanted to make sure that the git history was as clear as possible as to what happened here.
2012-04-16(#3757) move lockfile path logic into modulesChris Price2-28/+44
The Puppet::Agent::Locker and Puppet::Agent::Disabler had a weird dependency on the existence of some lockfile methods in Agent, but Agent didn't use those methods anywhere else. This commit moves all of the lockfile related stuff into the modules in an attempt to improve encapsulation and clarify the API of the modules.
2012-04-16(#3757) separate settings for agent lockfile pathsChris Price2-19/+19
There are now two different lockfiles for agents; one for indicating that an agent is administratively disabled, and one that indicates that an agent run is already in progress. In previous revisions, the paths for these lockfiles was being built from a single puppet setting via naming convention. This commit does the following: 1. Creates two settings (:agent_running_lockfile and :agent_disabled_lockfile) instead of the previously existing one (:puppetdlock). 2. Removes the Configurer class from the chain of command when the Agent class is determining the lockfile path.
2012-04-16(#3757) re-introduce lockfile changesChris Price2-12/+60
This commit re-introduces the lockfile behavior changes that were originally merged in to 2.7.x via this pull request: https://github.com/puppetlabs/puppet/pull/216 It was reverted because of mcollective compatibility issues. For more info see: http://projects.puppetlabs.com/issues/12844 It is now being reintroduced for Telly, but with some minor modifications. See #3757, #12933 and #12934 for details on those.
2012-03-05Merge branch '2.7.x'Patrick Carlisle2-60/+12
* 2.7.x: (#10722) Add spec to verify that an error is logged on bad http (#10722) Refactor http_spec to use expectations Updating CHANGELOG for 2.7.12rc2 (#7592) Remove redundant call to String#to_s (#11988) Work around Augeas reload bug when changing save modes (#11988) Don't overwrite symlinks in augeas provider (#8312) Fix zypper provider so ensure => 'latest' now works (#12844) Fix a unit test relating to lockfiles (#12914) Allow puppet to be interrupted while waiting for child (#12933) Better error message when agent is administratively disabled (#7592) Remove redundant call to String#to_s (#12844) Agent lockfiles: backwards compatibility with 2.7.10/2.7.11 (#10722) Display errors on HTTP report submission failures Revert "Merge remote-tracking branch 'masterzen/tickets/2.7.x/3757' into 2.7.x" Revert "(#12844) Backwards compatibility for 'puppet agent --enable'" (#11988) Work around Augeas reload bug when changing save modes (#11988) Don't overwrite symlinks in augeas provider (#12881) Fix cron type default name error on windows (#12844) Backwards compatibility for 'puppet agent --enable' (#8312) Fix zypper provider so ensure => 'latest' now works Conflicts: lib/puppet/provider/augeas/augeas.rb lib/puppet/reports/http.rb lib/puppet/util/pidlock.rb spec/unit/application/agent_spec.rb spec/unit/provider/augeas/augeas_spec.rb spec/unit/reports/http_spec.rb
2012-03-01Revert "Merge remote-tracking branch 'masterzen/tickets/2.7.x/3757' into 2.7.x"cprice2-60/+12
This reverts commit 86a806f595f8b7bb280c8c445eef51dfd71bf39d, reversing changes made to ac81771a9cc70b5fb58f86439ebb0585ce92d4e8. See tickets #3757, #12844, #4836, #11057. These changes were deemed to be breaking public APIs, and thus are being reverted from 2.7.x. They'll be reintroduced in 3.x. (The changes in question were relating to how puppet agent creates / manages its lockfiles.) Conflicts: lib/puppet/util/pidlock.rb spec/unit/agent_spec.rb spec/unit/util/pidlock_spec.rb
2012-03-01Revert "(#12844) Backwards compatibility for 'puppet agent --enable'"cprice1-71/+5
This reverts commit fcac8f7163c99884fc6b75e3851c4a5e16a3ff07, which was a backwards-compatibility workaround intended to handle some new behavior related to puppet agent lockfiles that was introduced in 2.7.10. The fix is being reverted because we've decided to remove the new lockfile behavior from the 2.7.x series entirely, and push it out to 3.x.
2012-02-29(#12844) Backwards compatibility for 'puppet agent --enable'cprice1-5/+71
In version 2.7.10 we changed the name of the lock file that is used by 'puppet agent --enable/--disable'. A side effect is that if the lockfile was created under an older version of puppet, the "--enable" command in the newer versions won't delete the old lockfile and thus you can't run your agents. Make --enable attempt to detect and resolve this situation.
2012-01-21Refactor: configurer now returns report.exit_statusBrice Figureau1-4/+4
None of the configurer client was directly using the returned report, but only its exit_status. Since now the configurer might run in a child process, we can't return the report, only a status code. This commit changes the configurer and call site so that only the report exit code is returned. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2011-12-28(#4836) - Agent --disable should allow to put a messageBrice Figureau1-0/+11
This way it is possible to let other users know why a puppet agent has been disabled. Usage: puppet agent --disable "because working on backup" When later on, the puppet agent run would abort with: "Run of Puppet configuration client is administratively disabled because working on backup; skipping" It's also possible to not set a message, in which case a default message is provided. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2011-12-28(#3757) - Refactor enable/disable to its own moduleBrice Figureau2-16/+49
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2011-12-28(#3757) - Move enable/disable to its own lockBrice Figureau1-2/+6
This change also contains a refactor split of Pidlock into its anonymous counterpart. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson1-1/+1
Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
2010-07-09Code smell: Two space indentationMarkus Roberts1-65/+65
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
2010-06-28[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts1-0/+0
Part 2 re-did the change on the spec files, which it shouldn't have.
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-0/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts1-0/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-02-17Feature #3394 REST Runner, preparationJesse Wolfe1-118/+0
Rename Puppet::Agent::Runner to Puppet::Run, for consistency
2009-02-06Adding an Agent::Runner class.Luke Kanies1-0/+118
This will eventually be used by puppetrun, but for now is just called by the old-school Runner handler. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Splitting the Agent class into Agent and ConfigurerLuke Kanies4-372/+14
Once I went to add runinterval support to the Agent class, I realized it's really two classes: One that handles starting, stopping, running, et al (still called Agent), and one that handles downloading the catalog, running it, etc. (now called Configurer). This commit includes some additional code, but 95% of it is just moving code around. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Moving the Agent locking code to a module.Luke Kanies1-0/+86
Also cleaning up the lock usage by yielding to a block when a lock is attained. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Refactoring how the Facter integration worksLuke Kanies1-29/+2
I moved all of the extra Fact modifications into the Facts class, and then moved the calls of those new methods into the Facter terminus. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Moving fact and plugin handling into modulesLuke Kanies3-1/+218
This doesn't change functionality, it just simplifies the agent class. I've also started the work to get the catalog handling done using REST/the Indirector. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Revert "This is work that I've decided not to keep"Luke Kanies2-47/+14
This reverts commit f57a5e88229578747dde2c90af3a696ad0172e72.
2009-02-06This is work that I've decided not to keepLuke Kanies2-14/+47
so I'm just applying it here so it continues to show up in the history in case I ever want to look at it again. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-02-06Adding a new Agent::Downloader class for downloading files.Luke Kanies1-0/+182
This will handling downloading facts and plugins. Signed-off-by: Luke Kanies <luke@madstop.com>