-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support modusDB instance per data directory #15
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jairad26 could you add a test for this? Because Dgraph uses global variables, I am not sure how this is working! |
@@ -56,8 +56,142 @@ func TestRestart(t *testing.T) { | |||
require.NoError(t, db.DropAll(context.Background())) | |||
} | |||
|
|||
func TestMultipleStartOnSameDir(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to fail because we have global variables in Dgraph repo
func TestMultipleDBsDifferentDir(t *testing.T) {
dataDir := t.TempDir()
dataDir2 := t.TempDir()
db1, err := modusdb.New(modusdb.NewDefaultConfig(), dataDir)
require.NoError(t, err)
defer func() { db1.Close() }()
db2, err := modusdb.New(modusdb.NewDefaultConfig(), dataDir2)
require.NoError(t, err)
defer func() { db2.Close() }()
_, err = db1.Mutate(context.Background(), []*api.Mutation{
{
Set: []*api.NQuad{
{
Namespace: 0,
Subject: "_:aman",
Predicate: "name",
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "A"}},
},
},
},
})
require.NoError(t, err)
_, err = db2.Mutate(context.Background(), []*api.Mutation{
{
Set: []*api.NQuad{
{
Namespace: 0,
Subject: "_:aman",
Predicate: "name",
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "B"}},
},
},
},
})
require.NoError(t, err)
query := `{
me(func: has(name)) {
name
}
}`
qresp, err := db1.Query(context.Background(), query)
require.NoError(t, err)
require.JSONEq(t, `{"me":[{"name":"A"}]}`, string(qresp.GetJson()))
// drop db1
require.NoError(t, db1.DropAll(context.Background()))
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for multiple modusDB instances in a single process, as long as they each reference their own dataDirectory. This moves the dataDirectory field out of the config and into the DB layer, and removes the validate function & WithDataDir functions, since DataDir is a mandatory field, it is now moved into an argument on the New() function.