mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Remove DelayAccept of the reverse proxy from the e2e test
Part of the patches to fix https://github.com/etcd-io/etcd/issues/17737 During the development of https://github.com/etcd-io/etcd/pull/17938, we agreed that during the transition to L7 forward proxy, unused features and features targeting L4 reverse proxy will be dropped. This feature falls under the unused feature. Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
This commit is contained in:
parent
462d24af9c
commit
925181a17f
@ -59,13 +59,6 @@ type Server interface {
|
||||
// Close closes listener and transport.
|
||||
Close() error
|
||||
|
||||
// DelayAccept adds latency ± random variable to accepting
|
||||
// new incoming connections.
|
||||
DelayAccept(latency, rv time.Duration)
|
||||
// UndelayAccept removes sending latencies.
|
||||
UndelayAccept()
|
||||
// LatencyAccept returns current latency on accepting
|
||||
// new incoming connections.
|
||||
LatencyAccept() time.Duration
|
||||
|
||||
// DelayTx adds latency ± random variable for "outgoing" traffic
|
||||
@ -616,39 +609,6 @@ func (s *server) Close() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *server) DelayAccept(latency, rv time.Duration) {
|
||||
if latency <= 0 {
|
||||
return
|
||||
}
|
||||
d := computeLatency(latency, rv)
|
||||
s.latencyAcceptMu.Lock()
|
||||
s.latencyAccept = d
|
||||
s.latencyAcceptMu.Unlock()
|
||||
|
||||
s.lg.Info(
|
||||
"set accept latency",
|
||||
zap.Duration("latency", d),
|
||||
zap.Duration("given-latency", latency),
|
||||
zap.Duration("given-latency-random-variable", rv),
|
||||
zap.String("from", s.From()),
|
||||
zap.String("to", s.To()),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *server) UndelayAccept() {
|
||||
s.latencyAcceptMu.Lock()
|
||||
d := s.latencyAccept
|
||||
s.latencyAccept = 0
|
||||
s.latencyAcceptMu.Unlock()
|
||||
|
||||
s.lg.Info(
|
||||
"removed accept latency",
|
||||
zap.Duration("latency", d),
|
||||
zap.String("from", s.From()),
|
||||
zap.String("to", s.To()),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *server) LatencyAccept() time.Duration {
|
||||
s.latencyAcceptMu.RLock()
|
||||
d := s.latencyAccept
|
||||
|
@ -175,65 +175,6 @@ func createTLSInfo(lg *zap.Logger, secure bool) transport.TLSInfo {
|
||||
return transport.TLSInfo{Logger: lg}
|
||||
}
|
||||
|
||||
func TestServer_Unix_Insecure_DelayAccept(t *testing.T) { testServerDelayAccept(t, false) }
|
||||
func TestServer_Unix_Secure_DelayAccept(t *testing.T) { testServerDelayAccept(t, true) }
|
||||
func testServerDelayAccept(t *testing.T, secure bool) {
|
||||
lg := zaptest.NewLogger(t)
|
||||
srcAddr, dstAddr := newUnixAddr(), newUnixAddr()
|
||||
defer func() {
|
||||
os.RemoveAll(srcAddr)
|
||||
os.RemoveAll(dstAddr)
|
||||
}()
|
||||
tlsInfo := createTLSInfo(lg, secure)
|
||||
scheme := "unix"
|
||||
ln := listen(t, scheme, dstAddr, tlsInfo)
|
||||
defer ln.Close()
|
||||
|
||||
cfg := ServerConfig{
|
||||
Logger: lg,
|
||||
From: url.URL{Scheme: scheme, Host: srcAddr},
|
||||
To: url.URL{Scheme: scheme, Host: dstAddr},
|
||||
}
|
||||
if secure {
|
||||
cfg.TLSInfo = tlsInfo
|
||||
}
|
||||
p := NewServer(cfg)
|
||||
|
||||
waitForServer(t, p)
|
||||
|
||||
defer p.Close()
|
||||
|
||||
data := []byte("Hello World!")
|
||||
|
||||
now := time.Now()
|
||||
send(t, data, scheme, srcAddr, tlsInfo)
|
||||
if d := receive(t, ln); !bytes.Equal(data, d) {
|
||||
t.Fatalf("expected %q, got %q", string(data), string(d))
|
||||
}
|
||||
took1 := time.Since(now)
|
||||
t.Logf("took %v with no latency", took1)
|
||||
|
||||
lat, rv := 700*time.Millisecond, 10*time.Millisecond
|
||||
p.DelayAccept(lat, rv)
|
||||
defer p.UndelayAccept()
|
||||
if err := p.ResetListener(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
now = time.Now()
|
||||
send(t, data, scheme, srcAddr, tlsInfo)
|
||||
if d := receive(t, ln); !bytes.Equal(data, d) {
|
||||
t.Fatalf("expected %q, got %q", string(data), string(d))
|
||||
}
|
||||
took2 := time.Since(now)
|
||||
t.Logf("took %v with latency %v±%v", took2, lat, rv)
|
||||
|
||||
if took1 >= took2 {
|
||||
t.Fatalf("expected took1 %v < took2 %v", took1, took2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_ModifyTx_corrupt(t *testing.T) {
|
||||
lg := zaptest.NewLogger(t)
|
||||
scheme := "unix"
|
||||
|
Loading…
x
Reference in New Issue
Block a user