mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
aggregator: add OpenAPI aggregation order test
This commit is contained in:
parent
1cca3f9d45
commit
ca19b4dcf3
@ -25,12 +25,12 @@ import (
|
|||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32) apiregistration.APIService {
|
func newAPIServiceForTest(name, group string, minGroupPriority, versionPriority int32, svc *apiregistration.ServiceReference) apiregistration.APIService {
|
||||||
r := apiregistration.APIService{}
|
r := apiregistration.APIService{}
|
||||||
r.Spec.Group = group
|
r.Spec.Group = group
|
||||||
r.Spec.GroupPriorityMinimum = minGroupPriority
|
r.Spec.GroupPriorityMinimum = minGroupPriority
|
||||||
r.Spec.VersionPriority = versionPriority
|
r.Spec.VersionPriority = versionPriority
|
||||||
r.Spec.Service = &apiregistration.ServiceReference{}
|
r.Spec.Service = svc
|
||||||
r.Name = name
|
r.Name = name
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@ -48,22 +48,31 @@ func assertSortedServices(t *testing.T, actual []openAPISpecInfo, expectedNames
|
|||||||
func TestAPIServiceSort(t *testing.T) {
|
func TestAPIServiceSort(t *testing.T) {
|
||||||
list := []openAPISpecInfo{
|
list := []openAPISpecInfo{
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5),
|
apiService: newAPIServiceForTest("FirstService", "Group1", 10, 5, &apiregistration.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3),
|
apiService: newAPIServiceForTest("SecondService", "Group2", 15, 3, &apiregistration.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3),
|
apiService: newAPIServiceForTest("FirstServiceInternal", "Group1", 16, 3, &apiregistration.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3),
|
apiService: newAPIServiceForTest("ThirdService", "Group3", 15, 3, &apiregistration.ServiceReference{}),
|
||||||
spec: &spec.Swagger{},
|
spec: &spec.Swagger{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
apiService: newAPIServiceForTest("local_service_1", "Group4", 15, 1, nil),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiService: newAPIServiceForTest("local_service_3", "Group5", 15, 2, nil),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiService: newAPIServiceForTest("local_service_2", "Group6", 15, 3, nil),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
sortByPriority(list)
|
sortByPriority(list)
|
||||||
assertSortedServices(t, list, []string{"FirstService", "FirstServiceInternal", "SecondService", "ThirdService"})
|
assertSortedServices(t, list, []string{"local_service_1", "local_service_2", "local_service_3", "FirstService", "FirstServiceInternal", "SecondService", "ThirdService"})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user