diff options
-rw-r--r-- | lib/puppet/face/node/clean.rb | 5 | ||||
-rwxr-xr-x | spec/unit/face/node_spec.rb | 222 |
2 files changed, 115 insertions, 112 deletions
diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb index a4df1bfaf..d2852de04 100644 --- a/lib/puppet/face/node/clean.rb +++ b/lib/puppet/face/node/clean.rb @@ -54,7 +54,10 @@ Puppet::Face.define(:node, '0.0.1') do clean_cached_facts(node) clean_cached_node(node) clean_reports(node) - clean_storeconfigs(node, unexport) + + # This is roughly functional, but seems to introduce order-dependent test + # failures; this can be re-added when those issues are resolved. + # clean_storeconfigs(node, unexport) end # clean signed cert for +host+ diff --git a/spec/unit/face/node_spec.rb b/spec/unit/face/node_spec.rb index 7151353a0..6f6edc6cc 100755 --- a/spec/unit/face/node_spec.rb +++ b/spec/unit/face/node_spec.rb @@ -10,7 +10,9 @@ describe Puppet::Face[:node, '0.0.1'] do "cached_facts" => ['hostname'], "cached_node" => ['hostname'], "reports" => ['hostname'], - "storeconfigs" => ['hostname', :unexport] + + # Support for cleaning storeconfigs has been temporarily suspended. + # "storeconfigs" => ['hostname', :unexport] }.each { |k, v| subject.expects("clean_#{k}".to_sym).with(*v) } subject.cleanup('hostname', :unexport) end @@ -152,116 +154,114 @@ describe Puppet::Face[:node, '0.0.1'] do end end - describe "when cleaning storeconfigs entries for host", :if => Puppet.features.rails? do - before :each do - # Stub this so we don't need access to the DB - require 'puppet/rails/host' - - Puppet.stubs(:[]).with(:storeconfigs).returns(true) - - Puppet::Rails.stubs(:connect) - @rails_node = stub_everything 'rails_node' - Puppet::Rails::Host.stubs(:find_by_name).returns(@rails_node) - end - - it "should connect to the database" do - Puppet::Rails.expects(:connect) - subject.clean_storeconfigs(@host, false) - end - - it "should find the right host entry" do - Puppet::Rails::Host.expects(:find_by_name).with(@host).returns(@rails_node) - - subject.clean_storeconfigs(@host, false) - end - - describe "without unexport" do - it "should remove the host and it's content" do - @rails_node.expects(:destroy) - - subject.clean_storeconfigs(@host, false) - end - end - - describe "with unexport" do - before :each do - @rails_node.stubs(:id).returns(1234) - - @type = stub_everything 'type' - @type.stubs(:validattr?).with(:ensure).returns(true) - - @ensure_name = stub_everything 'ensure_name', :id => 23453 - Puppet::Rails::ParamName.stubs(:find_or_create_by_name).returns(@ensure_name) - - @param_values = stub_everything 'param_values' - @resource = stub_everything 'resource', :param_values => @param_values, :restype => "File" - Puppet::Rails::Resource.stubs(:find).returns([@resource]) - end - - it "should find all resources" do - Puppet::Rails::Resource.expects(:find).with(:all, {:include => {:param_values => :param_name}, :conditions => ["exported=? AND host_id=?", true, 1234]}).returns([]) - - subject.clean_storeconfigs(@host, true) - end - - describe "with an exported native type" do - before :each do - Puppet::Type.stubs(:type).returns(@type) - @type.expects(:validattr?).with(:ensure).returns(true) - end - - it "should test a native type for ensure as an attribute" do - subject.clean_storeconfigs(@host, true) - end - - it "should delete the old ensure parameter" do - ensure_param = stub 'ensure_param', :id => 12345, :line => 12 - @param_values.stubs(:find).returns(ensure_param) - Puppet::Rails::ParamValue.expects(:delete).with(12345); - subject.clean_storeconfigs(@host, true) - end - - it "should add an ensure => absent parameter" do - @param_values.expects(:create).with(:value => "absent", - :line => 0, - :param_name => @ensure_name) - subject.clean_storeconfigs(@host, true) - end - end - - describe "with an exported definition" do - it "should try to lookup a definition and test it for the ensure argument" do - Puppet::Type.stubs(:type).returns(nil) - definition = stub_everything 'definition', :arguments => { 'ensure' => 'present' } - Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition) - subject.clean_storeconfigs(@host, true) - end - end - - it "should not unexport the resource of an unkown type" do - Puppet::Type.stubs(:type).returns(nil) - Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil) - Puppet::Rails::ParamName.expects(:find_or_create_by_name).never - subject.clean_storeconfigs(@host) - end - - it "should not unexport the resource of a not ensurable native type" do - Puppet::Type.stubs(:type).returns(@type) - @type.expects(:validattr?).with(:ensure).returns(false) - Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil) - Puppet::Rails::ParamName.expects(:find_or_create_by_name).never - subject.clean_storeconfigs(@host, true) - end - - it "should not unexport the resource of a not ensurable definition" do - Puppet::Type.stubs(:type).returns(nil) - definition = stub_everything 'definition', :arguments => { 'foobar' => 'someValue' } - Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition) - Puppet::Rails::ParamName.expects(:find_or_create_by_name).never - subject.clean_storeconfigs(@host, true) - end - end - end + # describe "when cleaning storeconfigs entries for host", :if => Puppet.features.rails? do + # before :each do + # # Stub this so we don't need access to the DB + # require 'puppet/rails/host' + # + # Puppet.stubs(:[]).with(:storeconfigs).returns(true) + # + # Puppet::Rails.stubs(:connect) + # @rails_node = stub_everything 'rails_node' + # Puppet::Rails::Host.stubs(:find_by_name).returns(@rails_node) + # end + # + # it "should connect to the database" do + # Puppet::Rails.expects(:connect) + # subject.clean_storeconfigs(@host, false) + # end + # + # it "should find the right host entry" do + # Puppet::Rails::Host.expects(:find_by_name).with(@host).returns(@rails_node) + # subject.clean_storeconfigs(@host, false) + # end + # + # describe "without unexport" do + # it "should remove the host and it's content" do + # @rails_node.expects(:destroy) + # subject.clean_storeconfigs(@host, false) + # end + # end + # + # describe "with unexport" do + # before :each do + # @rails_node.stubs(:id).returns(1234) + # + # @type = stub_everything 'type' + # @type.stubs(:validattr?).with(:ensure).returns(true) + # + # @ensure_name = stub_everything 'ensure_name', :id => 23453 + # Puppet::Rails::ParamName.stubs(:find_or_create_by_name).returns(@ensure_name) + # + # @param_values = stub_everything 'param_values' + # @resource = stub_everything 'resource', :param_values => @param_values, :restype => "File" + # Puppet::Rails::Resource.stubs(:find).returns([@resource]) + # end + # + # it "should find all resources" do + # Puppet::Rails::Resource.expects(:find).with(:all, {:include => {:param_values => :param_name}, :conditions => ["exported=? AND host_id=?", true, 1234]}).returns([]) + # + # subject.clean_storeconfigs(@host, true) + # end + # + # describe "with an exported native type" do + # before :each do + # Puppet::Type.stubs(:type).returns(@type) + # @type.expects(:validattr?).with(:ensure).returns(true) + # end + # + # it "should test a native type for ensure as an attribute" do + # subject.clean_storeconfigs(@host, true) + # end + # + # it "should delete the old ensure parameter" do + # ensure_param = stub 'ensure_param', :id => 12345, :line => 12 + # @param_values.stubs(:find).returns(ensure_param) + # Puppet::Rails::ParamValue.expects(:delete).with(12345); + # subject.clean_storeconfigs(@host, true) + # end + # + # it "should add an ensure => absent parameter" do + # @param_values.expects(:create).with(:value => "absent", + # :line => 0, + # :param_name => @ensure_name) + # subject.clean_storeconfigs(@host, true) + # end + # end + # + # describe "with an exported definition" do + # it "should try to lookup a definition and test it for the ensure argument" do + # Puppet::Type.stubs(:type).returns(nil) + # definition = stub_everything 'definition', :arguments => { 'ensure' => 'present' } + # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition) + # subject.clean_storeconfigs(@host, true) + # end + # end + # + # it "should not unexport the resource of an unknown type" do + # Puppet::Type.stubs(:type).returns(nil) + # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil) + # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never + # subject.clean_storeconfigs(@host) + # end + # + # it "should not unexport the resource of a not ensurable native type" do + # Puppet::Type.stubs(:type).returns(@type) + # @type.expects(:validattr?).with(:ensure).returns(false) + # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(nil) + # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never + # subject.clean_storeconfigs(@host, true) + # end + # + # it "should not unexport the resource of a not ensurable definition" do + # Puppet::Type.stubs(:type).returns(nil) + # definition = stub_everything 'definition', :arguments => { 'foobar' => 'someValue' } + # Puppet::Resource::TypeCollection.any_instance.expects(:find_definition).with('', "File").returns(definition) + # Puppet::Rails::ParamName.expects(:find_or_create_by_name).never + # subject.clean_storeconfigs(@host, true) + # end + # end + # end end end end |