Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: gatewayPort8080 conformance #339

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions controller/gateway/controller_reconciler_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func countAttachedRoutesForGatewayListener(ctx context.Context, g *gwtypes.Gatew
client.ObjectKeyFromObject(g), err,
)
}
count += int32(len(httpRoutes))
count += countAttachedHTTPRoutes(listener.Name, httpRoutes)
mlavacca marked this conversation as resolved.
Show resolved Hide resolved
default:
return 0, fmt.Errorf("unsupported route kind: %T", k)
}
Expand All @@ -723,13 +723,29 @@ func countAttachedRoutesForGatewayListener(ctx context.Context, g *gwtypes.Gatew
)
}

count += int32(len(httpRoutes))
count += countAttachedHTTPRoutes(listener.Name, httpRoutes)
}
}

return count, nil
}

// countAttachedHTTPRoutes counts the number of attached HTTPRoutes for a given listener,
// taking into account the ParentRefs' sectionName.
func countAttachedHTTPRoutes(listenerName gatewayv1.SectionName, httpRoutes []gatewayv1.HTTPRoute) int32 {
var count int32

for _, httpRoute := range httpRoutes {
if lo.ContainsBy(httpRoute.Spec.ParentRefs, func(parentRef gatewayv1.ParentReference) bool {
return parentRef.SectionName == nil || *parentRef.SectionName == listenerName
}) {
count++
}
}

return count
}

// setConflicted sets the gateway Conflicted condition according to the Gateway API specification.
func (g *gatewayConditionsAndListenersAwareT) setConflicted() {
for i, l := range g.Spec.Listeners {
Expand Down
41 changes: 24 additions & 17 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,31 @@ var skippedTestsForTraditionalCompatibleRouter = []string{
tests.HTTPRouteWeight.ShortName,
}

var traditionalCompatibleRouterSupportedFeatures = sets.New(
// core features
features.SupportHTTPRoute,
// extended
features.SupportHTTPRouteResponseHeaderModification,
features.SupportHTTPRoutePathRewrite,
features.SupportHTTPRouteHostRewrite,
)
var (
commonSupportedFeatures = sets.New(
// core features
features.SupportHTTPRoute,
features.SupportGateway,
features.SupportReferenceGrant,

// Gateway extended
features.SupportGatewayPort8080,

// HTTPRoute extended
features.SupportHTTPRouteResponseHeaderModification,
features.SupportHTTPRoutePathRewrite,
features.SupportHTTPRouteHostRewrite,
)

var expressionsRouterSupportedFeatures = sets.New(
// core features
features.SupportHTTPRoute,
// extended
features.SupportHTTPRouteResponseHeaderModification,
features.SupportHTTPRouteMethodMatching,
features.SupportHTTPRouteQueryParamMatching,
features.SupportHTTPRoutePathRewrite,
features.SupportHTTPRouteHostRewrite,
traditionalCompatibleRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// add here the traditional compatible router specific features
)

expressionsRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// extended
features.SupportHTTPRouteMethodMatching,
features.SupportHTTPRouteQueryParamMatching,
)
)

type ConformanceConfig struct {
Expand Down
Loading