Skip to content

feat(#11): Add multi-version traffic splitting E2E test, unit tests, and docs - #58

Merged
ricardozanini merged 4 commits into
mainfrom
issues/11
Oct 2, 2026
Merged

ricardozanini merged 4 commits into
mainfrom
issues/11

Conversation

@ricardozanini

@ricardozanini ricardozanini commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Completes feature #11 (Multi-Version Support & Traffic Splitting) with end-to-end testing, unit test coverage, and user-facing documentation.

Scope: Routing objects (Ingress/Route/HTTPRoute) and canary mechanics. Per-version health tracking deferred to #57.

Changes

E2E Test (4 specs, all passing)

  • Context: LogicFlowService multi-version traffic splitting
  • Setup: Shared runtime + two payment definitions (v1.0.0 / v1.1.0)
  • Specs:
    1. v1 as defaultDefinition → primary Ingress only, no canary
    2. Introduce v2 at 20% canary → primary + canary + direct Ingresses with nginx annotations
    3. Promote v2 to default → canary/direct cleaned up, primary→v1.1.0
    4. Decommission v1 → ConfigMap GC'd, service still healthy

Unit Tests (6 new)

  • TestSplitTrafficTargets_HigherWeightIsPrimary — 80/20 selects higher weight
  • TestSplitTrafficTargets_HigherWeightSecondIsPrimary — 30/70 selects v2 as primary
  • TestSplitTrafficTargets_EqualWeightsDeterministic — 50/50 deterministic primary (prevents flapping)
  • TestBuildTrafficTargets_DefaultDefinition — single version
  • TestBuildTrafficTargets_PreservesOrderAndWeights — order preservation

Documentation

  • New page: concepts/traffic-splitting.adoc
    • Version model: each LFD = distinct ConfigMap subdirectory (no file collision)
    • Routing modes: nginx (2 versions), Gateway API (N), OpenShift (1)
    • Direct version access: /v/<version> bypass
    • 4-step canary runbook with examples
    • Constraints & edge cases
  • Nav entry under Concepts

Makefile

  • Added make test-e2e-traffic target

Verification

✅ All 4 E2E specs pass (KIND cluster, real Ingress reconciliation)
✅ 6 unit tests pass
✅ go build ./..., go vet, golangci-lint clean
✅ Ginkgo dry-run confirms focus selects exactly 4 specs

Related Issues

…and docs

- Add 4-spec E2E test covering v1→canary(80/20)→promote(v2)→decommission(v1)
  - Verify primary/canary/direct Ingresses created with correct nginx annotations
  - Assert status reflects traffic split and cleanup on promotion
  - Test ConfigMap garbage collection when definition deleted

- Add 6 unit tests for traffic target selection logic
  - Cover primary selection (higher weight wins)
  - Test deterministic primary at equal weights (prevents flapping)
  - Verify order preservation and weight accuracy

- Add concepts/traffic-splitting.adoc guide
  - Version model: each LFD = separate ConfigMap mounted to distinct directory
  - Routing modes: nginx (2 versions), Gateway API (N), OpenShift (1)
  - Direct version access: /v/<version> bypass for testing
  - 4-step canary runbook with examples
  - Constraints and edge cases documented

- Add make test-e2e-traffic target for focused test runs

Closes #11 (routing/canary portion; per-version health deferred to #57)
Fixes ginkgo-linter issues with proper test structure
Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The decommission E2E does not verify that v2 remains executable, and the documentation overstates gateway reference immutability.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds multi-version traffic-splitting verification and user guidance for LogicFlowService.

Changes:

  • Adds a four-stage canary rollout E2E scenario and focused unit tests.
  • Adds a dedicated E2E Make target.
  • Documents routing modes, direct access, and rollout procedures.
File Description
test/​e2e/​logicflowservice_test.go Adds multi-version rollout E2E coverage.
test/​e2e/​e2e_test.go Registers the new E2E context.
Makefile Adds the traffic-splitting E2E target.
internal/​controller/​logicflowservice_objects_test.go Tests traffic-target selection and ordering.
docs/​antora/​modules/​ROOT/​pages/​concepts/​traffic-splitting.adoc Documents traffic splitting and canary rollouts.
docs/​antora/​modules/​ROOT/​nav.adoc Adds the new concept page to navigation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/e2e/logicflowservice_test.go Outdated
Comment thread docs/antora/modules/ROOT/pages/concepts/traffic-splitting.adoc Outdated
ricardozanini and others added 3 commits October 2, 2026 12:10
Clarify the immutability of ingress.gatewayRef after creation.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…and runtime status

Replace workflow invocation with direct state checks:
- Verify lfd-e2e-mv-def-v2 ConfigMap exists (not garbage collected)
- Verify runtime.status.definitions contains v1.1.0 (proven loaded and active)

This avoids timeout issues from workflow execution and directly proves
v2 remains operational after v1 deletion, addressing the original concern
that a stale Ingress annotation alone doesn't prove v2 can serve requests.
…sion tests

Add 1-second polling intervals to Consistently/Eventually blocks:
- Promotion check: poll every 1s instead of default ~100ms
- Canary cleanup check: poll every 1s instead of default ~100ms

This reduces kubectl command spam in test logs while maintaining reliability.
@ricardozanini
ricardozanini merged commit c9f0188 into main Oct 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-Version Support & Traffic Splitting

2 participants