Merge pull request #12736 from ptabor/20210301-fix-flakes

tests: Fixes a few recently spotted test-flakes
This commit is contained in:
Gyuho Lee 2021-03-01 14:22:29 -08:00 committed by GitHub
commit 6ace85b624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 5 deletions

View File

@ -52,6 +52,7 @@ func TestServer_Unix_Insecure_DelayTx(t *testing.T) { testServer(t, "unix", fals
func TestServer_TCP_Insecure_DelayTx(t *testing.T) { testServer(t, "tcp", false, true) }
func TestServer_Unix_Secure_DelayTx(t *testing.T) { testServer(t, "unix", true, true) }
func TestServer_TCP_Secure_DelayTx(t *testing.T) { testServer(t, "tcp", true, true) }
func testServer(t *testing.T, scheme string, secure bool, delayTx bool) {
srcAddr, dstAddr := newUnixAddr(), newUnixAddr()
if scheme == "tcp" {
@ -122,15 +123,15 @@ func testServer(t *testing.T, scheme string, secure bool, delayTx bool) {
}
took2 := time.Since(now)
if delayTx {
t.Logf("took %v with latency %v±%v", took2, lat, rv)
t.Logf("took %v with latency %v+-%v", took2, lat, rv)
} else {
t.Logf("took %v with no latency", took2)
}
if delayTx {
p.UndelayTx()
if took1 >= took2 {
t.Fatalf("expected took1 %v < took2 %v (with latency)", took1, took2)
if took2 < lat-rv {
t.Fatalf("expected took2 %v (with latency) > delay: %v", took2, lat-rv)
}
}

View File

@ -125,7 +125,8 @@ func interestingGoroutines() (gs []string) {
strings.Contains(stack, "created by runtime.gc") ||
strings.Contains(stack, "created by text/template/parse.lex") ||
strings.Contains(stack, "runtime.MHeap_Scavenger") ||
strings.Contains(stack, "rcrypto/internal/boring.(*PublicKeyRSA).finalize") {
strings.Contains(stack, "rcrypto/internal/boring.(*PublicKeyRSA).finalize") ||
strings.Contains(stack, "net.(*netFD).Close(...)") {
continue
}
gs = append(gs, stack)

View File

@ -234,10 +234,12 @@ func testBalancerUnderNetworkPartitionWatch(t *testing.T, isolateLeader bool) {
if err != nil {
t.Fatal(err)
}
t.Logf("watchCli created to: %v", target)
defer watchCli.Close()
// wait for eps[target] to be pinned
// wait for eps[target] to be connected
clientv3test.MustWaitPinReady(t, watchCli)
t.Logf("successful connection with server: %v", target)
// add all eps to list, so that when the original pined one fails
// the client can switch to other available eps
@ -250,6 +252,8 @@ func testBalancerUnderNetworkPartitionWatch(t *testing.T, isolateLeader bool) {
t.Fatal("took too long to create watch")
}
t.Logf("watch established")
// isolate eps[target]
clus.Members[target].InjectPartition(t,
clus.Members[(target+1)%3],

View File

@ -110,6 +110,7 @@ var (
defaultTokenJWT = "jwt,pub-key=../fixtures/server.crt,priv-key=../fixtures/server.key.insecure,sign-method=RS256,ttl=1s"
// Replace with just usage of testing.TB instead of zap
lg = zap.NewNop()
)
@ -1202,6 +1203,7 @@ func (m *member) InjectPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.CutPeer(other.s.ID())
other.s.CutPeer(m.s.ID())
t.Logf("network partition injected between: %v <-> %v", m.s.ID(), other.s.ID())
}
}
@ -1210,6 +1212,7 @@ func (m *member) RecoverPartition(t testing.TB, others ...*member) {
for _, other := range others {
m.s.MendPeer(other.s.ID())
other.s.MendPeer(m.s.ID())
t.Logf("network partition between: %v <-> %v", m.s.ID(), other.s.ID())
}
}