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 shouldConsumeGraph #3156

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 assertion at L98 in this test compares two instances of uk.gov.gchq.gaffer.graph.GraphSerialisable objects using the overridden Object.equals() method.
  • However, the elements of serialisedProperties are in a non-deterministic order and cause the assertion to fail.

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.GraphSerialisableTest#shouldConsumeGraph 
mvn -pl core/graph edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=uk.gov.gchq.gaffer.graph.GraphSerialisableTest#shouldConsumeGraph

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.586 s <<< FAILURE! -- in uk.gov.gchq.gaffer.graph.GraphSerialisableTest
[ERROR] uk.gov.gchq.gaffer.graph.GraphSerialisableTest.shouldConsumeGraph -- Time elapsed: 0.577 s <<< FAILURE!
org.opentest4j.AssertionFailedError: 

expected: 
  GraphSerialisable[config=GraphConfig[graphId=testGraphId,view=View[{
    "entities" : {
      "e1" : { }
    }
  }],library=uk.gov.gchq.gaffer.store.library.NoGraphLibrary@661d88a,hooks=[uk.gov.gchq.gaffer.graph.hook.NamedViewResolver@4b0b64cc, uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser@59ce792e]],schema=Schema[{
    "entities" : {
      "e1" : {
        "vertex" : "string"
      }
    },
    "types" : {
      "string" : {
        "class" : "java.lang.String"
      }
    }
  }],properties={gaffer.store.class=uk.gov.gchq.gaffer.integration.store.TestStore, gaffer.store.properties.class=uk.gov.gchq.gaffer.store.StoreProperties}]
 but was: 
  GraphSerialisable[config=GraphConfig[graphId=testGraphId,view=View[{
    "entities" : {
      "e1" : { }
    }
  }],library=uk.gov.gchq.gaffer.store.library.NoGraphLibrary@56399b9e,hooks=[uk.gov.gchq.gaffer.graph.hook.NamedViewResolver@34b9eb03, uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser@43fda8d9]],schema=Schema[{
    "entities" : {
      "e1" : {
        "vertex" : "string"
      }
    },
    "types" : {
      "string" : {
        "class" : "java.lang.String"
      }
    }
  }],properties={gaffer.store.properties.class=uk.gov.gchq.gaffer.store.StoreProperties, gaffer.store.class=uk.gov.gchq.gaffer.integration.store.TestStore}]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at uk.gov.gchq.gaffer.graph.GraphSerialisableTest.shouldConsumeGraph(GraphSerialisableTest.java:98)
...

We can see that the two jsons differ due to the non-deterministic order of properties, [StoreProperties, TestStore].

Description of fix

The flakiness can be resolved by evaluating the assertion using the overridden equals of StoreProperties instead of GraphSerialisable. We continue to compare the config and schema the same way as before.

Maven logs for before and after the fix:
graphSerialisableTestFail.txt
graphSerialisableTestSuccess.txt

Logs for flakiness detected in first commit: graphSerialisableTestFail_516915ea4.txt

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 (e1e6289).
Report is 124 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3156      +/-   ##
=============================================
- 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 reopened this Nov 7, 2024
@omkrpt omkrpt marked this pull request as ready for review November 7, 2024 09:48
Copy link

sonarcloud bot commented Nov 7, 2024

@omkrpt omkrpt changed the title gh-3153 fixing flaky test shouldConsumeGraph fixing flaky test shouldConsumeGraph Nov 7, 2024
@omkrpt omkrpt changed the title fixing flaky test shouldConsumeGraph Gh-3153 fixing flaky test shouldConsumeGraph 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