Fixed shouldWriteAndRead
flaky test
#1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a flaky test called
GraphBinaryReaderWriterRoundTripTest.shouldWriteAndRead
which can be found here.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.
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.
This test is flaky as there is an order mismatch of the
nestedMetrics
betweentraversalMetrics
which is an instance of theDefaultTraversalMetrics
class andm
which refers to an instance ofTraversalMetrics
that will be passed to theConsumer
for evaluation. TheConsumer
is defined using a lambda expression and is responsible for performing specific assertions on theTraversalMetrics
objectm
.The error occurs here:
tinkerpop/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/AbstractRoundTripTest.java
Line 280 in 1e9e18d
Specifically, the order of
nestedMetrics
which containsmetrics1
andmetrics2
does not match fortraversalMetrics
andm
.This PR fixes this error by calling the
getMetrics
on bothtraversalMetrics
andm
before callingtoString()
and comparing their equality. This fix works because thegetMetrics
method sorts the entries of the mappositionIndexedMetrics
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:
(Optional) You can also run the following command to run the test:
Test Environment: