Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing flaky test shouldConstructGraphAndCreateViewWithGroups #2

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

omkrpt
Copy link
Owner

@omkrpt omkrpt commented Feb 8, 2024

What is the purpose of this PR

Why the test fails

  • The assertions at L925-L926 in this test compare the keys of Map objects with the keySet of Maps in resultView.
  • However, while invoking the java.util.Map.keySet() is necessary for comparison, the second conversion by calling java.util.Set.toArray() returns the elements in a non-deterministic order.

How to reproduce the test failure

I used a tool called nondex.

mvn install -pl core/graph -am -DskipTests
mvn -pl core/graph test -Dtest=uk.gov.gchq.gaffer.graph.GraphTest#shouldConstructGraphAndCreateViewWithGroups
mvn -pl core/graph edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=uk.gov.gchq.gaffer.graph.GraphTest#shouldConstructGraphAndCreateViewWithGroups

Expected results

  • The test should run successfully when run with NonDex.

Actual results
We get the following failures:

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.551 s <<< FAILURE! -- in uk.gov.gchq.gaffer.graph.GraphTest
[ERROR] uk.gov.gchq.gaffer.graph.GraphTest.shouldConstructGraphAndCreateViewWithGroups(Store) -- Time elapsed: 0.537 s <<< FAILURE!
org.opentest4j.AssertionFailedError: array contents differ at index [0], expected: <entity2> but was: <entity3>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertArrayEquals.failArraysNotEqual(AssertArrayEquals.java:440)
	at org.junit.jupiter.api.AssertArrayEquals.assertArrayElementsEqual(AssertArrayEquals.java:389)
	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:346)
	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:159)
	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:155)
	at org.junit.jupiter.api.Assertions.assertArrayEquals(Assertions.java:1453)
	at uk.gov.gchq.gaffer.graph.GraphTest.shouldConstructGraphAndCreateViewWithGroups(GraphTest.java:925)
...

Description of fix
Comparing the sets directly, without converting them to arrays.

Maven logs for before and after the fix:
graphTestFail.txt
graphTestSuccess.txt

Logs for flakiness detected in initial commits:
graphTestFail_15fa8c3bb.txt
graphTestFail_6c4f85096.txt

@omkrpt omkrpt marked this pull request as ready for review February 8, 2024 05:56
@omkrpt omkrpt changed the title gh-3153 fixing flaky test shouldConstructGraphAndCreateViewWithGroups fixing flaky test shouldConstructGraphAndCreateViewWithGroups Feb 8, 2024
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.

1 participant