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

[ML] Functional tests - fix typing issue #52167

Merged
merged 14 commits into from
Dec 9, 2019
Merged

Conversation

pheyos
Copy link
Member

@pheyos pheyos commented Dec 4, 2019

Summary

This PR fixes the typing flakiness in ML wizards, where sometimes the first letter isn't typed in.

@elasticmachine

This comment has been minimized.

@pheyos

This comment has been minimized.

@pheyos

This comment has been minimized.

@pheyos

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@pheyos

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@pheyos
Copy link
Member Author

pheyos commented Dec 9, 2019

Summary:

  • With the first fix attempts, the typing issue reproduced 2-3 times in 60 executions.
  • The current fix passed 500x in a row

Also, I've discussed this with @jgowdyelastic and we consider this a temporary fix until we find a way to make the job wizard input elements more stable for the automated typing.

@pheyos pheyos marked this pull request as ready for review December 9, 2019 08:57
@pheyos pheyos requested a review from a team as a code owner December 9, 2019 08:57
@pheyos pheyos self-assigned this Dec 9, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@pheyos pheyos added the release_note:skip Skip the PR/issue when compiling release notes label Dec 9, 2019
@pheyos pheyos requested a review from dmlemeshko December 9, 2019 09:03
}
});
});
}
Copy link
Member

@dmlemeshko dmlemeshko Dec 9, 2019

Choose a reason for hiding this comment

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

I'm not sure if this solution will be effective and stable:

  • if the problem is that the letter may not be typed, it makes sense to reimplement WebElementWrapper: type function for ML tests. Wrapping existing code with 2 retries will slow things down and an additional check will not give a benefit if the wrong letter or in the letter is typed in the wrong order.
  • if the problem is that the field may be cleared during typing I suggest checking how the component re-rendering is triggered. Wrapping things with double retry will most like hide an issue the real user can face.

Copy link
Member

Choose a reason for hiding this comment

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

But 500 passing tests means the opposite :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@dmlemeshko thanks for the feedback!
Some explanations to this approach:

  • We're already investigating the component and will (hopefully) fix it as soon as we know why it behaves that way, so this PR is only a temporary solution to fix typing until then (this is the 1st reason why I've implemented this as a separate method).
  • The slowdown due to retries is expected. I've called the method setValueWithChecks to set the right expectations: when I cal something WithChecks, I expect it to be slower (2nd reason for a separate method).
  • I agree that the outer retry is probably not needed (but I think the same holds true for the setValue method). This will just retry the whole thing in case an error is thrown on the way, so it doesn't really hurt. For the inner retries:
    • The first block will retry to clear the field
    • The second block does basically the following:
      a. Type in the next character
      b. Check if it was appended to the input value (give it 1 second time to appear there)
      c. If it doesn't appear, try again, starting with step a. (retry for 5 seconds, then fail)
    • So I agree that it doesn't help to fix wrong letters or wrong order of letters. But that was not the scope of this fix, it should only check for missing letters.
  • I can see how this new method setValueWithChecks is very specialized to (hopefully temporarily) fix a specific issue and might not be appropriate for the testSubjects service. Happy to move it to a ML specific location if you think that's better.

Copy link
Member

Choose a reason for hiding this comment

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

@pheyos thank you for explaining the issue, it makes more sense now. Since you mentioned it is a temporary fix for ML-specific components, I suggest we don't put it in testSubjects.ts: we probably don't want other teams to start using it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@dmlemeshko agreed. I've moved the method to a common ML service in a11a340 .

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

import { MachineLearningCustomUrlsProvider } from './custom_urls';

export function MachineLearningJobWizardCommonProvider(
{ getService }: FtrProviderContext,
mlCommon: ProvidedType<typeof MachineLearningCommonProvider>,
Copy link
Contributor

@spalger spalger Dec 9, 2019

Choose a reason for hiding this comment

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

In the future, I usually like to export this type from the module containing the provider so I can just import the MlCommon type without having to use these long types everywhere.

in common.ts

export type MlCommon = ProvidedType<typeof MachineLearningCommonProvider>

in here

import { MlCommon } from './common'

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! I've created a PR for this: #52612

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for update

@spalger
Copy link
Contributor

spalger commented Dec 9, 2019

I keep running into this, and the changes have two reviews, so I'm going to go ahead and merge this.

@spalger spalger merged commit d429a9a into elastic:master Dec 9, 2019
spalger pushed a commit to spalger/kibana that referenced this pull request Dec 9, 2019
* Use char by char typing in all text fields

* Add dely before first typed charakter when typing char by char

* Remove delay before typing again

* Use clearCharByChar option for input fields

* Revert "Use clearCharByChar option for input fields"

This reverts commit e412d7b.

* Revert "Use char by char typing in all text fields"

This reverts commit 2fbccc5.

* Disable jobCreatorUpdate for tests

* Revert "Disable jobCreatorUpdate for tests"

This reverts commit e178fd8.

* Check typing char by char for job wizard inputs

* Remove .only from anomaly detection suite

* Move setValueWithChecks from testSubjects to a ML service

# Conflicts:
#	x-pack/test/functional/services/machine_learning/index.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_common.ts
#	x-pack/test/functional/services/ml.ts
spalger pushed a commit to spalger/kibana that referenced this pull request Dec 9, 2019
* Use char by char typing in all text fields

* Add dely before first typed charakter when typing char by char

* Remove delay before typing again

* Use clearCharByChar option for input fields

* Revert "Use clearCharByChar option for input fields"

This reverts commit e412d7b.

* Revert "Use char by char typing in all text fields"

This reverts commit 2fbccc5.

* Disable jobCreatorUpdate for tests

* Revert "Disable jobCreatorUpdate for tests"

This reverts commit e178fd8.

* Check typing char by char for job wizard inputs

* Remove .only from anomaly detection suite

* Move setValueWithChecks from testSubjects to a ML service

# Conflicts:
#	x-pack/test/functional/services/machine_learning/index.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_advanced.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_common.ts
#	x-pack/test/functional/services/ml.ts
spalger pushed a commit that referenced this pull request Dec 10, 2019
* Use char by char typing in all text fields

* Add dely before first typed charakter when typing char by char

* Remove delay before typing again

* Use clearCharByChar option for input fields

* Revert "Use clearCharByChar option for input fields"

This reverts commit e412d7b.

* Revert "Use char by char typing in all text fields"

This reverts commit 2fbccc5.

* Disable jobCreatorUpdate for tests

* Revert "Disable jobCreatorUpdate for tests"

This reverts commit e178fd8.

* Check typing char by char for job wizard inputs

* Remove .only from anomaly detection suite

* Move setValueWithChecks from testSubjects to a ML service

# Conflicts:
#	x-pack/test/functional/services/machine_learning/index.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_common.ts
#	x-pack/test/functional/services/ml.ts
@spalger
Copy link
Contributor

spalger commented Dec 10, 2019

7.x/7.6: ea28aa6
7.5: 3b83995

spalger pushed a commit that referenced this pull request Dec 10, 2019
* [ML] Functional tests - fix typing issue (#52167)

* Use char by char typing in all text fields

* Add dely before first typed charakter when typing char by char

* Remove delay before typing again

* Use clearCharByChar option for input fields

* Revert "Use clearCharByChar option for input fields"

This reverts commit e412d7b.

* Revert "Use char by char typing in all text fields"

This reverts commit 2fbccc5.

* Disable jobCreatorUpdate for tests

* Revert "Disable jobCreatorUpdate for tests"

This reverts commit e178fd8.

* Check typing char by char for job wizard inputs

* Remove .only from anomaly detection suite

* Move setValueWithChecks from testSubjects to a ML service

# Conflicts:
#	x-pack/test/functional/services/machine_learning/index.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_advanced.ts
#	x-pack/test/functional/services/machine_learning/job_wizard_common.ts
#	x-pack/test/functional/services/ml.ts

* fix bad merge
@pheyos pheyos deleted the fix_typing branch December 10, 2019 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants