Closed tomholub closed 3 years ago
I'm pulling this out into an issue - maybe can add ./script/compile.sh
or something similar. Either that, or update the readme - this is useful to know.
I'd say test.sh
There's a trouble with running tests inside the cloud Linux VM according to Den's instructions:
> Task :FlowCrypt:connectedDevTestDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':FlowCrypt:connectedDevTestDebugAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!
I just can't run native x86 Android emulator.
Unfortunately, your computer does not support hardware accelerated virtualization.
Here are some of your options:
1) Use a physical device for testing
2) Develop on a Windows/OSX computer with an Intel processor that supports VT-x and NX
3) Develop on a Linux computer that supports VT-x or SVM
4) Use an Android Virtual Device based on an ARM system image
(This is 10x slower than hardware accelerated virtualization)
Will try ARM one - looks like the only option.
The other option is to purchase dedicated physical box for Linux -$500 min for something reasonable (Core i5 Mobile, 16GB, SSD) - did not plan to do that.
But tests run in the CI. How is that possible? Does CI use physical machines?
CI supports virtualization. We can run x86 emulators
I'd say test.sh
Actually, you just print all tests. I think it'll be better to call it print-all-tests.sh.
@DenBond7 I've found that there's already a script named run-all-test.sh
with a following content:
./gradlew --console=verbose :FlowCrypt:connectedDevTestDebugAndroidTest
Isn't this the same?
You've added -Pandroid.testInstrumentationRunnerArguments.log=true
. What does it mean?
Maybe just update that script and add this extra option?
Found something about "nested virtualization" - will try to enable it on the VM. But meanwhile trying the ARM image.
Hmm... no luck with ARM either...
The emulator process for AVD ARM_Nexus_S_API_S was killed.
seems like need to try that "nested virtualization"
@IvanPizhenko
Isn't this the same?
Almost the same. run-all-test.sh
runs all tests. print-all-tests.sh
should be just print all tests.
You've added -Pandroid.testInstrumentationRunnerArguments.log=true. What does it mean?
From here
To run in 'log only' mode -e log true This option will load and iterate through all test classes and methods, but will bypass actual test execution. Useful for quickly obtaining info on the tests to be executed by an instrumentation command.
Maybe just update that script and add this extra option?
Yes, we can do that.
Hmm... no luck with ARM either...
The emulator process for AVD ARM_Nexus_S_API_S was killed.
seems like need to try that "nested virtualization"
@IvanPizhenko Please look at this line
That's how we enable virtualization.
I am talking about enabling nested virtualization in the VM settings. At the moment VM itself does not support it. Android studio has already installed emulator but it cannot be used because no any virtualization available in the my Linux VM.
I'd rather need to do something like this https://stackoverflow.com/questions/53931366/how-to-enable-nested-virtualization-on-an-existing-google-cloud-vm-instance/53934114
@IvanPizhenko are you in fact on Windows, and running a linux box in a VM itself? Is it VMWare or something else?
That would indeed explain why you cannot easily virtualize. Our CI most likely runs Ubuntu in a VM on top of Ubuntu, that may be a different situation than what you are doing, since they may be using different software to virtualize their host Ubuntu system.
I'm thinking, if you are on Windows it may be more worthwhile to focus on #1076 which would allow you to skip these nested virtualization issues.
I am currently using GCloud instance. I'd like to use VirtualBox locally, but things like IntellIJ are just very slow in it (the host system is laptop with 2nd generation Core i7 and 16GB memory purchased back in the 2011, I'd like to upgrade, but that can't be done immediately). So I think it is now faster to just recreate instance with nested virtualization enabled than solve #1076. Another problem with Windows is that tests use Docker. Docker on Windows requires WSL2, and WSL2 works bad with VirtualBox, which I have to use for some other stuff. So in sense of running tests Windows unfortunately is not a variant for me.
In that case, you may be able to follow the semaphore.yml
file more or less step by step to get tests working there.
Just recreated VM with nested virtualization, started AVD via AVD Manger and it just works. Just if someone else needs to do the same - one extra step is to add your Linux user into the group kvm.
@IvanPizhenko
It was compilation issues. To prevent such an issue you can use 2 ways (for both way you have to have at least 1 connected device - an emulator or a real device):
If that task passes there are no compilation issues
./gradlew clean :FlowCrypt:connectedDevTestDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.log=true
. If the task fails you will see compilation errors like thisOriginally posted by @DenBond7 in https://github.com/FlowCrypt/flowcrypt-android/issues/1102#issuecomment-803872204