Skip to content

Commit

Permalink
testing: increase timeouts
Browse files Browse the repository at this point in the history
Increase timeouts for TestRaft_UserRestore, as it makes file io calls.
  • Loading branch information
Mahmood Ali committed Mar 3, 2020
1 parent a6bc96a commit 387ddae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion inmem_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewInmemTransportWithTimeout(addr ServerAddress, timeout time.Duration) (Se
// NewInmemTransport is used to initialize a new transport
// and generates a random local address if none is specified
func NewInmemTransport(addr ServerAddress) (ServerAddress, *InmemTransport) {
return NewInmemTransportWithTimeout(addr, 50*time.Millisecond)
return NewInmemTransportWithTimeout(addr, 500*time.Millisecond)
}

// SetHeartbeatHandler is used to set optional fast-path for
Expand Down
32 changes: 23 additions & 9 deletions raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,13 @@ func TestRaft_UserSnapshot(t *testing.T) {
func snapshotAndRestore(t *testing.T, offset uint64) {
// Make the cluster.
conf := inmemConfig(t)

// snapshot operations perform some file IO operations.
// increase times out to account for that
conf.HeartbeatTimeout = 500 * time.Millisecond
conf.ElectionTimeout = 500 * time.Millisecond
conf.LeaderLeaseTimeout = 500 * time.Millisecond

c := MakeCluster(3, t, conf)
defer c.Close()

Expand Down Expand Up @@ -1282,15 +1289,22 @@ func snapshotAndRestore(t *testing.T, offset uint64) {
}

func TestRaft_UserRestore(t *testing.T) {
// Snapshots from the past.
snapshotAndRestore(t, 0)
snapshotAndRestore(t, 1)
snapshotAndRestore(t, 2)

// Snapshots from the future.
snapshotAndRestore(t, 100)
snapshotAndRestore(t, 1000)
snapshotAndRestore(t, 10000)
cases := []uint64{
0,
1,
2,

// Snapshots from the future
100,
1000,
10000,
}

for _, c := range cases {
t.Run(fmt.Sprintf("case %v", c), func(t *testing.T) {
snapshotAndRestore(t, c)
})
}
}

func TestRaft_SendSnapshotFollower(t *testing.T) {
Expand Down

0 comments on commit 387ddae

Please sign in to comment.