Bug 219069 - PersistenceTest unit tests are failing
Summary: PersistenceTest unit tests are failing
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P1 critical (vote)
Target Milestone: 3.0 M5   Edit
Assignee: David Dykstal CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on: 219086
Blocks:
  Show dependency tree
 
Reported: 2008-02-15 05:06 EST by Martin Oberhuber CLA
Modified: 2008-02-15 15:34 EST (History)
1 user (show)

See Also:


Attachments
Patch improving error reporting for event loop exceptions (1.64 KB, patch)
2008-02-15 07:33 EST, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2008-02-15 05:06:45 EST
With the RSE M5 candidate, PersistenceTest unit tests are failing.

When running the test suite, and following what's going on at the
screen, I also noticed that some connections seem duplicated. 

I think it's very important to check the failures since they might
be related to recent changes for lazy loading, and persistence is
a very important component of RSE.

-----------Enter bugs above this line-----------
TM 3.0M5
installation : eclipse-SDK-3.4M5 (I20080207-1530), cdt-4.0.0M5, emf-2.4.0M5
     DSF-N20071113, ECF-2.0m4, PHPEclipse-1.2.0-Nightly, Releng.Tools-3.4M5,
     Subversive-0.7.0m4, SWT-MemMonitor, WR-Retriever-3.0.v20070604
RSE install  : RSE-SDK-I20080212-2045, TM-terminal, TM-discovery
java.runtime : Sun 1.6.0_02-b06 -Xmx512m -XX:MaxPermSize=128m
os.name:     : Windows XP 5.1, Service Pack 2
------------------------------------------------
systemtype   : Windows-local, Dstore-win, Dstore-linux
targetos     : Red Hat Enterprise Linux WS release 4 (Nahant Update 3)
targetuname  : Linux parser 2.6.9-34.EL #1 i686 athlon i386 GNU/Linux
targetvm     : Sun Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2008-02-15 05:49:22 EST
After some initial investigation, it looks like I'm getting to the cause of the exception by chance - because I put a breakpoint in SWT.error(). Here is what's happening: The test calls JobManager.join() which runs a nested SWT Event Loop:

EventLoopProgressMonitor.runEventLoop() line: 127	
EventLoopProgressMonitor.isCanceled() line: 97	
JobManager.join(Object, IProgressMonitor) line: 773	
PersistenceTest.reload() line: 250	
PersistenceTest.testProfilePersistence() line: 87	

Inside the event loop, the following exception is happening and passed on to the exception handler - but the exception handler just prints an "Unhandled Exception in Event Loop" to the error log, and the error log is never seen from the unit test!

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:3716)
at org.eclipse.swt.SWT.error(SWT.java:3634)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3737)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3374)
at org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor.runEventLoop(EventLoopProgressMonitor.java:123)
at org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor.done(EventLoopProgressMonitor.java:82)
at org.eclipse.core.internal.jobs.JobManager.join(JobManager.java:783)
at org.eclipse.rse.tests.persistence.PersistenceTest.reload(PersistenceTest.java:250)
[...]
Caused by: java.lang.NullPointerException
at org.eclipse.jface.viewers.TreeViewer.getExpanded(TreeViewer.java:174)
at org.eclipse.rse.internal.ui.view.SafeTreeViewer.getExpanded(SafeTreeViewer.java:143)
at org.eclipse.rse.internal.ui.view.SystemView.moveTreeItem(SystemView.java:1503)
at org.eclipse.rse.internal.ui.view.SystemView.moveTreeItems(SystemView.java:1549)
at org.eclipse.rse.internal.ui.view.SystemView$ResourceChangedJob.runInUIThread(SystemView.java:2287)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:94)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:130)
... 59 more


So, the unit test continues with the exception being logged to an unvisible destination; and the result of the test is unexpected.

I think the first measure needs to be making the exception visible. This can either be done by registering an error handler with JobManager.join(); and/or by setting the WorkbenchUI.DEBUG flag by means of tracing, such that the "unhandled event loop exception" is not only printed to the Eclipse Log but also to stdout.

After that, of course, the reason for the NPE in TreeViewer.getExpanded() needs to be found, because this is what's causing not only this one but many other unit tests to fail. Uwe has proposed changing SafeTreeViewer to swallow the NPE's but I'm not sure this is the right solution... we should better go and find the real cause...
Comment 2 Martin Oberhuber CLA 2008-02-15 07:02:45 EST
Registering a different kind of event handler seems currently impossible, I created bug 219077 for this. The workaround is to enable Tracing of the Workbench Plugin in the Launch that runs the unit tests:

   org.eclipse.ui.workbench/debug = true

in the .options and start with -debug. I'm changing the checked-in RSECombinedTestSuite setting that flag now.
Comment 3 Martin Oberhuber CLA 2008-02-15 07:33:47 EST
Created attachment 89834 [details]
Patch improving error reporting for event loop exceptions

Attached patch is an example for improving error reporting about unhandled exceptions in the event loop, taken from a different test case. Attaching this patch as an example showing how such exceptions are best reported through JUnit.
Comment 4 Martin Oberhuber CLA 2008-02-15 07:35:09 EST
Committed the patch for improving error reporting:
[219069] Improved error reporting for exceptions in event loop while running junit plug-in tests
Comment 5 Martin Oberhuber CLA 2008-02-15 08:54:03 EST
Continuing investigations on bug 219086, which seems unrelated to the persistence test issues.
Comment 6 Martin Oberhuber CLA 2008-02-15 11:16:47 EST
Dave can you take this over please.

On RSE HEAD, the problem reproducably occurs even with the core RSE plugins activated. Also, the problem does NOT seem to be related to SWT issues in any way. Since bug 219086 has been fixed, I cannot see any SWT exceptions any more, but the assertion still fails.
Comment 7 David Dykstal CLA 2008-02-15 11:18:03 EST
This took an interesting turn. This is a testcase bug. The problem is that reload of a profile - i.e. a reset of the entire model - does not work and has never worked. This is an item for M6 and goes along with import/export. I've fixed the testcase so that it skips the reload and so it succeeds for now.
Comment 8 Martin Oberhuber CLA 2008-02-15 11:22:28 EST
Thanks Dave.
Do you have a bugzilla number for making reload() work? - I'm wondering whether it might make sense to keep the testcase - including reload() in there but just comment it out for now.

I'm using a special pattern for existing test cases that are just temporarily commented out. At some points, all of these comments should be re-enabled and the testcases should run:

//-test-disabled-//

So again, this is for tests which are correct but known to fail currently due to deficiencies, but should be enabled at some later time.
Comment 9 Martin Oberhuber CLA 2008-02-15 14:27:31 EST
I released the checkin, but verification FAILED on
http://download.eclipse.org/dsdp/tm/downloads/drops/I20080215-1245/index.php

Start Eclipse, Window > Show View > Other > RSE Testing
Select RSECombinedTestSuite, right-click > Run

--> testProfilePersistence fails:

junit.framework.AssertionFailedError: expected:<3> but was:<4>
[...]
	at org.eclipse.rse.tests.persistence.PersistenceTest.testProfilePersistence(PersistenceTest.java:97)

[...]
*** testProfilePersistence(org.eclipse.rse.tests.persistence.PersistenceTest): expected:<3> but was:<4>
Comment 10 Martin Oberhuber CLA 2008-02-15 14:44:51 EST
I also noticed that running the unit tests from the RSE Test Suites View in my normal workspace DELETED the connections that I had in there. This means loss of data, which I consider a CRITICAL issue even though few people would actually run the unit tests.

Please investigate.
Comment 11 David Dykstal CLA 2008-02-15 15:34:46 EST
This is the problem with reload - I managed to not get rid of them all the first time. It should be fixed now.
The reload problem is documented in bug 142720.