summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDominic Cleal <dcleal@redhat.com>2010-11-27 13:36:04 +0000
committerDominic Cleal <dcleal@redhat.com>2010-11-27 13:36:04 +0000
commitafe2d014feb2210a8666c93465d11e9c9d555f8b (patch)
tree208f5ac82b2c29610d2021821c8fca9b079e638b /test
parent143fc744a839affd328234fca26246d49d15d3d8 (diff)
parent4b35402ba85d8842d757becec5c8a7bf4d6f6654 (diff)
Merge branch 'master' of github.com:domcleal/puppet into master-old
Diffstat (limited to 'test')
-rwxr-xr-xtest/certmgr/ca.rb87
-rwxr-xr-xtest/certmgr/support.rb3
-rw-r--r--test/data/providers/host/parsed/valid_hosts19
-rwxr-xr-xtest/language/functions.rb2
-rwxr-xr-xtest/language/parser.rb93
-rwxr-xr-xtest/language/scope.rb6
-rw-r--r--test/lib/mocha_standalone.rb2
-rwxr-xr-xtest/lib/puppettest.rb30
-rw-r--r--test/lib/puppettest/fakes.rb2
-rw-r--r--test/lib/puppettest/parsertesting.rb13
-rw-r--r--test/lib/puppettest/support/assertions.rb2
-rw-r--r--test/lib/puppettest/support/utils.rb45
-rwxr-xr-xtest/other/provider.rb13
-rwxr-xr-xtest/other/report.rb7
-rwxr-xr-xtest/puppet/tc_suidmanager.rb19
-rwxr-xr-xtest/rails/railsparameter.rb2
-rwxr-xr-xtest/ral/manager/attributes.rb5
-rwxr-xr-xtest/ral/manager/type.rb2
-rwxr-xr-xtest/ral/providers/cron/crontab.rb5
-rwxr-xr-xtest/ral/providers/host/parsed.rb9
-rwxr-xr-xtest/ral/providers/provider.rb6
-rwxr-xr-xtest/util/metrics.rb4
22 files changed, 133 insertions, 243 deletions
diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb
deleted file mode 100755
index 7e0498dfb..000000000
--- a/test/certmgr/ca.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppet'
-require 'puppet/sslcertificates/ca.rb'
-require 'puppettest'
-require 'puppettest/certificates'
-require 'mocha'
-
-class TestCA < Test::Unit::TestCase
- include PuppetTest
-
- def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
- end
-
- def hosts
- %w{host.domain.com Other.Testing.Com}
- end
- def mkca
- Puppet::SSLCertificates::CA.new
- end
-
- def test_clean
- dirs = [:csrdir, :signeddir, :publickeydir, :privatekeydir, :certdir]
- ca = mkca
-
- hosts.each do |host|
- files = []
- dirs.each do |dir|
- dir = Puppet[dir]
- # We handle case insensitivity through downcasing
- file = File.join(dir, host.downcase + ".pem")
- File.open(file, "w") do |f|
- f.puts "testing"
- end
- files << file
- end
- assert_nothing_raised do
- ca.clean(host)
- end
- files.each do |f|
- assert(! FileTest.exists?(f), "File #{f} was not deleted")
- end
- end
- end
-
- def test_host2Xfile
- ca = mkca
- hosts.each do |host|
- {:signeddir => :host2certfile, :csrdir => :host2csrfile}.each do |dir, method|
- val = nil
- assert_nothing_raised do
- val = ca.send(method, host)
- end
- assert_equal(File.join(Puppet[dir], host.downcase + ".pem"), val,
- "incorrect response from #{method}")
- end
- end
- end
-
- def test_list
- ca = mkca
- # Make a fake csr
- dir = Puppet[:csrdir]
- list = []
- hosts.each do |host|
- file = File.join(dir, host.downcase + ".pem")
- File.open(file, "w") { |f| f.puts "yay" }
- list << host.downcase
- end
-
- assert_equal(list.sort, ca.list.sort, "list was not correct")
- end
-
- # #142 - test storing the public key
- def test_store_public_key
- ca = mkca
- assert_nothing_raised do
- ca.mkrootcert
- end
- assert(FileTest.exists?(Puppet[:capub]), "did not store public key")
- end
-end
-
diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb
index 3138c94d7..060c458d8 100755
--- a/test/certmgr/support.rb
+++ b/test/certmgr/support.rb
@@ -89,8 +89,9 @@ class TestCertSupport < Test::Unit::TestCase
should_path = Puppet[:hostprivkey]
dir, file = File.split(should_path)
- newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."}
+ newfile = file.sub(/^([-a-z.0-9]+)\./) { $1.upcase + "."}
upper_path = File.join(dir, newfile)
+p upper_path
File.open(upper_path, "w") { |f| f.print key.to_s }
user = CertUser.new
diff --git a/test/data/providers/host/parsed/valid_hosts b/test/data/providers/host/parsed/valid_hosts
new file mode 100644
index 000000000..24636295d
--- /dev/null
+++ b/test/data/providers/host/parsed/valid_hosts
@@ -0,0 +1,19 @@
+# Some leading comment, that should be ignored
+# The next line is empty so it should be ignored
+
+::1 localhost
+
+# We now try another delimiter: Several tabs
+127.0.0.1 localhost
+
+# No test trailing spaces
+10.0.0.1 host1
+
+# Ok its time to test aliases
+2001:252:0:1::2008:8 ipv6host alias1
+192.168.0.1 ipv4host alias2 alias3
+
+# Testing inlinecomments now
+192.168.0.2 host3 # This is host3
+192.168.0.3 host4 alias10 # This is host4
+192.168.0.4 host5 alias11 alias12 # This is host5
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 1d4ed8241..081063e2b 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -451,7 +451,7 @@ class TestLangFunctions < Test::Unit::TestCase
scope.function_include("nosuchclass")
end
- parser.newclass("myclass")
+ scope.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "myclass", {})
scope.compiler.expects(:evaluate_classes).with(%w{myclass otherclass}, scope, false).returns(%w{myclass otherclass})
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 5a433c724..6f3d751c2 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -39,9 +39,8 @@ class TestParser < Test::Unit::TestCase
failers { |file|
parser = mkparser
Puppet.debug("parsing failer #{file}") if __FILE__ == $0
- assert_raise(Puppet::ParseError, "Did not fail while parsing #{file}") {
- parser.file = file
- ast = parser.parse
+ assert_raise(Puppet::ParseError, Puppet::Error, "Did not fail while parsing #{file}") {
+ Puppet[:manifest] = file
config = mkcompiler(parser)
config.compile
#ast.hostclass("").evaluate config.topscope
@@ -97,7 +96,7 @@ class TestParser < Test::Unit::TestCase
}
4.times { |i|
- path = File.join(basedir, subdir, "subfile#{i}")
+ path = File.join(basedir, subdir, "subfile#{i}.pp")
mkmanifest(path)
}
@@ -137,8 +136,8 @@ class TestParser < Test::Unit::TestCase
end
def test_importedclasses
- imported = tempfile
- importer = tempfile
+ imported = tempfile '.pp'
+ importer = tempfile '.pp'
made = tempfile
@@ -288,7 +287,7 @@ class TestParser < Test::Unit::TestCase
ret = parser.parse
}
- ret.hostclass("").code.each do |obj|
+ ret.code.each do |obj|
assert_instance_of(AST::Collection, obj)
end
end
@@ -362,12 +361,12 @@ file { "/tmp/yayness":
assert_raise(Puppet::ParseError) {
- parser.parse %{define mydef($schedule) {}}
+ parser.known_resource_types.import_ast(parser.parse(%{define mydef($schedule) {}}), '')
}
assert_nothing_raised {
- parser.parse %{define adef($schedule = false) {}}
- parser.parse %{define mydef($schedule = daily) {}}
+ parser.known_resource_types.import_ast(parser.parse(%{define adef($schedule = false) {}}), '')
+ parser.known_resource_types.import_ast(parser.parse(%{define mydef($schedule = daily) {}}), '')
}
end
@@ -379,12 +378,12 @@ file { "/tmp/yayness":
str1 = %{if true { #{exec.call("true")} }}
ret = nil
assert_nothing_raised {
- ret = parser.parse(str1).hostclass("").code[0]
+ ret = parser.parse(str1).code[0]
}
assert_instance_of(Puppet::Parser::AST::IfStatement, ret)
parser = mkparser
str2 = %{if true { #{exec.call("true")} } else { #{exec.call("false")} }}
- ret = parser.parse(str2).hostclass("").code[0]
+ ret = parser.parse(str2).code[0]
assert_instance_of(Puppet::Parser::AST::IfStatement, ret)
assert_instance_of(Puppet::Parser::AST::Else, ret.else)
end
@@ -393,23 +392,23 @@ file { "/tmp/yayness":
parser = mkparser
assert_nothing_raised {
- parser.parse %{class myclass { class other {} }}
+ parser.known_resource_types.import_ast(parser.parse(%{class myclass { class other {} }}), '')
}
assert(parser.hostclass("myclass"), "Could not find myclass")
assert(parser.hostclass("myclass::other"), "Could not find myclass::other")
assert_nothing_raised {
- parser.parse "class base {}
+ parser.known_resource_types.import_ast(parser.parse("class base {}
class container {
class deep::sub inherits base {}
- }"
+ }"), '')
}
sub = parser.hostclass("container::deep::sub")
assert(sub, "Could not find sub")
# Now try it with a parent class being a fq class
assert_nothing_raised {
- parser.parse "class container::one inherits container::deep::sub {}"
+ parser.known_resource_types.import_ast(parser.parse("class container::one inherits container::deep::sub {}"), '')
}
sub = parser.hostclass("container::one")
assert(sub, "Could not find one")
@@ -417,7 +416,7 @@ file { "/tmp/yayness":
# Finally, try including a qualified class
assert_nothing_raised("Could not include fully qualified class") {
- parser.parse "include container::deep::sub"
+ parser.known_resource_types.import_ast(parser.parse("include container::deep::sub"), '')
}
end
@@ -426,20 +425,11 @@ file { "/tmp/yayness":
# Make sure we put the top-level code into a class called "" in
# the "" namespace
- assert_nothing_raised do
- out = parser.parse ""
-
- assert_instance_of(Puppet::Resource::TypeCollection, out)
- assert_nil(parser.hostclass(""), "Got a 'main' class when we had no code")
- end
-
- # Now try something a touch more complicated
parser.initvars
assert_nothing_raised do
- out = parser.parse "Exec { path => '/usr/bin:/usr/sbin' }"
- assert_instance_of(Puppet::Resource::TypeCollection, out)
- assert_equal("", parser.hostclass("").name)
- assert_equal("", parser.hostclass("").namespace)
+ parser.known_resource_types.import_ast(parser.parse("Exec { path => '/usr/bin:/usr/sbin' }"), '')
+ assert_equal("", parser.known_resource_types.hostclass("").name)
+ assert_equal("", parser.known_resource_types.hostclass("").namespace)
end
end
@@ -482,22 +472,26 @@ file { "/tmp/yayness":
ret = nil
assert_nothing_raised do
- ret = parser.parse("#{at}file { '/tmp/testing': owner => root }")
+ parser.known_resource_types.import_ast(parser.parse("#{at}file { '/tmp/testing': owner => root }"), '')
+ ret = parser.known_resource_types
end
assert_instance_of(AST::ASTArray, ret.hostclass("").code)
resdef = ret.hostclass("").code[0]
assert_instance_of(AST::Resource, resdef)
- assert_equal("/tmp/testing", resdef.title.value)
+ assert_instance_of(AST::ASTArray, resdef.instances)
+ assert_equal(1, resdef.instances.children.length)
+ assert_equal("/tmp/testing", resdef.instances[0].title.value)
# We always get an astarray back, so...
check.call(resdef, "simple resource")
# Now let's try it with multiple resources in the same spec
assert_nothing_raised do
- ret = parser.parse("#{at}file { ['/tmp/1', '/tmp/2']: owner => root }")
+ parser.known_resource_types.import_ast(parser.parse("#{at}file { ['/tmp/1', '/tmp/2']: owner => root }"), '')
+ ret = parser.known_resource_types
end
- ret.hostclass("").code.each do |res|
+ ret.hostclass("").code[0].each do |res|
assert_instance_of(AST::Resource, res)
check.call(res, "multiresource")
end
@@ -537,7 +531,7 @@ file { "/tmp/yayness":
ret = parser.parse("File #{arrow}")
end
- coll = ret.hostclass("").code[0]
+ coll = ret.code[0]
assert_instance_of(AST::Collection, coll)
assert_equal(form, coll.form)
end
@@ -560,7 +554,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -583,7 +577,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -607,7 +601,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised("Could not parse '#{test}'") do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -624,15 +618,11 @@ file { "/tmp/yayness":
def test_fully_qualified_definitions
parser = mkparser
+ types = parser.known_resource_types
assert_nothing_raised("Could not parse fully-qualified definition") {
- parser.parse %{define one::two { }}
+ types.import_ast(parser.parse(%{define one::two { }}), '')
}
assert(parser.definition("one::two"), "Could not find one::two with no namespace")
-
- # Now try using the definition
- assert_nothing_raised("Could not parse fully-qualified definition usage") {
- parser.parse %{one::two { yayness: }}
- }
end
# #524
@@ -655,9 +645,9 @@ file { "/tmp/yayness":
end
def test_multiple_imports_on_one_line
- one = tempfile
- two = tempfile
- base = tempfile
+ one = tempfile '.pp'
+ two = tempfile '.pp'
+ base = tempfile '.pp'
File.open(one, "w") { |f| f.puts "$var = value" }
File.open(two, "w") { |f| f.puts "$var = value" }
File.open(base, "w") { |f| f.puts "import '#{one}', '#{two}'" }
@@ -691,7 +681,7 @@ file { "/tmp/yayness":
result = parser.parse %{$variable = undef}
}
- main = result.hostclass("").code
+ main = result.code
children = main.children
assert_instance_of(AST::VarDef, main.children[0])
assert_instance_of(AST::Undef, main.children[0].value)
@@ -704,7 +694,8 @@ file { "/tmp/yayness":
str = "file { '/tmp/yay': ensure => file }\nclass yay {}\nnode foo {}\ndefine bar {}\n"
result = nil
assert_nothing_raised("Could not parse") do
- result = parser.parse(str)
+ parser.known_resource_types.import_ast(parser.parse(str), '')
+ result = parser.known_resource_types
end
assert_instance_of(Puppet::Resource::TypeCollection, result, "Did not get a ASTSet back from parsing")
@@ -734,12 +725,14 @@ file { "/tmp/yayness":
result = nil
assert_nothing_raised do
- result = parser.newclass "Yayness"
+ parser.known_resource_types.import_ast(parser.parse("class yayness { }"), '')
+ result = parser.known_resource_types.hostclass('yayness')
end
assert_equal(result, parser.find_hostclass("", "yayNess"))
assert_nothing_raised do
- result = parser.newdefine "FunTest"
+ parser.known_resource_types.import_ast(parser.parse("define funtest { }"), '')
+ result = parser.known_resource_types.definition('funtest')
end
assert_equal(result, parser.find_definition("", "fUntEst"), "#{"fUntEst"} was not matched")
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index cb5558aec..d9c122a92 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -163,7 +163,7 @@ class TestScope < Test::Unit::TestCase
config = mkcompiler
# Create a default source
- parser.newclass("")
+ parser.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
config.topscope.source = parser.known_resource_types.hostclass("")
# And a scope resource
@@ -175,12 +175,12 @@ class TestScope < Test::Unit::TestCase
)
# Create a top-level define
- parser.newdefine "one", :arguments => [%w{arg}],
+ parser.known_resource_types.add Puppet::Resource::Type.new(:definition, "one", :arguments => [%w{arg}],
:code => AST::ASTArray.new(
:children => [
resourcedef("file", "/tmp", {"owner" => varref("arg")})
]
- )
+ ))
# create a resource that calls our third define
obj = resourcedef("one", "boo", {"arg" => "parentfoo"})
diff --git a/test/lib/mocha_standalone.rb b/test/lib/mocha_standalone.rb
deleted file mode 100644
index ce605811a..000000000
--- a/test/lib/mocha_standalone.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'mocha/standalone'
-require 'mocha/object'
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index e31a31902..a60092cf7 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -6,17 +6,6 @@ mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
$LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib)
require 'puppet'
-
-# include any gems in vendor/gems
-Dir["#{mainlib}/../vendor/gems/**"].each do |path|
- libpath = File.join(path, "lib")
- if File.directory?(libpath)
- $LOAD_PATH.unshift(libpath)
- else
- $LOAD_PATH.unshift(path)
- end
-end
-
require 'mocha'
# Only load the test/unit class if we're not in the spec directory.
@@ -31,16 +20,7 @@ if ARGV.include?("-d")
$console = true
end
-# Some monkey-patching to allow us to test private methods.
-class Class
- def publicize_methods(*methods)
- saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
-
- self.class_eval { public(*saved_private_instance_methods) }
- yield
- self.class_eval { private(*saved_private_instance_methods) }
- end
-end
+require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods'))
module PuppetTest
# These need to be here for when rspec tests use these
@@ -205,7 +185,7 @@ module PuppetTest
#if rake? or ! Puppet[:debug]
#if defined?($puppet_debug) or ! rake?
Puppet[:color] = false if textmate?
- Puppet::Util::Log.newdestination(@logs)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
if defined? $console
Puppet.info @method_name
Puppet::Util::Log.newdestination(:console)
@@ -227,14 +207,14 @@ module PuppetTest
#Facter.stubs(:to_hash).returns({})
end
- def tempfile
+ def tempfile(suffix = '')
if defined?(@@tmpfilenum)
@@tmpfilenum += 1
else
@@tmpfilenum = 1
end
- f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s)
+ f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s + suffix)
@@tmpfiles ||= []
@@tmpfiles << f
f
@@ -325,7 +305,7 @@ module PuppetTest
def logstore
@logs = []
- Puppet::Util::Log.newdestination(@logs)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
end
end
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index aaa711004..712332b74 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -1,4 +1,4 @@
-require 'puppettest'
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/puppet/util'))
module PuppetTest
# A baseclass for the faketypes.
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index bd04c1ec5..411bad37a 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -94,16 +94,15 @@ module PuppetTest::ParserTesting
def resourcedef(type, title, params)
title = stringobj(title) unless title.is_a?(AST)
+ instance = AST::ResourceInstance.new(:title => title, :parameters => resourceparams(params))
assert_nothing_raised("Could not create #{type} #{title}") {
return AST::Resource.new(
:file => __FILE__,
:line => __LINE__,
- :title => title,
:type => type,
-
- :parameters => resourceinst(params)
+ :instances => AST::ASTArray.new(:children => [instance])
)
}
end
@@ -122,9 +121,7 @@ module PuppetTest::ParserTesting
:file => __FILE__,
:line => __LINE__,
:object => resourceref(type, title),
-
- :type => type,
- :parameters => resourceinst(params)
+ :parameters => resourceparams(params)
)
}
end
@@ -197,13 +194,13 @@ module PuppetTest::ParserTesting
}
end
- def resourceinst(hash)
+ def resourceparams(hash)
assert_nothing_raised("Could not create resource instance") {
params = hash.collect { |param, value|
resourceparam(param, value)
}
- return AST::ResourceInstance.new(
+ return AST::ASTArray.new(
:file => tempfile,
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 7f326b119..31fa3f1da 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -1,8 +1,6 @@
-require 'puppettest'
require 'puppettest/support/utils'
require 'fileutils'
-
module PuppetTest
include PuppetTest::Support::Utils
def assert_logged(level, regex, msg = nil)
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index edc81d3d6..e022f123c 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -1,5 +1,3 @@
-require 'puppettest'
-
module PuppetTest::Support
end
module PuppetTest::Support::Utils
@@ -7,6 +5,30 @@ module PuppetTest::Support::Utils
Puppet.warning "#{type}: #{ObjectSpace.each_object(type) { |o| }}"
end
+ def basedir(*list)
+ unless defined? @@basedir
+ Dir.chdir(File.dirname(__FILE__)) do
+ @@basedir = File.dirname(File.dirname(File.dirname(File.dirname(Dir.getwd))))
+ end
+ end
+ if list.empty?
+ @@basedir
+ else
+ File.join(@@basedir, *list)
+ end
+ end
+
+ def fakedata(dir,pat='*')
+ glob = "#{basedir}/test/#{dir}/#{pat}"
+ files = Dir.glob(glob,File::FNM_PATHNAME)
+ raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
+ files
+ end
+
+ def datadir(*list)
+ File.join(basedir, "test", "data", *list)
+ end
+
#
# TODO: I think this method needs to be renamed to something a little more
# explanatory.
@@ -38,10 +60,6 @@ module PuppetTest::Support::Utils
config
end
- # stop any services that might be hanging around
- def stopservices
- end
-
# TODO: rewrite this to use the 'etc' module.
# Define a variable that contains the name of my user.
@@ -84,7 +102,7 @@ module PuppetTest::Support::Utils
end
def fakefile(name)
- ary = [PuppetTest.basedir, "test"]
+ ary = [basedir, "test"]
ary += name.split("/")
file = File.join(ary)
raise Puppet::DevError, "No fakedata file #{file}" unless FileTest.exists?(file)
@@ -140,16 +158,3 @@ module PuppetTest::Support::Utils
config
end
end
-
-module PuppetTest
- include PuppetTest::Support::Utils
-
- def fakedata(dir,pat='*')
- glob = "#{basedir}/test/#{dir}/#{pat}"
- files = Dir.glob(glob,File::FNM_PATHNAME)
- raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
- files
- end
- module_function :fakedata
-
-end
diff --git a/test/other/provider.rb b/test/other/provider.rb
index 052d7a0d0..a539ee5a7 100755
--- a/test/other/provider.rb
+++ b/test/other/provider.rb
@@ -70,24 +70,13 @@ class TestImpl < Test::Unit::TestCase
child = @type.provide("child", :parent => parent.name) {}
}
- assert_nothing_raised {
- child.commands :which => "which"
- }
-
- assert(child.command(:which), "Did not find 'which' command")
-
- assert(child.command(:which) =~ /^\//,
- "Command did not become fully qualified")
- assert(FileTest.exists?(child.command(:which)),
- "Did not find actual 'which' binary")
-
assert_raise(Puppet::DevError) do
child.command(:nosuchcommand)
end
# Now create a parent command
assert_nothing_raised {
- parent.commands :sh => Puppet::Util.binary('sh')
+ parent.commands :sh => Puppet::Util.which('sh')
}
assert(parent.command(:sh), "Did not find 'sh' command")
diff --git a/test/other/report.rb b/test/other/report.rb
index b3b41da19..8a909b41c 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -35,10 +35,7 @@ class TestReports < Test::Unit::TestCase
config.retrieval_duration = 0.001
trans = config.apply
- report = Puppet::Transaction::Report.new
- trans.add_metrics_to_report(report)
-
- report
+ trans.generate_report
end
# Make sure we can use reports as log destinations.
@@ -95,7 +92,7 @@ class TestReports < Test::Unit::TestCase
assert_equal(yaml, File.read(file), "File did not get written")
end
- if Puppet.features.rrd?
+ if Puppet.features.rrd? || Puppet.features.rrd_legacy?
def test_rrdgraph_report
Puppet.settings.use(:main, :metrics)
report = mkreport
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb
index 449f2aef5..eeb56f2c9 100755
--- a/test/puppet/tc_suidmanager.rb
+++ b/test/puppet/tc_suidmanager.rb
@@ -80,20 +80,11 @@ class TestSUIDManager < Test::Unit::TestCase
warn "Cannot run this test on ruby < 1.8.4"
else
set_exit_status!
-
-
- Puppet::Util.expects(:execute).with(
- 'yay',
- { :failonfail => false,
- :uid => @user.uid,
-
- :gid => @user.gid }
- ).returns('output')
-
-
- output = Puppet::Util::SUIDManager.run_and_capture 'yay',
- @user.uid,
- @user.gid
+ Puppet::Util.
+ expects(:execute).
+ with('yay',:combine => true, :failonfail => false, :uid => @user.uid, :gid => @user.gid).
+ returns('output')
+ output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid
assert_equal 'output', output.first
assert_kind_of Process::Status, output.last
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index 9f6fc1c1e..77ce33912 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -22,7 +22,7 @@ class TestRailsParameter < Test::Unit::TestCase
# Now create a source
parser = mkparser
- source = parser.newclass "myclass"
+ source = parser.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "myclass")
host = Puppet::Rails::Host.new(:name => "myhost")
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb
index 74a4d0708..6d0284d9e 100755
--- a/test/ral/manager/attributes.rb
+++ b/test/ral/manager/attributes.rb
@@ -229,7 +229,10 @@ class TestTypeAttributes < Test::Unit::TestCase
end
yes.each { |a| assert(resource.should(a), "Did not get value for #{a} in #{prov.name}") }
no.each do |a|
- # These may or may not get passed to the provider. We shouldn't care.
+ assert_nil(resource.should(a), "Got value for unsupported %s in %s" % [a, prov.name])
+ if Puppet::Util::Log.sendlevel?(:info)
+ assert(@logs.find { |l| l.message =~ /not managing attribute #{a}/ and l.level == :info }, "No warning about failed %s" % a)
+ end
end
@logs.clear
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index 7df643005..145877722 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -276,7 +276,7 @@ class TestType < Test::Unit::TestCase
def test_isomorphic_names
catalog = mk_catalog
# First do execs, since they're not isomorphic.
- echo = Puppet::Util.binary "echo"
+ echo = Puppet::Util.which "echo"
exec1 = exec2 = nil
assert_nothing_raised do
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 0c87a5bba..be2af1e16 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -97,7 +97,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
# Then do them all at once.
records = []
text = ""
- sample_records.each do |name, options|
+ # Sort sample_records so that the :empty entry does not come last
+ # (if it does, the test will fail because the empty last line will
+ # be ignored)
+ sample_records.sort { |a, b| a.first.to_s <=> b.first.to_s }.each do |name, options|
records << options[:record]
text += options[:text] + "\n"
end
diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb
index c2367d566..955edd5d3 100755
--- a/test/ral/providers/host/parsed.rb
+++ b/test/ral/providers/host/parsed.rb
@@ -67,7 +67,8 @@ class TestParsedHostProvider < Test::Unit::TestCase
# Make sure we convert both directlys correctly using a simple host.
def test_basic_isomorphism
- hash = {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host}}
+ hash = {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host},
+ :comment => ''}
str = nil
assert_nothing_raised do
@@ -105,11 +106,13 @@ class TestParsedHostProvider < Test::Unit::TestCase
[
{:record_type => :comment, :line => "# comment one"},
{:record_type => :blank, :line => ""},
- {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host}},
+ {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host},
+ :comment => ''},
{:record_type => :blank, :line => " "},
{:record_type => :comment, :line => "# another comment"},
- {:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57", :host_aliases => []}
+ {:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57", :host_aliases => [],
+ :comment => ''}
], instances)
newtext = nil
diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb
index cb0b2a19e..f46e03f82 100755
--- a/test/ral/providers/provider.rb
+++ b/test/ral/providers/provider.rb
@@ -9,7 +9,7 @@ class TestProvider < Test::Unit::TestCase
include PuppetTest
def echo
- echo = Puppet::Util.binary("echo")
+ echo = Puppet::Util.which("echo")
raise "Could not find 'echo' binary; cannot complete test" unless echo
@@ -95,7 +95,7 @@ class TestProvider < Test::Unit::TestCase
provider.commands :testing => "/no/such/path"
- provider.stubs(:binary).returns "/no/such/path"
+ provider.stubs(:which).returns "/no/such/path"
provider.command(:testing)
assert_equal("/no/such/path", provider.command(:testing), "Did not return correct binary path")
@@ -187,7 +187,7 @@ class TestProvider < Test::Unit::TestCase
dir = tstdir
file = File.join(dir, "mycmd")
- sh = Puppet::Util.binary("sh")
+ sh = Puppet::Util.which("sh")
File.open(file, "w") { |f|
f.puts %{#!#{sh}
echo A Failure >&2
diff --git a/test/util/metrics.rb b/test/util/metrics.rb
index 1fd57f2f1..82e792d0b 100755
--- a/test/util/metrics.rb
+++ b/test/util/metrics.rb
@@ -8,7 +8,7 @@ require 'puppettest'
require 'puppet/type'
class TestMetric < PuppetTest::TestCase
- confine "Missing RRDtool library" => Puppet.features.rrd?
+ confine "Missing RRDtool library" => (Puppet.features.rrd? || Puppet.features.rrd_legacy?)
include PuppetTest
def gendata
@@ -43,7 +43,7 @@ class TestMetric < PuppetTest::TestCase
def rundata(report, time)
assert_nothing_raised {
gendata.each do |name, data|
- report.newmetric(name, data)
+ report.add_metric(name, data)
end
report.metrics.each { |n, m| m.store(time) }
}