Skip to content

Commit 1ab44d6

Browse files
committed
Add another split clients test case
1 parent a8cbd36 commit 1ab44d6

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

internal/controller/nginx/config/split_clients_test.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,17 +834,23 @@ func TestCreateBackendGroupSplitClientDistributions(t *testing.T) {
834834

835835
func TestGetSplitClientValue(t *testing.T) {
836836
t.Parallel()
837+
hrNsName := types.NamespacedName{Namespace: "test", Name: "hr"}
838+
837839
tests := []struct {
840+
source types.NamespacedName
838841
msg string
839842
expValue string
840843
backend dataplane.Backend
844+
ruleIdx int
841845
}{
842846
{
843847
msg: "valid backend",
844848
backend: dataplane.Backend{
845849
UpstreamName: "valid",
846850
Valid: true,
847851
},
852+
source: hrNsName,
853+
ruleIdx: 0,
848854
expValue: "valid",
849855
},
850856
{
@@ -853,6 +859,34 @@ func TestGetSplitClientValue(t *testing.T) {
853859
UpstreamName: "invalid",
854860
Valid: false,
855861
},
862+
source: hrNsName,
863+
ruleIdx: 0,
864+
expValue: invalidBackendRef,
865+
},
866+
{
867+
msg: "valid backend with endpoint picker config",
868+
backend: dataplane.Backend{
869+
UpstreamName: "inference-backend",
870+
Valid: true,
871+
EndpointPickerConfig: &dataplane.EndpointPickerConfig{
872+
NsName: "test-namespace",
873+
},
874+
},
875+
source: hrNsName,
876+
ruleIdx: 2,
877+
expValue: "/_ngf-internal-inference-backend-test-hr-rule2",
878+
},
879+
{
880+
msg: "invalid backend with endpoint picker config",
881+
backend: dataplane.Backend{
882+
UpstreamName: "invalid-inference-backend",
883+
Valid: false,
884+
EndpointPickerConfig: &dataplane.EndpointPickerConfig{
885+
NsName: "test-namespace",
886+
},
887+
},
888+
source: hrNsName,
889+
ruleIdx: 1,
856890
expValue: invalidBackendRef,
857891
},
858892
}
@@ -861,7 +895,7 @@ func TestGetSplitClientValue(t *testing.T) {
861895
t.Run(test.msg, func(t *testing.T) {
862896
t.Parallel()
863897
g := NewWithT(t)
864-
result := getSplitClientValue(test.backend, types.NamespacedName{Namespace: "test", Name: "hr"}, 0)
898+
result := getSplitClientValue(test.backend, test.source, test.ruleIdx)
865899
g.Expect(result).To(Equal(test.expValue))
866900
})
867901
}

0 commit comments

Comments
 (0)