|
@@ -7,6 +7,7 @@ import net.mooctest.www.android_auto_test.common.constant.enums.DeviceStatus;
|
|
|
import net.mooctest.www.android_auto_test.models.Device;
|
|
|
import net.mooctest.www.android_auto_test.services.ApkService;
|
|
|
import net.mooctest.www.android_auto_test.services.DeviceService;
|
|
|
+import net.mooctest.www.android_auto_test.services.TraceService;
|
|
|
import net.mooctest.www.android_auto_test.utils.*;
|
|
|
import net.mooctest.www.android_auto_test.vo.TraceMetaInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,11 +35,14 @@ public class MyApplicationRunner implements ApplicationRunner {
|
|
|
@Autowired
|
|
|
ApkService apkService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ TraceService traceService;
|
|
|
+
|
|
|
@Value("${poll-tasks}")
|
|
|
private boolean pollTasks;
|
|
|
|
|
|
@Override
|
|
|
- public void run(ApplicationArguments args) throws Exception {
|
|
|
+ public void run(ApplicationArguments args){
|
|
|
if (!pollTasks){
|
|
|
return;
|
|
|
}
|
|
@@ -64,7 +68,7 @@ public class MyApplicationRunner implements ApplicationRunner {
|
|
|
|| traceMetaInfo.getTraceId() == null){
|
|
|
PrintUtil.print("No trace task, free device, continue.", TAG, device.getUdid());
|
|
|
boolean t = deviceService.freeDevice(device.getUdid());
|
|
|
- if (!r){
|
|
|
+ if (!t){
|
|
|
PrintUtil.printErr("释放Device, 这个路径不会被触发。", TAG, device.getUdid());
|
|
|
}
|
|
|
continue;
|
|
@@ -89,7 +93,7 @@ public class MyApplicationRunner implements ApplicationRunner {
|
|
|
if (!haveDownloadApkFile){
|
|
|
PrintUtil.print("This is first task, save apkInfo.", TAG, device.getUdid());
|
|
|
apkService.saveApkInfo(apkInfo, apkPath, traceId);
|
|
|
- apkService.updateTraceStartTime(traceId);
|
|
|
+ traceService.updateTraceStartTime(traceId);
|
|
|
}
|
|
|
// 启动测试线程
|
|
|
PrintUtil.print("Start test thread and update device status", TAG, device.getUdid());
|
|
@@ -98,8 +102,8 @@ public class MyApplicationRunner implements ApplicationRunner {
|
|
|
coverageTest.setName(Consts.AUTO_TEST_THREAD_NAME_PREFIX + device.getUdid());
|
|
|
oneTraceTasks.add(coverageTest);
|
|
|
// CAS更新Device状态,OCCUPY -> RUNNING
|
|
|
- deviceService.startRunDevice(device.getUdid());
|
|
|
- if (!r){
|
|
|
+ boolean t = deviceService.startRunDevice(device.getUdid());
|
|
|
+ if (!t){
|
|
|
PrintUtil.printErr("开始Device任务, 这个路径不会被触发。", TAG, device.getUdid());
|
|
|
}
|
|
|
coverageTest.start();
|