aggregator: make linter happy
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
This commit is contained in:
		@@ -313,7 +313,7 @@ func (c *AvailableConditionController) sync(key string) error {
 | 
				
			|||||||
						resp.Body.Close()
 | 
											resp.Body.Close()
 | 
				
			||||||
						// we should always been in the 200s or 300s
 | 
											// we should always been in the 200s or 300s
 | 
				
			||||||
						if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
 | 
											if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
 | 
				
			||||||
							errCh <- fmt.Errorf("bad status from %v: %v", discoveryURL, resp.StatusCode)
 | 
												errCh <- fmt.Errorf("bad status from %v: %d", discoveryURL, resp.StatusCode)
 | 
				
			||||||
							return
 | 
												return
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
@@ -324,7 +324,7 @@ func (c *AvailableConditionController) sync(key string) error {
 | 
				
			|||||||
				select {
 | 
									select {
 | 
				
			||||||
				case err = <-errCh:
 | 
									case err = <-errCh:
 | 
				
			||||||
					if err != nil {
 | 
										if err != nil {
 | 
				
			||||||
						results <- fmt.Errorf("failing or missing response from %v: %v", discoveryURL, err)
 | 
											results <- fmt.Errorf("failing or missing response from %v: %w", discoveryURL, err)
 | 
				
			||||||
						return
 | 
											return
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,11 +25,9 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	availabilitymetrics "k8s.io/kube-aggregator/pkg/controllers/status/metrics"
 | 
					 | 
				
			||||||
	"k8s.io/utils/pointer"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/dump"
 | 
						"k8s.io/apimachinery/pkg/util/dump"
 | 
				
			||||||
	v1listers "k8s.io/client-go/listers/core/v1"
 | 
						v1listers "k8s.io/client-go/listers/core/v1"
 | 
				
			||||||
	clienttesting "k8s.io/client-go/testing"
 | 
						clienttesting "k8s.io/client-go/testing"
 | 
				
			||||||
@@ -39,10 +37,12 @@ import (
 | 
				
			|||||||
	"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
 | 
						"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
 | 
				
			||||||
	apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
 | 
						apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
 | 
				
			||||||
	listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
 | 
						listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
 | 
				
			||||||
 | 
						availabilitymetrics "k8s.io/kube-aggregator/pkg/controllers/status/metrics"
 | 
				
			||||||
 | 
						"k8s.io/utils/ptr"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	testServicePort     = 1234
 | 
						testServicePort     int32 = 1234
 | 
				
			||||||
	testServicePortName       = "testPort"
 | 
						testServicePortName       = "testPort"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -100,13 +100,18 @@ func newRemoteAPIService(name string) *apiregistration.APIService {
 | 
				
			|||||||
			Service: &apiregistration.ServiceReference{
 | 
								Service: &apiregistration.ServiceReference{
 | 
				
			||||||
				Namespace: "foo",
 | 
									Namespace: "foo",
 | 
				
			||||||
				Name:      "bar",
 | 
									Name:      "bar",
 | 
				
			||||||
				Port:      pointer.Int32Ptr(testServicePort),
 | 
									Port:      ptr.To(testServicePort),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func setupAPIServices(apiServices []*apiregistration.APIService) (*AvailableConditionController, *fake.Clientset) {
 | 
					type T interface {
 | 
				
			||||||
 | 
						Fatalf(format string, args ...interface{})
 | 
				
			||||||
 | 
						Errorf(format string, args ...interface{})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func setupAPIServices(t T, apiServices []runtime.Object) (*AvailableConditionController, *fake.Clientset) {
 | 
				
			||||||
	fakeClient := fake.NewSimpleClientset()
 | 
						fakeClient := fake.NewSimpleClientset()
 | 
				
			||||||
	apiServiceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
						apiServiceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
				
			||||||
	serviceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
						serviceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
				
			||||||
@@ -118,7 +123,9 @@ func setupAPIServices(apiServices []*apiregistration.APIService) (*AvailableCond
 | 
				
			|||||||
	defer testServer.Close()
 | 
						defer testServer.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, o := range apiServices {
 | 
						for _, o := range apiServices {
 | 
				
			||||||
		apiServiceIndexer.Add(o)
 | 
							if err := apiServiceIndexer.Add(o); err != nil {
 | 
				
			||||||
 | 
								t.Fatalf("failed to add APIService: %v", err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := AvailableConditionController{
 | 
						c := AvailableConditionController{
 | 
				
			||||||
@@ -145,7 +152,7 @@ func setupAPIServices(apiServices []*apiregistration.APIService) (*AvailableCond
 | 
				
			|||||||
func BenchmarkBuildCache(b *testing.B) {
 | 
					func BenchmarkBuildCache(b *testing.B) {
 | 
				
			||||||
	apiServiceName := "remote.group"
 | 
						apiServiceName := "remote.group"
 | 
				
			||||||
	// model 1 APIService pointing at a given service, and 30 pointing at local group/versions
 | 
						// model 1 APIService pointing at a given service, and 30 pointing at local group/versions
 | 
				
			||||||
	apiServices := []*apiregistration.APIService{newRemoteAPIService(apiServiceName)}
 | 
						apiServices := []runtime.Object{newRemoteAPIService(apiServiceName)}
 | 
				
			||||||
	for i := 0; i < 30; i++ {
 | 
						for i := 0; i < 30; i++ {
 | 
				
			||||||
		apiServices = append(apiServices, newLocalAPIService(fmt.Sprintf("local.group%d", i)))
 | 
							apiServices = append(apiServices, newLocalAPIService(fmt.Sprintf("local.group%d", i)))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -154,7 +161,7 @@ func BenchmarkBuildCache(b *testing.B) {
 | 
				
			|||||||
	for i := 0; i < 100; i++ {
 | 
						for i := 0; i < 100; i++ {
 | 
				
			||||||
		services = append(services, newService("foo", fmt.Sprintf("bar%d", i), testServicePort, testServicePortName))
 | 
							services = append(services, newService("foo", fmt.Sprintf("bar%d", i), testServicePort, testServicePortName))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	c, _ := setupAPIServices(apiServices)
 | 
						c, _ := setupAPIServices(b, apiServices)
 | 
				
			||||||
	b.ReportAllocs()
 | 
						b.ReportAllocs()
 | 
				
			||||||
	b.ResetTimer()
 | 
						b.ResetTimer()
 | 
				
			||||||
	for n := 1; n <= b.N; n++ {
 | 
						for n := 1; n <= b.N; n++ {
 | 
				
			||||||
@@ -175,7 +182,7 @@ func TestBuildCache(t *testing.T) {
 | 
				
			|||||||
		name string
 | 
							name string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		apiServiceName string
 | 
							apiServiceName string
 | 
				
			||||||
		apiServices    []*apiregistration.APIService
 | 
							apiServices    []runtime.Object
 | 
				
			||||||
		services       []*v1.Service
 | 
							services       []*v1.Service
 | 
				
			||||||
		endpoints      []*v1.Endpoints
 | 
							endpoints      []*v1.Endpoints
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -184,13 +191,13 @@ func TestBuildCache(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "api service",
 | 
								name:           "api service",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, tc := range tests {
 | 
						for _, tc := range tests {
 | 
				
			||||||
		t.Run(tc.name, func(t *testing.T) {
 | 
							t.Run(tc.name, func(t *testing.T) {
 | 
				
			||||||
			c, fakeClient := setupAPIServices(tc.apiServices)
 | 
								c, fakeClient := setupAPIServices(t, tc.apiServices)
 | 
				
			||||||
			for _, svc := range tc.services {
 | 
								for _, svc := range tc.services {
 | 
				
			||||||
				c.addService(svc)
 | 
									c.addService(svc)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -210,18 +217,19 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		name string
 | 
							name string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		apiServiceName  string
 | 
							apiServiceName  string
 | 
				
			||||||
		apiServices     []*apiregistration.APIService
 | 
							apiServices     []runtime.Object
 | 
				
			||||||
		services        []*v1.Service
 | 
							services        []*v1.Service
 | 
				
			||||||
		endpoints       []*v1.Endpoints
 | 
							endpoints       []*v1.Endpoints
 | 
				
			||||||
		backendStatus   int
 | 
							backendStatus   int
 | 
				
			||||||
		backendLocation string
 | 
							backendLocation string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		expectedAvailability apiregistration.APIServiceCondition
 | 
							expectedAvailability apiregistration.APIServiceCondition
 | 
				
			||||||
 | 
							expectedSyncError    string
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "local",
 | 
								name:           "local",
 | 
				
			||||||
			apiServiceName: "local.group",
 | 
								apiServiceName: "local.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newLocalAPIService("local.group")},
 | 
								apiServices:    []runtime.Object{newLocalAPIService("local.group")},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
			expectedAvailability: apiregistration.APIServiceCondition{
 | 
								expectedAvailability: apiregistration.APIServiceCondition{
 | 
				
			||||||
				Type:    apiregistration.Available,
 | 
									Type:    apiregistration.Available,
 | 
				
			||||||
@@ -233,7 +241,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "no service",
 | 
								name:           "no service",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "not-bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "not-bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
			expectedAvailability: apiregistration.APIServiceCondition{
 | 
								expectedAvailability: apiregistration.APIServiceCondition{
 | 
				
			||||||
@@ -246,7 +254,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "service on bad port",
 | 
								name:           "service on bad port",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services: []*v1.Service{{
 | 
								services: []*v1.Service{{
 | 
				
			||||||
				ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
 | 
									ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
 | 
				
			||||||
				Spec: v1.ServiceSpec{
 | 
									Spec: v1.ServiceSpec{
 | 
				
			||||||
@@ -268,7 +276,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "no endpoints",
 | 
								name:           "no endpoints",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
			expectedAvailability: apiregistration.APIServiceCondition{
 | 
								expectedAvailability: apiregistration.APIServiceCondition{
 | 
				
			||||||
@@ -281,7 +289,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "missing endpoints",
 | 
								name:           "missing endpoints",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:      []*v1.Endpoints{newEndpoints("foo", "bar")},
 | 
								endpoints:      []*v1.Endpoints{newEndpoints("foo", "bar")},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
@@ -295,7 +303,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "wrong endpoint port name",
 | 
								name:           "wrong endpoint port name",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, "wrongName")},
 | 
								endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, "wrongName")},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
@@ -309,7 +317,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "remote",
 | 
								name:           "remote",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
								endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:  http.StatusOK,
 | 
								backendStatus:  http.StatusOK,
 | 
				
			||||||
@@ -323,7 +331,7 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "remote-bad-return",
 | 
								name:           "remote-bad-return",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
								endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:  http.StatusForbidden,
 | 
								backendStatus:  http.StatusForbidden,
 | 
				
			||||||
@@ -333,11 +341,12 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
				Reason:  "FailedDiscoveryCheck",
 | 
									Reason:  "FailedDiscoveryCheck",
 | 
				
			||||||
				Message: `failing or missing response from`,
 | 
									Message: `failing or missing response from`,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								expectedSyncError: "failing or missing response from",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:            "remote-redirect",
 | 
								name:            "remote-redirect",
 | 
				
			||||||
			apiServiceName:  "remote.group",
 | 
								apiServiceName:  "remote.group",
 | 
				
			||||||
			apiServices:     []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:     []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:        []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:        []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:       []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
								endpoints:       []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:   http.StatusFound,
 | 
								backendStatus:   http.StatusFound,
 | 
				
			||||||
@@ -348,11 +357,12 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
				Reason:  "FailedDiscoveryCheck",
 | 
									Reason:  "FailedDiscoveryCheck",
 | 
				
			||||||
				Message: `failing or missing response from`,
 | 
									Message: `failing or missing response from`,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								expectedSyncError: "failing or missing response from",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "remote-304",
 | 
								name:           "remote-304",
 | 
				
			||||||
			apiServiceName: "remote.group",
 | 
								apiServiceName: "remote.group",
 | 
				
			||||||
			apiServices:    []*apiregistration.APIService{newRemoteAPIService("remote.group")},
 | 
								apiServices:    []runtime.Object{newRemoteAPIService("remote.group")},
 | 
				
			||||||
			services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
								services:       []*v1.Service{newService("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
								endpoints:      []*v1.Endpoints{newEndpointsWithAddress("foo", "bar", testServicePort, testServicePortName)},
 | 
				
			||||||
			backendStatus:  http.StatusNotModified,
 | 
								backendStatus:  http.StatusNotModified,
 | 
				
			||||||
@@ -362,12 +372,13 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
				Reason:  "FailedDiscoveryCheck",
 | 
									Reason:  "FailedDiscoveryCheck",
 | 
				
			||||||
				Message: `failing or missing response from`,
 | 
									Message: `failing or missing response from`,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								expectedSyncError: "failing or missing response from",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, tc := range tests {
 | 
						for _, tc := range tests {
 | 
				
			||||||
		t.Run(tc.name, func(t *testing.T) {
 | 
							t.Run(tc.name, func(t *testing.T) {
 | 
				
			||||||
			fakeClient := fake.NewSimpleClientset()
 | 
								fakeClient := fake.NewSimpleClientset(tc.apiServices...)
 | 
				
			||||||
			apiServiceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
								apiServiceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
				
			||||||
			serviceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
								serviceIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
				
			||||||
			endpointsIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
								endpointsIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
 | 
				
			||||||
@@ -398,7 +409,16 @@ func TestSync(t *testing.T) {
 | 
				
			|||||||
				proxyCurrentCertKeyContent: func() ([]byte, []byte) { return emptyCert(), emptyCert() },
 | 
									proxyCurrentCertKeyContent: func() ([]byte, []byte) { return emptyCert(), emptyCert() },
 | 
				
			||||||
				metrics:                    availabilitymetrics.New(),
 | 
									metrics:                    availabilitymetrics.New(),
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			c.sync(tc.apiServiceName)
 | 
								err := c.sync(tc.apiServiceName)
 | 
				
			||||||
 | 
								if tc.expectedSyncError != "" {
 | 
				
			||||||
 | 
									if err == nil {
 | 
				
			||||||
 | 
										t.Fatalf("%v expected error with %q, got none", tc.name, tc.expectedSyncError)
 | 
				
			||||||
 | 
									} else if !strings.Contains(err.Error(), tc.expectedSyncError) {
 | 
				
			||||||
 | 
										t.Fatalf("%v expected error with %q, got %q", tc.name, tc.expectedSyncError, err.Error())
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								} else if err != nil {
 | 
				
			||||||
 | 
									t.Fatalf("%v unexpected sync error: %v", tc.name, err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// ought to have one action writing status
 | 
								// ought to have one action writing status
 | 
				
			||||||
			if e, a := 1, len(fakeClient.Actions()); e != a {
 | 
								if e, a := 1, len(fakeClient.Actions()); e != a {
 | 
				
			||||||
@@ -445,19 +465,23 @@ func TestUpdateAPIServiceStatus(t *testing.T) {
 | 
				
			|||||||
	foo := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "foo"}}}}
 | 
						foo := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "foo"}}}}
 | 
				
			||||||
	bar := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "bar"}}}}
 | 
						bar := &apiregistration.APIService{Status: apiregistration.APIServiceStatus{Conditions: []apiregistration.APIServiceCondition{{Type: "bar"}}}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fakeClient := fake.NewSimpleClientset()
 | 
						fakeClient := fake.NewSimpleClientset(foo)
 | 
				
			||||||
	c := AvailableConditionController{
 | 
						c := AvailableConditionController{
 | 
				
			||||||
		apiServiceClient: fakeClient.ApiregistrationV1().(apiregistrationclient.APIServicesGetter),
 | 
							apiServiceClient: fakeClient.ApiregistrationV1().(apiregistrationclient.APIServicesGetter),
 | 
				
			||||||
		metrics:          availabilitymetrics.New(),
 | 
							metrics:          availabilitymetrics.New(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.updateAPIServiceStatus(foo, foo)
 | 
						if _, err := c.updateAPIServiceStatus(foo, foo); err != nil {
 | 
				
			||||||
 | 
							t.Fatalf("unexpected error: %v", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if e, a := 0, len(fakeClient.Actions()); e != a {
 | 
						if e, a := 0, len(fakeClient.Actions()); e != a {
 | 
				
			||||||
		t.Error(dump.Pretty(fakeClient.Actions()))
 | 
							t.Error(dump.Pretty(fakeClient.Actions()))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fakeClient.ClearActions()
 | 
						fakeClient.ClearActions()
 | 
				
			||||||
	c.updateAPIServiceStatus(foo, bar)
 | 
						if _, err := c.updateAPIServiceStatus(foo, bar); err != nil {
 | 
				
			||||||
 | 
							t.Fatalf("unexpected error: %v", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if e, a := 1, len(fakeClient.Actions()); e != a {
 | 
						if e, a := 1, len(fakeClient.Actions()); e != a {
 | 
				
			||||||
		t.Error(dump.Pretty(fakeClient.Actions()))
 | 
							t.Error(dump.Pretty(fakeClient.Actions()))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user