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.
fix: Rework the P2P integration tests (sourcenetwork#989)
* Duplicate net tests In order to preserve the order driven tests * Rework replicator tests so that each expected result is asserted upon Deletion of pretty much any property/item in the test case will now cause it to fail, before many of these deletions would permit it to pass without asserting the expected results. Much of this commit has been moved and reworked later, however I chose to preserve it as it highlights the behavioural change specific to this commit. * Expand replicator tests There was a typo, and the name suggests it tests everything replicator related - and that no further tests are required * Refactor test library This commit merges the properties associated with the peer-tests with the properties associated with the replicator tests. There was a lot of duplication, and it prevented testing of both peer and replicator tests within the same test case due to id/index clashes. It also reworks the code so that the two elements work in largely the same way. It should allow replicators to test updates, and peers to test creates. The both peer and replicator tests now assert on the final state of all databases for all nodes. This feels both more meaningful and clearer IMO, although it does add a few lines to each test, as well as some fanciness required to deal with the non-deterministic results of the peer sync tests. * Remove uneeded check Looks both overly defensive, and enables a silent failure * Breakup P2P test file Is about to get crowded :) * Expand tests
- Loading branch information
1 parent
1a0fd7c
commit d0c2a4b
Showing
11 changed files
with
1,584 additions
and
3 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
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
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
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,64 @@ | ||
// 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 peer_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/sourcenetwork/defradb/config" | ||
testUtils "github.com/sourcenetwork/defradb/tests/integration/net/state" | ||
) | ||
|
||
func TestP2PCreateDoesNotSync(t *testing.T) { | ||
test := testUtils.P2PTestCase{ | ||
NodeConfig: []*config.Config{ | ||
testUtils.RandomNetworkingConfig(), | ||
testUtils.RandomNetworkingConfig(), | ||
}, | ||
NodePeers: map[int][]int{ | ||
1: { | ||
0, | ||
}, | ||
}, | ||
SeedDocuments: map[int]string{ | ||
0: `{ | ||
"Name": "Shahzad", | ||
"Age": 300 | ||
}`, | ||
}, | ||
Creates: map[int]map[int]string{ | ||
0: { | ||
1: `{ | ||
"Name": "John", | ||
"Age": 21 | ||
}`, | ||
}, | ||
}, | ||
Results: map[int]map[int]map[string]any{ | ||
0: { | ||
0: { | ||
"Age": uint64(300), | ||
}, | ||
1: { | ||
"Age": uint64(21), | ||
}, | ||
}, | ||
1: { | ||
0: { | ||
"Age": uint64(300), | ||
}, | ||
// Peer sync should not sync new documents to nodes | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} |
Oops, something went wrong.