mirror of https://github.com/hashicorp/consul
Move ctx and cancel func setup into the Replicator.Start (#6115)
Previously a sequence of events like: Start Stop Start Stop would segfault on the second stop because the original ctx and cancel func were only initialized during the constructor and not during Start.pull/6121/head
parent
3f3cd9a164
commit
de23af071a
@ -0,0 +1,28 @@
|
||||
package consul
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestReplicationRestart(t *testing.T) {
|
||||
config := ReplicatorConfig{
|
||||
Name: "mock",
|
||||
ReplicateFn: func(ctx context.Context, lastRemoteIndex uint64) (uint64, bool, error) {
|
||||
return 1, false, nil
|
||||
},
|
||||
Rate: 1,
|
||||
Burst: 1,
|
||||
}
|
||||
|
||||
repl, err := NewReplicator(&config)
|
||||
require.NoError(t, err)
|
||||
|
||||
repl.Start()
|
||||
repl.Stop()
|
||||
repl.Start()
|
||||
// Previously this would have segfaulted
|
||||
repl.Stop()
|
||||
}
|
Loading…
Reference in new issue