Bug 64583 - org.apache.tomcat.websocket.pojo.TestEncodingDecoding / testAnnotatedEndPoints - testEvent fails occasionally
Summary: org.apache.tomcat.websocket.pojo.TestEncodingDecoding / testAnnotatedEndPoint...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: trunk
Hardware: PC All
: P2 minor (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-07 12:32 UTC by Konstantin Kolinko
Modified: 2020-07-10 15:54 UTC (History)
0 users



Attachments
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.APR.txt (8.93 KB, text/plain)
2020-07-07 12:34 UTC, Konstantin Kolinko
Details
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.NIO.txt (7.83 KB, text/plain)
2020-07-07 12:35 UTC, Konstantin Kolinko
Details
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.BIO.txt (7.0.x at 90f95ab8, Java 11) (10.33 KB, text/plain)
2020-07-08 14:35 UTC, Konstantin Kolinko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2020-07-07 12:32:48 UTC
Testing RC of Tomcat 7.0.105 I observe occasional failures with org.apache.tomcat.websocket.pojo.TestEncodingDecoding test.

I do not consider this a showstopper.

The following test fails:

[[[
Testcase: testAnnotatedEndPoints took 5,185 sec
	FAILED
null
junit.framework.AssertionFailedError
	at org.apache.tomcat.websocket.pojo.TestEncodingDecoding.testEvent(TestEncodingDecoding.java:230)
	at org.apache.tomcat.websocket.pojo.TestEncodingDecoding.testAnnotatedEndPoints(TestEncodingDecoding.java:164)
]]]

or

[[[
Testcase: testAnnotatedEndPoints took 5,181 sec
	FAILED
null
junit.framework.AssertionFailedError
	at org.apache.tomcat.websocket.pojo.TestEncodingDecoding.testEvent(TestEncodingDecoding.java:230)
	at org.apache.tomcat.websocket.pojo.TestEncodingDecoding.testAnnotatedEndPoints(TestEncodingDecoding.java:162)
]]]

1. Note the line number difference:
TestEncodingDecoding.testAnnotatedEndPoints(TestEncodingDecoding.java:164)
TestEncodingDecoding.testAnnotatedEndPoints(TestEncodingDecoding.java:162)

"testEvent()" is a helper method, and the line number in testAnnotatedEndPoints shows the actual event being tested:

[[[
161   // Should not take very long but some failures have been seen
162   i = testEvent(MsgStringEncoder.class.getName()+":init", 0);
163   i = testEvent(MsgStringDecoder.class.getName()+":init", i);
164   i = testEvent(MsgByteEncoder.class.getName()+":init", i);
165   i = testEvent(MsgByteDecoder.class.getName()+":init", i);
]]]

2. The failures are not reliable.

I observed the failures with AdoptOpenJDK 8u252 (jdk-8.0.252.09-hotspot) 64-bit and AdoptOpenJDK 11.0.7 (jdk-11.0.7.10-hotspot) on Windows 10 1909.

Out of (1 + 1 + 10) * 3 connectors = 36 runs there are 6 failures, with different connectors (BIO/NIO/APR). I guess that a connector does not matter.

3. The test could be improved to provide some better diagnostics, instead of failing on the first error and with no message (null).
Comment 1 Konstantin Kolinko 2020-07-07 12:34:22 UTC
Created attachment 37352 [details]
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.APR.txt

A log from testing with Java 8 (AdoptOpenJDK jdk-8.0.252.09-hotspot)
Comment 2 Konstantin Kolinko 2020-07-07 12:35:23 UTC
Created attachment 37353 [details]
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.NIO.txt

A log from testing with Java 11 (AdoptOpenJDK jdk-11.0.7.10-hotspot)
Comment 3 Konstantin Kolinko 2020-07-07 12:48:13 UTC
Searching other mentions of the test class in Bugzilla,
it looks that those checks in the test were added when fixing bug 55127.
Comment 4 Mark Thomas 2020-07-07 18:39:47 UTC
I see some potential concurrency issues in that test class but I am having trouble reproducing the issue. I've only managed once out of ~50 runs so far. If I address the issues I see, can you re-test?
Comment 5 Mark Thomas 2020-07-07 20:05:23 UTC
OK. Done. Please re-test assuming you are able to.
Comment 6 Konstantin Kolinko 2020-07-08 14:35:23 UTC
Created attachment 37354 [details]
TEST-org.apache.tomcat.websocket.pojo.TestEncodingDecoding.BIO.txt (7.0.x at 90f95ab8, Java 11)

Testing current 7.0.x (at 90f95ab83874dba5a7062fc0bc8803aecaba1937),
thus far I have 1 failure out of {(20 runs with Java 8 + 20 runs with Java 11) x 3 connectors}.

I am attaching the log file for the failed test.
The test was with Java 11, BIO connector.

Its a different test method that was failing, so this is really a different issue.
The failure:
[[[
Testcase: testMessagesEndPoints took 0,08 sec
	FAILED
expected:<2> but was:<1>
junit.framework.AssertionFailedError: expected:<2> but was:<1>
	at org.apache.tomcat.websocket.pojo.TestEncodingDecoding.testMessagesEndPoints(TestEncodingDecoding.java:267)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
]]]
Comment 7 Mark Thomas 2020-07-08 14:54:41 UTC
That looks a lot better.

That new failure is in one of the disabled tests that I enabled. Let me see if I missed something when I reviewed the test.
Comment 8 Mark Thomas 2020-07-08 15:00:20 UTC
Yep. I missed the additional client message. I've updated the test code. It should pass now.
Comment 9 Konstantin Kolinko 2020-07-08 15:53:58 UTC
Testing current 7.0.x (at 4ac8e86347a6a82133354312e7eb8c1aa09bb129):

I had {(30 runs with Java 8, 60 runs with Java 11, 30 runs with Java 14) x all 3 connectors - on Windows 10}. No issues noted - Testing this test class completes successfully.

Thus I marking this issue as RESOLVED.