summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-18 21:03:18 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-18 21:03:18 +0000
commit099bf6c582b8e68263f25c0430fcf3d5ac7b1b7f (patch)
tree34ac81add7aeb9cd48ac599a02255d15218d6e13
parentf96ec6d7ab9d18d2068f388508d811c39973df1e (diff)
downloadpuppet-099bf6c582b8e68263f25c0430fcf3d5ac7b1b7f.tar.gz
puppet-099bf6c582b8e68263f25c0430fcf3d5ac7b1b7f.tar.xz
puppet-099bf6c582b8e68263f25c0430fcf3d5ac7b1b7f.zip
Fixing some failing tests.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2616 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/network/handler/master.rb2
-rw-r--r--lib/puppet/rails/host.rb1
-rwxr-xr-xtest/network/handler/master.rb47
-rwxr-xr-xtest/rails/host.rb47
4 files changed, 44 insertions, 53 deletions
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index 50c988917..e889c1ba8 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -71,7 +71,7 @@ class Puppet::Network::Handler
host = Puppet::Rails::Host.find_or_create_by_name(client)
host.last_freshcheck = Time.now
- if clientip and (! host.ip or host.ip == "")
+ if clientip and (! host.ip or host.ip == "" or host.ip == "NULL")
host.ip = clientip
end
host.save
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index cd60a2b4b..ca1e10c93 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -95,6 +95,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
ar_hash_merge(get_facts_hash(), facts,
:create => Proc.new { |name, values|
fact_name = Puppet::Rails::FactName.find_or_create_by_name(name)
+ values = [values] unless values.is_a?(Array)
values.each do |value|
fact_values.build(:value => value,
:fact_name => fact_name)
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 917e5d8d9..08e17373b 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -7,10 +7,6 @@ require 'puppet/network/handler/master'
class TestMaster < Test::Unit::TestCase
include PuppetTest::ServerTest
- def teardown
- super
- #print "\n\n\n\n" if Puppet[:debug]
- end
# run through all of the existing test files and make sure everything
# works
@@ -303,49 +299,6 @@ class TestMaster < Test::Unit::TestCase
assert_equal(fakename, name)
assert_equal(fakeip, ip)
end
-
- if Puppet.features.rails?
- def test_freshness_connect_update
- Puppet::Rails.init
- Puppet[:storeconfigs] = true
-
- # this is the default server setup
- master = Puppet::Network::Handler.master.new(
- :Code => "",
- :UseNodes => true,
- :Local => true
- )
-
- # Create a host
- Puppet::Rails::Host.new(:name => "test", :ip => "192.168.0.3").save
-
- assert_nothing_raised("Failed to update last_connect for unknown host") do
- master.freshness("created",'192.168.0.1')
- end
-
- # Make sure it created the host
- created = Puppet::Rails::Host.find_by_name("created")
- assert(created, "Freshness did not create host")
- assert(created.last_freshcheck,
- "Did not set last_freshcheck on created host")
- assert_equal("192.168.0.1", created.ip,
- "Did not set IP address on created host")
-
- # Now check on the existing host
- assert_nothing_raised("Failed to update last_connect for unknown host") do
- master.freshness("test",'192.168.0.2')
- end
-
- # Recreate it, so we're not using the cached object.
- host = Puppet::Rails::Host.find_by_name("test")
-
- # Make sure it created the host
- assert(host.last_freshcheck,
- "Did not set last_freshcheck on existing host")
- assert_equal("192.168.0.3", host.ip,
- "Overrode IP on found host")
- end
- end
end
# $Id$
diff --git a/test/rails/host.rb b/test/rails/host.rb
index 3005ac5e2..f3190c047 100755
--- a/test/rails/host.rb
+++ b/test/rails/host.rb
@@ -12,7 +12,8 @@ require 'puppettest/parsertesting'
require 'puppettest/resourcetesting'
require 'puppettest/railstesting'
-class TestRailsHost < Test::Unit::TestCase
+class TestRailsHost < PuppetTest::TestCase
+ confine "Missing ActiveRecord" => Puppet.features.rails?
include PuppetTest::ParserTesting
include PuppetTest::ResourceTesting
include PuppetTest::RailsTesting
@@ -33,8 +34,6 @@ class TestRailsHost < Test::Unit::TestCase
}
end
- # Don't do any tests w/out this class
- if Puppet.features.rails?
def test_store
@interp, @scope, @source = mkclassframing
# First make some objects
@@ -157,8 +156,46 @@ class TestRailsHost < Test::Unit::TestCase
"loglevel was not added")
end
end
- else
- $stderr.puts "Install Rails for Rails and Caching tests"
+
+ def test_freshness_connect_update
+ Puppet::Rails.init
+ Puppet[:storeconfigs] = true
+
+ # this is the default server setup
+ master = Puppet::Network::Handler.master.new(
+ :Code => "",
+ :UseNodes => true,
+ :Local => true
+ )
+
+ # Create a host
+ Puppet::Rails::Host.new(:name => "test", :ip => "192.168.0.3").save
+
+ assert_nothing_raised("Failed to update last_connect for unknown host") do
+ master.freshness("created",'192.168.0.1')
+ end
+
+ # Make sure it created the host
+ created = Puppet::Rails::Host.find_by_name("created")
+ assert(created, "Freshness did not create host")
+ assert(created.last_freshcheck,
+ "Did not set last_freshcheck on created host")
+ assert_equal("192.168.0.1", created.ip,
+ "Did not set IP address on created host")
+
+ # Now check on the existing host
+ assert_nothing_raised("Failed to update last_connect for unknown host") do
+ master.freshness("test",'192.168.0.2')
+ end
+
+ # Recreate it, so we're not using the cached object.
+ host = Puppet::Rails::Host.find_by_name("test")
+
+ # Make sure it created the host
+ assert(host.last_freshcheck,
+ "Did not set last_freshcheck on existing host")
+ assert_equal("192.168.0.3", host.ip,
+ "Overrode IP on found host")
end
end