|
@@ -14,8 +14,8 @@ const (
|
|
|
testClientURL = "localhost:4401"
|
|
testClientURL = "localhost:4401"
|
|
|
testRaftURL = "localhost:7701"
|
|
testRaftURL = "localhost:7701"
|
|
|
testSnapshotCount = 10000
|
|
testSnapshotCount = 10000
|
|
|
- testHeartbeatTimeout = 50
|
|
|
|
|
- testElectionTimeout = 200
|
|
|
|
|
|
|
+ testHeartbeatTimeout = time.Duration(50) * time.Millisecond
|
|
|
|
|
+ testElectionTimeout = time.Duration(200) * time.Millisecond
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Starts a server in a temporary directory.
|
|
// Starts a server in a temporary directory.
|
|
@@ -26,10 +26,8 @@ func RunServer(f func(*server.Server)) {
|
|
|
store := store.New()
|
|
store := store.New()
|
|
|
registry := server.NewRegistry(store)
|
|
registry := server.NewRegistry(store)
|
|
|
|
|
|
|
|
- ps := server.NewPeerServer(testName, path, "http://"+testRaftURL, testRaftURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, registry, store, testSnapshotCount)
|
|
|
|
|
|
|
+ ps := server.NewPeerServer(testName, path, "http://"+testRaftURL, testRaftURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, registry, store, testSnapshotCount, testHeartbeatTimeout, testElectionTimeout)
|
|
|
ps.MaxClusterSize = 9
|
|
ps.MaxClusterSize = 9
|
|
|
- ps.ElectionTimeout = testElectionTimeout
|
|
|
|
|
- ps.HeartbeatTimeout = testHeartbeatTimeout
|
|
|
|
|
s := server.New(testName, "http://"+testClientURL, testClientURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, ps, registry, store)
|
|
s := server.New(testName, "http://"+testClientURL, testClientURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, ps, registry, store)
|
|
|
ps.SetServer(s)
|
|
ps.SetServer(s)
|
|
|
|
|
|