From 4fb134157e36434a164b97c4029f2d4dde803891 Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Tue, 31 Jan 2023 16:58:35 -0800 Subject: [PATCH] Fix SupportedKinds check * Find the expcted SupportedKind element in the actual SupportedKind slice instead of doing an exact match because the actual/implementation populated SupportedKinds field might support more Kind that defined in the test. Fixes: https://github.com/kubernetes-sigs/gateway-api/issues/1691 Signed-off-by: Arko Dasgupta --- conformance/utils/kubernetes/helpers.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/conformance/utils/kubernetes/helpers.go b/conformance/utils/kubernetes/helpers.go index 0208229872..c2fccc0a41 100644 --- a/conformance/utils/kubernetes/helpers.go +++ b/conformance/utils/kubernetes/helpers.go @@ -626,9 +626,21 @@ func listenersMatch(t *testing.T, expected, actual []v1beta1.ListenerStatus) boo t.Logf("Name doesn't match") return false } - if !reflect.DeepEqual(aListener.SupportedKinds, eListener.SupportedKinds) { - t.Logf("Expected SupportedKinds to be %v, got %v", eListener.SupportedKinds, aListener.SupportedKinds) - return false + // Ensure that the expected Listener.SupportedKinds items are present in actual Listener.SupportedKinds + // Find the items instead of performing an exact match of the slice because the implementation + // might support more Kinds than defined in the test + for _, eKind := range eListener.SupportedKinds { + found := false + for _, aKind := range aListener.SupportedKinds { + if eKind.Kind == aKind.Kind { + found = true + break + } + } + if !found { + t.Logf("Expected %s to be present in SupportedKinds", eKind.Kind) + return false + } } if aListener.AttachedRoutes != eListener.AttachedRoutes { t.Logf("Expected AttachedRoutes to be %v, got %v", eListener.AttachedRoutes, aListener.AttachedRoutes)