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

test: remove follower node flaky TestSyncRoundWithRemake #5415

Merged
Merged
Changes from all commits
Commits
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
79 changes: 0 additions & 79 deletions node/follower_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package node
import (
"context"
"testing"
"time"

"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
Expand Down Expand Up @@ -152,84 +151,6 @@ func TestDevModeWarning(t *testing.T) {
require.Contains(t, foundEntry.Message, "Follower running on a devMode network. Must submit txns to a different node.")
}

// TestSyncRoundWithRemake extends TestSyncRound to simulate starting and stopping the network
func TestSyncRoundWithRemake(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

maxAcctLookback := uint64(10)

followNode, tempDir := remakeableFollowNode(t, "", maxAcctLookback)
addBlock := func(round basics.Round) {
b := bookkeeping.Block{
BlockHeader: bookkeeping.BlockHeader{
GenesisHash: followNode.ledger.GenesisHash(),
Round: round,
RewardsState: bookkeeping.RewardsState{
RewardsRate: 0,
RewardsPool: poolAddr,
FeeSink: sinkAddr,
},
},
}
b.CurrentProtocol = protocol.ConsensusCurrentVersion
err := followNode.Ledger().AddBlock(b, agreement.Certificate{})
require.NoError(t, err)

status, err := followNode.Status()
require.NoError(t, err)
require.Equal(t, round, status.LastRound)
}

// Part I. redo TestSyncRound
// main differences are:
// * cfg.DisableNetworking = true
// * cfg.MaxAcctLookback = 10 (instead of 4)

addBlock(basics.Round(1))

dbRound := uint64(followNode.Ledger().LatestTrackerCommitted())
// Sync Round should be initialized to the ledger's dbRound + 1
require.Equal(t, dbRound+1, followNode.GetSyncRound())
// Set a new sync round
require.NoError(t, followNode.SetSyncRound(dbRound+11))
// Ensure it is persisted
require.Equal(t, dbRound+11, followNode.GetSyncRound())
// Unset the sync round and make sure get returns 0
followNode.UnsetSyncRound()
require.Equal(t, uint64(0), followNode.GetSyncRound())

// Part II. fast forward and then remake the node

newRound := basics.Round(2 * maxAcctLookback)
for i := basics.Round(2); i <= newRound; i++ {
addBlock(i)
}

followNode, _ = remakeableFollowNode(t, tempDir, maxAcctLookback)

// Wait for follower to catch up. This rarely is needed, but can happen
// and cause flakey test failures. Timing out can still occur, but is less
// likely than the being caught behind a few rounds.
var status *StatusReport
require.Eventually(t, func() bool {
st, err := followNode.Status()
require.NoError(t, err)
if st.LastRound >= newRound {
status = &st
return true
}
return false
}, 20*time.Second, 500*time.Millisecond, "failed to reach newRound within the allowed time")

require.Equal(t, newRound, status.LastRound)

// syncRound should be at
// newRound - maxAcctLookback + 1 = maxAcctLookback + 1
syncRound := followNode.GetSyncRound()
require.Equal(t, uint64(maxAcctLookback+1), syncRound)
}

func TestFastCatchupResume(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
Expand Down