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

Gh-3153 fixing flaky test shouldConstructGraphAndCreateViewWithGroups #3155

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

Conversation

omkrpt
Copy link

@omkrpt omkrpt commented Feb 7, 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 changed the title fixing flaky test shouldConstructGraphAndCreateViewWithGroups gh-3153 fixing flaky test shouldConstructGraphAndCreateViewWithGroups Feb 7, 2024
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.33%. Comparing base (ac60289) to head (3472917).
Report is 124 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3155      +/-   ##
=============================================
- Coverage      66.34%   66.33%   -0.02%     
+ Complexity      2543     2541       -2     
=============================================
  Files            909      909              
  Lines          29026    29026              
  Branches        3225     3225              
=============================================
- Hits           19257    19253       -4     
- Misses          8333     8335       +2     
- Partials        1436     1438       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@omkrpt omkrpt closed this Feb 8, 2024
@omkrpt omkrpt changed the title gh-3153 fixing flaky test shouldConstructGraphAndCreateViewWithGroups fixing flaky test shouldConstructGraphAndCreateViewWithGroups Nov 7, 2024
@omkrpt omkrpt reopened this Nov 7, 2024
@omkrpt omkrpt marked this pull request as ready for review November 7, 2024 09:54
Copy link

sonarcloud bot commented Nov 7, 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