This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 179946 - NbTestCase violates contract of method timeOut()
Summary: NbTestCase violates contract of method timeOut()
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: NB JUnit (show other bugs)
Version: 6.x
Hardware: Macintosh Mac OS X
: P2 normal (vote)
Assignee: Alexander Simon
URL:
Keywords: RANDOM, TEST
Depends on:
Blocks:
 
Reported: 2010-01-28 03:03 UTC by Alexander Simon
Modified: 2010-02-03 22:00 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dump (9.00 KB, text/plain)
2010-01-28 03:03 UTC, Alexander Simon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Simon 2010-01-28 03:03:10 UTC
Created attachment 93623 [details]
thread dump

Sometimes CND test are hung on:
org.openide.text.CloneableEditorSupport.openDocumentImpl(CloneableEditorSupport.java:867)
I see some lack of class design:
- lock does not final. It may be root of problem.
Comment 1 Alexander Simon 2010-02-01 06:17:57 UTC
Implementation of
org.netbeans.junit.NbTestCase$1Guard.waitFinished(NbTestCase.java:304)
does not guarantee of needed waiting.
So on Mac test case can be terminated after arbitrary time interval.
For example output of test case with overridden timeOut()
    protected int timeOut() {
        return 500000;
    }
Log show that test case was terminated after 3 seconds:
---------------------------------
    [junit] ------------- Standard Error -----------------
    [junit] Start testPkgConfig at Mon Feb 01 14:35:26 MSK 2010
    [junit] Found required tool: gzip=/usr/bin/gzip
    [junit] Found required tool: rm=/bin/rm
    [junit] Found required tool: tar=/usr/bin/tar
    [junit] Found required tool: wget=/Users/tester/bin/wget
    [junit] End   testPkgConfig at Mon Feb 01 14:35:29 MSK 2010
    [junit] ------------- ---------------- ---------------
    [junit] Testcase: testPkgConfig(org.netbeans.modules.cnd.discovery.project.cases.PkgConfigTestCase):	FAILED
    [junit] The test testPkgConfig did not finish in 500000ms
    [junit] Group system
    [junit]   Group main
    [junit]     Thread main
    [junit] 	at java.lang.Thread.dumpThreads(Thread.java:-2)
    [junit] 	at java.lang.Thread.getAllStackTraces(Thread.java:1511)
    [junit] 	at org.netbeans.junit.NbTestCase.threadDump(NbTestCase.java:247)
    [junit] 	at org.netbeans.junit.NbTestCase.access$000(NbTestCase.java:89)
    [junit] 	at org.netbeans.junit.NbTestCase$1Guard.waitFinished(NbTestCase.java:304)
    [junit] 	at org.netbeans.junit.NbTestCase.runBare(NbTestCase.java:362)
    [junit] 	at junit.framework.TestResult$1.protect(TestResult.java:110)
    [junit] 	at junit.framework.TestResult.runProtected(TestResult.java:128)
    [junit] 	at junit.framework.TestResult.run(TestResult.java:113)
    [junit] 	at junit.framework.TestCase.run(TestCase.java:124)
    [junit] 	at org.netbeans.junit.NbTestCase.run(NbTestCase.java:214)
    [junit] 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
    [junit] 	at junit.framework.TestSuite.run(TestSuite.java:227)
    [junit] 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
    [junit] 	at junit.framework.TestSuite.run(TestSuite.java:227)
    [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
    [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
    [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)
.............
Comment 2 Vladimir Voskresensky 2010-02-01 09:32:39 UTC
So, the issue is with 
wait(time);
without any while(condition) checks

'wait(timeout)' doesn't wait for the "timeout". It only prevents waiting "longer than 'timeout'" while JVM can wake up you anytime
Comment 3 Alexander Simon 2010-02-02 03:07:21 UTC
proposed fix:
http://hg.netbeans.org/cnd-main/rev/c7780d068ca2
Sorry for changing code, I cannot verify fix on build machines without pushing.
Comment 4 Alexander Simon 2010-02-02 08:46:33 UTC
It seems problem was fixed.
Comment 5 Jesse Glick 2010-02-02 10:40:47 UTC
Fix sounds right, thanks. Do nbjunit module tests pass with the change? (Is it feasible to write a test for this fix?)
Comment 6 Alexander Simon 2010-02-02 11:03:39 UTC
Yes, nbjunit module tests are passed.
I do not know how to create test for fix because:
- Mac specific bug (cnd run tests on 7 platforms, other platforms do not have such bug).
- repeatability is: 1/4000 tests or 1 bug on 1 hour testing.
Comment 7 Quality Engineering 2010-02-03 22:00:12 UTC
Integrated into 'main-golden', will be available in build *201002040200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c7780d068ca2
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixing BZ#179946 NbTestCase violates contract of method timeOut()