Sha256: 48ff3782f23a82ff616deba5ea20eb5b65c8ec5bb769329d986e56f1da6d7a65

Contents?: true

Size: 1.44 KB

Versions: 21

Compression:

Stored size: 1.44 KB

Contents

require 'puppettest'

module PuppetTest::ServerTest
  include PuppetTest
  def setup
    super

    if defined?(@@port)
      @@port += 1
    else
      @@port = 20000
    end
  end

  # create a simple manifest that just creates a file
  def mktestmanifest
    file = File.join(Puppet[:confdir], "#{(self.class.to_s + "test")}site.pp")
    #@createdfile = File.join(tmpdir, self.class.to_s + "manifesttesting" +
    #    "_#{@method_name}")
    @createdfile = tempfile

    File.open(file, "w") { |f|
      f.puts "file { \"%s\": ensure => file, mode => 755 }\n" % @createdfile
    }

    @@tmpfiles << @createdfile
    @@tmpfiles << file

    file
  end

  # create a server, forked into the background
  def mkserver(handlers = nil)
    Puppet[:name] = "puppetmasterd"
    # our default handlers
    unless handlers
      handlers = {
        :CA => {}, # so that certs autogenerate
        :Master => {
          :Manifest => mktestmanifest,
          :UseNodes => false
        },
      }
    end

    # then create the actual server
    server = nil
    assert_nothing_raised {

            server = Puppet::Network::HTTPServer::WEBrick.new(
                
        :Port => @@port,
        
        :Handlers => handlers
      )
    }

    # fork it
    spid = fork {
      trap(:INT) { server.shutdown }
      server.start
    }

    # and store its pid for killing
    @@tmppids << spid

    # give the server a chance to do its thing
    sleep 1
    spid
  end

end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
puppet-2.6.18 test/lib/puppettest/servertest.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
puppet-2.6.17 test/lib/puppettest/servertest.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
puppet-2.6.16 test/lib/puppettest/servertest.rb
puppet-2.6.15 test/lib/puppettest/servertest.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
puppet-2.7.11 test/lib/puppettest/servertest.rb
puppet-2.6.14 test/lib/puppettest/servertest.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/servertest.rb
puppet-2.6.13 test/lib/puppettest/servertest.rb
puppet-2.7.9 test/lib/puppettest/servertest.rb
puppet-2.7.8 test/lib/puppettest/servertest.rb
puppet-2.7.6 test/lib/puppettest/servertest.rb