Merge pull request #14946 from aveshagarwal/master-proxy-changes

Adds new tests to improve coverage and removes unused params passed to proxy server.
This commit is contained in:
Dawn Chen
2015-10-12 14:53:03 -07:00
2 changed files with 31 additions and 25 deletions

View File

@@ -67,15 +67,10 @@ type ProxyServerConfig struct {
} }
type ProxyServer struct { type ProxyServer struct {
Client *kubeclient.Client Config *ProxyServerConfig
Config *ProxyServerConfig IptInterface utiliptables.Interface
EndpointsConfig *proxyconfig.EndpointsConfig Proxier proxy.ProxyProvider
EndpointsHandler proxyconfig.EndpointsConfigHandler Recorder record.EventRecorder
IptInterface utiliptables.Interface
OOMAdjuster *oom.OOMAdjuster
Proxier proxy.ProxyProvider
Recorder record.EventRecorder
ServiceConfig *proxyconfig.ServiceConfig
} }
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet // AddFlags adds flags for a specific ProxyServer to the specified FlagSet
@@ -122,25 +117,15 @@ func NewProxyConfig() *ProxyServerConfig {
func NewProxyServer( func NewProxyServer(
config *ProxyServerConfig, config *ProxyServerConfig,
client *kubeclient.Client,
endpointsConfig *proxyconfig.EndpointsConfig,
endpointsHandler proxyconfig.EndpointsConfigHandler,
iptInterface utiliptables.Interface, iptInterface utiliptables.Interface,
oomAdjuster *oom.OOMAdjuster,
proxier proxy.ProxyProvider, proxier proxy.ProxyProvider,
recorder record.EventRecorder, recorder record.EventRecorder,
serviceConfig *proxyconfig.ServiceConfig,
) (*ProxyServer, error) { ) (*ProxyServer, error) {
return &ProxyServer{ return &ProxyServer{
Client: client, Config: config,
Config: config, IptInterface: iptInterface,
EndpointsConfig: endpointsConfig, Proxier: proxier,
EndpointsHandler: endpointsHandler, Recorder: recorder,
IptInterface: iptInterface,
OOMAdjuster: oomAdjuster,
Proxier: proxier,
Recorder: recorder,
ServiceConfig: serviceConfig,
}, nil }, nil
} }
@@ -272,8 +257,7 @@ func NewProxyServerDefault(config *ProxyServerConfig) (*ProxyServer, error) {
UID: types.UID(hostname), UID: types.UID(hostname),
Namespace: "", Namespace: "",
} }
return NewProxyServer(config, iptInterface, proxier, recorder)
return NewProxyServer(config, client, endpointsConfig, endpointsHandler, iptInterface, oomAdjuster, proxier, recorder, serviceConfig)
} }
// Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set). // Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set).

View File

@@ -19,6 +19,7 @@ package app
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
) )
@@ -59,3 +60,24 @@ func Test_mayTryIptablesProxy(t *testing.T) {
} }
} }
} }
//This test verifies that Proxy Server does not crash that means
//Config and iptinterface are not nil when CleanupAndExit is true.
//To avoid proxy crash: https://github.com/kubernetes/kubernetes/pull/14736
func TestProxyServerWithCleanupAndExit(t *testing.T) {
//creates default config
config := NewProxyConfig()
//sets CleanupAndExit manually
config.CleanupAndExit = true
//creates new proxy server
proxyserver, err := NewProxyServerDefault(config)
//verifies that nothing is nill except error
assert.Nil(t, err)
assert.NotNil(t, proxyserver)
assert.NotNil(t, proxyserver.Config)
assert.NotNil(t, proxyserver.IptInterface)
}