From b5e2b6c34c609a6bcf2a84045d8c65e209d2a0fa Mon Sep 17 00:00:00 2001 From: Kiran Meduri Date: Fri, 14 Jan 2022 14:02:23 -0800 Subject: [PATCH] Fix App Mesh Reconciler to honor TrafficRoutingReconciler interface Signed-off-by: Kiran Meduri --- rollout/trafficrouting/appmesh/appmesh.go | 2 +- test/e2e/appmesh_test.go | 33 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/rollout/trafficrouting/appmesh/appmesh.go b/rollout/trafficrouting/appmesh/appmesh.go index f9cba2a890..73db7dd3d4 100644 --- a/rollout/trafficrouting/appmesh/appmesh.go +++ b/rollout/trafficrouting/appmesh/appmesh.go @@ -64,7 +64,7 @@ func NewReconciler(cfg ReconcilerConfig) *Reconciler { // virtual-nodes with appropriate match-labels in pod-selector. It will mutate the pod-selector in two ways. // Firstly it will update a label with name v1alpha1.DefaultRolloutUniqueLabelKey if one exists. Secondly it will add a // new label with name v1alpha1.DefaultRolloutUniqueLabelKey if one does not exist. -func (r *Reconciler) UpdateHash(canaryHash, stableHash string) error { +func (r *Reconciler) UpdateHash(canaryHash, stableHash string, additionalDestinations ...v1alpha1.WeightDestination) error { ctx := context.TODO() r.log.Debugf("UpdateHash: canaryHash (%s), stableHash (%s)", canaryHash, stableHash) diff --git a/test/e2e/appmesh_test.go b/test/e2e/appmesh_test.go index c241615e2e..33367626f4 100644 --- a/test/e2e/appmesh_test.go +++ b/test/e2e/appmesh_test.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" "testing" + "time" - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" "github.com/argoproj/argo-rollouts/test/fixtures" "github.com/stretchr/testify/suite" "github.com/tj/assert" @@ -31,22 +31,43 @@ func (s *AppMeshSuite) SetupSuite() { func (s *AppMeshSuite) TestAppMeshCanaryRollout() { s.Given(). - HealthyRollout(`@appmesh/appmesh-canary-rollout.yaml`). + RolloutObjects(`@appmesh/appmesh-canary-rollout.yaml`). + When(). + ApplyManifests(). + WaitForRolloutStatus("Healthy"). + Sleep(1 * time.Second). + Then(). + //Before rollout canary should be 0 weight + Assert(func(t *fixtures.Then) { + uVr := t.GetAppMeshVirtualRouter() + canaryWeight := int64(0) + s.assertWeightedTargets(uVr, canaryWeight) + }). When(). UpdateSpec(). WaitForRolloutStatus("Paused"). + Sleep(1 * time.Second). Then(). + //During deployment canary should increment to stepWeight Assert(func(t *fixtures.Then) { uVr := t.GetAppMeshVirtualRouter() - s.assertWeightedTargets(uVr, t.Rollout(), 0) + canaryWeight := int64(*(t.Rollout().Spec.Strategy.Canary.Steps[0].SetWeight)) + s.assertWeightedTargets(uVr, canaryWeight) }). When(). PromoteRollout(). - WaitForRolloutStatus("Healthy") + WaitForRolloutStatus("Healthy"). + Sleep(1 * time.Second). + Then(). + //After deployment canary should get back to 0 weight + Assert(func(t *fixtures.Then) { + uVr := t.GetAppMeshVirtualRouter() + canaryWeight := int64(0) + s.assertWeightedTargets(uVr, canaryWeight) + }) } -func (s *AppMeshSuite) assertWeightedTargets(uVr *unstructured.Unstructured, rollout *v1alpha1.Rollout, stepIndex int) { - canaryWeight := int64(*(rollout.Spec.Strategy.Canary.Steps[stepIndex].SetWeight)) +func (s *AppMeshSuite) assertWeightedTargets(uVr *unstructured.Unstructured, canaryWeight int64) { wtMap := s.getWeightedTargets(uVr) for routeName, wt := range wtMap { assert.Equal(s.T(), canaryWeight, wt.canaryWeight, fmt.Sprintf("Route %s has wrong weight for canary", routeName))