graph/db: expand TestPopulateViaMigration for easy testing#10158
graph/db: expand TestPopulateViaMigration for easy testing#10158guggero merged 1 commit intolightningnetwork:masterfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @ellemouton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the TestPopulateViaMigration test function within the graph/db package. The primary goal is to make it much easier for developers to manually test the graph database migration process from various KV (key-value) store backends (BBolt, SQLite, Postgres) to SQL backends (SQLite, Postgres). The changes introduce clear, step-by-step instructions and configurable parameters directly within the test, streamlining the setup and execution of migration tests for different database configurations.
Highlights
- Improved Test Configurability: The TestPopulateViaMigration function has been expanded with detailed, commented steps, allowing users to easily configure source and destination database types (BBolt, SQLite, Postgres) and their respective connection parameters.
- Refactored BBolt Connection: The logic for connecting to a BBolt database for testing has been extracted into a new helper function, kvdbBBolt, improving code modularity and reusability.
- Dynamic ChainHash: The ChainHash parameter used in the MigrateGraphToSQL function within the test is now dynamically configurable, allowing for more flexible testing scenarios.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request refactors the database connection logic for bbolt and significantly expands TestPopulateViaMigration to make it a flexible helper for testing database migrations. The changes are well-structured and improve testability. I've added a couple of minor comments regarding a missing function comment and a typo, in line with the project's style guide.
Expand the test and make it easily configurable for the purposes of locally testing the graph SQL migration.
| // use in the DNS you set below. | ||
| const sqlPostgresDNS = "postgres://user@host/graphtest" | ||
|
|
||
| // ======= YOUR WORK IS DONE ============= |
|
(cc @guggero for override pls 🙏 i added the tag too late it seems & re-running that check doesnt re-check if the tag is present. dont wanna re-run the whole ci for this test that is skipped anyways. |
|
I tested the migration from bbolt to sqlite and it took about a minute for mainnet data, ending up with a 90 MB sqlite graph db file. I also didn't see excessive memory usage. Great work 🎉🎉!! |
Testing the Graph SQL migration
Steps:
TestPopulateViaMigrationtest ingraph/db/benchmark_test.go.3.1 Steps 1 - 6 is all about setting up the source DB (this can even be a bbolt channel.db file).
3.2 Steps 7 - 10 is about setting up the source database (sqlite or postgres)
Example successful output:
Debugging:
See step 9 in TestPopulateViaMigration