TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.36k stars 2.57k forks source link

Some flaky tests #1329

Open Agorguy opened 1 year ago

Agorguy commented 1 year ago

Hello,

We tried running your project and discovered that it contains some flaky tests (i.e., tests that nondeterministically pass and fail). We found these tests to fail more frequently when running them on certain machines of ours.

To prevent others from running this project and its tests in machines that may result in flaky tests, we suggest adding information to the README.md file indicating the minimum resource configuration for running the tests of this project as to prevent observation of test flakiness.

If we run this project in a machine with 1cpu and 1gb ram, we observe flaky tests. We found that the tests in this project did not have any flaky tests when we ran it on machines with 2cpu and 4gb ram.

Here is a list of the tests we have identified and their likelihood of failure on a system with less than the recommended 2 CPUs and 4 GB RAM.

  1. org.java_websocket.issues.Issue764Test#testIssue (3 out 10)
  2. org.java_websocket.issues.Issue997Test#test_localServer_ServerLocalhost_ClientLocalhost_CheckDefault (1 out 10)
  3. org.java_websocket.issues.Issue825Test#testIssue (5 out 10)
  4. org.java_websocket.issues.Issue997Test#test_localServer_ServerLocalhost_Client127_CheckDefault (1 out 10)
  5. org.java_websocket.issues.Issue997Test#test_localServer_ServerLocalhost_Client127_CheckActive (1 out 10)
  6. org.java_websocket.issues.Issue598Test#runBelowSplitLimitBytebuffer (4 out 10)

    Reproducing


FROM maven:3.5.4-jdk-11

WORKDIR /home/

RUN git clone https://github.com/TooTallNate/Java-WebSocket && \
  cd Java-WebSocket && \
  git checkout 30ba037006b8203b56aeb760ee36949b65803175 

WORKDIR /home/Java-WebSocket

RUN mvn install -DskipTests

ENTRYPOINT ["mvn", "test", "-fn"]

Build the image:

$> mkdir tmp

$> cp Dockerfile tmp

$> cd tmp

$> docker build -t java-websocket . # estimated time of build 3m

Running: this configuration likely prevents flakiness (no flakiness in 10 runs)

$> docker run --rm --memory=3g --cpus=4 --memory-swap=-1 java-websocket | tee output.txt
$> grep "Failures:"  output.txt # checking results

checking results

this other configuration –similar to the previous– can’t prevent flaky tests (observation in 10 runs)

$> docker run --rm --memory=1g --cpus=1 --memory-swap=-1 java-websocket | tee output2.txt

$> grep "Failures:"  output2.txt # checking results

Thank you for your attention to this matter. We hope that our recommendations will be helpful in improving the quality and performance of your project.