From e993c2801855dce68da37d7265a450c790023f4f Mon Sep 17 00:00:00 2001 From: Jonathan West Date: Wed, 3 Apr 2024 07:26:01 -0400 Subject: [PATCH] Ensure when alternatebackends is empty, canary weight should be 0 Signed-off-by: Jonathan West --- tests/fixtures/route/route.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/route/route.go b/tests/fixtures/route/route.go index ce65182..fd61228 100644 --- a/tests/fixtures/route/route.go +++ b/tests/fixtures/route/route.go @@ -32,7 +32,12 @@ func HaveWeights(stableWeight, canaryWeight int32) matcher.GomegaMatcher { return false } - if len(route.Spec.AlternateBackends) == 1 && *route.Spec.AlternateBackends[0].Weight != canaryWeight { + if len(route.Spec.AlternateBackends) == 0 && canaryWeight != 0 { + // If alternate backend is empty, that is equivalent to a canary weight of 0, so we verify here that canary weight is 0. + fmt.Printf("Canary weight mismatch: got %d, want %d\n", 0, canaryWeight) + return false + + } else if len(route.Spec.AlternateBackends) == 1 && *route.Spec.AlternateBackends[0].Weight != canaryWeight { fmt.Printf("Canary weight mismatch: got %d, want %d\n", *route.Spec.AlternateBackends[0].Weight, canaryWeight) return false }