Skip to content

fix(e2e): fix "eventually" helper in e2e tests #3917

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

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions features/extra/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ module.exports = {
if (!options.backoff) options.backoff = 500;
if (!options.maxTime) options.maxTime = 5;

const delay = options.delay;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function has likely been broken for a very long time. delay += options.backoff; could never have worked with const delay. It's likely the AWS.util.date.getDate() call did not return a reasonable value and the retry did not happen, meaning previously passing e2e tests always succeeded on the first try of the next.condition.

Copy link
Member

@trivikr trivikr Sep 9, 2022

Choose a reason for hiding this comment

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

The AWS.util.date.getDate() is a remnant from AWS SDK for JavaScript (v2), which wouldn't have worked in v3. We would have missed removing it when migrating integration tests.

Thanks for catching it!

//TODO: apply clock offset
const started = new Date();
let delay = options.delay;
const started = Date.now();

const self = this;
const retry = function () {
callback();
};
retry.fail = function (err) {
const now = self.AWS.util.date.getDate();
const now = Date.now();
if (now - started < options.maxTime * 1000) {
setTimeout(function () {
delay += options.backoff;
Expand Down
1 change: 1 addition & 0 deletions features/sqs/step_definitions/queues.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Then("list queues should eventually return the queue urls", function (callback)
}
return matchingCount == this.createdQueues.length;
};

this.request(null, "listQueues", {}, next);
},
{ maxTime: 60 }
Expand Down