🧪 Bind replica fault injection to application queries
This commit is contained in:
parent
7624987768
commit
f68b40e9cf
@ -1,6 +1,7 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -172,11 +173,13 @@ type replicaFaultConn struct {
|
||||
armed *atomic.Bool
|
||||
}
|
||||
|
||||
func (c *replicaFaultConn) Read(b []byte) (int, error) {
|
||||
if c.armed.CompareAndSwap(true, false) {
|
||||
// Inject only on an application find wire message. A shared read switch can
|
||||
// be consumed by the driver heartbeat connection before the application read.
|
||||
func (c *replicaFaultConn) Write(b []byte) (int, error) {
|
||||
if bytes.Contains(b, []byte("\x02find\x00")) && c.armed.CompareAndSwap(true, false) {
|
||||
return 0, context.DeadlineExceeded
|
||||
}
|
||||
return c.Conn.Read(b)
|
||||
return c.Conn.Write(b)
|
||||
}
|
||||
|
||||
func TestQueryReplicaLargeResponseShrinksWithinFixedDeadlineLocal(t *testing.T) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user