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

fix dbtest backend #8745

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented May 9, 2024

Replaces #8462

  1. This PR fixes a testcase where we would basically test not what the testcase was suppose to test (reopening the same database).

  2. Moreover it enhances a lot of unit-tests which would initially only test the bolt db backend and makes those tests compatible with the global kvdb backend, so those tests are now executed depending on the selected golang kv tag.

Copy link

coderabbitai bot commented May 9, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ziggie1984
Copy link
Collaborator Author

Let's see whether all the unit tests pass using the global kvdb backend tag

channeldb/db.go Outdated
// golang tags (e.g. kvdb_sqlite, kvdb_etcd, kvdb_postgres or default bolt if
// nothing is explicitly specified).
// Any necessary schemas migrations due to updates will take place as necessary.
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be better to name this OpenTestDB and make the renames in the tests too as otherwise this method could be mistaken for a generic open.

channeldb/db.go Outdated
// to updates will take place as necessary.
// TODO(bhandras): deprecate this function.
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
// OpenBoltDB opens or creates channeldb using the boltDB type and enables
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I think we can even remove this one, I kept it because in lnwallet/test_utils.go we use the dbModifiers but not for the opening option but rather when we create the final backend ( CreateWithBackend(backend, modifiers...)) tho I find it useful in case we want to use the db opening options in the future to have the function ready for it ? But also open to remove it.

@ziggie1984 ziggie1984 force-pushed the fix-dbtest-backend branch 2 times, most recently from f99f3f0 to 3ce2edd Compare May 9, 2024 16:51
@saubyk saubyk added this to the v0.18.1 milestone May 9, 2024
@ziggie1984 ziggie1984 force-pushed the fix-dbtest-backend branch 4 times, most recently from ac8f8cc to 9001910 Compare May 9, 2024 19:17
@ziggie1984 ziggie1984 marked this pull request as ready for review May 9, 2024 19:17
// to updates will take place as necessary.
// TODO(bhandras): deprecate this function.
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
// OpenTestBoltDB opens or creates channeldb using the boltDB type and enables
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this function is currently not used, because in all of our testcases we used the default opening options for boltdb:

BoltBackendConfig: kvdb.BoltBackendConfig{
			NoFreelistSync:    true,
			AutoCompact:       false,
			AutoCompactMinAge: kvdb.DefaultBoltAutoCompactMinAge,
			DBTimeout:         kvdb.DefaultDBTimeout,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I think its best to remove it? @bhandras

Previously we would open the kvdb backend only for the dbbolt
option which meant that most of the tests where exectued using the
bolt db backend although started via a different db backend e.g.
sqlite.
Now two functions are provided, one opens and creates the db for
the bolt specific backend and the other one uses the golang
specified db backend.

This commit also fixes a bug in TestOpenWithCreate where we would open
a different db with a different name and therefore the tests would
fail to test its objective.
Moreover precautiously parts in the codebase are improved where we
would use a different name for the database than the global name
"channel.db" which is error prune and therefore improved.
@ziggie1984
Copy link
Collaborator Author

Short summary of the current PR:

The current set of unit tests are not easily portable to all available backends. We are currently running a lot of tests on the boltdb backend, switching over to the global kvdb_architecture flag (e.g. kvdb_etcd ...) needs still work to be done. For example the copy of the db file needs to be different for all backends, we cannot just copy a file like in boltdb in the etcd case. Moreover postgres seems to have problems handling the workload while running embedded (but not sure, this needs to be investigated too).

@bhandras proposed taking over this issue because he is already very knowledge in this code area.

@ziggie1984 ziggie1984 assigned bhandras and unassigned ziggie1984 May 14, 2024
@lightninglabs-deploy
Copy link

@ziggie1984, remember to re-request review from reviewers when ready

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.

None yet

4 participants