ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <khat...@axiomsystems.com>
Subject RE: Waiting for server to start
Date Mon, 16 Feb 2004 08:57:09 GMT
Thanks Seb, that looks like the kind of thing I am after, will give it a try when I have the
time ...

Keith


-----Original Message-----
From: Sebastien Blanc [mailto:Sebastien.Blanc@alcatel.com]
Sent: 13 February 2004 20:32
To: Ant Users List
Subject: Re: Waiting for server to start


Hi !
I'm using jython to check in the log traces that jboss is up and that ear is
deployed. the following uses BSF but the same could be done with a  <java
classname="org.python.util.jython" failonerror="true" fork="true" >.
seb.

 <target name="ignite" depends="lclinit">
    <parallel>
      <!--
        Start the APPSERVER in parallel.
        And wait for the server to be ready.
        Launch the test client when ready.
      -->
      <sequential>
        <ant target="server.removeTrace" />
        <ant target="server.cleanup" />
        <ant target="server.dropGemdb" />
        <echo message="TEST_CLIENT: Starting the APPSERVER in parallel ..."/>
        <ant dir="../../../script" target="start"/>
        <echo message="TEST_CLIENT: Warning: APPSERVER Thread is back here
..."/>
      </sequential>

      <sequential>
        <echo message="TEST_CLIENT: Sleeping on APPSERVER to start for a few
seconds ..."/>
        <sleep seconds="60" />

        <ant target="runTests" />

        <echo message="TEST_CLIENT: The non reg tests are done. May see the
reports ... ..."/>
      </sequential>
    </parallel>

  </target>

  <target name="runTests" depends="server.ready, theNE.aligned, lclinit">
    <!-- Run the integration test scripts -->
    <antcall target="integtests" />
    <antcall target="tests-report" />
  </target>

  <target name="server.ready" depends="lclinit">

    <script language="jpython"> <![CDATA[
from java.lang import String;
import time;
beforeLastLine='';

runtime = project.getProperty("runtime.dir");
print 'runtime.dir = ' + runtime

up = 'INFO  [org.jboss.system.server.Server] JBoss'
started = 'Started in'

while (not beforeLastLine is None):
     f = open(runtime + '/trace/jboss_server_ems.log', "r");
     lines = f.readlines();
     l = len(lines);
     beforeLastLine=lines[l-1];

     # remove trailing character
     ll = len(beforeLastLine) - 1;
     purgedLine = '';
     i = 0;
     for c in beforeLastLine:
         if (i < ll):
             purgedLine = purgedLine + c; # todo: add break to optimize
         i = i+1
     beforeLastLine = purgedLine;
     print 'TEST_CLIENT: Waiting for the APPSERVER to be UP ...'
     f.close();

     if ((not String(beforeLastLine).indexOf(String(up)) == -1) or ( not
String(beforeLastLine).indexOf(String(started)))):
         beforeLastLine = None;
     time.sleep(10)

print 'TEST_CLIENT: The APPSERVER is ready now ...'
    ]]> </script>

seb.

Nick Neuberger wrote:

> I don't quite understand the reason why you would want to run the test cases
> before the app server is started.  Can you just run a task to start the
> appserver, then run the tests.
>
> Another possiblity.  Are you using an Http Server on port 80, then the
> appserver hooked to another port.  You may be getting a response from an
> http server before the app server is ready.  FYI - This does happen with IBM
> Http Server and WebSphere app server.  If this is the case...  Start app
> server, then start http server, then start test cases....
>
> Hope it helps.
>
> Nick
>
> -----Original Message-----
> From: Keith Hatton [mailto:khatton@axiomsystems.com]
> Sent: Friday, February 13, 2004 4:37 AM
> To: Ant-User (E-mail 2)
> Subject: Waiting for server to start
>
> Hi all,
>
> Part of my build file starts an application server, performs test cases
> against it, and shuts down the server. I'm successfully using the <parallel>
> task to achive this, conceptually like so:
>
>         |
>   +-----+-----+
>   |           |
> start       wait
>   |           |
>   |        run tests
>   |           |
>   |         stop
>   |           |
>   +-----+-----+
>         |
>
> My problem is the "wait" part. I have been using <waitfor> and <url> to
> check for the app server's URL, but recently I have noticed that sometimes
> the URL is available before the server initialisation has really completed,
> which can lead to spurious test failures, and (for very small projects) even
> the possibility that the "stop" task is called before the server has really
> started.
>
> The server is JBoss, and strictly I should be checking the server output for
> a text string. Any ideas on the best way to do this?
>
> (Current "start" target):
>             <echo>Starting JBoss ...</echo>
>             <exec dir="${jboss.home}/bin" executable="cmd.exe" os="Windows
> 2000" output="jboss.out">
>                 <arg line="/c run.bat"/>
>                 <env key="NOPAUSE" value="true"/>
>             </exec>
>             <echo>JBoss has stopped</echo>
>
> (Current "wait" target ... the <sleep> is a hack to work around the
> problem):
>             <echo>Waiting for JBoss ...</echo>
>             <waitfor maxwait="120" maxwaitunit="second" checkevery="20"
> checkeveryunit="second">
>                 <http url="http://localhost:8080/jmx-console"/>
>             </waitfor>
>             <sleep seconds="10"/>
>             <echo>JBoss has started</echo>
>
> Thanks for any suggestions
> Keith
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
> - - - - - -
> This e-mail message is intended only for the use of the individual or entity
> identified in the alias address of this message and may contain confidential
> and privileged information. Any unauthorized review, use, disclosure or
> distribution of this e-mail message is strictly prohibited. If you have
> received this e-mail message in error, please notify the sender immediately
> by reply e-mail and delete this message from your system. Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message