Skip to content

Commit 242086d

Browse files
committed
Updated tests WRT new feature flag features
Signed-off-by: Shmuel Kallner <kallner@il.ibm.com>
1 parent 38e3a00 commit 242086d

3 files changed

Lines changed: 63 additions & 21 deletions

File tree

pkg/epp/config/loader/configloader_test.go

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
configapi "github.com/llm-d/llm-d-router/apix/config/v1alpha1"
3333
"github.com/llm-d/llm-d-router/pkg/common/observability/logging"
3434
"github.com/llm-d/llm-d-router/pkg/epp/config"
35-
"github.com/llm-d/llm-d-router/pkg/epp/datalayer"
3635
"github.com/llm-d/llm-d-router/pkg/epp/flowcontrol"
3736
"github.com/llm-d/llm-d-router/pkg/epp/flowcontrol/registry"
3837
fwkdl "github.com/llm-d/llm-d-router/pkg/epp/framework/interface/datalayer"
@@ -67,6 +66,8 @@ const (
6766
testProfileHandler = "test-profile-handler"
6867
testSourceType = "test-source"
6968
testExtractorType = "test-extractor"
69+
70+
testFeatureGate = "test-feature-gate"
7071
)
7172

7273
// --- Test: Phase 1 (Raw Loading & Static Defaults) ---
@@ -75,19 +76,20 @@ func TestLoadRawConfiguration(t *testing.T) {
7576
t.Parallel()
7677

7778
// Register known feature gates for validation.
78-
RegisterFeatureGate(datalayer.ExperimentalDatalayerFeatureGate)
79-
RegisterFeatureGate(flowcontrol.FeatureGate)
79+
RegisterFeatureGate(testFeatureGate, true)
80+
RegisterFeatureGate(flowcontrol.FeatureGate, false)
8081

8182
queueScorerWeight := 2.0
8283
kvCacheUtilizationScorerWeight := 2.0
8384
prefixCacheScorerWeight := 3.0
8485

8586
tests := []struct {
86-
name string
87-
configText string
88-
want *configapi.EndpointPickerConfig
89-
wantErr bool
90-
deprecated bool
87+
name string
88+
configText string
89+
want *configapi.EndpointPickerConfig
90+
wantFeatures map[string]bool
91+
wantErr bool
92+
deprecated bool
9193
}{
9294
{
9395
name: "Success - Full Configuration",
@@ -114,7 +116,7 @@ func TestLoadRawConfiguration(t *testing.T) {
114116
},
115117
},
116118
FeatureGates: configapi.FeatureGates{
117-
datalayer.ExperimentalDatalayerFeatureGate,
119+
testFeatureGate,
118120
flowcontrol.FeatureGate,
119121
},
120122
FlowControl: &configapi.FlowControlConfig{
@@ -123,6 +125,10 @@ func TestLoadRawConfiguration(t *testing.T) {
123125
},
124126
},
125127
},
128+
wantFeatures: map[string]bool{
129+
testFeatureGate: true,
130+
flowcontrol.FeatureGate: true,
131+
},
126132
wantErr: false,
127133
deprecated: false,
128134
},
@@ -151,7 +157,7 @@ func TestLoadRawConfiguration(t *testing.T) {
151157
},
152158
},
153159
FeatureGates: configapi.FeatureGates{
154-
datalayer.ExperimentalDatalayerFeatureGate,
160+
testFeatureGate,
155161
flowcontrol.FeatureGate,
156162
},
157163
FlowControl: &configapi.FlowControlConfig{
@@ -174,7 +180,13 @@ func TestLoadRawConfiguration(t *testing.T) {
174180
Plugins: []configapi.PluginSpec{
175181
{Name: "test1", Type: testPluginType, Parameters: json.RawMessage(`{"threshold":10}`)},
176182
},
177-
FeatureGates: configapi.FeatureGates{},
183+
FeatureGates: configapi.FeatureGates{
184+
testFeatureGate + "=false",
185+
},
186+
},
187+
wantFeatures: map[string]bool{
188+
testFeatureGate: false,
189+
flowcontrol.FeatureGate: false,
178190
},
179191
wantErr: false,
180192
deprecated: false,
@@ -240,6 +252,10 @@ func TestLoadRawConfiguration(t *testing.T) {
240252
},
241253
},
242254
},
255+
wantFeatures: map[string]bool{
256+
testFeatureGate: true,
257+
flowcontrol.FeatureGate: false,
258+
},
243259
wantErr: false,
244260
deprecated: false,
245261
},
@@ -322,6 +338,12 @@ func TestLoadRawConfiguration(t *testing.T) {
322338
wantErr: true,
323339
deprecated: false,
324340
},
341+
{
342+
name: "Error - Bad Feature Gate",
343+
configText: errorBadFeatureGateText,
344+
wantErr: true,
345+
deprecated: false,
346+
},
325347
}
326348

327349
for _, tc := range tests {
@@ -330,7 +352,7 @@ func TestLoadRawConfiguration(t *testing.T) {
330352
writer := &strings.Builder{}
331353
logger := logging.NewTestLoggerWithWriter(writer)
332354

333-
got, _, err := LoadRawConfig([]byte(tc.configText), logger)
355+
got, featureGates, err := LoadRawConfig([]byte(tc.configText), logger)
334356

335357
if tc.wantErr {
336358
require.Error(t, err, "Expected LoadRawConfig to fail")
@@ -340,6 +362,11 @@ func TestLoadRawConfiguration(t *testing.T) {
340362
diff := cmp.Diff(tc.want, got)
341363
require.Empty(t, diff, "Config mismatch (-want +got):\n%s", diff)
342364

365+
if tc.wantFeatures != nil {
366+
diff = cmp.Diff(tc.wantFeatures, featureGates)
367+
require.Empty(t, diff, "Config feature gates mismatch (-want +got):\n%s", diff)
368+
}
369+
343370
if strings.Contains(writer.String(), "deprecated") {
344371
require.True(t, tc.deprecated, "Deprecated configuration wasn't marked as deprecated")
345372
} else {
@@ -355,8 +382,8 @@ func TestInstantiateAndConfigure(t *testing.T) {
355382
// Not parallel because it modifies global plugin registry.
356383
registerTestPlugins(t)
357384

358-
RegisterFeatureGate(datalayer.ExperimentalDatalayerFeatureGate)
359-
RegisterFeatureGate(flowcontrol.FeatureGate)
385+
RegisterFeatureGate(testFeatureGate, true)
386+
RegisterFeatureGate(flowcontrol.FeatureGate, false)
360387

361388
tests := []struct {
362389
name string

pkg/epp/config/loader/testdata_test.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ schedulingProfiles:
4444
weight: 50
4545
- pluginRef: testPicker
4646
featureGates:
47-
- dataLayer
47+
- test-feature-gate
4848
- flowControl
4949
flowControl:
5050
saturationDetector:
@@ -76,7 +76,7 @@ schedulingProfiles:
7676
weight: 50
7777
- pluginRef: testPicker
7878
featureGates:
79-
- dataLayer
79+
- test-feature-gate
8080
- flowControl
8181
flowControl:
8282
saturationDetector:
@@ -93,6 +93,8 @@ plugins:
9393
type: test-plugin
9494
parameters:
9595
threshold: 10
96+
featureGates:
97+
- test-feature-gate=false
9698
`
9799

98100
// successSchedulerConfigText represents a complex scheduler setup.
@@ -124,7 +126,7 @@ dataLayer:
124126
extractors:
125127
- pluginRef: testExtractor
126128
featureGates:
127-
- dataLayer
129+
- test-feature-gate
128130
- flowControl
129131
`
130132

@@ -360,6 +362,19 @@ featureGates:
360362
- unknown-gate
361363
`
362364

365+
// errorBadFeatureGateText includes a feature gate with an invalid value
366+
const errorBadFeatureGateText = `
367+
apiVersion: llm-d.ai/v1alpha1
368+
kind: EndpointPickerConfig
369+
plugins:
370+
- name: test1
371+
type: test-plugin
372+
parameters:
373+
threshold: 10
374+
featureGates:
375+
- flowControl=qwerty
376+
`
377+
363378
// --- Invalid Configurations (Logical/Architectural) ---
364379

365380
// errorNoProfileNameText is missing the required profile name.
@@ -585,7 +600,7 @@ dataLayer:
585600
extractors:
586601
- pluginRef: testExtractor
587602
featureGates:
588-
- dataLayer
603+
- test-feature-gate
589604
`
590605

591606
// errorBadSourceReferenceText has a bad DataSource plugin reference
@@ -605,7 +620,7 @@ dataLayer:
605620
sources:
606621
- pluginRef: test-one
607622
featureGates:
608-
- dataLayer
623+
- test-feature-gate
609624
- flowControl
610625
`
611626

@@ -629,7 +644,7 @@ dataLayer:
629644
extractors:
630645
- test-one
631646
featureGates:
632-
- dataLayer
647+
- test-feature-gate
633648
- flowControl
634649
`
635650

test/testdata/configloader_1_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dataLayer:
2727
extractors:
2828
- pluginRef: test-extractor
2929
featureGates:
30-
- dataLayer
30+
- test-feature-gate
3131
flowControl:
3232
saturationDetector:
3333
metricsStalenessThreshold: 150ms

0 commit comments

Comments
 (0)