running the package spec before the puppetral spec got the following problem: Failure/Error: @agent = MCollective::Test::LocalAgentTest.new("puppetral", :agent_file => agent_file).plugin RuntimeError: Plugin connector_plugin already loaded # /home/vagrant/work/marionette-collective/lib/mcollective/pluginmanager.rb:37:in `<<' # /home/vagrant/work/mcollective-test/lib/mcollective/test/util.rb:60:in `create_connector_mock' # /home/vagrant/work/mcollective-test/lib/mcollective/test/local_agent_test.rb:15:in `initialize' # ./agent/puppetral/spec/puppetral_spec.rb:7:in `new' # ./agent/puppetral/spec/puppetral_spec.rb:7 For some reason the PluginManager isn't clearing properly in the package specs with the spec_helper. After manually clearing the PluginManager there was still the issue of the package test reopening the Puppet::Type, which then also caused problems for puppetral. Now all the specs pass with the rake task.
The rake task to run all the specs was having issues with the fact that requiring the spec_helper with different paths does multiple requires and leads to issues with declaring the mock framework: >RUBYLIB=~/work/marionette-collective/lib:$RUBYLIB rake test (in /home/vagrant/work/mcollective-plugins) /usr/bin/ruby1.8 -S rspec --format s --colour --backtrace agent/package/spec/package_application_spec.rb agent/package/spec/package_agent_spec.rb agent/puppetral/spec/puppetral_spec.rb agent/puppetd/spec/puppetd_application_spec.rb agent/puppetd/spec/puppetd_agent_spec.rb agent/puppetca/spec/puppetca_agent_spec.rb agent/nrpe/spec/nrpe_agent_spec.rb agent/service/spec/service_application_spec.rb agent/service/spec/service_agent_spec.rb /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:470:in `assert_no_example_groups_defined': RSpec's mock_framework configuration option must be configured before any example groups are defined, but you have already defined a group. (RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError) from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:168:in `mock_framework=' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:142:in `mock_with' from /home/vagrant/work/mcollective-plugins/agent/puppetral/spec/../../../spec/spec_helper.rb:12 from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core.rb:71:in `configure' from /home/vagrant/work/mcollective-plugins/agent/puppetral/spec/../../../spec/spec_helper.rb:11 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require' from /home/vagrant/work/mcollective-plugins/agent/puppetral/spec/puppetral_spec.rb:3 from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `autorun' from /usr/bin/rspec:19 rake aborted! One option is to wrap all the requires of spec_helper in expand path, but I prefer the more succinct syntax available when rspec is in the shebang.
Instead of returning the result of the Puppet::Resource.indirection.save under the :resource key, we now instead do a find. This has the effect of returning more information about the created resource, since the return value of indirection.save only contains info about the parameters that changed, and not about all properties of the resource. Reviewed-by: Joshua Lifton <email@example.com>
This commit changes the service and package agents (and DDL files) to the Apache 2.0 license, in order to match the current licensing of Puppet.
This commit edits the comments and user-facing prompts in the puppetral, puppetd, service, package, sshkey, meta, and actionpolicy plugins, in preparation for PE 2.0.
Some erroneous code ended up in the agent due to a merge mixup, and also we weren't pruning the parameters from resource hashes returned by the create method. This commit resolves these issues and updates the specs. Reviewed-by: Joshua Lifton <firstname.lastname@example.org>
never used and so never worked. Fix the variables used to store stdout etc
* feature/master/9923-puppetd-support-for-puppet-as-daemon: Making cleaner status logic Increment puppetd agent version number Adding spec test for dead process Check the running PID, else start --onetime Handle cases for Puppet running vs idling (#9923) Support puppet agent as a daemon from puppetd Use 2-space indenting everywhere in the plugins. Fix bad input stub => failing test for puppetd agent. Conflicts: agent/puppetral/agent/puppetral.rb
Recent changes to the agent caused all non-property parameters to be trimmed from resources when finding & searching; this is desirable in all cases except for when dealing with packages, where it is necessary to know the provider. This commit adds a method for parameter pruning (which was previously being duplicated between the find and search action) and also special-cases package providers to retain them. Reviewed-by: Joshua Lifton <email@example.com>
Previously, to check whether a resource creation succeeded, we only checked the :ensure value of the resource returned by the Puppet::Resource indirection#save; however, there are some cases where resource creation will fail, but this :ensure value will still not be :absent. Instead, we now check the status of the report returned by Puppet (only in Puppet 2.7.6 or greater) to see what the status of the catalog application was; this will also give us any error information we might want to return to the client. Also, the avoid_conflict key must be changed to a symbol when accessing the value from the resources found on the system because Puppet::Resource#to_pson_hash is indexed by symbol. Paired-with: Matt Robinson <firstname.lastname@example.org>
The `puppetd` MCollective agent didn't play nicely with a daemonized Puppet agent; it would notice the lockfile and refuse to run. Now, instead, it will send SIGUSR1 to the daemon. That will trigger an immediate run of Puppet, unless we are still in the middle of the first (and only) splay interval. During that window the agent will just pick a new splay and wait that out; this is a limitation of the agent and there is nothing else we can do. Signed-off-by: Daniel Pittman <email@example.com>
In Ruby you can use an array deference on a Fixnum and get the bits at that position; when you use a non-integer key you get zero, which is valid. The test stubbed 0, a Fixnum, as a return value to stimulate an error return, but it actually worked. Replacing that with a more invalid value lets us get the failure expected, and so exercise the right code path. Signed-off-by: Daniel Pittman <firstname.lastname@example.org>
This commit adds tests for lots of recently added functionality. In the process of adding these tests, I uncovered some bugs in our conflict resolution features (which allow potentially conflicting parameters to be removed before resource creation). These have been fixed, with tests to confirm the fixes. Reviewed-by: Matt Robinson <email@example.com>