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

Running several tests simultaneously on the same machine can lead to errors #209

Open
artikz opened this issue Mar 26, 2017 · 15 comments
Open

Comments

@artikz
Copy link

artikz commented Mar 26, 2017

For example, let's have the following sequence of statements executed in the given order in two different processes:

Process 1: device = uiautomator.Device(serial="1")
Process 2: device = uiautomator.Device(serial="2")
Process 1: device.screen.on()
Process 2: device.screen.on()

After this both processes will be attached to the same device "2", because local_port calculated in AutomatorServer.init() is not used until AutomatorServer.start(), and there is no way for process 2 to know that the port is already used when it selects it.

In addition adb forward will silently rebind port by default without returning an error, so neither of the processes will know that it talks to incorrect device.

@artikz
Copy link
Author

artikz commented Mar 26, 2017

I've sent a pull request that should fix this issue: #208

@codeskyblue
Copy link

Just tested, everything works fine.

@artikz
Copy link
Author

artikz commented Mar 26, 2017

Do you mean that you can't reproduce the problem?

@codeskyblue
Copy link

codeskyblue commented Mar 26, 2017

yes, I also read the code, nothing need to change, I think.

@artikz
Copy link
Author

artikz commented Mar 27, 2017

This is how to reproduce it:

  1. connect 2 devices to a computer

  2. copy the scripts and put correct device's serials in placeholders:

test1.py: https://gist.github.com/artikz/c4e9d87820f9dad2a4bacab11a45692b
test2.py: https://gist.github.com/artikz/af3d7feb4706d7b7c8203fec0b5a900a

They just initialize uiautomator.Device() and take screenshot in 60 seconds after initialization.

  1. make sure that you don't have any adb port forwarding set up (if you have, then it will trigger another flow in uiautomator code and will work correctly):

$ adb forward --remove-all

  1. start test1.py in one terminal and after a few seconds start test2.py in another terminal

  2. see that they take screenshot of the same device, also check output of:

$ adb forward --list

You'll see that there is only one forward set up.

@codeskyblue
Copy link

Maybe you can try my fork version https://github.com/openatx/atx-uiautomator but I remember I did not change the code related to adb forward.

@siva-kranthi
Copy link

We also faced similar issue while executing on 2 devices simultaneously

@artikz
Copy link
Author

artikz commented Mar 27, 2017

@codeskyblue, reproduced it with your fork as well

@codeskyblue
Copy link

@artikz finally, I meet the same problem, like you. try to fix it tomorrow.

@artikz
Copy link
Author

artikz commented Apr 13, 2017

The fix is here: #208

@codeskyblue
Copy link

I see that pr, very good code with lot of test codes, I just need a little change in order to use in atx-uiautomator

@siva-kranthi
Copy link

Still we are observing some issues in CI executions even after using @artikz fix. Need to debug

@artikz
Copy link
Author

artikz commented Apr 13, 2017

@SivaKranthiKumar, what issues do you see? Same as here? (I.e., test talks to incorrect device)

@siva-kranthi
Copy link

siva-kranthi commented Apr 13, 2017

Yeah. Other device operations were happening in some other device. But didn't debug them yet. We did apply your fix

@artikz
Copy link
Author

artikz commented Apr 13, 2017

This is interesting. If you will be able to understand why it didn't work, please, let me know

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

No branches or pull requests

3 participants