Skip to content

Comments

[6.x] [retry] implement waitFor method (#21747)#21969

Merged
spalger merged 1 commit intoelastic:6.xfrom
spalger:backport/6.x/pr-21747
Aug 14, 2018
Merged

[6.x] [retry] implement waitFor method (#21747)#21969
spalger merged 1 commit intoelastic:6.xfrom
spalger:backport/6.x/pr-21747

Conversation

@spalger
Copy link
Contributor

@spalger spalger commented Aug 14, 2018

Backports the following commits to 6.x:

We currently use the `retry` service to call a function over and over in a loop, waiting for it to run without throwing an error, and ultimately failing if it does not succeed before a timeout is exceeded. This is the easiest way to get certain interactions to work, either because we don't know when we should be able to execute the interaction successfully, or because the timing is just too tricky to plan out correctly. Another place where we are using the `retry` service, which I don't think is appropriate, is when we need to wait for a certain condition to be met. This is where `retry.waitFor()` comes in:

```js
await retry.waitFor('dashboard search to be enabled', async () => {
  const searchInput = await testSubjects.find('savedObjectFinderSearchInput');
  return await searchInput.isEnabled();
})
```

The `retry.waitFor()` method behaves much like the `retry.try()` method behind the scenes, calling a function over and over, but instead of waiting for it to run without throwing an error it waits for it to return a "truthy" value. It also requires a description string that is used to make rather nice log output and a more descriptive error message than something like https://github.com/elastic/kibana/blob/master/test/functional/apps/dashboard/_data_shared_attributes.js#L61-L67
@spalger spalger added the backport This PR is a backport of another PR label Aug 14, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@spalger spalger merged commit 0072315 into elastic:6.x Aug 14, 2018
@spalger spalger deleted the backport/6.x/pr-21747 branch August 14, 2018 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants