You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Steve Loughran <st...@apache.org> on 2005/08/12 16:38:21 UTC
starting and killing background exec or java task
I'm just reviewing what major changes I am needing to do to my (big)
work project to simplify stuff. One troublespot is running functional
tests against a running system, I need to (maybe) start a program, run
tests against it and then stop the program if I started it (but not if
it was already running under a debugger or something). what we have
today is nasty and brittle.
I have to start something in parallel, wait by polling a port for a
signal that it is running, then run the tests, finally shut it down if
we started it (broken).
<target name="system-tests"
depends="parse,dist,compile-tests,init-codebase"
description="run system tests"
if="system.tests.enabled">
<parallel>
<!-- first thread runs the daemon -->
<sequential>
<antcall target="start-daemon-if-needed"/>
</sequential>
<!-- this is the next thread -->
<sequential>
<!--
wait ten seconds for the harness to start
without this the first tests will fail as there is no
sf daemon around
-->
<sf-waitfordaemon maxwait="10" timeoutproperty="daemon.missing"/>
<fail if="daemon.missing">No daemon</fail>
<sf-junit
errorProperty="test.failed"
failureProperty="test.failed"
>
<classpath>
<path refid="tests.run.classpath"/>
<pathelement location="${test.classes.dir}"/>
</classpath>
<sysproperty key="org.smartfrog.codebase" value="${codebase}"/>
<syspropertyset>
<propertyref prefix="runtime"/>
</syspropertyset>
<!-- #Test case isolation technique -->
<test name="${testcase}" if="testcase"/>
<batchtest todir="${test.data.dir}" unless="testcase">
<!-- bulk test case -->
<fileset dir="${test.classes.dir}">
<include
name="org/smartfrog/services/junit/test/*Test.class"/>
</fileset>
</batchtest>
</sf-junit>
<!-- conditionally stop the daemon -->
<antcall target="conditional-daemon-exit"/>
<!-- end the test thread -->
</sequential>
</parallel>
</target>
Life would be simpler if I could exec something in the background. Not
spawned, which is designed to outlive ant, just in the background.
stopping ant would stop background stuff. output would still go to the
logger.
I would also like to be able to kill a background process by name, a
name I assigned it earlier. My testing would then be
<java ... background="server" />
<junit ... />
<killbackground name="server" />
Nice and simple to use. To implement? I dont know, yet.
What do people think?
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: starting and killing background exec or java task
Posted by Phil Weighill Smith <ph...@volantis.com>.
Would be handy. I'm assuming that the "name" could create a property of
that name, set to the process ID for example. You can then just "kill"
that process using this ID...
Phil :n.
On Fri, 2005-08-12 at 15:38 +0100, Steve Loughran wrote:
> I'm just reviewing what major changes I am needing to do to my (big)
> work project to simplify stuff. One troublespot is running functional
> tests against a running system, I need to (maybe) start a program, run
> tests against it and then stop the program if I started it (but not if
> it was already running under a debugger or something). what we have
> today is nasty and brittle.
>
> I have to start something in parallel, wait by polling a port for a
> signal that it is running, then run the tests, finally shut it down if
> we started it (broken).
>
> <target name="system-tests"
> depends="parse,dist,compile-tests,init-codebase"
> description="run system tests"
> if="system.tests.enabled">
> <parallel>
>
> <!-- first thread runs the daemon -->
> <sequential>
> <antcall target="start-daemon-if-needed"/>
> </sequential>
>
> <!-- this is the next thread -->
> <sequential>
>
> <!--
> wait ten seconds for the harness to start
> without this the first tests will fail as there is no
> sf daemon around
> -->
> <sf-waitfordaemon maxwait="10" timeoutproperty="daemon.missing"/>
> <fail if="daemon.missing">No daemon</fail>
> <sf-junit
> errorProperty="test.failed"
> failureProperty="test.failed"
> >
> <classpath>
> <path refid="tests.run.classpath"/>
> <pathelement location="${test.classes.dir}"/>
> </classpath>
> <sysproperty key="org.smartfrog.codebase" value="${codebase}"/>
> <syspropertyset>
> <propertyref prefix="runtime"/>
> </syspropertyset>
>
> <!-- #Test case isolation technique -->
> <test name="${testcase}" if="testcase"/>
> <batchtest todir="${test.data.dir}" unless="testcase">
> <!-- bulk test case -->
> <fileset dir="${test.classes.dir}">
> <include
> name="org/smartfrog/services/junit/test/*Test.class"/>
> </fileset>
> </batchtest>
> </sf-junit>
>
> <!-- conditionally stop the daemon -->
> <antcall target="conditional-daemon-exit"/>
> <!-- end the test thread -->
> </sequential>
> </parallel>
> </target>
>
>
> Life would be simpler if I could exec something in the background. Not
> spawned, which is designed to outlive ant, just in the background.
> stopping ant would stop background stuff. output would still go to the
> logger.
>
> I would also like to be able to kill a background process by name, a
> name I assigned it earlier. My testing would then be
>
> <java ... background="server" />
>
> <junit ... />
>
> <killbackground name="server" />
>
> Nice and simple to use. To implement? I dont know, yet.
>
> What do people think?
>
> -steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: starting and killing background exec or java task
Posted by Matt Benson <gu...@yahoo.com>.
--- Steve Loughran <st...@apache.org> wrote:
[SNIP]
> Life would be simpler if I could exec something in
> the background. Not
> spawned, which is designed to outlive ant, just in
> the background.
> stopping ant would stop background stuff. output
> would still go to the
> logger.
>
> I would also like to be able to kill a background
> process by name, a
> name I assigned it earlier. My testing would then be
>
> <java ... background="server" />
>
> <junit ... />
>
> <killbackground name="server" />
>
> Nice and simple to use. To implement? I dont know,
> yet.
>
> What do people think?
Wouldn't ac:forget satisfy the first req?
-Matt
>
> -steve
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org