jakartaee / nosql

The specification in Jakarta EE to help Jakarta EE developers create enterprise-grade applications using Java® and NoSQL technologies.
https://projects.eclipse.org/projects/ee4j.nosql
Eclipse Public License 2.0
92 stars 28 forks source link

Eventual consistency issues during TCK execution against jnosql-elasticsearch-driver #149

Closed dearrudam closed 1 year ago

dearrudam commented 1 year ago

@otaviojava could you help me with it?

After the bigbang update, I've tried to contribute again with the jnosql-elasticsearch-driver project by setting up the TCK driver-tck-document into the POM in order to run their tests.

The tests have failed as we can see down below:

[ERROR] Tests run: 19, Failures: 3, Errors: 0, Skipped: 4, Time elapsed: 0.598 s <<< FAILURE! - in jakarta.nosql.tck.communication.driver.document.DocumentManagerTest
[ERROR] shouldSelect{DocumentArgument}[1]  Time elapsed: 0.167 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <1> but was: <0>
        at jakarta.nosql.tck.communication.driver.document.DocumentManagerTest.shouldSelect(DocumentManagerTest.java:251)

[ERROR] shouldSingleResult{DocumentArgument}[1]  Time elapsed: 0.015 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
        at jakarta.nosql.tck.communication.driver.document.DocumentManagerTest.shouldSingleResult(DocumentManagerTest.java:277)

[ERROR] shouldReturnAnErrorEmptySingleResult{DocumentArgument}[1]  Time elapsed: 0.025 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: Expected jakarta.nosql.NonUniqueResultException to be thrown, but nothing was thrown.
        at jakarta.nosql.tck.communication.driver.document.DocumentManagerTest.shouldReturnAnErrorEmptySingleResult(DocumentManagerTest.java:299)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   DocumentManagerTest.shouldReturnAnErrorEmptySingleResult:299 Expected jakarta.nosql.NonUniqueResultException to be thrown, but nothing was thrown.
[ERROR]   DocumentManagerTest.shouldSelect:251 expected: <1> but was: <0>
[ERROR]   DocumentManagerTest.shouldSingleResult:277 expected: <true> but was: <false>
[INFO] 
[ERROR] Tests run: 43, Failures: 3, Errors: 0, Skipped: 4
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  48.853 s
[INFO] Finished at: 2023-01-07T21:27:13-03:00
[INFO] ------------------------------------------------------------------------

It makes me learn more about the Elasticsearch indexing process. Such process is an asynchronous process, it means, the server responses for index requests acts like an ACK signal meaning that the sent document will be indexed in another time. Such behavior causes eventual inconsistencies during the TCK test executions.

In the jnosql-elasticsearch-driver project, the tests are using the Awaitility library to handle this situation. After any document insert or update request, the execution awaits a little bit to be resumed, making sure the documents were stored or updated.

Maybe, we should use the same strategy on the TCK driver-tck-document. I could work on it!

@otaviojava what do you think about that?

otaviojava commented 1 year ago

Hey @dearrudam, that is a good topic.

The TCK requires a lot of work, mainly because it needs to handle it with eventual consistency.

If you wish, please be my guest :)