From 269ad3216f85268c47d82494a4eec004021938b0 Mon Sep 17 00:00:00 2001 From: Subin M Date: Fri, 13 Mar 2015 01:40:48 +0530 Subject: [PATCH] fix proxy_test.go file to avoid ChooseHostInterface --- pkg/proxy/proxier.go | 4 ++++ pkg/proxy/proxier_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/proxy/proxier.go b/pkg/proxy/proxier.go index 3b275df3b8976..864036dfede86 100644 --- a/pkg/proxy/proxier.go +++ b/pkg/proxy/proxier.go @@ -325,6 +325,10 @@ func NewProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.In return nil } glog.Infof("Setting Proxy IP to %v", hostIP) + return CreateProxier(loadBalancer, listenIP, iptables, hostIP) +} + +func CreateProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, hostIP net.IP) *Proxier { glog.Infof("Initializing iptables") // Clean up old messes. Ignore erors. iptablesDeleteOld(iptables) diff --git a/pkg/proxy/proxier_test.go b/pkg/proxy/proxier_test.go index 5215bb546eba2..6f23084e4718b 100644 --- a/pkg/proxy/proxier_test.go +++ b/pkg/proxy/proxier_test.go @@ -201,7 +201,7 @@ func TestTCPProxy(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -221,7 +221,7 @@ func TestUDPProxy(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -250,7 +250,7 @@ func TestTCPProxyStop(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -281,7 +281,7 @@ func TestUDPProxyStop(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -312,7 +312,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -342,7 +342,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -372,7 +372,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -411,7 +411,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -450,7 +450,7 @@ func TestTCPProxyUpdatePort(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -486,7 +486,7 @@ func TestUDPProxyUpdatePort(t *testing.T) { }, }) - p := NewProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}) + p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second)