-
Notifications
You must be signed in to change notification settings - Fork 56
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
test: Expand tests for Peer subscribe actions #1287
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8bfdf25
Expand peer P2PCollection func documentation
AndrewSisley 421b60d
Allow framework to test multi col ids for subscribe
AndrewSisley 0f72641
Add tests for multiple peer subscribe
AndrewSisley 9027c82
Add tests for remove peer subscription
AndrewSisley ef5fa76
Return empty array instead of default
AndrewSisley 31bc6c7
Add tests for GetAllP2PCollections
AndrewSisley 57c9d9d
Add tests for add subscription with error
AndrewSisley 38c6660
Add error tests for remove subscription
AndrewSisley 0bb0f78
PR FIXUP - Correct Peer func documentation names
AndrewSisley e695ca3
PR FIXUP - Add test for add p2p col with empty set
AndrewSisley f054282
PR FIXUP - Add test for remove p2p col with empty set
AndrewSisley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
89 changes: 89 additions & 0 deletions
89
tests/integration/net/state/simple/peer/subscribe/with_add_get_remove_test.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package subscribe_test | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestP2PSubscribeAddRemoveGetSingle(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.ConnectPeers{ | ||
SourceNodeID: 1, | ||
TargetNodeID: 0, | ||
}, | ||
testUtils.SubscribeToCollection{ | ||
NodeID: 1, | ||
CollectionIDs: []int{0}, | ||
}, | ||
testUtils.UnsubscribeToCollection{ | ||
NodeID: 1, | ||
CollectionIDs: []int{0}, | ||
}, | ||
testUtils.GetAllP2PCollections{ | ||
NodeID: 1, | ||
ExpectedCollectionIDs: []int{}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, []string{"Users"}, test) | ||
} | ||
|
||
func TestP2PSubscribeAddRemoveGetMultiple(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users { | ||
name: String | ||
} | ||
type Giraffes { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.ConnectPeers{ | ||
SourceNodeID: 1, | ||
TargetNodeID: 0, | ||
}, | ||
testUtils.SubscribeToCollection{ | ||
NodeID: 1, | ||
CollectionIDs: []int{0, 1}, | ||
}, | ||
testUtils.UnsubscribeToCollection{ | ||
NodeID: 1, | ||
// Unsubscribe from Users, but remain subscribed to Giraffes | ||
CollectionIDs: []int{0}, | ||
}, | ||
testUtils.GetAllP2PCollections{ | ||
NodeID: 1, | ||
ExpectedCollectionIDs: []int{1}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, []string{"Users", "Giraffes"}, test) | ||
} |
83 changes: 83 additions & 0 deletions
83
tests/integration/net/state/simple/peer/subscribe/with_add_get_test.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package subscribe_test | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestP2PSubscribeAddGetSingle(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.ConnectPeers{ | ||
SourceNodeID: 1, | ||
TargetNodeID: 0, | ||
}, | ||
testUtils.SubscribeToCollection{ | ||
NodeID: 1, | ||
CollectionIDs: []int{0}, | ||
}, | ||
testUtils.GetAllP2PCollections{ | ||
NodeID: 1, | ||
ExpectedCollectionIDs: []int{0}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, []string{"Users"}, test) | ||
} | ||
|
||
func TestP2PSubscribeAddGetMultiple(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users { | ||
name: String | ||
} | ||
type Giraffes { | ||
name: String | ||
} | ||
type Bears { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.ConnectPeers{ | ||
SourceNodeID: 1, | ||
TargetNodeID: 0, | ||
}, | ||
testUtils.SubscribeToCollection{ | ||
NodeID: 1, | ||
CollectionIDs: []int{0, 2}, | ||
}, | ||
testUtils.GetAllP2PCollections{ | ||
NodeID: 1, | ||
ExpectedCollectionIDs: []int{2, 0}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, []string{"Users", "Giraffes", "Bears"}, test) | ||
} |
Oops, something went wrong.
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.
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.
suggestion: We could probably add a test where we specify no collection in the subscription request and it will add automatically add all collections
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.
The code does not look like it does that - it would just add nothing? Is a good spot either way though, as it is not tested :)
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.
Sorry my mistake. I mixed up with replicators.