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

Change the default behaviour of useNewWDA capability #456

Merged
merged 6 commits into from
Jun 24, 2017

Conversation

mykola-mokhnach
Copy link
Contributor

This PR tries to address real device issues like facebookarchive/WebDriverAgent#507 by keeping WDA session running for as long as possible and reuse it every time the new session is created instead of recompiling/redeploying WDA. Also, it should significantly shorten the duration of driver initialisation stage between multiple test cases.

@imurchie Could you please assist with testing, since it is necessary to significantly change our automation framework to test these changes on Simulator and (especially) on real device? Thanks in advance.

@imurchie
Copy link
Contributor

Sure. I have some real device stuff I need to do today, so I'll take a whirl.

Copy link
Contributor

@imurchie imurchie left a comment

Choose a reason for hiding this comment

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

This seems to work well in local tests. One remark about short-circuiting.

lib/driver.js Outdated
this.logEvent('wdaStartFailed');
if (this.isRealDevice() && launchRetriesCount > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume you want to not retry if there is an xcodebuild failure on a real device?

This will not do that. Any error thrown here will trigger a retry at the retryInterval level (on line 427). It would be better to check for real device before the retryInterval, and adjust the startupRetries accordingly.

const startupRetries = this.isRealDevice() ? 1 : (this.opts.wdaStartupRetries || WDA_STARTUP_RETRIES);

Copy link
Contributor Author

@mykola-mokhnach mykola-mokhnach Jun 20, 2017

Choose a reason for hiding this comment

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

It might not be a good idea to implicitly override user-supplied option.

How about this one?

const startupRetries = this.opts.wdaStartupRetries || (this.isRealDevice() ? 1 : WDA_STARTUP_RETRIES);

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Yeah, that would work. Since the number varies, it should probably be logged, as well.

lib/driver.js Outdated
@@ -434,7 +461,13 @@ class XCUITestDriver extends BaseDriver {
});
this.logEvent('wdaSessionStarted');
} catch (err) {
return await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`);
let errorMsg = `Unable to start WebDriverAgent sesssion because of xcodebuild failure: ${err.message}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor into a function call to handle the error, so it's not repeated here?

Copy link
Contributor Author

@mykola-mokhnach mykola-mokhnach Jun 20, 2017

Choose a reason for hiding this comment

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

error messages are different for both cases. I separated them intentionally for a case when it is necessary to add any other helpful message details to help user to fix his problem for the particular case.

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

this will be really useful!

README.md Outdated
@@ -134,7 +134,7 @@ Differences noted here
|`usePrebuiltWDA`|Skips the build phase of running the WDA app. Building is then the responsibility of the user. Only works for Xcode 8+. Defaults to `false`.|e.g., `true`|
|`preventWDAAttachments`|Sets read only permissions to Attachments subfolder of WebDriverAgent root inside Xcode's DerivedData. This is necessary to prevent XCTest framework from creating tons of unnecessary screenshots and logs, which are impossible to turn off using programming interfaces provided by Apple.|Setting the capability to `true` will set Posix permissions of the folder to `555` and `false` will reset them back to `755`. `true` by default|
|`webDriverAgentUrl`|If provided, Appium will connect to an existing WebDriverAgent instance at this URL instead of starting a new one.|e.g., `http://localhost:8100`|
|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. This can provide stability in some situations. Defaults to `false`.|e.g., `true`|
|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. Set it to `true` if you want to apply different startup options for WebDriverAgent for each session. Although, it is only guaranteed to work stable on Simulator. Real devices require WebDriverAgent client to run for as long as possible without reinstall/restart to avoid issues like https://github.com/facebook/WebDriverAgent/issues/507. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`|
Copy link
Member

Choose a reason for hiding this comment

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

probably don't want to refer to appium versions in the xcuitest repo, maybe refer to the xcuitest version? unless the default is set in appium and not here. which might be the case, hmm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to driver version

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 see a change

lib/driver.js Outdated
await quitAndUninstall(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`);
let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: "${err.message}".`;
if (this.isRealDevice()) {
errorMsg += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` +
Copy link
Member

Choose a reason for hiding this comment

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

formatting looks goofy here, maybe because the lines are too long (we try to stick to 80 chars when possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

n/m saw the change. one more comment.

README.md Outdated
@@ -134,7 +134,7 @@ Differences noted here
|`usePrebuiltWDA`|Skips the build phase of running the WDA app. Building is then the responsibility of the user. Only works for Xcode 8+. Defaults to `false`.|e.g., `true`|
|`preventWDAAttachments`|Sets read only permissions to Attachments subfolder of WebDriverAgent root inside Xcode's DerivedData. This is necessary to prevent XCTest framework from creating tons of unnecessary screenshots and logs, which are impossible to turn off using programming interfaces provided by Apple.|Setting the capability to `true` will set Posix permissions of the folder to `555` and `false` will reset them back to `755`. `true` by default|
|`webDriverAgentUrl`|If provided, Appium will connect to an existing WebDriverAgent instance at this URL instead of starting a new one.|e.g., `http://localhost:8100`|
|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. This can provide stability in some situations. Defaults to `false`.|e.g., `true`|
|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. Set it to `true` if you want to apply different startup options for WebDriverAgent for each session. Although, it is only guaranteed to work stable on Simulator. Real devices require WebDriverAgent client to run for as long as possible without reinstall/restart to avoid issues like https://github.com/facebook/WebDriverAgent/issues/507. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`|
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 see a change

lib/driver.js Outdated
await quitAndUninstall(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`);
let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: "${err.message}".`;
if (this.isRealDevice()) {
errorMsg += ` Make sure you follow the tutorial at ` +
Copy link
Member

Choose a reason for hiding this comment

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

there's now quite a bit of duplication with this error message; maybe make it a global constant?

Copy link
Contributor Author

@mykola-mokhnach mykola-mokhnach Jun 21, 2017

Choose a reason for hiding this comment

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

What if I only extract the tutorial URL into a constant? I want to keep message texts separated, since it might be necessary to tune them in the future for launch session and wait for status cases

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

fine with me if we think we will likely want to do that

@imurchie imurchie merged commit 8857a2b into appium:master Jun 24, 2017
@imurchie
Copy link
Contributor

Published in [email protected].

@mykola-mokhnach mykola-mokhnach deleted the new_wda_behavior branch June 26, 2017 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants