MarathonLabs / marathon

Cross-platform test runner

Home Page:https://docs.marathonlabs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

com.malinskiy.marathon.exceptions.TransferException when trying to pull an empty text file from device.

IosephKnecht opened this issue · comments

Describe the bug
When pulling allure reports using allureConfiguration { enabled = true } a TransferException occurs if there are one or more empty files in the reports folder.

To Reproduce
Steps to reproduce the behaviour:

  1. extract zip with project marathon-transfer-exception-playground-main.zip
  2. execute in terminal from project folder ./gradlew :app:marathonDebugAndroidTest
  3. see output there will be something like this:
com.malinskiy.marathon.exceptions.TransferException: Couldn't pull file /data/local/tmp/files/allure-results/f56a8e79-1a62-492b-b67a-15677ac66971-attachment.txt from device 127.0.0.1:5037:emulator-5554
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice.pullFile(AdamAndroidDevice.kt:173)
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice$pullFile$1.invokeSuspend(AdamAndroidDevice.kt)
	at ���(Coroutine boundary.�(�)
	at kotlinx.coroutines.TimeoutKt.withTimeoutOrNull(Timeout.kt:100)
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice.pullFolder(AdamAndroidDevice.kt:251)
	at com.malinskiy.marathon.android.BaseAndroidDevice.safePullFolder$suspendImpl(BaseAndroidDevice.kt:145)
	at com.malinskiy.marathon.android.executor.listeners.filesync.FileSyncTestRunListener.afterTestRun(FileSyncTestRunListener.kt:127)
	at com.malinskiy.marathon.android.executor.listeners.CompositeTestRunListener.afterTestRun(CompositeTestRunListener.kt:52)
	at com.malinskiy.marathon.android.adam.AndroidDeviceTestRunner.execute(AndroidDeviceTestRunner.kt:95)
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice$execute$2$1.invokeSuspend(AdamAndroidDevice.kt:391)
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice$execute$2.invokeSuspend(AdamAndroidDevice.kt:389)
Caused by: com.malinskiy.marathon.exceptions.TransferException: Couldn't pull file /data/local/tmp/files/allure-results/f56a8e79-1a62-492b-b67a-15677ac66971-attachment.txt from device 127.0.0.1:5037:emulator-5554
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice.pullFile(AdamAndroidDevice.kt:173)
	at com.malinskiy.marathon.android.adam.AdamAndroidDevice$pullFile$1.invokeSuspend(AdamAndroidDevice.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Expected behavior
Empty files are successfully pulled into the output directory from devices.

Logs and reports
marathon_debug_android_test.log
marathon-transfer-exception-playground-main.zip
marathon-transfer-exception-playground-main.zip

Devices (please complete the following information):

  • Device: Emulator
  • OS: Android 11

Additional context

  • Reproduced on marathon versions 0.7.6/0.8.0
  • Bug leads to absence of test cases in the final allure report.

Hey @IosephKnecht
AFAIK the empty file will just produce a warning but won't affect the execution flow. Why does the absence of an empty file influence the allure report? Do you think this is an issue with marathon or with allure?

I'm not sure what's the value of pulling/creating empty files, happy to discuss. This shouldn't be a hard problem to fix, but marathon tries to save the pulling time by not doing "stat" on the filesystem for each and every file so that we don't end up with 2 requests per file pull

Hey @Malinskiy
It seems that I am really wrong here. Absence of an attachment file in {uuid}-result.json indeed will not prevent the generation of allure report. I double-checked the example, it turned out that if there is an empty attachment file, allure report {uuid}-result.json itself is not pulled, hence the losses in the final report of the test cases.

However, the bug itself is floating, it can be reproduced if there are several tests and empty attachments are attached. At the same time, allure report files are not always lost, it may be that the report will be unloaded, but without attachments (which were not empty).

How is this related to empty attachments? To be honest, I don't know, but we managed to minimize loss of allure reports on CI by putting the text in our potential empty attachment.

In any case, I updated the example and also attach:

  • logs of one of the test runs -> logs
  • results from the reports folder reports.zip
  • report (also available in the archive)

Screen Shot 2023-04-21 at 10 26 15

This may be a problem with pullFolder method rather than pullFile. Maybe presence of an empty file produces an exception and this will trigger failure of pullFolder which means not everything will be pulled including files that are non-empty. Let me investigate this a bit, I'll get back to you

I've found the culprit. Should be in the 0.8.2

@Malinskiy Great. Thanks.