You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@debrunners.com> on 2005/11/17 23:06:38 UTC
Test Harness useprocess=false question
The test harness can run tests within the same jvm if useprocess=false.
This is set for the nist suite, so that all the sub-scripts are run in a
single JVM, mainly for performance reasons.
I'm looking at the code in RunTest.java so I can add security manager to
this in-process mode.
The buildTestCommand() method is called regardless of the setting of
useprocess, though it seems its result is only used for useprocess=true.
Thus it seems that the call to buildTestCommand could move into the same
if (useprocess) block around line 438.
This leads me to the question, it seems buildTestCommand() performs a
some amount of setup through property setting with -D that does not
occur when running in process (useprocess=false).
Apart from the security properties, the console encoding is set in
buildTestCommand(), but there doesn't seem to be a corresponding setting
in the in-process way.
Is this intentional, or a source for concern?
Thanks,
Dan.
Re: Test Harness useprocess=false question
Posted by Kristian Waagan <Kr...@Sun.COM>.
Daniel John Debrunner wrote:
>John Embretsen wrote:
>
>
>
>>Myrna van Lunteren wrote:
>>
>>
>
>
>
>>>I'm wondering if this wouldn't be a nice thing to have after all...? A
>>>washwombat() method?
>>>
>>>
>>Absolutely, I was wondering whether such a method existed somewhere
>>already myself, until I saw the e-mail you referred to.
>>
>>
>>
>>>I'm imagining it to be tricky though, 'd have to cycle through
>>>metadata calls and loop to remove views and triggers etc before
>>>tables... and ensuring no attempts at removing system stuff are
>>>made... Anyone any thoughts on this?
>>>
>>>
>
>I think I've seen an extension to Junit called something like DBUnit
>that has this functionality, to clean up databases between Junit tests.
>I'm not sure what licence it is under, but it may be another reason to
>spend move effort on moving to Junit.
>
>Dan.
>
>
Just for the record, DBUnit is distributed under the LGPL license.
For a quick description of how DBUnit can be used, have a look at
http://dbunit.sourceforge.net/howto.html.
--
Kristian
Re: Test Harness useprocess=false question
Posted by Daniel John Debrunner <dj...@debrunners.com>.
John Embretsen wrote:
> Myrna van Lunteren wrote:
>> I'm wondering if this wouldn't be a nice thing to have after all...? A
>> washwombat() method?
>
>
> Absolutely, I was wondering whether such a method existed somewhere
> already myself, until I saw the e-mail you referred to.
>
>> I'm imagining it to be tricky though, 'd have to cycle through
>> metadata calls and loop to remove views and triggers etc before
>> tables... and ensuring no attempts at removing system stuff are
>> made... Anyone any thoughts on this?
I think I've seen an extension to Junit called something like DBUnit
that has this functionality, to clean up databases between Junit tests.
I'm not sure what licence it is under, but it may be another reason to
spend move effort on moving to Junit.
Dan.
Re: Test Harness useprocess=false question
Posted by John Embretsen <Jo...@Sun.COM>.
John Embretsen wrote:
> Myrna van Lunteren wrote:
>
>> John,
>>
>> I found that indeed, using mainMethod.invoke(null,arguments) was
>> required and worked well. Thx.
>
>
> I'm glad to hear that!
>
> I noticed that you included this code change in your (rather large)
> patch for DERBY-413. One consequence of this code change is that the
> first parameter to RunClass.java ("Class theClass") is not used or
> needed anymore, hence it should be removed (I don't think you included
> this in your patch). This means that the classes instantiating a
> RunClass object (RunTest.java at least, any others?) also need to be
> modified somewhat. I guess it looks cleaner if we do this in a separate
> patch - maybe even creating a new Jira issue - or what do you think?
Myrna,
For some reason, I did not get any e-mails from Jira with your comments
to DERBY-413 (could not find it in the derby-dev archives either), but
I got the "[jira] Resolved" e-mail. I see you have implemented my
suggestions in the patch that was committed by Andrew. Thanks for doing
the work! :)
--
John
Re: Test Harness useprocess=false question
Posted by John Embretsen <Jo...@Sun.COM>.
Myrna van Lunteren wrote:
> John,
>
> I found that indeed, using mainMethod.invoke(null,arguments) was
> required and worked well. Thx.
I'm glad to hear that!
I noticed that you included this code change in your (rather large)
patch for DERBY-413. One consequence of this code change is that the
first parameter to RunClass.java ("Class theClass") is not used or
needed anymore, hence it should be removed (I don't think you included
this in your patch). This means that the classes instantiating a
RunClass object (RunTest.java at least, any others?) also need to be
modified somewhat. I guess it looks cleaner if we do this in a separate
patch - maybe even creating a new Jira issue - or what do you think?
I also think that it would not hurt adding some more comments to
RunClass.java. But, of course, there are limits to how much effort one
should put into feeding a dying horse...
> I did modify a few tests classes to be public rather than have the
> default package protection in addition, for the above approach did not
> get around that limitation.
> I did not investigate all tests in the derbynet(client)mats suites -
> which includes jdbcapi, multi, jdbc20 and jdk14 suites, but most. I did
> not run into any test that did an unfortunate System.exit in this bunch.
OK, that's good. I'll let the list know if I find more issues, but it's
not likely that I'll be looking very hard.
> Still, even in those suites, there will still be a few tests that cannot
> run ok with useprocess=false because they leave 'stuff' behind. I
> probably spend most of the time working on this patch making individual
> tests run 'clean'.
>
> I've been thinking a method to clean up databases actually would be
> really nice. We could hang it in RunTest.execNoTestProcess(). That way
> we could run more tests with useprocess=false, and speed up the test
> run. Recently a user also asked for this functionality...
[snipped links]
> I'm wondering if this wouldn't be a nice thing to have after all...? A
> washwombat() method?
Absolutely, I was wondering whether such a method existed somewhere
already myself, until I saw the e-mail you referred to.
> I'm imagining it to be tricky though, 'd have to
> cycle through metadata calls and loop to remove views and triggers etc
> before tables... and ensuring no attempts at removing system stuff are
> made... Anyone any thoughts on this?
I'm afraid I must pass on this for now - but I'm sure other people on
this list have the knowledge required to give some sensible input...
--
John
Re: Test Harness useprocess=false question
Posted by Myrna van Lunteren <m....@gmail.com>.
John,
I found that indeed, using mainMethod.invoke(null,arguments) was required
and worked well. Thx.
I did modify a few tests classes to be public rather than have the default
package protection in addition, for the above approach did not get around
that limitation.
I did not investigate all tests in the derbynet(client)mats suites - which
includes jdbcapi, multi, jdbc20 and jdk14 suites, but most. I did not run
into any test that did an unfortunate System.exit in this bunch.
Still, even in those suites, there will still be a few tests that cannot run
ok with useprocess=false because they leave 'stuff' behind. I probably spend
most of the time working on this patch making individual tests run 'clean'.
I've been thinking a method to clean up databases actually would be really
nice. We could hang it in RunTest.execNoTestProcess(). That way we could run
more tests with useprocess=false, and speed up the test run. Recently a user
also asked for this functionality...see:
http://mail-archives.apache.org/mod_mbox/db-derby-user/200512.mbox/%3c82dc60e00512110508u68b10785ne6d7fb2b1612e476@mail.gmail.com%3e
and reply:
http://mail-archives.apache.org/mod_mbox/db-derby-user/200512.mbox/%3c439D513C.4020108@Sun.com%3e
I'm wondering if this wouldn't be a nice thing to have after all...? A
washwombat() method? I'm imagining it to be tricky though, 'd have to cycle
through metadata calls and loop to remove views and triggers etc before
tables... and ensuring no attempts at removing system stuff are
made... Anyone any thoughts on this?
Myrna
On 11/20/05, John Embretsen <Jo...@sun.com> wrote:
>
> Friday, November 18, 2005, 8:31:28 PM, Myrna van Lunteren wrote:
>
> >> On 11/18/05, John Embretsen <Jo...@sun.com> wrote:
>
> >> Are there other cases (other than the nist tests) where we should be
> >> able to run with useprocess set to false?
> >
> >
> > As I need to use useprocess for DERBY-413, I am cleaning up the tests
> > in derbynetclientmats (which includes jdbcapi, jdbc20 and jdk14 suites),
> but I'm not going beyond.
>
> OK, so are you running into InstantiationExceptions anywhere? I noticed
> that with useprocess=false, the main method of the test class is invoked
> through reflection. RunTest.java calls RunClass.java, which does this by
>
> mainMethod.invoke(testClass.newInstance(), arguments);
>
> Now, the call to newInstance() will fail if the test class does not
> include a (public) nullary constructor, or because of some other issue
> (see JavaDoc for java.lang.Class). A simple solution to this problem (I
> know that some java tests does not include such a constructor) would be
> to pass "null" instead of "testClass.newInstance()" to the invoke
> method, since the method called (main) is static anyway... ("If the
> underlying method is static, then the specified obj argument is ignored.
> It may be null.", from JavaDoc for java.lang.reflect.Method.invoke(...)).
>
> --
> John
>
>
Re: Test Harness useprocess=false question
Posted by John Embretsen <Jo...@Sun.COM>.
Friday, November 18, 2005, 8:31:28 PM, Myrna van Lunteren wrote:
>> On 11/18/05, John Embretsen <Jo...@sun.com> wrote:
>> Are there other cases (other than the nist tests) where we should be
>> able to run with useprocess set to false?
>
>
> To be frank, a former Cloudscape QA had at one point made it his goal
> to clean up and make as many tests as possible run with
> useprocess=false. However, that person was sent packing somewhere in
> the take-overs and lay-off rounds (first by Informix, then by IBM)
> before finishing that project. And it has not been high on anyones list since.
I see, that's interesting...
> I think most tests *ought* to be able to run with useprocess set to
> false. However, this requires a certain mindset of the test writer -
> as it involves leaving the database behind exactly as you found it; or
> if absolutely required, use identifiers that are not used anywhere
> else in the tests. This is not always the case - we happily rely on
> the test harness cleaning up after us, and it's hard to think of
> imaginative name for a test table with an integer and character column.
>
> As I need to use useprocess for DERBY-413, I am cleaning up the tests
> in derbynetclientmats (which includes jdbcapi, jdbc20 and jdk14 suites), but I'm not going beyond.
OK, so are you running into InstantiationExceptions anywhere? I noticed
that with useprocess=false, the main method of the test class is invoked
through reflection. RunTest.java calls RunClass.java, which does this by
mainMethod.invoke(testClass.newInstance(), arguments);
Now, the call to newInstance() will fail if the test class does not
include a (public) nullary constructor, or because of some other issue
(see JavaDoc for java.lang.Class). A simple solution to this problem (I
know that some java tests does not include such a constructor) would be
to pass "null" instead of "testClass.newInstance()" to the invoke
method, since the method called (main) is static anyway... ("If the
underlying method is static, then the specified obj argument is ignored.
It may be null.", from JavaDoc for java.lang.reflect.Method.invoke(...)).
> So, in short, as you found the only tests that are currently running with useprocess=false are nist.
>
>
>> I dug into some of the test harness code a while ago, trying to
>> understand a little better how the machinery works (I won't say anything
>> about how successful I was... ;) ).
>
> :-) well, it works after a fashion...sort of. The whole thing could
> do with a clean-up, but it seems more sensible to spend time on
> writing JUnit tests, at this point.
I could not agree more... I liked Dan's remark about this not so long ago
(something like: Trying to fix the current harness instead of
starting afresh with JUnit tests would be insane) ;)
>> I think I found other issues with
>> useprocess=false...
>
>
>
> Very likely.
Another one is described above...
>> For example, there are a number of tests that include a call to
>> System.exit(), which means that when useprocess=false, the test shuts
>> down the JVM, and the harness is not able to process the results and
>> clean up after itself.
>> So I guess the question is: Is this a bug? If so, is it a documentation
>> bug or a bug in each of the tests listed in the attachment to this e-mail?
> Not a bug perse, but if someone wants, they can open a jira
> enhancement & start making the rest of the tests (not including
> derbynetmats, derbynetclientmats, jdbcapi, jdbc20, jdk14 and multi, 'cause I'm doing those) run ok.
Sounds good. (Although I will not be that someone anytime soon...)
--
John
Re: Test Harness useprocess=false question
Posted by Myrna van Lunteren <m....@gmail.com>.
On 11/18/05, John Embretsen <Jo...@sun.com> wrote:
>
> Myrna van Lunteren wrote:
> > On 11/17/05, *Daniel John Debrunner* <djd@debrunners.com
> > <ma...@debrunners.com>> wrote:
> >
> > The test harness can run tests within the same jvm if useprocess=false.
> > This is set for the nist suite, so that all the sub-scripts are run
> > in a
> > single JVM, mainly for performance reasons.
> >
>
> [snip]
>
> >
> > This also implies that any tests that need special flags cannot be run
> > with useprocess = false.
>
> Are there other cases (other than the nist tests) where we should be
> able to run with useprocess set to false?
To be frank, a former Cloudscape QA had at one point made it his goal to
clean up and make as many tests as possible run with useprocess=false.
However, that person was sent packing somewhere in the take-overs and
lay-off rounds (first by Informix, then by IBM) before finishing that
project. And it has not been high on anyones list since.
I think most tests *ought* to be able to run with useprocess set to false.
However, this requires a certain mindset of the test writer - as it involves
leaving the database behind exactly as you found it; or if absolutely
required, use identifiers that are not used anywhere else in the tests. This
is not always the case - we happily rely on the test harness cleaning up
after us, and it's hard to think of imaginative name for a test table with
an integer and character column.
As I need to use useprocess for DERBY-413, I am cleaning up the tests in
derbynetclientmats (which includes jdbcapi, jdbc20 and jdk14 suites), but
I'm not going beyond.
So, in short, as you found the only tests that are currently running with
useprocess=false are nist.
I dug into some of the test harness code a while ago, trying to
> understand a little better how the machinery works (I won't say anything
> about how successful I was... ;) ).
:-) well, it works after a fashion...sort of. The whole thing could do with
a clean-up, but it seems more sensible to spend time on writing JUnit tests,
at this point.
I think I found other issues with
> useprocess=false...
Very likely.
For example, there are a number of tests that include a call to
> System.exit(), which means that when useprocess=false, the test shuts
> down the JVM, and the harness is not able to process the results and
> clean up after itself.
>
> README.htm in the java/testing directory states the following:
>
> <Quote>
>
> useprocess
>
> (default=true) Controls whether RunTest runs the test in a separate VM
> or in a thread in harness VM. It is potentially useful for debugging
> tests. Unit tests are not (yet) runnable with "useprocess=false", though.
>
> <end Quote>
>
> It does not say anything about which tests "useprocess=false" may or may
> not work with, other than unit tests.
>
> So I guess the question is: Is this a bug? If so, is it a documentation
> bug or a bug in each of the tests listed in the attachment to this e-mail?
Not a bug perse, but if someone wants, they can open a jira enhancement &
start making the rest of the tests (not including derbynetmats,
derbynetclientmats, jdbcapi, jdbc20, jdk14 and multi, 'cause I'm doing
those) run ok.
--
> John
>
>
> Executing: find
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/
> -print | xargs grep -n 'System.exit(' | grep -v '.svn'
>
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SpillHash.java:104:
> System.exit(0);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SpillHash.java:109:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/timestampArith.java:312:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/timestampArith.java:358:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/timestampArith.java:364:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/timestampArith.java:366:
> System.exit(0);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CharUTF8.java:118:
> System.exit(-1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/longStringColumn.java:118:
> System.exit(-1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java:81:
> System.exit(-1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetAutoStart.java:98:
> System.exit(0);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetAutoStart.java:103:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetAutoStart.java:149:
> System.exit(0);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetAutoStart.java:171:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetAutoStart.java:246:
> System.exit(1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java:87:
> System.exit(-1);
> ../clean/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/TestDiskHashtable.java:93:
> System.exit( (failed == 0) ? 0 : 1);
>
>
>
Re: Test Harness useprocess=false question
Posted by John Embretsen <Jo...@Sun.COM>.
Myrna van Lunteren wrote:
> On 11/17/05, *Daniel John Debrunner* <djd@debrunners.com
> <ma...@debrunners.com>> wrote:
>
> The test harness can run tests within the same jvm if useprocess=false.
> This is set for the nist suite, so that all the sub-scripts are run
> in a
> single JVM, mainly for performance reasons.
>
[snip]
>
> This also implies that any tests that need special flags cannot be run
> with useprocess = false.
Are there other cases (other than the nist tests) where we should be
able to run with useprocess set to false?
I dug into some of the test harness code a while ago, trying to
understand a little better how the machinery works (I won't say anything
about how successful I was... ;) ). I think I found other issues with
useprocess=false...
For example, there are a number of tests that include a call to
System.exit(), which means that when useprocess=false, the test shuts
down the JVM, and the harness is not able to process the results and
clean up after itself.
README.htm in the java/testing directory states the following:
<Quote>
useprocess
(default=true) Controls whether RunTest runs the test in a separate VM
or in a thread in harness VM. It is potentially useful for debugging
tests. Unit tests are not (yet) runnable with "useprocess=false", though.
<end Quote>
It does not say anything about which tests "useprocess=false" may or may
not work with, other than unit tests.
So I guess the question is: Is this a bug? If so, is it a documentation
bug or a bug in each of the tests listed in the attachment to this e-mail?
--
John
Re: Test Harness useprocess=false question
Posted by Myrna van Lunteren <m....@gmail.com>.
On 11/17/05, Daniel John Debrunner <dj...@debrunners.com> wrote:
>
> The test harness can run tests within the same jvm if useprocess=false.
> This is set for the nist suite, so that all the sub-scripts are run in a
> single JVM, mainly for performance reasons.
>
> I'm looking at the code in RunTest.java so I can add security manager to
> this in-process mode.
>
> The buildTestCommand() method is called regardless of the setting of
> useprocess, though it seems its result is only used for useprocess=true.
> Thus it seems that the call to buildTestCommand could move into the same
> if (useprocess) block around line 438.
>
> This leads me to the question, it seems buildTestCommand() performs a
> some amount of setup through property setting with -D that does not
> occur when running in process (useprocess=false).
> Apart from the security properties, the console encoding is set in
> buildTestCommand(), but there doesn't seem to be a corresponding setting
> in the in-process way.
>
> Is this intentional, or a source for concern?
>
> Thanks,
> Dan.
I need useprocess also for DERBY-413...:-)
I think it is like this - someone please correct me if it looks I'm off...
Setting encoding is being done in both createPropString() and
buildTestCommand(). This is needed because when useprocess is false, the
properties need to be passed on to the resulting process that will actually
run the test with -D, not just put out to the existing properties. So, the
result from createPropString is used both directly in execTestProcess() and
indirectly, via buildtestCommand() in execTestNoProcess(). When there is no
separate process kicked off, test harness classes that require encoding info
(and other details) pick the settings up directly from the properties
string. So, encoding and other settings are being set in two places, but
both should get picked up in different ways with and without useprocess.
This also implies that any tests that need special flags cannot be run with
useprocess = false.
I think you're right that buildtestCommand can be moved inside the
if(useprocess) block.
Myrna