Skip to content

Commit 7d93f0b

Browse files
committed
Updates to tests due to API changes
Signed-off-by: Shmuel Kallner <[email protected]>
1 parent e39e926 commit 7d93f0b

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

pkg/epp/config/loader/configloader_test.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
configapi "sigs.k8s.io/gateway-api-inference-extension/apix/config/v1alpha1"
3131
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/config"
32+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer"
3233
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
3334
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
3435
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework"
@@ -99,7 +100,7 @@ func TestLoadRawConfiguration(t *testing.T) {
99100
},
100101
},
101102
},
102-
FeatureGates: &configapi.FeatureGates{EnableDataLayer: true},
103+
FeatureGates: &configapi.FeatureGates{datalayer.FeatureGate: true},
103104
SaturationDetector: &configapi.SaturationDetector{
104105
MetricsStalenessThreshold: metav1.Duration{Duration: 150 * time.Millisecond},
105106
},
@@ -205,7 +206,7 @@ func TestLoadRawConfigurationWithDefaults(t *testing.T) {
205206
},
206207
},
207208
},
208-
FeatureGates: &configapi.FeatureGates{EnableDataLayer: true},
209+
FeatureGates: &configapi.FeatureGates{datalayer.FeatureGate: true},
209210
SaturationDetector: &configapi.SaturationDetector{
210211
QueueDepthThreshold: saturationdetector.DefaultQueueDepthThreshold,
211212
KVCacheUtilThreshold: saturationdetector.DefaultKVCacheUtilThreshold,
@@ -364,6 +365,7 @@ func checkError(t *testing.T, function string, test testStruct, err error) {
364365
}
365366

366367
func TestInstantiatePlugins(t *testing.T) {
368+
registerNeededFeatureGates()
367369
handle := utils.NewTestHandle(context.Background())
368370
_, err := LoadConfig([]byte(successConfigText), handle, logging.NewTestLogger())
369371
if err != nil {
@@ -438,8 +440,14 @@ func TestLoadConfig(t *testing.T) {
438440
configText: errorNoProfileHandlersText,
439441
wantErr: true,
440442
},
443+
{
444+
name: "errorUnknownFeatureGate",
445+
configText: errorUnknownFeatureGateText,
446+
wantErr: true,
447+
},
441448
}
442449

450+
registerNeededFeatureGates()
443451
registerNeededPlgugins()
444452

445453
logger := logging.NewTestLogger()
@@ -457,6 +465,10 @@ func TestLoadConfig(t *testing.T) {
457465
}
458466
}
459467

468+
func registerNeededFeatureGates() {
469+
RegisterFeatureGate(datalayer.FeatureGate)
470+
}
471+
460472
func registerNeededPlgugins() {
461473
plugins.Register(prefix.PrefixCachePluginType, prefix.PrefixCachePluginFactory)
462474
plugins.Register(picker.MaxScorePickerType, picker.MaxScorePickerFactory)
@@ -550,7 +562,7 @@ schedulingProfiles:
550562
weight: 50
551563
- pluginRef: testPicker
552564
featureGates:
553-
enableDataLayer: true
565+
dataLayer: true
554566
saturationDetector:
555567
metricsStalenessThreshold: 150ms
556568
`
@@ -718,6 +730,21 @@ schedulingProfiles:
718730
- pluginRef: test2
719731
`
720732

733+
// error with an unknown feature gate
734+
//
735+
//nolint:dupword
736+
const errorUnknownFeatureGateText = `
737+
apiVersion: inference.networking.x-k8s.io/v1alpha1
738+
kind: EndpointPickerConfig
739+
plugins:
740+
- name: test1
741+
type: test-one
742+
parameters:
743+
threshold: 10
744+
featureGates:
745+
qwerty: true
746+
`
747+
721748
// compile-time type validation
722749
var _ framework.Filter = &test1{}
723750

@@ -857,6 +884,8 @@ schedulingProfiles:
857884
- pluginRef: prefixCacheScorer
858885
weight: 50
859886
- pluginRef: maxScorePicker
887+
featureGates:
888+
dataLayer: true
860889
`
861890

862891
// valid configuration, with default weight for scorer

test/testdata/configloader_1_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ schedulingProfiles:
2020
weight: 50
2121
- pluginRef: testPicker
2222
featureGates:
23-
enableDataLayer: true
23+
dataLayer: true
2424
saturationDetector:
2525
metricsStalenessThreshold: 150ms

0 commit comments

Comments
 (0)