The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20121113

[SOLVED] sahi ant task - java.net.ConnectException: Connection refused

i created a sahi ant task to run a test suite:
<target name="runSahiTests">
    <antcall target="start-web" />
    <antcall target="runSahi" />
    <antcall target="stop-web" />
</target>

<target name="start-web" description="starts web">
    <exec executable="../testing/sahi/userdata/bin/start_sahi.sh" osfamily="unix" spawn="true"/>
</target>

<target name="stop-web" description="stop web server">
    <get dest="stopserver.htm" src="http://localhost:9999/dyn/stopserver" ignoreerrors="true" />
    <delete file="stopserver.htm"/>
</target>

<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="../testing/sahi/lib/ant-sahi.jar" />
<target name="failsahi" if="sahi.failed">
    <fail message="Sahi tests failed!" />
</target>
<target name="runSahi">
    <sahi suite="/home/me/workspace/myApp/testing/functional_testing/stage_1/sahi/smoketest.suite"
        browserType="firefox"
        baseurl="http://myserver.example.com:9001"
        sahihost="localhost"
        sahiport="9999"
        failureproperty="sahi.failed"
        haltonfailure="false"
        threads="1">
        <report type="html" />
        <report type="junit" logdir="/home/me/workspace/myApp/testing/sahi/userdata/temp/junit" />
    </sahi>
    <antcall target="failsahi" />
</target>


but when i ran it i would get the following error:
[sahi] java.net.ConnectException: Connection refused
[sahi]     at java.net.PlainSocketImpl.socketConnect(Native Method)


to fix this i inserted a sleep call in the start-web target:
<target name="start-web" description="starts web">
    <exec executable="../testing/sahi/userdata/bin/start_sahi.sh" osfamily="unix" spawn="true"/>

    <sleep seconds="5"/>
</target>


to give the sahi proxy server enough time to start up beforing running the sahi task.

i also noticed that red paths above had to be fully qualified paths instead of relative paths, otherwise the sahi task would start, but it would never do anything and i would have to kill it in order to stop it.

see also how to run sahi tests in ant build file using testrunner

No comments:

Post a Comment