Skip to content

Commit

Permalink
Fix App Mesh Reconciler to honor TrafficRoutingReconciler interface
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Meduri <meduri@amazon.com>
  • Loading branch information
kiranmeduri committed Jan 15, 2022
1 parent 2e52129 commit b5e2b6c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rollout/trafficrouting/appmesh/appmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 27 additions & 6 deletions test/e2e/appmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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))
Expand Down

0 comments on commit b5e2b6c

Please sign in to comment.