Updating Kubernetes tests to properly test missing endpoints code path
This fixes #1307
This commit is contained in:
parent
9ed55e9eae
commit
d24ba90900
1 changed files with 10 additions and 71 deletions
|
@ -264,10 +264,6 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
"bar": {
|
"bar": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{
|
||||||
"2": {
|
|
||||||
URL: "http://10.0.0.2:802",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
"https://10.15.0.1:8443": {
|
"https://10.15.0.1:8443": {
|
||||||
URL: "https://10.15.0.1:8443",
|
URL: "https://10.15.0.1:8443",
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
|
@ -498,12 +494,7 @@ func TestGetPassHostHeader(t *testing.T) {
|
||||||
expected := &types.Configuration{
|
expected := &types.Configuration{
|
||||||
Backends: map[string]*types.Backend{
|
Backends: map[string]*types.Backend{
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"1": {
|
|
||||||
URL: "http://10.0.0.1:801",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -610,12 +601,7 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
||||||
expected := &types.Configuration{
|
expected := &types.Configuration{
|
||||||
Backends: map[string]*types.Backend{
|
Backends: map[string]*types.Backend{
|
||||||
"foo": {
|
"foo": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"1": {
|
|
||||||
URL: "http://10.0.0.1:80",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -799,12 +785,7 @@ func TestLoadNamespacedIngresses(t *testing.T) {
|
||||||
expected := &types.Configuration{
|
expected := &types.Configuration{
|
||||||
Backends: map[string]*types.Backend{
|
Backends: map[string]*types.Backend{
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"1": {
|
|
||||||
URL: "http://10.0.0.1:801",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -812,16 +793,7 @@ func TestLoadNamespacedIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"bar": {
|
"bar": {
|
||||||
Servers: map[string]types.Server{
|
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -1043,12 +1015,7 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
expected := &types.Configuration{
|
expected := &types.Configuration{
|
||||||
Backends: map[string]*types.Backend{
|
Backends: map[string]*types.Backend{
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"1": {
|
|
||||||
URL: "http://10.0.0.1:801",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -1056,16 +1023,7 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"bar": {
|
"bar": {
|
||||||
Servers: map[string]types.Server{
|
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -1073,12 +1031,7 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"awesome/quix": {
|
"awesome/quix": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"17": {
|
|
||||||
URL: "http://10.0.0.4:801",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -1190,12 +1143,7 @@ func TestHostlessIngress(t *testing.T) {
|
||||||
expected := &types.Configuration{
|
expected := &types.Configuration{
|
||||||
Backends: map[string]*types.Backend{
|
Backends: map[string]*types.Backend{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Servers: map[string]types.Server{
|
Servers: map[string]types.Server{},
|
||||||
"1": {
|
|
||||||
URL: "http://10.0.0.1:801",
|
|
||||||
Weight: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: &types.LoadBalancer{
|
LoadBalancer: &types.LoadBalancer{
|
||||||
Sticky: false,
|
Sticky: false,
|
||||||
|
@ -2016,11 +1964,8 @@ func TestMissingResources(t *testing.T) {
|
||||||
services: services,
|
services: services,
|
||||||
endpoints: endpoints,
|
endpoints: endpoints,
|
||||||
watchChan: watchChan,
|
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{}
|
provider := Provider{}
|
||||||
actual, err := provider.loadIngresses(client)
|
actual, err := provider.loadIngresses(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2093,8 +2038,6 @@ type clientMock struct {
|
||||||
|
|
||||||
apiServiceError error
|
apiServiceError error
|
||||||
apiEndpointsError error
|
apiEndpointsError error
|
||||||
|
|
||||||
properExists bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c clientMock) GetIngresses(namespaces Namespaces) []*v1beta1.Ingress {
|
func (c clientMock) GetIngresses(namespaces Namespaces) []*v1beta1.Ingress {
|
||||||
|
@ -2132,11 +2075,7 @@ func (c clientMock) GetEndpoints(namespace, name string) (*v1.Endpoints, bool, e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.properExists {
|
return &v1.Endpoints{}, false, nil
|
||||||
return nil, false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &v1.Endpoints{}, true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c clientMock) WatchAll(labelString string, stopCh <-chan struct{}) (<-chan interface{}, error) {
|
func (c clientMock) WatchAll(labelString string, stopCh <-chan struct{}) (<-chan interface{}, error) {
|
||||||
|
|
Loading…
Reference in a new issue