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

wait and shut down the device after trying erase device's contents and setting #368

Merged
merged 2 commits into from
May 5, 2015

Conversation

thanhcs
Copy link
Contributor

@thanhcs thanhcs commented Apr 15, 2015

Old code: Erase right after shutting down the device may fail because the device at that time is still in booted state. After that the old code tries to shut down the device while the device is already in shutdown state.
Output example: https://gist.github.com/thanhcs/f590b45726d84f47c5ea

new: Improve the code by wait 1 second after making an attempt at erasing device's contents and settings (3 times)
after that if the code still fails, shut down the device. If the shutdown is successful, erase the device's again.

Throw an exception if all attempts are failed.

@thanhcs thanhcs force-pushed the improve-eraseContentsetting branch from 8177eec to e6f1a19 Compare April 15, 2015 23:58
@thanhcs thanhcs force-pushed the improve-eraseContentsetting branch from e6f1a19 to 8a64491 Compare April 16, 2015 00:04
@thanhcs
Copy link
Contributor Author

thanhcs commented Apr 27, 2015

@mach6 @freynaud @lukeis Could you take a look at this PR?

I changed the code because it tries to reset the simulator at the time it is shutting down, and it will fail. We need to wait an amount of time to let the simulator completely shuts down before trying to reset it.

simctlArgs.add(deviceUUID);
Command simctlCmd = new Command(simctlArgs, true);
List<String> simctlArgs;
simctlArgs = Arrays.asList("xcrun", "simctl", "erase", deviceUUID);

Choose a reason for hiding this comment

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

looks like most of the changes to eraseSimulator() are formatting changes. I think they are generally for the better although I would go ahead and combine the above 2 lines into a single line:

List<String> simctlArgs = Arrays.asList("xcrun", "simctl", "erase", deviceUUID);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@thanhcs thanhcs force-pushed the improve-eraseContentsetting branch from fda9790 to 8a64491 Compare April 29, 2015 17:43
@thanhcs
Copy link
Contributor Author

thanhcs commented May 4, 2015

Hi @freynaud,

I addressed all of @mmccartney's comments. I think it's ready to merge. Can you take a look?

Thanks,
Thanh

lukeis added a commit that referenced this pull request May 5, 2015
wait and shut down the device after trying erase device's contents and setting
@lukeis lukeis merged commit b41bcba into ios-driver:dev May 5, 2015
@mach6
Copy link
Member

mach6 commented May 5, 2015

@thanhcs One problem I have with this commit is the use of shutdown vs shut down vs shuts down.. We need to be consistent in our messages.

@thanhcs
Copy link
Contributor Author

thanhcs commented May 5, 2015

@mach6 There is a line 318. It should be:

+ ". Now try to shut down the device: " + deviceUUID;

I'm not sure about shut down and shuts down. They are used to describe the current process of the device. Do you have any suggestion?

I don't think I can modify this PR anymore.

@lukeis
Copy link
Member

lukeis commented May 5, 2015

this may be causing a travis-ci issue, the whole suite is taking too long and causing the 'build to fail'. Maybe because it can't shutdown the simulator and is causing it to take longer?

@thanhcs you can open a new PR for that other change (and thus spin up another travis-ci job to check if it was just a one-time failure, or an on going issue)

@thanhcs
Copy link
Contributor Author

thanhcs commented May 5, 2015

@lukeis I think this code is necessary. It only runs if the simulator needs more time to shut down (1 over 10 times when I ran the tests)

You're right about failing to shut down the simulator will cause travis-CI take longer time to finish the build (even causing "build to fail" if the building time reaches 50 minutes). However, I think the problem is that there are a lot of tests needs to be fixed. Those failing tests, in my view, cause the build take longer time to finish.

What I suggest is if we can disable all of the failing tests and only enable it after we fix it.

I'm using travis-CI on my fork right now. Yes, sometimes it finishes the build, sometimes it doesn't. What I see is the failing tests run randomly (the order), and it will cause the "sometimes".

@lukeis
Copy link
Member

lukeis commented May 6, 2015

@thanhcs sounds good to me :)

@thanhcs
Copy link
Contributor Author

thanhcs commented May 6, 2015

@lukeis @mach6 👍 I think we really need to fix the tests. Around 300 tests in ios-driver package (I fixed around 100 in UICatalog) and around 500 tests in ios-selenium-tests need to be fixed.

Note that apps' behaviors are different on different Xcode versions. You can see that if you run the tests in UICatalog on Xcode 6.1 (they work fine on Xcode 6.3). Any suggestion on that issue will be great.

@lukeis
Copy link
Member

lukeis commented May 6, 2015

we should always target the latest version of xcode... even though travis-ci is behind (we need to wait for saucelabs to deploy the latest version of xcode). If we can identify the version of xcode running and mark the test skipped that fails on the earlier versions... although that sounds like a lot of busy work :)

@thanhcs
Copy link
Contributor Author

thanhcs commented May 6, 2015

That is what @mmccartney suggested when I asked him about this issue. However, if we always use the lastest version of xcode, it is not important right now. Thanks @lukeis for pointing that out.

@mach6
Copy link
Member

mach6 commented May 6, 2015

@thanhcs line 347 log.info("This device shuts down already: " + deviceUUID); ... Do you mean to say "This device is already shut down"?

@thanhcs
Copy link
Contributor Author

thanhcs commented May 6, 2015

@mach6 Yes. Sorry for my English.

To be clear, that is an reasonable assumption after waiting a certain time for the simulator to shut down. If we send a shutdown command to the simulator which is already shut down, the system will return error code 146

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.

4 participants