Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Add Test Orchestrator support. #90

Closed
artem-zinnatullin opened this issue Jul 27, 2017 · 24 comments · Fixed by #157
Closed

Add Test Orchestrator support. #90

artem-zinnatullin opened this issue Jul 27, 2017 · 24 comments · Fixed by #157
Assignees
Milestone

Comments

@artem-zinnatullin
Copy link
Collaborator

You can trick Composer to work with Orchestrator right now, but more official solution would be better.

Also, as we've measured in #66 instrumenting each test separately can add 3-5 seconds overhead for each test which can be unacceptable for those who run them frequently (each PR/commit), but we need to actually measure this with Orchestrator.

See:

@artem-zinnatullin
Copy link
Collaborator Author

@ming13 any additions here since you've tried Orchestrator? I am also curious about test run duration in compare to regular am instrumentation.

@arturdryomov
Copy link
Member

Okay, I’m doing everything manually from the command line.

$ adb install -r app.apk
$ adb install -r test.apk

$ adb install -r orchestrator.apk
$ adb install -r test-services.apk

Just instrument

adb shell "am instrument -r -w \
  -e package com.gojuno.actually.some.package \
  com.gojuno.rider.test/android.support.test.runner.JunoAndroidRunner"
  • There is instrument output.
  • Final result — OK (21 tests), INSTRUMENTATION_CODE: -1.
  • Time — 5 runs in 760 seconds.

Orchestrator

adb shell 'CLASSPATH=$(pm path android.support.test.services) app_process / \
  android.support.test.services.shellexecutor.ShellMain am instrument -r -w \
  -e package com.gojuno.actually.some.package \
  -e targetInstrumentation com.gojuno.rider.test/android.support.test.runner.JunoAndroidRunner \
  android.support.test.orchestrator/.AndroidTestOrchestrator'
  • There is no instrument output.
    • The only thing gets printed after finished run — INSTRUMENTATION_RESULT: stream=.
  • Final result — OK (0 tests), INSTRUMENTATION_CODE: 0.
    • Please notice that tests were executed just fine.
  • Time — 5 runs in 591 seconds (SURPRISE).

BTW.

-e numShards and -e shardIndex runner arguments aren't currently supported

Links:

@arturdryomov
Copy link
Member

I’ll file the issue about missing instrument output (maybe) tomorrow.

@artem-zinnatullin
Copy link
Collaborator Author

Very interesting to see that it took THAT less time. I suspect that not all tests were run

@artem-zinnatullin
Copy link
Collaborator Author

Great, please crosslink this issue with instrumentation output issue in Google bugtracker!

@arturdryomov
Copy link
Member

Very interesting to see that it took THAT less time. I suspect that not all tests were run

I actually counted them visually and they all were here.

@arturdryomov
Copy link
Member

Here we go — https://issuetracker.google.com/issues/64486480

@artem-zinnatullin
Copy link
Collaborator Author

You probably better copy "steps to reproduce" there as well

@handstandsam
Copy link
Contributor

@artem-zinnatullin - You mentioned there is a way to currently trick composer into using the test orchestrator? What is that trick?

I have been able to run my tests with the orchestrator via adb shell like @ming13 did, but haven't figured out how to do it via Composer. Thanks!

@artem-zinnatullin
Copy link
Collaborator Author

Unfortunately since adb shell am command is really different with Orchestrator there is no way to "trick" Composer to use Orchestrator, also it's unclear from https://issuetracker.google.com/issues/64486480 and release notes if they fixed instrumentation output of Orchestrator or not.

Once they fix it, we can start implementing support for Orchestrator :)

@yunikkk
Copy link
Contributor

yunikkk commented Oct 25, 2017

I've just tried the latest version of test libs and discovered that it writes xml reports to the sdcard /sdcard/odo/*, eg.

<?xml version='1.0' encoding='UTF-8' ?>
<testsuite name="" tests="6" failures="0" errors="0" skipped="1" time="25.982" timestamp="2017-10-25T23:22:20" hostname="localhost">
  <properties />
  <testcase name="testAboutAndCheckUpdates" classname="com.gojuno.driver.robotPattern.tests.menu.about.AboutUITest" start-time="1508973716.203" end-time="1508973718.141" time="1.938" />
  <testcase name="testCommonHelp" classname="com.gojuno.driver.robotPattern.tests.menu.account.help.HelpForAuthorizedUserUITest" start-time="1508973720.870" end-time="1508973723.102" time="2.232" />
  <testcase name="testMoreOptions" classname="com.gojuno.driver.robotPattern.tests.menu.account.help.HelpForAuthorizedUserUITest" start-time="1508973725.621" end-time="1508973728.267" time="2.646" />
  <testcase name="testHelpContactDataAreDisplayed" classname="com.gojuno.driver.robotPattern.tests.menu.account.help.HelpForUnauthorizedUserUITest" start-time="1508973730.770" end-time="1508973731.869" time="1.099" />
  <testcase name="testErrorOnCheckForUpdatesIsDisplayed" classname="com.gojuno.driver.robotPattern.tests.unauthorized.LoginWithOldAppVersionTest" start-time="1508973734.374" end-time="0.000" time="-1.508973734374E9">
    <skipped />
  </testcase>
  <testcase name="testADSHardBlockScreenIsDisplayed" classname="com.gojuno.driver.robotPattern.tests.unauthorized.LoginWithOldAppVersionTest" start-time="1508973736.861" end-time="1508973739.655" time="2.794" />
</testsuite>

@artem-zinnatullin
Copy link
Collaborator Author

Well we can hook into that, but that won't be "reactive", instrumentation output is printed asap, but I bet JUnit report only appears after test run

start-time="1508973734.374" end-time="0.000" time="-1.508973734374E9"

lol wut

@yunikkk
Copy link
Contributor

yunikkk commented Oct 27, 2017

Yup, reports appears only after run, checked that.
Also, sharding seems to be working, too.

@yunikkk
Copy link
Contributor

yunikkk commented Oct 27, 2017

start-time="1508973734.374" end-time="0.000" time="-1.508973734374E9"
its for ignored test =)

@originx
Copy link

originx commented Mar 7, 2018

any news on this issue, is it possible to implement it with current version of orchestrator.

Btw have you ever considered JUnit listeners, or piggybacking on existing ones:
https://android.googlesource.com/platform/frameworks/testing/+/3352c37/androidtestlib/src/com/android/test/runner/listener/

?

@yunikkk
Copy link
Contributor

yunikkk commented Mar 8, 2018

Well, I haven't tried since October, will need to recheck status of issues we faced.

Regarding listeners - to use them we'll need to run tests with our own customized TestRunner, I guess. That will broke cases for the users who implements their own runners in the test apk. Not sure if there is a workaround...
@artem-zinnatullin wdyt about listeners & runner?

@originx
Copy link

originx commented Mar 8, 2018

you can add the listeners to the existing test runner:
To specify one or more RunListeners to observe the test run: -e listener com.foo.Listener,com.foo.Listener2
https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html

there is also a possibility to add them in manifest or via gradle configuration ie. instrumentation arguments.

or in the end you can go like spoon did and provide the customized testrunner via the gradle plugin:
https://github.com/square/spoon/tree/master/spoon-runner/src/main/java/com/squareup/spoon

but I think it is a safer way to go compared to the bash output from the instrumentation process?

@trevjonez
Copy link

even if they use the listener interface they still need to communicate back to the host machine for report generation. parsing instrumentation process output is tedious and perhaps fragile from the maintenance perspective but the next obvious communication medium for streaming the data back to the host would be some sort of network connection from the device which can probably be statistically proven as a large source of flake if any data was tracked/analyzed.

perhaps if not a network connection the listener would write to a file on device that could then be tailed over adb on the host?

Other than being able to control the communication format I don't see a huge value to doing it that way.

@artem-zinnatullin
Copy link
Collaborator Author

artem-zinnatullin commented Mar 14, 2018 via email

@evgengal
Copy link

Any news on this issue?

@artem-zinnatullin
Copy link
Collaborator Author

Last related PR: #138

However Google is working on Nitrogen that overlaps with Composer functionality which might affect our plans

@evgengal
Copy link

Do you mean Nitrogen OS?

@dsvoronin
Copy link
Contributor

Nope, "Project nitrogen" announced on IO https://www.youtube.com/watch?v=wYMIadv9iF8

@CristianGM
Copy link
Contributor

@artem-zinnatullin If the year ends without Google releasing Nitrogen ( it wouldn't be the first time, thats why usually they don't say dates ) all devs using Orchestrator will have wasted a year without Composer ( so, having a good sharding and report ).

I don't get the answer saying Nitrogen might affect Composer plans, is like abandoning the project just because eventually there will be something better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants