mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix the DATA RACE issue of TestCloseProposerInflight
This commit is contained in:
parent
08f4c340eb
commit
8ad87be7a6
@ -21,6 +21,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -152,8 +153,12 @@ func TestCloseProposerInflight(t *testing.T) {
|
|||||||
clus := newCluster(1)
|
clus := newCluster(1)
|
||||||
defer clus.closeNoErrors(t)
|
defer clus.closeNoErrors(t)
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
// some inflight ops
|
// some inflight ops
|
||||||
go func() {
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
clus.proposeC[0] <- "foo"
|
clus.proposeC[0] <- "foo"
|
||||||
clus.proposeC[0] <- "bar"
|
clus.proposeC[0] <- "bar"
|
||||||
}()
|
}()
|
||||||
@ -162,6 +167,8 @@ func TestCloseProposerInflight(t *testing.T) {
|
|||||||
if c, ok := <-clus.commitC[0]; !ok || c.data[0] != "foo" {
|
if c, ok := <-clus.commitC[0]; !ok || c.data[0] != "foo" {
|
||||||
t.Fatalf("Commit failed")
|
t.Fatalf("Commit failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPutAndGetKeyValue(t *testing.T) {
|
func TestPutAndGetKeyValue(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user