Skip to content

Commit

Permalink
*: make TestEtcdWithHangLeaderEnableCheck stable (#8072)
Browse files Browse the repository at this point in the history
close #7292

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Apr 16, 2024
1 parent a767a5f commit 2a4a7b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/utils/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,10 @@ func checkEtcdWithHangLeader(t *testing.T) error {
etcd2 := MustAddEtcdMember(t, &cfg1, client1)
defer etcd2.Close()
checkMembers(re, client1, []*embed.Etcd{etcd1, etcd2})
time.Sleep(1 * time.Second) // wait for etcd client sync endpoints

// Hang the etcd1 and wait for the client to connect to etcd2.
enableDiscard.Store(true)
time.Sleep(time.Second)
time.Sleep(3 * time.Second)
_, err = EtcdKVGet(client1, "test/key1")
return err
}
Expand Down Expand Up @@ -366,7 +365,8 @@ func ioCopy(ctx context.Context, dst io.Writer, src io.Reader, enableDiscard *at
return nil
default:
if enableDiscard.Load() {
io.Copy(io.Discard, src)
_, err := io.Copy(io.Discard, src)
return err
}
readNum, errRead := src.Read(buffer)
if readNum > 0 {
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/mcs/scheduling/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ func (suite *apiTestSuite) checkStores(cluster *tests.TestCluster) {
Version: "2.0.0",
},
}
// prevent the offline store from changing to tombstone
tests.MustPutRegion(re, cluster, 3, 6, []byte("a"), []byte("b"))
for _, store := range stores {
tests.MustPutStore(re, cluster, store)
}
// prevent the offline store from changing to tombstone
tests.MustPutRegion(re, cluster, 3, 6, []byte("a"), []byte("b"))
// Test /stores
apiServerAddr := cluster.GetLeaderServer().GetAddr()
urlPrefix := fmt.Sprintf("%s/pd/api/v1/stores", apiServerAddr)
Expand Down

0 comments on commit 2a4a7b7

Please sign in to comment.