diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/Scanner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/Scanner.java index b52aeceec..7377fe08f 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/Scanner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/Scanner.java @@ -29,15 +29,26 @@ public void execute(AnalysisTask analysisTask, TestRun testRun) throws Exception T report = initReport(analysisTask); report.setTaskId(analysisTask.getId()); report.setTaskRunId(testRun.getId()); + + testRun.setTotalCount(analysisTask.getAnalysisConfigs().size()); for (AnalysisTask.AnalysisConfig config : analysisTask.getAnalysisConfigs()) { String analysisType = config.getAnalysisType(); - if (AnalysisTask.AnalysisType.LEAK_INFO.name().equals(analysisType)) { - report = scanSensitiveWords(report, analysisTask.getAppFile(), testRun.getResultFolder(), config, testRun.getLogger()); - } else if (AnalysisTask.AnalysisType.FILE_SIZE.name().equals(analysisType)) { - report = analysisPackage(report, analysisTask.getAppFile(), testRun.getResultFolder(), config, testRun.getLogger()); + try { + if (AnalysisTask.AnalysisType.LEAK_INFO.name().equals(analysisType)) { + report = scanSensitiveWords(report, analysisTask.getAppFile(), testRun.getResultFolder(), config, testRun.getLogger()); + } else if (AnalysisTask.AnalysisType.FILE_SIZE.name().equals(analysisType)) { + report = analysisPackage(report, analysisTask.getAppFile(), testRun.getResultFolder(), config, testRun.getLogger()); + } else { + testRun.oneMoreFailure(); + testRun.getLogger().error("Unsupported analysis type: " + analysisType); + } + } catch (Exception e) { + testRun.oneMoreFailure(); + testRun.getLogger().error("Failed to execute analysis task: " + analysisTask.getId() + " with analysis type: " + analysisType, e); } } testRun.setTaskResult(report); + testRun.setSuccess(testRun.getFailCount() == 0); } abstract T initReport(AnalysisTask task); diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkAnalyzeExecutor.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkAnalyzeExecutor.java index 5a2481bb1..6c6397e75 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkAnalyzeExecutor.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkAnalyzeExecutor.java @@ -76,18 +76,20 @@ public ApkReport analyzeApk(ApkReport report, String apkPath, Logger logger) { sizeInMB = (float) Math.round(sizeInMB * 100) / 100; report.getApkSizeReport().setDownloadSizeInMB(sizeInMB); + return report; } catch (Exception e) { logger.info("failed to get download size"); + throw new RuntimeException(e); } } - logger.error("error in apk analyzer: {}", error); - + logger.error("failed to get download size, code: {}, error: {}", code, error); + throw new RuntimeException(error); } catch (InterruptedException e) { logger.error("Interrupted in APK analyser", e); + throw new RuntimeException(e); } catch (IOException e) { logger.error("error in APK analyser", e); + throw new RuntimeException(e); } - return report; } - } diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkCanaryExecutor.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkCanaryExecutor.java index f5a159aca..c04bc0432 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkCanaryExecutor.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkCanaryExecutor.java @@ -160,12 +160,14 @@ public ApkReport analyzeApk(ApkReport report, String apkPath, Logger logger) { return getApkReportFromJsonReport(report, reportFile); } logger.info(error); + throw new RuntimeException(error); } catch (InterruptedException e) { logger.error("Interrupted in analyzeApk", e); + throw new RuntimeException(e); } catch (IOException e) { logger.error("error in analyzeApk", e); + throw new RuntimeException(e); } - return report; } public static ApkReport getApkReportFromJsonReport(ApkReport apkReport, File file) { diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkLeaksExecutor.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkLeaksExecutor.java index 9b8453672..bde6cf820 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkLeaksExecutor.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/analysis/scanner/apk/ApkLeaksExecutor.java @@ -124,12 +124,14 @@ public ApkReport analyzeLeaks(ApkReport report, String apkPath, Map getTaskStatus(@CurrentSecurityContext SysUser requestor, // if (!sysUserService.checkUserAdmin(requestor) && !userTeamManagementService.checkRequestorTeamRelation(requestor, testTask.getTeamId())) { // return Result.error(HttpStatus.UNAUTHORIZED.value(), "Unauthorized, the TestTask doesn't belong to user's Teams"); // } + task.setDeviceTestResults(task.getTaskRunList()); return Result.ok(task); } TestTaskQueuedInfo queuedInfo = testTaskService.getTestQueuedInfo(testId); diff --git a/center/src/main/java/com/microsoft/hydralab/center/service/TestDataService.java b/center/src/main/java/com/microsoft/hydralab/center/service/TestDataService.java index 55073cbd6..2ffba72a4 100644 --- a/center/src/main/java/com/microsoft/hydralab/center/service/TestDataService.java +++ b/center/src/main/java/com/microsoft/hydralab/center/service/TestDataService.java @@ -196,11 +196,21 @@ public void saveTaskDataFromAgent(Task task, boolean persistence, String agentId @CachePut(key = "#task.id") public Task saveTaskData(Task task) { - taskRepository.save(task); List deviceTestResults = task.getTaskRunList(); if (deviceTestResults.isEmpty()) { + task.setSucceed(false); + taskRepository.save(task); return task; } + boolean isSuccess = true; + for (TestRun deviceTestResult : deviceTestResults) { + if (!deviceTestResult.isSuccess()) { + isSuccess = false; + break; + } + } + task.setSucceed(isSuccess); + taskRepository.save(task); testRunRepository.saveAll(deviceTestResults); diff --git a/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java b/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java index 45cf295ce..42ac0a0b6 100644 --- a/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java +++ b/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java @@ -84,10 +84,11 @@ public class Task implements Serializable { private String notifyUrl; @Transient private boolean disableRecording = false; + @Column(columnDefinition = "boolean default false") + private boolean isSucceed = false; @Transient - @Deprecated - private List deviceTestResults = taskRunList; + private List deviceTestResults; public synchronized void addTestedDeviceResult(TestRun deviceTestResult) { taskRunList.add(deviceTestResult); diff --git a/react/src/component/TasksView.jsx b/react/src/component/TasksView.jsx index 60732ad9d..bdcbd4390 100644 --- a/react/src/component/TasksView.jsx +++ b/react/src/component/TasksView.jsx @@ -702,15 +702,15 @@ class TasksView extends BaseView { if (this.state.selectedParams.Result.length < 2) { if (this.state.selectedParams.Result.includes('Passed')) { queryParams.push({ - "key": "totalFailCount", + "key": "isSucceed", "op": "equal", - "value": 0 + "value": 1 }) } if (this.state.selectedParams.Result.includes('Failed')) { queryParams.push({ - "key": "totalFailCount", - "op": "gt", + "key": "isSucceed", + "op": "equal", "value": 0 }) }