Skip to content
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

[Monitoring] Await promise properly #29001

Conversation

chrisronline
Copy link
Contributor

@chrisronline chrisronline commented Jan 18, 2019

Fixes #28989
Properly awaits the promise.

Unfortunately, I couldn't figure a good way to add a test for this, or modify the existing tests. Any thoughts here would be appreciated

cc @pickypg

@elasticmachine
Copy link
Contributor

Pinging @elastic/stack-monitoring

@elasticmachine
Copy link
Contributor

💔 Build Failed

@@ -103,7 +103,7 @@ export class BulkUploader {
if (payload) {
try {
this._log.debug(`Uploading bulk stats payload to the local cluster`);
this._onPayload(payload);
await this._onPayload(payload);
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to await this on the tests that mock Elasticsearch, then assert that it sent the payload (or failed) with itself returning until it did that while also avoiding an exception being thrown from this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this will work: be5c697

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pinging my favorite Chris @pickypg!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@chrisronline
Copy link
Contributor Author

cc @mattapperson @justinkambic

Either of you able to look at this this week?

@chrisronline chrisronline merged commit 5b9f2ba into elastic:master Jan 29, 2019
@chrisronline chrisronline deleted the monitoring/handle_async_code_in_bulk_uploader branch January 29, 2019 14:26
chrisronline added a commit to chrisronline/kibana that referenced this pull request Jan 29, 2019
* Await this promise

* Add one additional log message and a test around that
chrisronline added a commit that referenced this pull request Jan 29, 2019
* Await this promise

* Add one additional log message and a test around that
@chrisronline
Copy link
Contributor Author

Backport:

6.x: 67dc8c0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants