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

View File

@@ -19,6 +19,7 @@ package app
import (
"testing"
"github.com/stretchr/testify/assert"
"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)
}