Skip to content

Hybrid Gateway - Unit tests for httpRoute converter implementation #2583

@alacuku

Description

@alacuku

Problem Statement

The httpRouteConverter in controller/hybridgateway/converter/http_route.go has only one test (TestHostnamesIntersection) covering ~15% of its functionality. Critical methods like Translate(), UpdateRootObjectStatus(), getHybridGatewayParents(), and the main translate() logic are completely untested.

This leaves core HTTPRoute-to-Kong translation business logic vulnerable to regressions and makes debugging difficult when issues arise.

Proposed Solution

Add comprehensive unit tests covering:

  • Core methods: Translate(), GetOutputStore(), UpdateRootObjectStatus()
  • Translation logic: HTTPRoute rules → Kong resources (Services, Upstreams, Targets, Routes)
  • Status management: Parent acceptance, backend reference resolution, condition building
  • Error scenarios: Invalid configs, missing resources, ReferenceGrant failures
  • Edge cases: Cross-namespace refs, empty rules, hostname mismatches

Additional Information

Current coverage: ~15% (1 test for hostname logic only)
Target coverage: >85% with focus on business-critical translation paths

The converter is a core component that transforms Gateway API resources into Kong configuration - comprehensive testing is essential for reliability.

Acceptance Criteria

  • Tests are added for this feature / enhancement
  • As a user, I can rely on stable HTTPRoute translation behavior protected by comprehensive tests
  • Unit test coverage for httpRouteConverter reaches >85%
  • All public methods have dedicated test coverage
  • Translation logic tests cover multiple HTTPRoute configurations
  • Error handling and edge cases are tested
  • Cross-namespace ReferenceGrant scenarios have test coverage

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions