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

Database tests 2db #707

Merged
merged 63 commits into from
Oct 15, 2024
Merged

Database tests 2db #707

merged 63 commits into from
Oct 15, 2024

Conversation

paulo-ocean
Copy link
Contributor

@paulo-ocean paulo-ocean commented Oct 3, 2024

Fixes # .

Changes proposed in this PR:

  • Refactor, clean and fix tests, on top of changes for Elastic Search support branch
  • Removed DB specific config/env override from individual test suites (DB is only configured ONCE on the hooks)
  • DB config is properly set & read from Configuration object (avoid constant direct access to process.env )
    (sometimes we had different components running with different DB, on same tests, and some tests only passed because they "caught" a specific DB, but would not run on the other.. it was a bit random, with all the.envchanges going on)
  • All tests suites run on the same DB configuration picked at startup (sometimes can be Elastic, others can be Typesense, but is DOES NOT change until the end)
  • cleaned some old tests

@paulo-ocean paulo-ocean changed the base branch from main to feature/add-elasticdb October 3, 2024 18:45
@paulo-ocean paulo-ocean marked this pull request as draft October 9, 2024 08:43
@paulo-ocean
Copy link
Contributor Author

paulo-ocean commented Oct 9, 2024

there is a random segmentation fault on the unit tests, checking

@paulo-ocean paulo-ocean marked this pull request as ready for review October 9, 2024 11:30
@paulo-ocean
Copy link
Contributor Author

there is a random segmentation fault on the unit tests, checking

apparently its was an issue related with the storage tests, seems fixed now

docs/env.md Outdated Show resolved Hide resolved
docs/PolicyServer.md Outdated Show resolved Hide resolved
Copy link
Member

@bogdanfazakas bogdanfazakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, there are few comments that maybe we need to remove with old db setup from before and after hooks, and something is looking strange with the unit tests 🤔
also i'll make the enterprise team aware of the change of the Indexer components

@jamiehewitt15
Copy link
Member

Are the tests failing due to the changes in this PR or is something else random going on? Other than that it all looks good.

@paulo-ocean
Copy link
Contributor Author

paulo-ocean commented Oct 14, 2024

Are the tests failing due to the changes in this PR or is something else random going on? Other than that it all looks good.

its bigger than that, its also related with the issue experienced on #551
when the worker thread exits, we cannot process any code there... and also we can't start crawling when we don't have a DB connection and a valid blockchain connection. Its fixed now.

@@ -85,15 +90,83 @@ export class OceanIndexer {
return false
}

// it does not start crawling until the network connectin is ready
async startCrawler(blockchain: Blockchain): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there a reason why you moved this to index from the thread, or was just one of the things you tried. Asking from curiosity mainly 😄 ?

Copy link
Contributor Author

@paulo-ocean paulo-ocean Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both :-)
Remember this? #551
When the thread exits we CANNOT process any more code inside, that's what originates the segmentation fault / core dumps
Everything works fine when we have proper DB and RPC connections, but when we don't we get a lot of errors, From DB errors to RPC errors.. Many of these can also cause the thread to exit, and we get that error code 1 on 'exit'..
If we exit the thread and are still trying to connect to a provider (wrong rpc for instance), that is one example.
Either by us retrying the connection (checking if is ready), or the JSONRPCProvider itself, like here:
https://github.com/ethers-io/ethers.js/blob/9e7e7f3e2f2d51019aaa782e6290e079c38332fb/src.ts/providers/provider-jsonrpc.ts#L767
when we create a new JSONRPCProvider it retries at least 4 or 5 times on its own.. We can't have any of this code on the crawler thread. Blockchain connection MUST be already established before starting the thread, same goes for DB

return false
}
}
// async function retryCrawlerWithDelay(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if we decide to keep in the index lets remove it for real from the thread

let config: OceanNodeConfig
before(async () => {
config = await getConfiguration(true)
mockDatabase = await new Database(config.dbConfig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this this test starts to look more like an integration test, not 100% sure if we should keep it or lets say keep it under unit tests 😃 , but nothing critical from my point of view

Copy link
Contributor Author

@paulo-ocean paulo-ocean Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really :-) , its just creating an instance of the class and calling a few public functions, not much different than all the others on the unit test suite

In this particular case, the issue with test was that the mockup functions were not doing anything... only the real indexer code was called...And now with new DB (when the test is actually running on Elastic)
the thread exits because of all the elastic db connections errors. Elastic seems to be more harsh than typesense on the thread itself, i think because of the uncaugh exceptions on "initializeIndex calls") ... These make the thread to exit ....and after it exits ... we still have the JSONRPCProvider code running and trying to connect to a wrong RPC, detect connection status, etc... all inside a thread that no longer exists
Therefore a core dump

I alread suspected of the CrawlerThread running code after it exits, when we were discussing #551 but could not understand exactly what could be... now i'm certain it was this RPC/blockchain fail/retry mechanism. We also have that while(true) with a sleep() in between... which can also be problematic if the thread exits in the middle... but lets not worry much with that atm, as long as we only start the crawling when everything is OK we should be safer

Copy link
Member

@mariacarmina mariacarmina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it also fixes the issue with unit tests.

@paulo-ocean paulo-ocean merged commit 65c3d8f into feature/add-elasticdb Oct 15, 2024
8 checks passed
@paulo-ocean paulo-ocean deleted the database-tests-2db branch October 15, 2024 09:29
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.

4 participants