diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-31 02:34:28 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-31 02:34:28 +0000 |
commit | 7547baf6424ccb5f172566b11b9e3d7fe324fe00 (patch) | |
tree | 747d3bd72a006288303522d889b3cfe757549bdc /ext | |
parent | 1e11a1a418bc3449e7606c450b500005afc2c7d1 (diff) | |
download | puppet-7547baf6424ccb5f172566b11b9e3d7fe324fe00.tar.gz puppet-7547baf6424ccb5f172566b11b9e3d7fe324fe00.tar.xz puppet-7547baf6424ccb5f172566b11b9e3d7fe324fe00.zip |
Adding a test for rails
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2731 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/puppet-test | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/ext/puppet-test b/ext/puppet-test index c67bbd525..b89156caa 100755 --- a/ext/puppet-test +++ b/ext/puppet-test @@ -176,7 +176,8 @@ class Suite } end - $options[:repeat].times do + $options[:repeat].times do |i| + @count = i if forked? msg = doc + " in PID %s" % Process.pid else @@ -256,6 +257,72 @@ Suite.new :file, "File interactions" do end end +# Note that this uses an env variable to determine how many resources per +# host to create (with a default of 10). 'repeat' determines how +# many hosts to create. You probably will get mad failures if you +# use forking and sqlite. +# Here's an example run of this test, using sqlite: +# RESOURCE_COUNT=50 ext/puppet-test --suite rails --test storage --confdir /tmp/storagetesting --vardir /tmp/storagetesting --repeat 10 +Suite.new :rails, "Rails Interactions" do + def prepare + Puppet::Rails.init + @facts = Facter.to_hash + + if num = ENV["RESOURCECOUNT"] + @resources = Integer(num) + else + @resources = 10 + end + end + + Resource = Puppet::Parser::Resource + + def execute(test, msg) + begin + send(test) + rescue => detail + puts detail.backtrace if Puppet[:trace] + Puppet.err "%s failed: %s" % [@name, detail.to_s] + end + end + + def mkresource(type, title, parameters) + source = "fakesource" + res = Resource.new(:type => type, :title => title, :source => source, :scope => "fakescope") + + parameters.each do |param, value| + res.set(param, value, source) + end + res + end + + def ref(type, title) + Resource::Reference.new(:type => type, :title => title) + end + + newtest :storage, "Stored resources" do + hostname = "host%s" % @count + @facts["hostname"] = hostname + args = {:facts => @facts, :name => hostname} + + # Make all of the resources we want. Make them at least slightly complex, + # so we model real resources as close as we can. + resources = [] + args[:resources] = resources + @resources.times do |resnum| + exec = mkresource("exec", "exec%s" % resnum, :command => "/bin/echo do something %s" % resnum) + exec.tags = %w{exec one} << "exec%s" % resnum + user = mkresource("user", "user%s" % resnum, :uid => resnum.to_s, :require => ref("exec", "exec%s" % resnum)) + user.tags = %w{user one two} << "user%s" % resnum + file = mkresource("file", "/tmp/file%s" % resnum, :owner => resnum.to_s, :require => [ref("exec", "exec%s" % resnum), ref("user", "user%s" % resnum)]) + file.tags = %w{file one three} << "file%s" % resnum + file.exported = true + resources << exec << user << file + end + Puppet::Rails::Host.store(args) + end +end + $cmdargs = [ [ "--compile", "-c", GetoptLong::NO_ARGUMENT ], [ "--describe", "-D", GetoptLong::REQUIRED_ARGUMENT ], |