gchq / Gaffer

A large-scale entity and relation database supporting aggregation of properties
Apache License 2.0
1.75k stars 353 forks source link

gh-3153 fixing flaky test shouldConsumeGraph #3156

Closed omkrpt closed 5 months ago

omkrpt commented 5 months ago

What is the purpose of this PR

Why the test fails

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

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.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (ac60289) 66.34% compared to head (e1e6289) 66.33%.

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.