Bug 142528 - Order of test execution affects test results
Summary: Order of test execution affects test results
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Releng-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 142544 144458 144460 144503 144504 144506 146015
Blocks:
  Show dependency tree
 
Reported: 2006-05-18 12:06 EDT by Sonia Dimitrov CLA
Modified: 2009-07-09 17:07 EDT (History)
7 users (show)

See Also:


Attachments
Result output from runtests all (736.70 KB, application/octet-stream)
2006-05-30 04:23 EDT, Thomas Hallgren CLA
no flags Details
Patched version of junit.framework.TestSuite for junit-4.1 (7.63 KB, text/plain)
2006-05-30 04:24 EDT, Thomas Hallgren CLA
no flags Details
Patched version of junit.framework.TestSuite for junit-3.8.1 (6.95 KB, text/plain)
2006-05-30 04:25 EDT, Thomas Hallgren CLA
no flags Details
Patched version of org.eclipse.jdt.core.tests.junit.extension.TestCase (20.46 KB, text/plain)
2006-05-30 04:26 EDT, Thomas Hallgren CLA
no flags Details
Patched version of org.eclipse.jdt.core.tests.junit.extension.PerformanceTestSuite (2.90 KB, text/plain)
2006-05-30 04:26 EDT, Thomas Hallgren CLA
no flags Details
Precompiled junit.jar with patch applied (117.42 KB, application/octet-stream)
2006-05-30 04:27 EDT, Thomas Hallgren CLA
no flags Details
Precompiled junit.jar-4.1 with patch applied (107.98 KB, application/octet-stream)
2006-05-30 04:28 EDT, Thomas Hallgren CLA
no flags Details
Program that will merge the managementapi.jar into the rt.jar in a JRockit JRE (2.94 KB, application/octet-stream)
2006-07-06 08:54 EDT, Thomas Hallgren CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sonia Dimitrov CLA 2006-05-18 12:06:57 EDT
From Thomas Hallgren (BEA):

"When investigating some of the failures that JRockit encounters I came
across this scenario in the 'update' test
org.eclipse.update.tests.regularInstall.TestInstall.

Using JRockit, the tests run in the following order:

  testFileSiteWithoutSiteXML 
  testInstall
  testHTTPSite
  testFileSite

using the Sun JDK, the order is:

  testFileSite
  testHTTPSite
  testInstall
  testFileSiteWithoutSiteXML

Using the JRockit case, the last test will fail. It consults the
org.eclipse.update.internal.core.InstallRegistry.justInstalledPlugins
HashMap, concludes that the plugin it is about to install is installed
by another feature already, and skips it. Unfortunately, the parent
folder of the installed plugin was removed without a corresponding call
to InstallRegistry.cleanup() before that.

I'd consider this a bug in the test framework. The order by which the
tests are run is determined by the JUnit TestSuite class:

  Method[] methods= superClass.getDeclaredMethods();
  for (int i= 0; i < methods.length; i++) {
      addTestMethod(methods[i], names, theClass);
  }

The documentation on the Class.getDeclaredMethod() says "The elements in
the array returned are not sorted and are not in any particular order"."
Comment 1 Sonia Dimitrov CLA 2006-05-18 12:11:06 EDT
more..

"When running the org.eclipse.ui.workbench.texteditor.tests.FindReplaceDialogTest, JRockit
will use the following order of execution:

  testDisableWholeWordIfNotWord
  testDisableWholeWordIfRegEx
  testInitialButtonState

The testInitialButtonState test fail since the isWholeWordSetting is set
to true by the preceeding test.

A Sun JDK will execute the tests in the following order:

  testInitialButtonState
  testDisableWholeWordIfRegEx
  testDisableWholeWordIfNotWord"

...

"I知 beginning to suspect that a vast majority of the errors that we see when running the Eclipse tests with JRockit are contributed to the fact that they depend on a certain order or execution. I consider that a fairly serious flaw in the test framework and something that needs to be fixed in order for me to proceed.
 
Perhaps you could create a patched version of the JUnit TestSuite class that will add the test methods in reverse order. Something like:
 
  Method[] methods= superClass.getDeclaredMethods();
  int i = methods.length;
  while(--i >= 0) {
      addTestMethod(methods[i], names, theClass);
  }
 
Such a patch will reveal a lot of your issues that are related to order of execution."
Comment 2 Thomas Hallgren CLA 2006-05-18 12:38:13 EDT
I would like to raise the priority of this bug to P1. We are trying to get JRockit certified for Eclipse and this bug effectively blocks that effort completely.
Comment 3 Martin Aeschlimann CLA 2006-05-18 12:44:16 EDT
I guess you would have to file that against junit.org where that offending code is located.

What I think the answer will be is that a well written test should never depend on the execution order. There are test frameworks that on propose run tests in random order. We are, for example, offering to run only failed tests.

So I suggest to move the bug back to the writers of the failing tests and have them make sure that their tests can run in any order. They can also rewrite their tests to not use new TestSuite(Test.class) but
suite= new TestSuite();
suite.addTest(new TextCase("test1")):
suite.addTest(new TextCase("test2")):
Comment 4 Sonia Dimitrov CLA 2006-05-18 13:20:23 EDT
Re-assigning to platform-releng until we have a list of all components that need to revisit their tests.
Comment 5 Sonia Dimitrov CLA 2006-05-18 13:31:32 EDT
I've entered bug 142544 and bug 142542 for the scenarios mentioned here.
Comment 6 Thomas Hallgren CLA 2006-05-18 13:58:45 EDT
(In reply to comment #3)
> I guess you would have to file that against junit.org where that offending code
> is located.
> 
> What I think the answer will be is that a well written test should never depend
> on the execution order.
>
The offending code is definitely *not* in junit.org. I included that code just to show how the order of execution is determined (or rather, not determined). The fact that junit tests run in random order is well known and not a bug.

The errors are solely located in the Eclipse test framework itself. The patch that I suggest should be considered temporary. It's just one way to conveniently provoke the errors.
Comment 7 Dejan Glozic CLA 2006-05-23 10:32:45 EDT
Branko, please take a look at this - seems to be that some Update JUnit test cases are sequential - must be run in a certain order.
Comment 8 Branko Tripkovic CLA 2006-05-23 11:28:13 EDT
Hi Sonia,
You seem to be right about this. JUnit tests should be self contianed. I encounter similar issues before with location (drive) of the test. I will investigate more in update but at that time it looked more like tear down of the tests not happen properly or timely. Since, I new how to go around it and both ibm and hotspot VM behaving the same and it happening only on my dev machines I did not take it as priority. But testFileSiteWithoutSiteXML was really main offender and I will now look into it. Once i have resolution I will post my findings. 
Thomas: Can you try disabling testFileSiteWithoutSiteXML and running update junit tests to see if this is really the offending party.
Comment 9 Thomas Hallgren CLA 2006-05-23 13:14:46 EDT
The tests all run without errors when I run them independently. The whole suite is error free if I force the order to be the same as when using a Sun JVM.

Please try my suggested temporary patch for the TestSuite. It will immediately reveal *all* problems of this nature.
Comment 10 Branko Tripkovic CLA 2006-05-26 15:38:50 EDT
Thomas,
I think I fixed update junit tests. I can not be 100% sure since i do not have jrockit. Can you obtain them from eclipse CVS and run them?
Comment 11 Thomas Hallgren CLA 2006-05-29 03:25:34 EDT
You can find JRockit downloads here http://www.bea.com/framework.jsp?CNT=index.htm&FP=/content/products/jrockit if you'd care to try it out yourself. An alternative to using JRockit is to install my suggested patch.

My quest is to certify JRockit on Eclipse. In order to do so, it must pass all test in the Eclipse test framework. The update junit tests is just one example of tests that fail due to order of execution. You will see that there are a large number of tests in various places (not just in the update and texteditor tests) that fail consistently due to the ordering issue when my suggested temporary patch is used. It seems to me the easiest way to proceed would be to fix them all in one go.

I will be happy to verify your CVS version with JRockit as soon as the ordering issue has been addressed everywhere. In order to do so, I'll need instructions on exactly what to download and how to rebuild the test framework from scratch.
Comment 12 Branko Tripkovic CLA 2006-05-29 09:32:20 EDT
Thomas,
I am only responsible for update, other junit tests will have to be fixed by other people. I did not apply your patch, however I changed the order of method to get to your order of execution and I after this fix I had no problems. That said I am not sure I can install JRockit due to licensing issues, so I will wait for you to run it.
Comment 13 Thomas Hallgren CLA 2006-05-29 09:56:07 EDT
Sorry, I didn't mean you should fix all the tests. I'm merely suggesting that "someone" could use my patch to reproduce all errors caused by order of execution. Then that "someone" could coordinate the effort to fix all those issues. Who that "someone" is must be decided by people responsible for the Eclipse testing in general.

I'm just the bystander who discovered this fairly serious and fairly common flaw in the Eclipse test framework and it's not very efficient for me to try out CVS releases with individual fixes.

Regarding JRockit licensing. What issues do you see that would prevent you from installing?
Comment 14 Sonia Dimitrov CLA 2006-05-29 09:58:54 EDT
"You will see that there are a
large number of tests in various places (not just in the update and texteditor
tests) that fail consistently due to the ordering issue when my suggested
temporary patch is used."

If you have already identified which components are failing with ordering issues, please attach results here and we can open bug reports for those.
Comment 15 Thomas Hallgren CLA 2006-05-29 10:08:38 EDT
Perhaps you could try my suggested patch and run the tests yourself? That way you can do far more then just open individual bug reports. Installing the patch takes a couple of minutes and the resulting setup will help you find, analyze, and also debug all the errors. I don't see how a bunch of results with mixed in failures caused by other aspects of using JRockit would help in that process.
Comment 16 Sonia Dimitrov CLA 2006-05-29 10:27:13 EDT
Each test plug-in is contributed by the various components and they are solely responsible for debugging and analyzing their tests.

Given the resource constraints there are in releng land, we can certainly help direct issues to the right component owners, but cannot go beyond that until at least July :(
Comment 17 Thomas Hallgren CLA 2006-05-30 04:23:25 EDT
Created attachment 42926 [details]
Result output from runtests all

Here are the test results when my patch is applied to the junit.framework.TestSuite class. The tests are all run using Sun JDK 1.5.0_07 on a Windows XP workstation.

I discovered that the Eclipse that I used (3.2RC6) comes with both junit-3.8.1 and junit4-4.1.0 so I created a patched jar for both. Both the jars and the modified source files are attached.

I performed some surgery and replaced the junit.jar in both the eclipse-junit-tests-I20060526-0010.zip and in the eclipse-SDK-I20060526-0010-win32.zip. In the latter I also replaced the junit4.1.jar.

That concludes what needs to be done in order to provoke the order dependency errors in almost all the tests. The jdt.core tests however, required some extra attention. They don't use the standard junit TestSuite class. So I did the following:

I pached the constructor of the class  org.eclipse.jdt.core.tests.junit.extension.PerformanceTestSuite. Same patch as before, simply reverse the order by which the addTestMethod is called. After some tests, it became apparent that this change was not enough. I also had to patch the buildTestsList method of the org.eclipse.jdt.core.tests.junit.extension.TestCase so that it returned the names in reverse order.

The patched sources for the PerformanceTestSuite and TestCase are also attached.
Comment 18 Thomas Hallgren CLA 2006-05-30 04:24:37 EDT
Created attachment 42927 [details]
Patched version of junit.framework.TestSuite for junit-4.1
Comment 19 Thomas Hallgren CLA 2006-05-30 04:25:22 EDT
Created attachment 42928 [details]
Patched version of junit.framework.TestSuite for junit-3.8.1
Comment 20 Thomas Hallgren CLA 2006-05-30 04:26:14 EDT
Created attachment 42929 [details]
Patched version of org.eclipse.jdt.core.tests.junit.extension.TestCase
Comment 21 Thomas Hallgren CLA 2006-05-30 04:26:58 EDT
Created attachment 42930 [details]
Patched version of org.eclipse.jdt.core.tests.junit.extension.PerformanceTestSuite
Comment 22 Thomas Hallgren CLA 2006-05-30 04:27:41 EDT
Created attachment 42931 [details]
Precompiled junit.jar with patch applied
Comment 23 Thomas Hallgren CLA 2006-05-30 04:28:18 EDT
Created attachment 42932 [details]
Precompiled junit.jar-4.1 with patch applied
Comment 24 Thomas Hallgren CLA 2006-05-30 04:36:55 EDT
One thing I forgot to mention. The cvs test results shouldn't count. They are caused by an incorrect cvs setup so please disregard them. All other failures and errors (somewhere between 150 and 200) are caused by the change in order of execution.

Also, please note. JRockit is *not* needed. This is all done using Sun JDK with my patches installed.

Sonia, when you distribute the bugs to their respective owners, would you be so kind and add me (thomas@tada.se) as a CC?
Comment 25 Sonia Dimitrov CLA 2006-05-30 14:25:01 EDT
Entered a number of blocking bugs based on results with the exception of the org.eclipse.jdt.debug.tests - there are failures here that appear to be related to a missing src.jar/src.zip in the vm.

Darin, could you comment on the JDT Debug test results please and whether there are failures related to an reverse ordering of test method execution?
Comment 26 Thomas Hallgren CLA 2006-05-30 14:29:01 EDT
> ... with the exception of the
> org.eclipse.jdt.debug.tests - there are failures here that appear to be related
> to a missing src.jar/src.zip in the vm.
>
The VM in question is a standard Sun JDK 1.5.0_07 installation. It does indeed contain a src.zip so that cannot be the problem.
Comment 27 Philipe Mulet CLA 2006-06-08 10:40:13 EDT
FYI - when upgrading to JRE 1.5.0_08, there seems to be changes in some hash map implementations which are breaking some of the JDT/Core tests. We are going to address these for 3.2.1; pls advise if these changes are required for JRockit/3.2.0
Comment 28 Frederic Fusier CLA 2006-06-08 11:01:25 EDT
comment #27 follow-up:

I've opened specific bug 146015 for JDT/Core tests remaining problems while running other VMs and put it as prerequesite of this bug...
Comment 29 Thomas Hallgren CLA 2006-06-08 11:17:59 EDT
JRockit will use the same rt.jar as Sun does so I would expect the same problems with hash map changes there but as long as the errors occur on both platforms I doubt it will have a negative impact on JRockit certification. No extra rush needed on our behalf.
Comment 30 Frederic Fusier CLA 2006-06-09 06:35:50 EDT
from comment 29: HashMap keys order specific issue for JDT/Core tests has been splitted in separated bug 146215 as it does not sound to be a prerequesite for JRockit certification and so does not block current bug...
Comment 31 Thomas Hallgren CLA 2006-07-06 08:54:40 EDT
Created attachment 45836 [details]
Program that will merge the managementapi.jar into the rt.jar in a JRockit JRE

This is a java program that will merge the managementapi.jar into the rt.jar in a JRockit JVM. The merge is necessary since some tests starts a new JVM with -Xbootclasspath set explicitly to rt.jar. JRockit requires the managementapi classes when debugging.
Comment 32 Kim Moir CLA 2009-07-09 13:49:48 EDT
Can this bug be closed, does it still apply?
Comment 33 Thomas Hallgren CLA 2009-07-09 17:07:31 EDT
I think this bug can be closed. If I recall correctly, the issues with JRockit later became issues with the Sun JVM as well and the problems were fixed in bugs 146015 and 146215. So I'm closing this as fixed.