[sql-59] Add kv store kvdb->SQL migration itest#1217
[sql-59] Add kv store kvdb->SQL migration itest#1217ViktorT-11 wants to merge 1 commit intolightninglabs:migration-itest-sessionsfrom
Conversation
Implement itest coverage for migrating kv entries data from kvdb to sql. The itest coverage mimics the unit tests for kv stores in firewalldb/sql_migration_test.go, except for the randomized migration tests. This coverage ensures that the full kvdb->SQL migration flow for litd works as expected for the kv entries.
Summary of ChangesHello @ViktorT-11, 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 introduces a comprehensive integration test for the migration of existing key-value store data to a SQL database. This is a critical step in modernizing the application's data persistence layer. The changes also encompass an update to the Go programming language version and substantial architectural improvements to how SQL database interactions are managed, utilizing a new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This PR adds integration test coverage for the migration of firewall key-value store data from bbolt to SQL. The changes are well-contained within the itest/litd_migration_test.go file and follow the existing structure for migration tests. The test cases are comprehensive, covering various scenarios for global, session-specific, and feature-specific KV entries. I have a couple of suggestions to improve code clarity and reduce duplication.
| switch { | ||
| case entry.groupAlias == nil && !entry.perm: | ||
| store = tx.GlobalTemp() | ||
| case entry.groupAlias == nil && entry.perm: | ||
| store = tx.Global() | ||
| case entry.groupAlias != nil && !entry.perm: | ||
| store = tx.LocalTemp() | ||
| default: | ||
| store = tx.Local() | ||
| } |
There was a problem hiding this comment.
This switch statement for selecting the correct KVStore is duplicated in the insertFirewallKVEntry function (lines 1354-1363). To improve maintainability and reduce code duplication, consider extracting this logic into a shared helper function. For example:
func getFirewallKVStore(tx firewalldb.KVStoreTx, entry *firewallKVEntryExpectation) firewalldb.KVStore {
switch {
case entry.groupAlias == nil && !entry.perm:
return tx.GlobalTemp()
case entry.groupAlias == nil && entry.perm:
return tx.Global()
case entry.groupAlias != nil && !entry.perm:
return tx.LocalTemp()
default: // entry.groupAlias != nil && entry.perm
return tx.Local()
}
}This helper could then be called from both insertFirewallKVEntry and assertFirewallKVEntryBolt.
|
@ViktorT-11, remember to re-request review from reviewers when ready |
Based on #1211
Implements part of step 6. of "Phase 3" in #917.
This PR implements itest coverage for the migration of kv store values.