Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Kubernetes tests to properly test missing endpoints code path #1436

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 10 additions & 71 deletions provider/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ func TestLoadIngresses(t *testing.T) {
},
"bar": {
Servers: map[string]types.Server{
"2": {
URL: "http://10.0.0.2:802",
Weight: 1,
},
"https://10.15.0.1:8443": {
URL: "https://10.15.0.1:8443",
Weight: 1,
Expand Down Expand Up @@ -498,12 +494,7 @@ func TestGetPassHostHeader(t *testing.T) {
expected := &types.Configuration{
Backends: map[string]*types.Backend{
"foo/bar": {
Servers: map[string]types.Server{
"1": {
URL: "http://10.0.0.1:801",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Expand Down Expand Up @@ -610,12 +601,7 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
expected := &types.Configuration{
Backends: map[string]*types.Backend{
"foo": {
Servers: map[string]types.Server{
"1": {
URL: "http://10.0.0.1:80",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Expand Down Expand Up @@ -799,29 +785,15 @@ func TestLoadNamespacedIngresses(t *testing.T) {
expected := &types.Configuration{
Backends: map[string]*types.Backend{
"foo/bar": {
Servers: map[string]types.Server{
"1": {
URL: "http://10.0.0.1:801",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Method: "wrr",
},
},
"bar": {
Servers: map[string]types.Server{
"2": {
URL: "http://10.0.0.2:802",
Weight: 1,
},
"3": {
URL: "https://10.0.0.3:443",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Expand Down Expand Up @@ -1043,42 +1015,23 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
expected := &types.Configuration{
Backends: map[string]*types.Backend{
"foo/bar": {
Servers: map[string]types.Server{
"1": {
URL: "http://10.0.0.1:801",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Method: "wrr",
},
},
"bar": {
Servers: map[string]types.Server{
"2": {
URL: "http://10.0.0.2:802",
Weight: 1,
},
"3": {
URL: "https://10.0.0.3:443",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Method: "wrr",
},
},
"awesome/quix": {
Servers: map[string]types.Server{
"17": {
URL: "http://10.0.0.4:801",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Expand Down Expand Up @@ -1190,12 +1143,7 @@ func TestHostlessIngress(t *testing.T) {
expected := &types.Configuration{
Backends: map[string]*types.Backend{
"/bar": {
Servers: map[string]types.Server{
"1": {
URL: "http://10.0.0.1:801",
Weight: 1,
},
},
Servers: map[string]types.Server{},
CircuitBreaker: nil,
LoadBalancer: &types.LoadBalancer{
Sticky: false,
Expand Down Expand Up @@ -2016,11 +1964,8 @@ func TestMissingResources(t *testing.T) {
services: services,
endpoints: endpoints,
watchChan: watchChan,

// TODO: Update all tests to cope with "properExists == true" correctly and remove flag.
// See https://github.com/containous/traefik/issues/1307
properExists: true,
}

provider := Provider{}
actual, err := provider.loadIngresses(client)
if err != nil {
Expand Down Expand Up @@ -2093,8 +2038,6 @@ type clientMock struct {

apiServiceError error
apiEndpointsError error

properExists bool
}

func (c clientMock) GetIngresses(namespaces Namespaces) []*v1beta1.Ingress {
Expand Down Expand Up @@ -2132,11 +2075,7 @@ func (c clientMock) GetEndpoints(namespace, name string) (*v1.Endpoints, bool, e
}
}

if c.properExists {
return nil, false, nil
}

return &v1.Endpoints{}, true, nil
return &v1.Endpoints{}, false, nil
}

func (c clientMock) WatchAll(labelString string, stopCh <-chan struct{}) (<-chan interface{}, error) {
Expand Down