Skip to content

Conversation

@tlrx
Copy link
Member

@tlrx tlrx commented Jan 31, 2018

Similarly to other documentation tests in the high level client, the
asynchronous operation like update, index or delete can make the test
fail if it sneak in between the middle of another operation.

This commit moves the async doc tests to be the last ones executed and
adds await busy loops to ensure that the asynchronous operations are
correctly terminated.

closes #28446

@tlrx tlrx added >test Issues or PRs that are addressing/adding tests review v7.0.0 labels Jan 31, 2018
@tlrx tlrx requested review from cbuescher and javanna January 31, 2018 14:36
Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I expect assertBusy will produce better error messages one failure. Also, I don't think you had to move these to the last ones, right? I don't mind either way, but just for my own sanity, can you confirm that or correct me?

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM I would do assertBusy too, I am curious about the answers to Nik's questions too.

Copy link
Member

Choose a reason for hiding this comment

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

what happens if we don't wait for this one?

Copy link
Member

Choose a reason for hiding this comment

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

I was also thinking, given that this is a recurring problem and we don't want to have latches to show in our docs, shall we make this more clear doing something through a listener that blocks (without showing in the snippets what the listener really does)?

Copy link
Member Author

Choose a reason for hiding this comment

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

what happens if we don't wait for this one?

After each test method, the ESRestTestCase.cleanUpCluster() is executed. As you know this method deletes the cluster indices, waits for the pending cluster states tasks to finish and logs a message if there is still inflight requests.

By not waiting for the async request to respond, it's possible that an index got re created because the index (or update) operation is processed after the indices have been deleted and s recreates the index and breaks following tests.

I'm pretty sure I saw this error, but sadly I can't find a test execution log that clearly shows this behavior. In any way I think it's better to wait for the completion of any write operation that could recreate an index for the reason I mentioned.

Copy link
Member

Choose a reason for hiding this comment

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

makes sense, thanks for explaining.

Copy link
Member

Choose a reason for hiding this comment

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

what do you think about the listener idea above?

Copy link
Member

Choose a reason for hiding this comment

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

yea this sounds good to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will have an impact on documentation (2 code snippets instead of one), should we align all documentation for async execution to be like this? I think so.

Copy link
Member

Choose a reason for hiding this comment

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

yes I would adapt the docs, let me know if you prefer me to take this over given that it's becoming a bigger task.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do it. Do you prefer a follow up PR or be part of this one?

Copy link
Member

Choose a reason for hiding this comment

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

I don't mind either way

Copy link
Member

Choose a reason for hiding this comment

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

once you have changed the id of the update, it won't sneak in anymore and cause version conflict, so I think it doesn't necessarily needs to be moved down? But maybe it's good like you did. Maybe we don't even need to wait for it at this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was for readability, as some test use the same document to index or update multiple times. But I can move them back if you prefer.

Maybe we don't even need to wait for it at this point?

We need to wait for any writing operation, but we can relax this for read operations.

Copy link
Member

Choose a reason for hiding this comment

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

same comment as above, once we change the id, do we need to still wait for it?

@tlrx
Copy link
Member Author

tlrx commented Jan 31, 2018

Thanks for the reviews @nik9000 and @javanna.

Also, I don't think you had to move these to the last ones, right?

This is not a requirement of course but some tests use the same document (like /posts/doc/1) and update or index it multiple times. Since I changed the async operations to use a different doc I moved them down so that it does not interleave with other request executions as I found this more readable.

tlrx added 2 commits February 1, 2018 13:43
Similarly to other documentation tests in the high level client, the
asynchronous operation like update, index or delete can make the test
fail if it sneak in between the middle of another operation.

This commit moves the async doc tests to be the last ones executed and
adds await busy loops to ensure that the asynchronous operations are
correctly terminated.

closes elastic#28446
@tlrx tlrx merged commit ec187ca into elastic:master Feb 1, 2018
tlrx added a commit that referenced this pull request Feb 1, 2018
Similarly to other documentation tests in the high level client, the
asynchronous operation like update, index or delete can make the test
fail if it sneak in between the middle of another operation.

This commit moves the async doc tests to be the last ones executed and
adds assert busy loops to ensure that the asynchronous operations are
correctly terminated.

closes #28446
tlrx added a commit to tlrx/elasticsearch that referenced this pull request Feb 1, 2018
This commit splits the async execution documentation into 2 parts, one
for the async method itself and one for the action listener. This allows
to add more doc and to use CountDownLatches in doc tests to wait for
asynchronous operations to be completed before moving to the next test.

It also renames few files.

Related to elastic#28457
tlrx added a commit that referenced this pull request Feb 1, 2018
This commit splits the async execution documentation into 2 parts, one
for the async method itself and one for the action listener. This allows
to add more doc and to use CountDownLatches in doc tests to wait for
asynchronous operations to be completed before moving to the next test.

It also renames few files.

Related to #28457
tlrx added a commit that referenced this pull request Feb 2, 2018
This commit splits the async execution documentation into 2 parts, one
for the async method itself and one for the action listener. This allows
to add more doc and to use CountDownLatches in doc tests to wait for
asynchronous operations to be completed before moving to the next test.

It also renames few files.

Related to #28457
tlrx added a commit that referenced this pull request Feb 21, 2018
Similarly to other documentation tests in the high level client, the
asynchronous operation like update, index or delete can make the test
fail if it sneak in between the middle of another operation.

This commit moves the async doc tests to be the last ones executed and
adds assert busy loops to ensure that the asynchronous operations are
correctly terminated.

closes #28446
tlrx added a commit that referenced this pull request Feb 21, 2018
This commit splits the async execution documentation into 2 parts, one
for the async method itself and one for the action listener. This allows
to add more doc and to use CountDownLatches in doc tests to wait for
asynchronous operations to be completed before moving to the next test.

It also renames few files.

Related to #28457
@tlrx tlrx added the v6.2.3 label Feb 21, 2018
@tlrx tlrx deleted the fix-cruddocit branch February 21, 2018 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>test Issues or PRs that are addressing/adding tests v6.2.3 v6.3.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] CRUDDocumentationIT.testUpdate fails on 5.6

4 participants