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: Rework the P2P integration tests #989

Merged
merged 25 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bf0e53a
Duplicate net tests
AndrewSisley Dec 29, 2022
4363173
Rework replicator tests so that each expected result is asserted upon
AndrewSisley Dec 20, 2022
8e87660
Expand replicator tests
AndrewSisley Dec 20, 2022
adab1eb
Refactor test library
AndrewSisley Dec 20, 2022
384713e
Remove uneeded check
AndrewSisley Dec 21, 2022
0f26001
Breakup P2P test file
AndrewSisley Dec 21, 2022
b76adb9
Expand tests
AndrewSisley Dec 21, 2022
2192116
PR FIXUP - Rename order/state dirs
AndrewSisley Jan 11, 2023
afb9ffb
PR FIXUP - handle unmapped peer sources
AndrewSisley Jan 11, 2023
78de646
PR FIXUP - Remove pointless spread
AndrewSisley Jan 11, 2023
3726488
PR FIXUP - Document mode of failure for failing test
AndrewSisley Jan 11, 2023
b3e4824
PR FIXUP - Rename unhelpful var
AndrewSisley Jan 11, 2023
bb263eb
PR FIXUP - Rename unhelpful var
AndrewSisley Jan 11, 2023
0e97db1
WIP PR FIXUP - Test strong eventual consistency
AndrewSisley Jan 11, 2023
f318d54
PR FIXUP - Update test to reflect desired reality
AndrewSisley Jan 17, 2023
0cd9b06
PR FIXUP - Add inverted replicator update test
AndrewSisley Jan 17, 2023
11f44d3
PR FIXUP - Wait for seed docs to sync
AndrewSisley Jan 17, 2023
e41ab9c
PR FIXUP - Improve assert message
AndrewSisley Jan 17, 2023
0d050a5
PR FIXUP - Correctly handle concurrent P2P mutations
AndrewSisley Jan 17, 2023
1858962
PR FIXUP - Uncomment previously failing test
AndrewSisley Jan 17, 2023
c0cf3c1
PR FIXUP - De-document test as incorrect behaviour
AndrewSisley Jan 17, 2023
57e6f69
PR FIXUP - Remove unessecary ifs
AndrewSisley Jan 18, 2023
460d8ee
PR FIXUP - Update documentation to better describe WaitForPushLogEvent
AndrewSisley Jan 18, 2023
f7ce146
PR FIXUP - Simplify wait group logic
AndrewSisley Jan 18, 2023
8b1f0d4
PR FIXUP - Correctly return err if max retries hit
AndrewSisley Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ func (n *Node) WaitForPubSubEvent(id peer.ID) error {
}

// WaitForPushLogEvent listens to the event channel for a push log event from a given peer.
//
// It will block the calling thread until an event is yielded to an internal channel. This
// event is not nessecarily the next event and is dependent on the number of concurrent callers
// (each event will only notify a single caller, not all of them).
func (n *Node) WaitForPushLogEvent(id peer.ID) error {
for {
select {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package net
package order

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package net
package order

import (
"context"
Expand Down Expand Up @@ -220,7 +220,7 @@ func executeTestCase(t *testing.T, test P2PTestCase) {
require.NoError(t, err)

if i == 0 {
dockeys = append(dockeys, d...)
dockeys = d
}
nodes = append(nodes, n)
}
Expand Down
64 changes: 64 additions & 0 deletions tests/integration/net/state/peer/with_create_test.go
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)
}
Loading