Skip to content

Conversation

yesh385
Copy link
Owner

@yesh385 yesh385 commented Nov 6, 2023

This PR fixes a flaky test called GraphBinaryReaderWriterRoundTripTest.shouldWriteAndRead which can be found here.

  1. How was this test identified as flaky?

This test was identifies as flaky by using an open-source research tool named NonDex which is responsible for finding and diagnosing non-deterministic runtime exceptions in Java programs.

  1. What does this test do?

This test verifies that a value can be successfully written to a buffer and subsequently read back, with the option to apply a custom assertion on the result.

  1. Why this test is flaky?

This test is flaky as there is an order mismatch of the nestedMetrics between traversalMetrics which is an instance of the DefaultTraversalMetrics class and m which refers to an instance of TraversalMetrics that will be passed to the Consumer for evaluation. TheConsumer is defined using a lambda expression and is responsible for performing specific assertions on the TraversalMetrics object m.

The error occurs here:

assertEquals(m.toString(), traversalMetrics.toString());

Specifically, the order of nestedMetrics which contains metrics1 and metrics2 does not match for traversalMetrics and m.

  1. How I fixed this test?

This PR fixes this error by calling the getMetrics on both traversalMetrics and m before calling toString() and comparing their equality. This fix works because the getMetrics method sorts the entries of the map positionIndexedMetrics by their keys, retains the original values for any duplicate keys, and returns the values in the sorted order.

You can run the following command to run the test using NonDex tool:

mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -pl gremlin-util -Dtest=org.apache.tinkerpop.gremlin.driver.ser.binary.GraphBinaryReaderWriterRoundTripTest#shouldWriteAndRead

(Optional) You can also run the following command to run the test:

mvn -pl gremlin-util test -Dtest=org.apache.tinkerpop.gremlin.driver.ser.binary.GraphBinaryReaderWriterRoundTripTest#shouldWriteAndRead

Test Environment:

java version "1.8.0_202"
Apache Maven 3.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants