forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Expand tests for Peer subscribe actions (sourcenetwork#1287)
* Expand peer P2PCollection func documentation * Allow framework to test multi col ids for subscribe The function under test takes a set of schemaIDs, so the tests should be able to set multiple in the same test action - this will allow testing of the function with multiple ids. * Add tests for multiple peer subscribe Adds tests for subscribing to multiple collections in the same call. This is done in a new sub-directory as we will expand the number of subscription-specific tests shortly and they should not polute or by drowned out by the normal/existing p2p-peer tests. * Add tests for remove peer subscription * Return empty array instead of default Whilst there is not much difference in terms of behaviour, they are still different and it notable enough to result in a test failure * Add tests for GetAllP2PCollections * Add tests for add subscription with error * Add error tests for remove subscription
- Loading branch information
1 parent
c8d8774
commit 4bbe7d9
Showing
12 changed files
with
1,003 additions
and
26 deletions.
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.