summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-28 08:06:46 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-28 08:06:46 +0000
commit652982257d7d4b1fdfada25880d70b29702a4c69 (patch)
tree9c538a33e20f7ca131ece23fde1f1c7824f1a5f3 /test
parent038d6a6e79da9db5a12ca3e78c4539178cc49b44 (diff)
downloadpuppet-652982257d7d4b1fdfada25880d70b29702a4c69.tar.gz
puppet-652982257d7d4b1fdfada25880d70b29702a4c69.tar.xz
puppet-652982257d7d4b1fdfada25880d70b29702a4c69.zip
I have not yet finished testing, but most of the providers now successfully pass arrays to execute() instead of strings, which means that the vast majority of execution problems are now gone. I will finish testing tomorrow, hopefully, and will also hopefully be able to verify that the execution-related bugs are fixed.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1979 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/certmgr/certmgr.rb5
-rw-r--r--test/lib/puppettest/railstesting.rb4
-rwxr-xr-x[-rw-r--r--]test/other/relationship.rb0
-rwxr-xr-xtest/other/report.rb3
-rwxr-xr-xtest/other/transactions.rb15
-rwxr-xr-xtest/providers/host/netinfo.rb (renamed from test/providers/netinfo_host.rb)0
-rwxr-xr-xtest/providers/host/parsed.rb (renamed from test/providers/parsedhost.rb)0
-rwxr-xr-xtest/providers/nameservice.rb3
-rwxr-xr-xtest/providers/package.rb9
-rwxr-xr-xtest/providers/user.rb7
-rwxr-xr-xtest/rails/host.rb4
-rwxr-xr-xtest/types/basic.rb69
-rwxr-xr-xtest/types/file.rb14
-rwxr-xr-xtest/types/filesources.rb4
-rwxr-xr-xtest/types/query.rb99
-rwxr-xr-xtest/types/type.rb4
-rwxr-xr-xtest/util/utiltest.rb17
17 files changed, 68 insertions, 189 deletions
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb
index 90d516cb4..561012c12 100755
--- a/test/certmgr/certmgr.rb
+++ b/test/certmgr/certmgr.rb
@@ -243,6 +243,7 @@ class TestCertMgr < Test::Unit::TestCase
assert(!store.verify(h1, [ca.cert]))
assert( store.verify(h2, [ca.cert]))
+ Puppet.err :yay
ca.revoke(h2.serial)
assert_equal(1, ca.crl.extensions.size)
@@ -250,8 +251,8 @@ class TestCertMgr < Test::Unit::TestCase
ca = mkCA()
store = mkStore(ca)
assert( store.verify(ca.cert))
- assert(!store.verify(h1, [ca.cert]), "revoked cert passed")
- assert(!store.verify(h2, [ca.cert]), "revoked cert passed")
+ assert(!store.verify(h1, [ca.cert]), "first revoked cert passed")
+ assert(!store.verify(h2, [ca.cert]), "second revoked cert passed")
end
def test_ttl
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index 2014c17ef..8b5f074a2 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -8,7 +8,9 @@ module PuppetTest::RailsTesting
# If we don't clean up the connection list, then the rails
# lib will still think it's connected.
- ActiveRecord::Base.clear_active_connections!
+ if Puppet.features.rails?
+ ActiveRecord::Base.clear_active_connections!
+ end
end
def railsinit
diff --git a/test/other/relationship.rb b/test/other/relationship.rb
index c6f8eb763..c6f8eb763 100644..100755
--- a/test/other/relationship.rb
+++ b/test/other/relationship.rb
diff --git a/test/other/report.rb b/test/other/report.rb
index 551cf4b28..e53cb0050 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -61,7 +61,8 @@ class TestReports < Test::Unit::TestCase
# Create a bunch of log messages in an array.
report = Puppet::Transaction::Report.new
- # We have to reuse reporting here because of something going on in the server/report.rb file
+ # We have to reuse reporting here because of something going on in the
+ # server/report.rb file
Puppet.config.use(:reporting)
3.times { |i|
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 5feec5c96..6e2b28717 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -209,18 +209,6 @@ class TestTransactions < Test::Unit::TestCase
}
end
- def newservice
- assert_nothing_raised() {
- return Puppet.type(:service).create(
- :name => "sleeper",
- :type => "init",
- :path => exampledir("root/etc/init.d"),
- :hasstatus => true,
- :check => [:ensure]
- )
- }
- end
-
def newexec(file)
assert_nothing_raised() {
return Puppet.type(:exec).create(
@@ -528,7 +516,8 @@ class TestTransactions < Test::Unit::TestCase
# Make sure all of the components are gone
comps = graph.vertices.find_all { |v| v.is_a?(Puppet::Type::Component)}
- assert(comps.empty?, "Deps graph still contains components %s" % comps.inspect)
+ assert(comps.empty?, "Deps graph still contains components %s" %
+ comps.collect { |c| c.ref }.join(","))
assert_equal([], comps, "Deps graph still contains components")
diff --git a/test/providers/netinfo_host.rb b/test/providers/host/netinfo.rb
index e6bbc22d6..e6bbc22d6 100755
--- a/test/providers/netinfo_host.rb
+++ b/test/providers/host/netinfo.rb
diff --git a/test/providers/parsedhost.rb b/test/providers/host/parsed.rb
index 6f7d36b8c..6f7d36b8c 100755
--- a/test/providers/parsedhost.rb
+++ b/test/providers/host/parsed.rb
diff --git a/test/providers/nameservice.rb b/test/providers/nameservice.rb
index 157cf83f2..20624d175 100755
--- a/test/providers/nameservice.rb
+++ b/test/providers/nameservice.rb
@@ -4,13 +4,14 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
require 'puppet'
+require 'puppet/provider/nameservice'
require 'facter'
class TestNameServiceProvider < Test::Unit::TestCase
include PuppetTest::FileTesting
def test_option
- klass = Class.new(Puppet::Type::Provider::NameService)
+ klass = Class.new(Puppet::Provider::NameService)
klass.model = Puppet::Type.type(:user)
val = nil
diff --git a/test/providers/package.rb b/test/providers/package.rb
index 6de88eace..7511fde30 100755
--- a/test/providers/package.rb
+++ b/test/providers/package.rb
@@ -79,8 +79,13 @@ class TestPackageProvider < Test::Unit::TestCase
assert_nothing_raised("Could not query provider") do
result = provider.query
end
- assert_instance_of(Hash, result, "query did not return hash")
- assert(result[:ensure] != :absent, msg)
+ assert((result == :listed or result.is_a?(Hash)),
+ "query did not return hash or :listed")
+ if result == :listed
+ assert(provider.model.is(:ensure) != :absent, msg)
+ else
+ assert(result[:ensure] != :absent, msg)
+ end
end
# Run a package through all of its paces. FIXME This should use the
diff --git a/test/providers/user.rb b/test/providers/user.rb
index 40d3828cc..fd2008504 100755
--- a/test/providers/user.rb
+++ b/test/providers/user.rb
@@ -291,8 +291,11 @@ class TestUserProvider < Test::Unit::TestCase
return
end
- assert_raise(ArgumentError, "gid allowed a non-integer value") do
- user.gid = group.name
+ # Stupid netinfo
+ if Facter.value(:operatingsystem) == "Darwin"
+ assert_raise(ArgumentError, "gid allowed a non-integer value") do
+ user.gid = group.name
+ end
end
assert_nothing_raised("Failed to specify group by id") {
diff --git a/test/rails/host.rb b/test/rails/host.rb
index 38389ac64..9c3ce3d16 100755
--- a/test/rails/host.rb
+++ b/test/rails/host.rb
@@ -19,11 +19,11 @@ class TestRailsHost < Test::Unit::TestCase
def setup
super
- railsinit
+ railsinit if Puppet.features.rails?
end
def teardown
- railsteardown
+ railsteardown if Puppet.features.rails?
super
end
diff --git a/test/types/basic.rb b/test/types/basic.rb
index 2e9a6be58..e54f22ccb 100755
--- a/test/types/basic.rb
+++ b/test/types/basic.rb
@@ -7,14 +7,12 @@ require 'puppettest'
class TestBasic < Test::Unit::TestCase
include PuppetTest
- # hmmm
- # this is complicated, because we store references to the created
- # objects in a central store
+
def setup
super
@component = nil
@configfile = nil
- @sleeper = nil
+ @command = nil
assert_nothing_raised() {
@component = Puppet.type(:component).create(
@@ -25,7 +23,6 @@ class TestBasic < Test::Unit::TestCase
assert_nothing_raised() {
@filepath = tempfile()
- @@tmpfiles << @filepath
@configfile = Puppet.type(:file).create(
:path => @filepath,
:ensure => "file",
@@ -33,27 +30,27 @@ class TestBasic < Test::Unit::TestCase
)
}
assert_nothing_raised() {
- @sleeper = Puppet.type(:service).create(
- :name => "sleeper",
- :provider => "init",
- :path => exampledir("root/etc/init.d"),
- :hasstatus => true,
- :ensure => :running
+ @command = Puppet.type(:exec).create(
+ :title => "echo",
+ :command => "echo yay",
+ :path => ENV["PATH"]
)
}
assert_nothing_raised() {
@component.push(
@configfile,
- @sleeper
+ @command
)
}
-
- #puts "Component is %s, id %s" % [@component, @component.object_id]
- #puts "ConfigFile is %s, id %s" % [@configfile, @configfile.object_id]
+ end
+
+ def teardown
+ super
+ stopservices
end
def test_name_calls
- [@sleeper,@configfile].each { |obj|
+ [@command, @configfile].each { |obj|
Puppet.debug "obj is %s" % obj
assert_nothing_raised(){
obj.name
@@ -62,48 +59,20 @@ class TestBasic < Test::Unit::TestCase
end
def test_name_equality
- #puts "Component is %s, id %s" % [@component, @component.object_id]
- assert_equal(
- @filepath,
- @configfile.name
- )
+ assert_equal(@filepath, @configfile.title)
- assert_equal(
- "sleeper",
- @sleeper.name
- )
+ assert_equal("echo", @command.title)
end
def test_object_retrieval
- [@sleeper,@configfile].each { |obj|
- assert_equal(
- obj.class[obj.name].object_id,
- obj.object_id
- )
- }
- end
-
- def test_transaction
- transaction = nil
- assert_nothing_raised() {
- transaction = @component.evaluate
- }
- assert_nothing_raised() {
- transaction.evaluate
- }
- assert_nothing_raised() {
- @sleeper[:ensure] = :running
- }
- assert_nothing_raised() {
- transaction = @component.evaluate
- }
- assert_nothing_raised() {
- transaction.evaluate
+ [@command, @configfile].each { |obj|
+ assert_equal(obj.class[obj.name].object_id, obj.object_id,
+ "%s did not match class version" % obj.ref)
}
end
def test_paths
- [@configfile,@sleeper,@component].each { |obj|
+ [@configfile, @command, @component].each { |obj|
assert_nothing_raised {
assert_instance_of(String, obj.path)
}
diff --git a/test/types/file.rb b/test/types/file.rb
index 0a330eee3..cebdac636 100755
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1797,7 +1797,7 @@ class TestFile < Test::Unit::TestCase
assert_equal(:false, file[:replace], ":replace did not alias :false to :no")
end
- # #365
+ # #365 -- make sure generated files also use filebuckets.
def test_recursive_filebuckets
source = tempfile()
dest = tempfile()
@@ -1830,16 +1830,20 @@ class TestFile < Test::Unit::TestCase
end
# Now modify the source files to make sure things get backed up correctly
- [s1, s2].each { |sf| File.open(sf, "w") { |f| f.puts "boo: %s" % File.basename(sf) } }
+ [s1, s2].each { |sf| File.open(sf, "w") { |f|
+ f.puts "boo: %s" % File.basename(sf)
+ } }
assert_apply(file)
dfiles.each do |f|
- assert_equal("boo: %s\n" % File.basename(f), File.read(f), "file was not copied correctly")
+ assert_equal("boo: %s\n" % File.basename(f), File.read(f),
+ "file was not copied correctly")
end
# Make sure we didn't just copy the files over to backup locations
dfiles.each do |f|
- assert(! FileTest.exists?(f + "rtest"), "file %s was copied for backup instead of bucketed" % File.basename(f))
+ assert(! FileTest.exists?(f + "rtest"),
+ "file %s was copied for backup instead of bucketed" % File.basename(f))
end
# Now make sure we can get the source sums from the bucket
@@ -1890,7 +1894,7 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised do
file[:backup] = "testing"
end
- assert_equal(obj.bucket, file[:backup], "bucket was not retrieved")
+ assert_equal("testing", file[:backup], "backup value was reset")
assert_equal(obj.bucket, file.bucket, "file's bucket was not set")
end
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index 09036cca0..a3f229a02 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -14,7 +14,7 @@ class TestFileSources < Test::Unit::TestCase
if defined? @port
@port += 1
else
- @port = 8800
+ @port = 12345
end
@file = Puppet::Type.type(:file)
end
@@ -625,7 +625,7 @@ class TestFileSources < Test::Unit::TestCase
Puppet[:masterport] = @port
serverpid = nil
- assert_nothing_raised() {
+ assert_nothing_raised("Could not start on port %s" % @port) {
server = Puppet::Server.new(
:Port => @port,
:Handlers => {
diff --git a/test/types/query.rb b/test/types/query.rb
deleted file mode 100755
index a7ccb7f2e..000000000
--- a/test/types/query.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
-
-require 'puppet'
-require 'puppettest'
-
-# $Id$
-
-class TestQuery < Test::Unit::TestCase
- include PuppetTest
- # hmmm
- # this is complicated, because we store references to the created
- # objects in a central store
- def file
- assert_nothing_raised() {
- cfile = exampledir("root/etc/configfile")
- unless Puppet.type(:file).has_key?(cfile)
- Puppet.type(:file).create(
- :path => cfile,
- :check => [:mode, :owner, :checksum]
- )
- end
- @configfile = Puppet.type(:file)[cfile]
- }
- return @configfile
- end
-
- def service
- assert_nothing_raised() {
- unless Puppet.type(:service).has_key?("sleeper")
- Puppet.type(:service).create(
- :name => "sleeper",
- :provider => "init",
- :path => exampledir("root/etc/init.d"),
- :hasstatus => true,
- :check => [:ensure]
- )
- end
- @sleeper = Puppet.type(:service)["sleeper"]
- }
-
- return @sleeper
- end
-
- def component(name,*args)
- assert_nothing_raised() {
- @component = Puppet.type(:component).create(:name => name)
- }
-
- args.each { |arg|
- assert_nothing_raised() {
- @component.push arg
- }
- }
-
- return @component
- end
-
- def test_file
- yayfile = file()
- #p yayfile
- yayfile.eachstate { |state|
- assert_nil(state.is)
- }
-
- assert_nothing_raised() {
- yayfile.retrieve
- }
-
- assert_nothing_raised() {
- yayfile[:check] = :group
- }
-
- assert_nothing_raised() {
- yayfile.retrieve
- }
- end
-
- def test_service
- service = service()
- assert(service, "Did not get service object")
- service.eachstate { |state|
- assert_nil(state.is)
- }
-
- assert_nothing_raised() {
- service.retrieve
- }
- end
-
- def test_component
- component = component("a",file(),service())
-
- assert_nothing_raised() {
- component.retrieve
- }
- end
-end
diff --git a/test/types/type.rb b/test/types/type.rb
index 8a90271d6..98ff8101d 100755
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -229,7 +229,7 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised {
user = Puppet.type(:user).create(
- :name => "pptestAA",
+ :name => "pptestAB",
:comment => "Testingness"
)
}
@@ -238,7 +238,7 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised {
user = Puppet.type(:user).create(
- :name => "pptestBB",
+ :name => "pptestBC",
:comment => "A fake user"
)
}
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 3e9082bf5..86db02305 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -303,21 +303,24 @@ class TestPuppetUtil < Test::Unit::TestCase
assert(FileTest.exists?(file), "file was not created")
assert_equal(user.uid, File.stat(file).uid, "uid was not set correctly")
- # We can't really check the gid, because it just behaves too inconsistently everywhere.
- # assert_equal(group.gid, File.stat(file).gid, "gid was not set correctly")
+ # We can't really check the gid, because it just behaves too
+ # inconsistently everywhere.
+ # assert_equal(group.gid, File.stat(file).gid,
+ # "gid was not set correctly")
end
end
+ # Check whether execute() accepts strings in addition to arrays.
def test_string_exec
cmd = "/bin/echo howdy"
output = nil
- assert_nothing_raised {
+ assert_raise(ArgumentError) {
output = Puppet::Util.execute(cmd)
}
- assert_equal("howdy\n", output)
- assert_raise(RuntimeError) {
- Puppet::Util.execute(cmd, 0, 0)
- }
+ #assert_equal("howdy\n", output)
+ #assert_raise(RuntimeError) {
+ # Puppet::Util.execute(cmd, 0, 0)
+ #}
end
# This is mostly to test #380.