-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved assertions & resource clean-up for E2E tests #311
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,8 +144,9 @@ func (env *Framework) ExpectToBeClean(ctx context.Context) { | |
|
||
retrievedTargetGroups, _ := env.LatticeClient.ListTargetGroupsAsList(ctx, &vpclattice.ListTargetGroupsInput{}) | ||
for _, tg := range retrievedTargetGroups { | ||
Logger(ctx).Infof("Found TargetGroup: %v, checking it whether it's created by current EKS Cluster", tg) | ||
Logger(ctx).Infof("Found TargetGroup: %s, checking it whether it's created by current EKS Cluster", *tg.Id) | ||
if currentClusterVpcId != *tg.VpcIdentifier { | ||
Logger(ctx).Infof("Target group VPC Id: %s, does not match current EKS Cluster VPC Id: %s", *tg.VpcIdentifier, currentClusterVpcId) | ||
//This tg is not created by current EKS Cluster, skip it | ||
continue | ||
} | ||
|
@@ -156,6 +157,7 @@ func (env *Framework) ExpectToBeClean(ctx context.Context) { | |
Logger(ctx).Infof("Found Tags for tg %v tags: %v", *tg.Name, retrievedTags) | ||
tagValue, ok := retrievedTags.Tags[lattice.K8SParentRefTypeKey] | ||
if ok && *tagValue == lattice.K8SServiceExportType { | ||
Logger(ctx).Infof("TargetGroup: %s was created by k8s controller, by a ServiceExport", *tg.Id) | ||
//This tg is created by k8s controller, by a ServiceExport, | ||
//ServiceExport still have a known targetGroup leaking issue, | ||
//so we temporarily skip to verify whether ServiceExport created TargetGroup is deleted or not | ||
|
@@ -220,9 +222,9 @@ func (env *Framework) EventuallyExpectNotFound(ctx context.Context, objects ...c | |
Logger(ctx).Infof("Checking whether %s %s %s is not found", reflect.TypeOf(object), object.GetNamespace(), object.GetName()) | ||
g.Expect(errors.IsNotFound(env.Get(ctx, client.ObjectKeyFromObject(object), object))).To(BeTrue()) | ||
} | ||
// Wait for 6 minutes at maximum just in case the k8sService deletion triggered targets draining time | ||
// Wait for 7 minutes at maximum just in case the k8sService deletion triggered targets draining time | ||
// and httproute deletion need to wait for that targets draining time finish then it can return | ||
}).WithTimeout(6 * time.Minute).WithOffset(1).Should(Succeed()) | ||
}).WithTimeout(7 * time.Minute).WithOffset(1).Should(Succeed()) | ||
} | ||
|
||
func (env *Framework) EventuallyExpectNoneFound(ctx context.Context, objectList client.ObjectList) { | ||
|
@@ -459,7 +461,9 @@ func (env *Framework) DeleteAllFrameworkTracedVpcLatticeServices(ctx aws.Context | |
_, err := env.LatticeClient.DeleteServiceNetworkServiceAssociationWithContext(ctx, &vpclattice.DeleteServiceNetworkServiceAssociationInput{ | ||
ServiceNetworkServiceAssociationIdentifier: snsaId, | ||
}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
if err != nil { | ||
Expect(err.(awserr.Error).Code()).To(Equal(vpclattice.ErrCodeResourceNotFoundException)) | ||
} | ||
} | ||
|
||
Eventually(func(g Gomega) { | ||
|
@@ -493,6 +497,9 @@ func (env *Framework) DeleteAllFrameworkTracedTargetGroups(ctx aws.Context) { | |
tgIds := lo.Map(filteredTgs, func(targetGroup *vpclattice.TargetGroupSummary, _ int) *string { | ||
return targetGroup.Id | ||
}) | ||
|
||
log.Println("Number of traced target groups to delete is:", len(tgIds)) | ||
|
||
for _, tgId := range tgIds { | ||
targetSummaries, err := env.LatticeClient.ListTargetsAsList(ctx, &vpclattice.ListTargetsInput{ | ||
TargetGroupIdentifier: tgId, | ||
|
@@ -510,6 +517,18 @@ func (env *Framework) DeleteAllFrameworkTracedTargetGroups(ctx aws.Context) { | |
TargetGroupIdentifier: tgId, | ||
Targets: targets, | ||
}) | ||
} else { | ||
Logger(ctx).Infof("Target group %s no longer has targets registered. Deleting now.", *tgId) | ||
Eventually(func() bool { | ||
_, err := env.LatticeClient.DeleteTargetGroup(&vpclattice.DeleteTargetGroupInput{ | ||
TargetGroupIdentifier: tgId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part looks good |
||
}) | ||
if err != nil { | ||
// Allow time for related service to be deleted prior | ||
return err.(awserr.Error).Code() == vpclattice.ErrCodeResourceNotFoundException | ||
} | ||
return true | ||
}).WithPolling(15 * time.Second).WithTimeout(2 * time.Minute).Should(BeTrue()) | ||
} | ||
} | ||
|
||
|
@@ -518,7 +537,7 @@ func (env *Framework) DeleteAllFrameworkTracedTargetGroups(ctx aws.Context) { | |
//After initiating the DeregisterTargets call, the Targets will be in `draining` status for the next 5 minutes, | ||
//And VPC lattice backend will run a background job to completely delete the targets within 6 minutes at maximum in total. | ||
Eventually(func(g Gomega) { | ||
log.Println("Trying to clear Target group", tgIdsThatNeedToWaitForDrainingTargetsToBeDeleted, " need to wait for draining targets to be deregistered") | ||
log.Println("Trying to clear Target group", tgIdsThatNeedToWaitForDrainingTargetsToBeDeleted, "need to wait for draining targets to be deregistered") | ||
|
||
for _, tgId := range tgIdsThatNeedToWaitForDrainingTargetsToBeDeleted { | ||
_, err := env.LatticeClient.DeleteTargetGroupWithContext(ctx, &vpclattice.DeleteTargetGroupInput{ | ||
|
@@ -528,7 +547,7 @@ func (env *Framework) DeleteAllFrameworkTracedTargetGroups(ctx aws.Context) { | |
g.Expect(err.(awserr.Error).Code()).To(Equal(vpclattice.ErrCodeResourceNotFoundException)) | ||
} | ||
} | ||
}).WithTimeout(360 * time.Second).Should(Succeed()) | ||
}).WithPolling(time.Minute).WithTimeout(7 * time.Minute).Should(Succeed()) | ||
|
||
} | ||
env.TestCasesCreatedServiceNames = make(map[string]bool) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 20 retries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VPC lattice cp api have pretty low per account throttling setting, controller and e2etest code can quite easily get "Too Many Request" error if we use default max retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these retries with exponential backoff? or whats the retry strategy?