You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Balasubramanian, Ravi Shankar" <rb...@informatica.com> on 2007/04/17 13:58:47 UTC
Starting a new java process from within a test case is hanging the maven JVM
Hi all,
We use maven-surefire-plugin to run our testng test cases. I encountered
a problem where in the maven VM is hanging when one of the test cases
start a separate java process from within it using the java
ProcessBuilder class(which I think is inconsequential here). What I am
doing in the test case is starting a server which I need to be running
throughout my maven builds across different projects. (Some sort of
integration tests.). Following is the structure for my build:
MainTestModule
------setupTests
------functionality1Tests
------functionality2Tests
...............................
My requirement is to have a server started (a separate java process) in
one of the test cases in the setupTests module which needs to be running
for all other tests to run.
One of the test case which starts the server looks something like below:
@Test
public void startUpgradeTestRepository() throws Exception{
ProcessBuilder pb = new
ProcessBuilder("cmd.exe","/c","C:\startrepo.bat");
Map<String, String> env = pb.environment();
pb.directory(new File(infa_home));
Process raprocess = pb.start();
//Process p = Runtime.getRuntime().exec("cmd.exe
/c dir");
}
This calls a batch script which starts a java process from within it:
startrepo.bat:
"@echo off
rem #
------------------------------------------------------------------------
-
rem # Script for starting the Repository
rem #
------------------------------------------------------------------------
-
java
com.informatica.repository.applications.repository.server.RepAgentApp
%REP_AGENT_ARGS%
exit
"
My problem is when I run "mvn test" from the setupTests directory or
from the parent directory, the maven java process that gets started for
the setupTests module does not end until the java process started by the
test case above is ended or is terminated. I am running the tests
through the surefire plugin.
When I run mvn test from the setupTests module, it runs all the test
cases in the module successfully(the java process is also started
successfully) and then it exits from the surefire's java process.
However the build is not ending until the java process is ended or
terminated. The maven java process that gets started for the setupTests
is not ending until the java process started by my test case is
terminated. Hence I am not able to run other tests of other modules
automatically.
Can one of you please let me know if there is any glitch anywhere in the
way I have coded my test case or in my setup?
Regards,
Ravi.
"Tough times never last, but tough men do..."
Re: Starting a new java process from within a test case is hanging the maven JVM
Posted by Jerome Lacoste <je...@gmail.com>.
On 4/17/07, Balasubramanian, Ravi Shankar <rb...@informatica.com> wrote:
> Hi all,
>
> We use maven-surefire-plugin to run our testng test cases. I encountered
> a problem where in the maven VM is hanging when one of the test cases
> start a separate java process from within it using the java
> ProcessBuilder class(which I think is inconsequential here). What I am
> doing in the test case is starting a server which I need to be running
> throughout my maven builds across different projects. (Some sort of
> integration tests.). Following is the structure for my build:
[...]
>
> Can one of you please let me know if there is any glitch anywhere in the
> way I have coded my test case or in my setup?
Your problem can come from several places. The best way to
troubleshoot it is to obtain a thread dump from you JVM.
kill -3 PID under Unix, CTRL+Break on Windows I think.
J
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Starting a new java process from within a test case is hanging the maven JVM
Posted by Jerome Lacoste <je...@gmail.com>.
On 4/20/07, Balasubramanian, Ravi Shankar <rb...@informatica.com> wrote:
> Hi,
> Following is my test class that starts a notepad process from within:
> " public void startProcessNotepad() throws IOException {
> Process p = Runtime.getRuntime().exec("notepad");
> System.out.println("....NOTEPAD STARTED....");
> }
> "
>
> When I execute this test through maven using "mvn test" through the
> surefire plugin, maven does not exit until the notepad process is
> closed/terminated.
> I have attached the thread dump long along with this mail. Please look
> into it and let me know if there is a way to work around this. I will
> want to be starting a server process in one of my test cases and wants
> maven to continue with other builds for whose test cases, the server
> needs to be running.
maven forks the test execution. This forked execution doesn't
terminate so maven doesn't terminate.
As to why the forked execution doesn't terminate, it's because you
didn't spaw a new process independent of the original one.
To achieve this you will have to use a cmd and special options. You
will also have to be careful at what your executed process does with
stdin/stdout/stderr
I suggest you to read this:
http://forums.java.net/jive/thread.jspa?threadID=24837
Jerome
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Starting a new java process from within a test case is hanging the maven JVM
Posted by "Balasubramanian, Ravi Shankar" <rb...@informatica.com>.
Hi,
Following is my test class that starts a notepad process from within:
" public void startProcessNotepad() throws IOException {
Process p = Runtime.getRuntime().exec("notepad");
System.out.println("....NOTEPAD STARTED....");
}
"
When I execute this test through maven using "mvn test" through the
surefire plugin, maven does not exit until the notepad process is
closed/terminated.
I have attached the thread dump long along with this mail. Please look
into it and let me know if there is a way to work around this. I will
want to be starting a server process in one of my test cases and wants
maven to continue with other builds for whose test cases, the server
needs to be running.
Thanks for any help,
Ravi
-----Original Message-----
From: Jerome Lacoste [mailto:jerome.lacoste@gmail.com]
Sent: Thursday, April 19, 2007 9:37 PM
To: Maven Users List
Subject: Re: Starting a new java process from within a test case is
hanging the maven JVM
On 4/19/07, Balasubramanian, Ravi Shankar <rb...@informatica.com>
wrote:
> Hi all,
> I did work on this and found that maven's java process is not waiting
> until all other processes started during the build is completed /
> terminated. Following is what I did:
>
> In one of my test cases, I start a new process using the java Runtime
> class. For experimentation I executed the command "notepad" on windows
> which would start a separate process for me. The test case is as
> follows:
> Process p = Runtime.getRuntime().exec("notepad");
>
> When I do a mvn test, the java process started by the maven build does
> not exit until the notepad is closed or terminated.
>
> Is there a way or configuration in maven to work around such a setting
> or is maven designed like this? I might want to be starting a server
> like process in one of my test cases and would want maven to complete
> the build which currently is not happening.
Again, can you provide a thread dump log ?
That will help us identify where maven hangs, and help us give you an
answer.
Jerome
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Starting a new java process from within a test case is hanging the maven JVM
Posted by Jerome Lacoste <je...@gmail.com>.
On 4/19/07, Balasubramanian, Ravi Shankar <rb...@informatica.com> wrote:
> Hi all,
> I did work on this and found that maven's java process is not waiting
> until all other processes started during the build is completed /
> terminated. Following is what I did:
>
> In one of my test cases, I start a new process using the java Runtime
> class. For experimentation I executed the command "notepad" on windows
> which would start a separate process for me. The test case is as
> follows:
> Process p = Runtime.getRuntime().exec("notepad");
>
> When I do a mvn test, the java process started by the maven build does
> not exit until the notepad is closed or terminated.
>
> Is there a way or configuration in maven to work around such a setting
> or is maven designed like this? I might want to be starting a server
> like process in one of my test cases and would want maven to complete
> the build which currently is not happening.
Again, can you provide a thread dump log ?
That will help us identify where maven hangs, and help us give you an answer.
Jerome
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Starting a new java process from within a test case is hanging the maven JVM
Posted by "Balasubramanian, Ravi Shankar" <rb...@informatica.com>.
Hi all,
I did work on this and found that maven's java process is not waiting
until all other processes started during the build is completed /
terminated. Following is what I did:
In one of my test cases, I start a new process using the java Runtime
class. For experimentation I executed the command "notepad" on windows
which would start a separate process for me. The test case is as
follows:
Process p = Runtime.getRuntime().exec("notepad");
When I do a mvn test, the java process started by the maven build does
not exit until the notepad is closed or terminated.
Is there a way or configuration in maven to work around such a setting
or is maven designed like this? I might want to be starting a server
like process in one of my test cases and would want maven to complete
the build which currently is not happening.
Regards,
Ravi
-----Original Message-----
From: Balasubramanian, Ravi Shankar
Sent: Wednesday, April 18, 2007 11:48 AM
To: Maven Users List
Subject: RE: Starting a new java process from within a test case is
hanging the maven JVM
Just in case, if anybody is looking into this, I tried creating a new
java process from a simple Java class in it's main method and verified
if the main class exits. It does exit and only when I run it through a
test case in maven, the maven's java process is not exiting.
Regards,
Ravi
-----Original Message-----
From: Balasubramanian, Ravi Shankar
Sent: Tuesday, April 17, 2007 5:29 PM
To: Maven Users List
Subject: Starting a new java process from within a test case is hanging
the maven JVM
Hi all,
We use maven-surefire-plugin to run our testng test cases. I encountered
a problem where in the maven VM is hanging when one of the test cases
start a separate java process from within it using the java
ProcessBuilder class(which I think is inconsequential here). What I am
doing in the test case is starting a server which I need to be running
throughout my maven builds across different projects. (Some sort of
integration tests.). Following is the structure for my build:
MainTestModule
------setupTests
------functionality1Tests
------functionality2Tests
...............................
My requirement is to have a server started (a separate java process) in
one of the test cases in the setupTests module which needs to be running
for all other tests to run.
One of the test case which starts the server looks something like below:
@Test
public void startUpgradeTestRepository() throws Exception{
ProcessBuilder pb = new
ProcessBuilder("cmd.exe","/c","C:\startrepo.bat");
Map<String, String> env = pb.environment();
pb.directory(new File(infa_home));
Process raprocess = pb.start();
//Process p = Runtime.getRuntime().exec("cmd.exe
/c dir");
}
This calls a batch script which starts a java process from within it:
startrepo.bat:
"@echo off
rem #
------------------------------------------------------------------------
-
rem # Script for starting the Repository
rem #
------------------------------------------------------------------------
-
java
com.informatica.repository.applications.repository.server.RepAgentApp
%REP_AGENT_ARGS%
exit
"
My problem is when I run "mvn test" from the setupTests directory or
from the parent directory, the maven java process that gets started for
the setupTests module does not end until the java process started by the
test case above is ended or is terminated. I am running the tests
through the surefire plugin.
When I run mvn test from the setupTests module, it runs all the test
cases in the module successfully(the java process is also started
successfully) and then it exits from the surefire's java process.
However the build is not ending until the java process is ended or
terminated. The maven java process that gets started for the setupTests
is not ending until the java process started by my test case is
terminated. Hence I am not able to run other tests of other modules
automatically.
Can one of you please let me know if there is any glitch anywhere in the
way I have coded my test case or in my setup?
Regards,
Ravi.
"Tough times never last, but tough men do..."
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Starting a new java process from within a test case is hanging the maven JVM
Posted by "Balasubramanian, Ravi Shankar" <rb...@informatica.com>.
Just in case, if anybody is looking into this, I tried creating a new
java process from a simple Java class in it's main method and verified
if the main class exits. It does exit and only when I run it through a
test case in maven, the maven's java process is not exiting.
Regards,
Ravi
-----Original Message-----
From: Balasubramanian, Ravi Shankar
Sent: Tuesday, April 17, 2007 5:29 PM
To: Maven Users List
Subject: Starting a new java process from within a test case is hanging
the maven JVM
Hi all,
We use maven-surefire-plugin to run our testng test cases. I encountered
a problem where in the maven VM is hanging when one of the test cases
start a separate java process from within it using the java
ProcessBuilder class(which I think is inconsequential here). What I am
doing in the test case is starting a server which I need to be running
throughout my maven builds across different projects. (Some sort of
integration tests.). Following is the structure for my build:
MainTestModule
------setupTests
------functionality1Tests
------functionality2Tests
...............................
My requirement is to have a server started (a separate java process) in
one of the test cases in the setupTests module which needs to be running
for all other tests to run.
One of the test case which starts the server looks something like below:
@Test
public void startUpgradeTestRepository() throws Exception{
ProcessBuilder pb = new
ProcessBuilder("cmd.exe","/c","C:\startrepo.bat");
Map<String, String> env = pb.environment();
pb.directory(new File(infa_home));
Process raprocess = pb.start();
//Process p = Runtime.getRuntime().exec("cmd.exe
/c dir");
}
This calls a batch script which starts a java process from within it:
startrepo.bat:
"@echo off
rem #
------------------------------------------------------------------------
-
rem # Script for starting the Repository
rem #
------------------------------------------------------------------------
-
java
com.informatica.repository.applications.repository.server.RepAgentApp
%REP_AGENT_ARGS%
exit
"
My problem is when I run "mvn test" from the setupTests directory or
from the parent directory, the maven java process that gets started for
the setupTests module does not end until the java process started by the
test case above is ended or is terminated. I am running the tests
through the surefire plugin.
When I run mvn test from the setupTests module, it runs all the test
cases in the module successfully(the java process is also started
successfully) and then it exits from the surefire's java process.
However the build is not ending until the java process is ended or
terminated. The maven java process that gets started for the setupTests
is not ending until the java process started by my test case is
terminated. Hence I am not able to run other tests of other modules
automatically.
Can one of you please let me know if there is any glitch anywhere in the
way I have coded my test case or in my setup?
Regards,
Ravi.
"Tough times never last, but tough men do..."
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org