start.pl revision 6e9b7dc9c7aa9351dcebe815417de7ffe101e5ea
a3128c1995310262648e575a9ff148d5741fd167Tinderbox User# Copyright (C) 2010, 2012 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# Permission to use, copy, modify, and/or distribute this software for any
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# purpose with or without fee is hereby granted, provided that the above
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# copyright notice and this permission notice appear in all copies.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# PERFORMANCE OF THIS SOFTWARE.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# $Id: start.pl,v 1.2 2010/06/17 05:38:05 marka Exp $
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Framework for starting test servers.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Based on the type of server specified, check for port availability, remove
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# temporary files, start the server, and verify that the server is running.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# If a server is specified, start it. Otherwise, start all servers for test.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Option handling
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# --noclean test [server [options]]
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# --noclean - Do not cleanup files in server directory
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# test - name of the test directory
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# server - name of the server directory
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# options - alternate options for the server
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrewsmy $usage = "usage: $0 [--noclean] test-directory [server-directory [server-options]]";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "$usage\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "No test directory: \"$test\"\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "No server directory: \"$test/$server\"\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Global variables
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Start the server(s)
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews # Determine which servers need to be started for this test.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews # Start the servers we found.
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews foreach (@ns) {
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews foreach (@ns) {
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# Subroutines
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews my $return = system("$PERL $topdir/testsock.pl -p 5300 $options");
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "$0: could not bind to server addresses, still running?\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "I:server sockets not available\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "R:FAIL\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews system("$PERL $topdir/stop.pl $testdir"); # Is this the correct behavior?
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "I:Couldn't bind to socket (yet)\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews $cleanup_files = "{*.jnl,*.bk,*.st,named.run}";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "I:Unknown server type $server\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "R:FAIL\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews system "$PERL $topdir/stop.pl $testdir";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews# print "I:starting server $server\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews chdir "$testdir/$server";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews system "$command";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews while (!-f $pid_file) {
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "I:Couldn't start server $server\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "R:FAIL\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews system "$PERL $topdir/stop.pl $testdir";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews my $return = system("$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p 5300 version.bind. chaos txt \@10.53.0.$n > dig.out");
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "I:no response from $server\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews print "R:FAIL\n";
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews system("$PERL $topdir/stop.pl $testdir");
43c770b9987375e9e0efa19617b22e8e6a748a63Mark Andrews unlink "dig.out";