diff --git a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java index 4611d9ab7..776d1ebd1 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java @@ -1039,18 +1039,23 @@ public TestCaseExecutionFile recordHar(TestCaseExecution execution, JSONObject h return null; } - try { + if ((execution.getRobotLog() == 2 || (execution.getRobotLog() == 1 && !execution.getControlStatus().equals("OK"))) + && parameterService.getParameterBooleanByKey("cerberus_executionloghar_enable", execution.getSystem(), true)) { - // RESULT. - Recorder recorder = this.initFilenames(execution.getId(), null, null, null, null, null, null, null, 0, "enriched_har", "json", false); - recordFile(recorder.getFullPath(), recorder.getFileName(), har.toString(1), execution.getSecrets()); + try { - // Index file created to database. - object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Network HAR File", recorder.getRelativeFilenameURL(), "JSON", "", null, "", null); - testCaseExecutionFileService.save(object); + // RESULT. + Recorder recorder = this.initFilenames(execution.getId(), null, null, null, null, null, null, null, 0, "enriched_har", "json", false); + recordFile(recorder.getFullPath(), recorder.getFileName(), har.toString(1), execution.getSecrets()); + + // Index file created to database. + object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Network HAR File", recorder.getRelativeFilenameURL(), "JSON", "", null, "", null); + testCaseExecutionFileService.save(object); + + } catch (Exception ex) { + LOG.error(ex.toString(), ex); + } - } catch (Exception ex) { - LOG.error(ex.toString(), ex); } return object; diff --git a/source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java b/source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java index 7c078aeaf..19ecf7054 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java @@ -1160,15 +1160,11 @@ public boolean stopServer(TestCaseExecution tce) { testCaseExecutionHttpStatService.create(answHttpStat.getItem()); - // Log Execution - if ((tce.getVerbose() > 0) - && !tce.getControlStatus().equals(TestCaseExecution.CONTROLSTATUS_OK) - && parameterService.getParameterBooleanByKey("cerberus_executionloghar_enable", tce.getSystem(), true)) { - try { - tce.addFileList(recorderService.recordHar(tce, har)); - } catch (Exception ex) { - LOG.error("Exception Saving Har Files " + tce.getId(), ex); - } + // Log Full HAR Network Execution + try { + tce.addFileList(recorderService.recordHar(tce, har)); + } catch (Exception ex) { + LOG.error("Exception Saving Har Files " + tce.getId(), ex); } } catch (Exception ex) { diff --git a/source/src/main/resources/database.sql b/source/src/main/resources/database.sql index fd08745bf..be5c43e15 100644 --- a/source/src/main/resources/database.sql +++ b/source/src/main/resources/database.sql @@ -6560,4 +6560,6 @@ ALTER TABLE `robot` ADD COLUMN `AcceptNotifications` TINYINT(1) NULL DEFAULT 0 A INSERT INTO `parameter` (`system`, `param`, `value`, `description`) VALUES ('', 'cerberus_executionloghar_enable', 'false', 'Enable saving of har file at the end of non OK executions.'); +-- 1859 +UPDATE parameter SET description='Enable saving of har file at the end of executions (robotlog=2 for all executions or robotlog=1 for all non OK executions).' WHERE param='cerberus_executionloghar_enable';