0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2010, 2012, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
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";