mirror of
https://github.com/alibaba/higress.git
synced 2026-05-28 06:37:26 +08:00
Feat: upgrade gateway api to latest (#3160)
This commit is contained in:
@@ -19,45 +19,46 @@ import (
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
inferencev1alpha2 "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2"
|
||||
inferencev1 "sigs.k8s.io/gateway-api-inference-extension/api/v1"
|
||||
|
||||
higressconstants "github.com/alibaba/higress/v2/pkg/config/constants"
|
||||
"istio.io/istio/pilot/pkg/features"
|
||||
"istio.io/istio/pkg/config/constants"
|
||||
"istio.io/istio/pkg/kube/krt"
|
||||
"istio.io/istio/pkg/ptr"
|
||||
"istio.io/istio/pkg/test"
|
||||
"istio.io/istio/pkg/test/util/assert"
|
||||
)
|
||||
|
||||
func TestReconcileInferencePool(t *testing.T) {
|
||||
test.SetForTest(t, &features.EnableGatewayAPIInferenceExtension, true)
|
||||
pool := &inferencev1alpha2.InferencePool{
|
||||
pool := &inferencev1.InferencePool{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pool",
|
||||
Namespace: "default",
|
||||
},
|
||||
Spec: inferencev1alpha2.InferencePoolSpec{
|
||||
TargetPortNumber: 8080,
|
||||
Selector: map[inferencev1alpha2.LabelKey]inferencev1alpha2.LabelValue{
|
||||
"app": "test",
|
||||
Spec: inferencev1.InferencePoolSpec{
|
||||
TargetPorts: []inferencev1.Port{
|
||||
{
|
||||
Number: inferencev1.PortNumber(8080),
|
||||
},
|
||||
},
|
||||
EndpointPickerConfig: inferencev1alpha2.EndpointPickerConfig{
|
||||
ExtensionRef: &inferencev1alpha2.Extension{
|
||||
ExtensionReference: inferencev1alpha2.ExtensionReference{
|
||||
Name: "dummy",
|
||||
// Kind: &inferencev1alpha2.Kind(),
|
||||
PortNumber: ptr.Of(inferencev1alpha2.PortNumber(5421)),
|
||||
},
|
||||
Selector: inferencev1.LabelSelector{
|
||||
MatchLabels: map[inferencev1.LabelKey]inferencev1.LabelValue{
|
||||
"app": "test",
|
||||
},
|
||||
},
|
||||
EndpointPickerRef: inferencev1.EndpointPickerRef{
|
||||
Name: "dummy",
|
||||
Port: &inferencev1.Port{
|
||||
Number: inferencev1.PortNumber(5421),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
controller := setupController(t,
|
||||
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "default"}},
|
||||
NewGateway("test-gw", InNamespace(DefaultTestNS), WithGatewayClass(higressconstants.DefaultGatewayClass)),
|
||||
NewGateway("test-gw", InNamespace(DefaultTestNS), WithGatewayClass("istio")),
|
||||
NewHTTPRoute("test-route", InNamespace(DefaultTestNS),
|
||||
WithParentRefAndStatus("test-gw", DefaultTestNS, HigressController),
|
||||
WithParentRefAndStatus("test-gw", DefaultTestNS, IstioController),
|
||||
WithBackendRef("test-pool", DefaultTestNS),
|
||||
),
|
||||
pool,
|
||||
@@ -82,4 +83,5 @@ func TestReconcileInferencePool(t *testing.T) {
|
||||
assert.Equal(t, service.ObjectMeta.Labels[InferencePoolRefLabel], pool.Name)
|
||||
assert.Equal(t, service.OwnerReferences[0].Name, pool.Name)
|
||||
assert.Equal(t, service.Spec.Ports[0].TargetPort.IntVal, int32(8080))
|
||||
assert.Equal(t, service.Spec.Ports[0].Port, int32(54321)) // dummyPort + i
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user