1
require 'puppettest/servertest'
3
module PuppetTest::ExeTest
4
include PuppetTest::ServerTest
13
File.join(basedir, "bin")
17
File.join(basedir, "sbin")
21
ENV["PATH"] = [bindir, ENV["PATH"]].join(":") unless ENV["PATH"].split(":").include?(bindir)
22
ENV["PATH"] = [sbindir, ENV["PATH"]].join(":") unless ENV["PATH"].split(":").include?(sbindir)
26
ENV["RUBYLIB"] = $LOAD_PATH.find_all { |dir|
27
dir =~ /puppet/ or dir =~ /\.\./
31
# Run a ruby command. This explicitly uses ruby to run stuff, since we
32
# don't necessarily know where our ruby binary is, dernit.
33
# Currently unused, because I couldn't get it to work.
35
@ruby ||= %x{which ruby}.chomp
36
cmd = cmd.unshift(@ruby).join(" ")
40
out = %x{#{@ruby} #{cmd}}
45
def startmasterd(args = "")
48
manifest = mktestmanifest
49
args += " --manifest #{manifest}"
50
args += " --confdir #{Puppet[:confdir]}"
51
args += " --rundir #{File.join(Puppet[:vardir], "run")}"
52
args += " --vardir #{Puppet[:vardir]}"
53
args += " --certdnsnames #{Puppet[:certdnsnames]}"
54
args += " --masterport #{@@port}"
55
args += " --user #{Puppet::Util::SUIDManager.uid}"
56
args += " --group #{Puppet::Util::SUIDManager.gid}"
57
args += " --autosign true"
63
cmd = "puppetmasterd #{args}"
66
assert_nothing_raised {
67
output = %x{#{cmd}}.chomp
69
assert_equal("", output, "Puppetmasterd produced output #{output}")
70
assert($CHILD_STATUS == 0, "Puppetmasterd exit status was #{$CHILD_STATUS}")
81
def stopmasterd(running = true)
82
ps = Facter["ps"].value || "ps -ef"
84
pidfile = File.join(Puppet[:vardir], "run", "puppetmasterd.pid")
87
if FileTest.exists?(pidfile)
88
pid = File.read(pidfile).chomp.to_i
95
%x{#{ps}}.chomp.split(/\n/).each { |line|
96
if line =~ /ruby.+puppetmasterd/
97
next if line =~ /\.rb/ # skip the test script itself
98
next if line =~ /^puppet/ # skip masters running as 'puppet'
99
ary = line.sub(/^\s+/, '').split(/\s+/)
106
# we default to mandating that it's running, but teardown
107
# doesn't require that
110
raise Puppet::Error, "Tried to kill own pid"
113
Process.kill(:INT, pid)