From 22832cfb78195838e8c50c5793a0b87cc3f306e8 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Fri, 31 May 2019 08:45:59 -0400 Subject: [PATCH] ipvs proxy: add unit test for udp graceful termination Signed-off-by: Andrew Sy Kim --- pkg/proxy/ipvs/graceful_termination_test.go | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/pkg/proxy/ipvs/graceful_termination_test.go b/pkg/proxy/ipvs/graceful_termination_test.go index c99feef993f..626bef565bf 100644 --- a/pkg/proxy/ipvs/graceful_termination_test.go +++ b/pkg/proxy/ipvs/graceful_termination_test.go @@ -242,6 +242,70 @@ func Test_GracefulDeleteRS(t *testing.T) { }, err: nil, }, + { + name: "graceful delete, real server has connections, but udp connections are deleted immediately", + vs: &utilipvs.VirtualServer{ + Address: net.ParseIP("1.1.1.1"), + Protocol: "udp", + Port: uint16(80), + }, + rs: &utilipvs.RealServer{ + Address: net.ParseIP("10.0.0.1"), + Port: uint16(80), + Weight: 100, + ActiveConn: 10, + InactiveConn: 10, + }, + existingIPVS: &utilipvstest.FakeIPVS{ + Services: map[utilipvstest.ServiceKey]*utilipvs.VirtualServer{ + { + IP: "1.1.1.1", + Port: 80, + Protocol: "udp", + }: { + Address: net.ParseIP("1.1.1.1"), + Protocol: "udp", + Port: uint16(80), + }, + }, + Destinations: map[utilipvstest.ServiceKey][]*utilipvs.RealServer{ + { + IP: "1.1.1.1", + Port: 80, + Protocol: "udp", + }: { + { + Address: net.ParseIP("10.0.0.1"), + Port: uint16(80), + Weight: 100, + ActiveConn: 10, + InactiveConn: 10, + }, + }, + }, + }, + expectedIPVS: &utilipvstest.FakeIPVS{ + Services: map[utilipvstest.ServiceKey]*utilipvs.VirtualServer{ + { + IP: "1.1.1.1", + Port: 80, + Protocol: "udp", + }: { + Address: net.ParseIP("1.1.1.1"), + Protocol: "udp", + Port: uint16(80), + }, + }, + Destinations: map[utilipvstest.ServiceKey][]*utilipvs.RealServer{ + { + IP: "1.1.1.1", + Port: 80, + Protocol: "udp", + }: {}, // udp real server deleted immediately + }, + }, + err: nil, + }, { name: "graceful delete, real server mismatch should be no-op", vs: &utilipvs.VirtualServer{