Skip to content

Commit

Permalink
Change criteria on save of HAR file to robot tab (same rule as Seleni…
Browse files Browse the repository at this point in the history
…um logs).
  • Loading branch information
vertigo17 committed Oct 30, 2024
1 parent 94de8ec commit 7ee57f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions source/src/main/resources/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 7ee57f2

Please sign in to comment.