Start including logs in test results

This commit is contained in:
Steve Soltys 2023-10-10 22:03:41 -04:00
parent b50797fc2d
commit 8711bbeda3
4 changed files with 28 additions and 18 deletions

View file

@ -13,8 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
android_target: [33]
emulator_type: [default, google_apis]
android_target: [ 33 ]
emulator_type: [ default, google_apis ]
steps:
- name: Checkout Code
uses: actions/checkout@v3
@ -32,7 +32,7 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: aosp-${{ matrix.emulator_type }}-${{ matrix.android_target }}-${{ runner.os }}
key: avd-${{ matrix.emulator_type }}-${{ matrix.android_target }}
- name: Build Release APK
run: ./gradlew :app:assembleRelease
@ -99,14 +99,14 @@ jobs:
medium_test_exit_code=0
./gradlew --stacktrace -Pinstrumented_test_size=medium :app:connectedAndroidTest || medium_test_exit_code=$?
adb pull /sdcard/seedvault_test_videos
adb pull /sdcard/seedvault_test_results
if [ $large_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
if [ $medium_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
- name: Upload screenshots and videos
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: seedvault_test_videos
path: seedvault_test_videos/**/*.mp4
name: ${{ matrix.emulator_type }}-${{ matrix.android_target }}-results
path: seedvault_test_results/**/*

View file

@ -199,7 +199,7 @@ tasks.register('provisionEmulator', Exec) {
doFirst {
commandLine "${project.projectDir}/development/scripts/provision_emulator.sh",
"seedvault",
"system-images;android-33;google_apis;x86_64"
"system-images;android-33;default;x86_64"
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
environment "JAVA_HOME", System.properties['java.home']

View file

@ -44,7 +44,7 @@ internal interface LargeTestBase : KoinComponent {
companion object {
private const val TEST_STORAGE_FOLDER = "seedvault_test"
private const val TEST_VIDEO_FOLDER = "seedvault_test_videos"
private const val TEST_VIDEO_FOLDER = "seedvault_test_results"
}
val externalStorageDir: String get() = Environment.getExternalStorageDirectory().absolutePath
@ -106,19 +106,23 @@ internal interface LargeTestBase : KoinComponent {
uiAutomation.executeShellCommand(command).close()
}
fun testResultFilename(testName: String): String {
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
return "${timeStamp}_${testName.replace(" ", "_")}"
}
@OptIn(DelicateCoroutinesApi::class)
@WorkerThread
suspend fun startScreenRecord(
suspend fun startRecordingTest(
keepRecordingScreen: AtomicBoolean,
testName: String,
) {
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
val fileName = "${timeStamp}_${testName.replace(" ", "_")}"
val folder = testVideoPath
runCommand("mkdir -p $folder")
val fileName = testResultFilename(testName)
// screen record automatically stops after 3 minutes
// we need to block on a loop and split it into multiple files
GlobalScope.launch(Dispatchers.IO) {
@ -131,10 +135,16 @@ internal interface LargeTestBase : KoinComponent {
}
@WorkerThread
fun stopScreenRecord(keepRecordingScreen: AtomicBoolean) {
fun stopRecordingTest(
keepRecordingScreen: AtomicBoolean,
testName: String,
) {
keepRecordingScreen.set(false)
runCommand("pkill -2 screenrecord")
// write logcat to file
val fileName = testResultFilename(testName)
runCommand("logcat -d -f $testVideoPath/$fileName.log")
}
fun uninstallPackages(packages: Collection<PackageInfo>) {

View file

@ -38,13 +38,13 @@ internal abstract class SeedvaultLargeTest :
resetApplicationState()
clearTestBackups()
startScreenRecord(keepRecordingScreen, name.methodName)
startRecordingTest(keepRecordingScreen, name.methodName)
restoreBaselineBackup()
}
@After
open fun tearDown() {
stopScreenRecord(keepRecordingScreen)
stopRecordingTest(keepRecordingScreen, name.methodName)
}
/**