From 9eb821b3e44b276152fb2ab58dabdc7a4e687cad Mon Sep 17 00:00:00 2001 From: Tristan Chuine Date: Mon, 6 Nov 2023 16:29:55 +0100 Subject: [PATCH] Add aggregation for new log line --- .../server/reports/ReportMapperCourcirc.java | 20 ++++++++++ .../resources/reporter_courcirc_modified.json | 40 +++++++++++++++++++ .../resources/reporter_courcirc_test.json | 27 +++++++++++++ 3 files changed, 87 insertions(+) diff --git a/src/main/java/org/gridsuite/shortcircuit/server/reports/ReportMapperCourcirc.java b/src/main/java/org/gridsuite/shortcircuit/server/reports/ReportMapperCourcirc.java index 81e3574d..d51de28a 100644 --- a/src/main/java/org/gridsuite/shortcircuit/server/reports/ReportMapperCourcirc.java +++ b/src/main/java/org/gridsuite/shortcircuit/server/reports/ReportMapperCourcirc.java @@ -102,6 +102,10 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) { ReportWrapper logsTransientReactanceTooLowSummary = null; TypedValue logsTransientReactanceTooLowSeverity = null; + long logsTransientReactanceUndefinedCount = 0L; + ReportWrapper logsTransientReactanceUndefinedSummary = null; + TypedValue logsTransientReactanceUndefinedSeverity = null; + long logsSimulatingShortCircuitLocatedCount = 0L; ReportWrapper logsSimulatingShortCircuitLocatedSummary = null; TypedValue logsSimulatingShortCircuitLocatedSeverity = null; @@ -121,6 +125,15 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) { } copyReportAsTrace(newReporter, report); logsTransientReactanceTooLowCount++; + } else if (StringUtils.endsWith(report.getDefaultMessage(), " : transient reactance undefined ==> generator ignored")) { + //we match line "X.ABCDEF2 : transient reactance undefined ==> generator ignored" + if (logsTransientReactanceUndefinedSummary == null) { + logsTransientReactanceUndefinedSummary = new ReportWrapper(); + newReporter.report(logsTransientReactanceUndefinedSummary); + logsTransientReactanceUndefinedSeverity = report.getValue(Report.REPORT_SEVERITY_KEY); + } + copyReportAsTrace(newReporter, report); + logsTransientReactanceUndefinedCount++; } else if (StringUtils.startsWith(report.getDefaultMessage(), "Simulating : short-circuit located on node ")) { //we match line "Simulating : short-circuit located on node .BRIDGE_0" if (logsSimulatingShortCircuitLocatedSummary == null) { @@ -153,6 +166,13 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) { Map.of(Report.REPORT_SEVERITY_KEY, ObjectUtils.defaultIfNull(logsTransientReactanceTooLowSeverity, TypedValue.WARN_SEVERITY), "nb", new TypedValue(logsTransientReactanceTooLowCount, TypedValue.UNTYPED)))); } + log.debug("Found {} lines in courcirc logs matching \"MYNODE : transient reactance undefined ==> generator ignored\"", logsTransientReactanceUndefinedCount); + if (logsTransientReactanceUndefinedSummary != null) { + logsTransientReactanceUndefinedSummary.setReport(new Report("transientReactanceUndefinedSummary", + "${nb} node(s) with transient reactance undefined ==> generator ignored", + Map.of(Report.REPORT_SEVERITY_KEY, ObjectUtils.defaultIfNull(logsTransientReactanceUndefinedSeverity, TypedValue.WARN_SEVERITY), + "nb", new TypedValue(logsTransientReactanceUndefinedCount, TypedValue.UNTYPED)))); + } log.debug("Found {} lines in courcirc logs matching \"Simulating : short-circuit located on node MYNODE\"", logsSimulatingShortCircuitLocatedCount); if (logsSimulatingShortCircuitLocatedSummary != null) { logsSimulatingShortCircuitLocatedSummary.setReport(new Report("simulatingShortCircuitLocatedNodeSummary", diff --git a/src/test/resources/reporter_courcirc_modified.json b/src/test/resources/reporter_courcirc_modified.json index 9f6ddc5a..8b0f1cdc 100644 --- a/src/test/resources/reporter_courcirc_modified.json +++ b/src/test/resources/reporter_courcirc_modified.json @@ -189,6 +189,42 @@ "type" : "SEVERITY" } } + }, { + "reportKey" : "transientReactanceUndefinedSummary", + "values" : { + "reportSeverity" : { + "value" : "WARN", + "type" : "SEVERITY" + }, + "nb" : { + "value" : 3, + "type" : "UNTYPED" + } + } + }, { + "reportKey" : "REC_15", + "values" : { + "reportSeverity" : { + "value" : "TRACE", + "type" : "SEVERITY" + } + } + }, { + "reportKey" : "REC_16", + "values" : { + "reportSeverity" : { + "value" : "TRACE", + "type" : "SEVERITY" + } + } + }, { + "reportKey" : "REC_17", + "values" : { + "reportSeverity" : { + "value" : "TRACE", + "type" : "SEVERITY" + } + } }, { "reportKey" : "REC_245", "values" : { @@ -309,6 +345,9 @@ "REC_11" : "T:NODE2 : transient reactance too low ==> generator ignored", "REC_12" : "T NODE3 : transient reactance too low ==> generator ignored", "REC_13" : "T—NODE4 : transient reactance too low ==> generator ignored", + "REC_15" : "NODE-1 : transient reactance undefined ==> generator ignored", + "REC_16" : "NODE-2 : transient reactance undefined ==> generator ignored", + "REC_17" : "NODE-3 : transient reactance undefined ==> generator ignored", "REC_245" : "Simulating : short-circuits located on nodes with branches contributions", "REC_246" : "Simulating : short-circuit located on node NODE123_0", "REC_274" : "Simulating : short-circuit located on node ABCDEFG_1", @@ -318,6 +357,7 @@ "REC_306" : "Short circuit on node DUPOND2_0 is not simulated : it is located in an out of voltage part of the network", "REC_307" : "Simulating : short-circuit located on node CAPTAIN_0", "transientReactanceTooLowSummary" : "${nb} node(s) with transient reactance too low ==> generator ignored", + "transientReactanceUndefinedSummary" : "${nb} node(s) with transient reactance undefined ==> generator ignored", "simulatingShortCircuitLocatedNodeSummary": "Simulating: short-circuits located on ${nb} nodes", "shortCircuitNodeNotSimulatedOutOfVoltageSummary": "Short circuit on ${nb} nodes is not simulated : they are in an out of voltage part of the network." } diff --git a/src/test/resources/reporter_courcirc_test.json b/src/test/resources/reporter_courcirc_test.json index 4b4930aa..60f2157c 100644 --- a/src/test/resources/reporter_courcirc_test.json +++ b/src/test/resources/reporter_courcirc_test.json @@ -177,6 +177,30 @@ "type" : "SEVERITY" } } + }, { + "reportKey" : "REC_15", + "values" : { + "reportSeverity" : { + "value" : "WARN", + "type" : "SEVERITY" + } + } + }, { + "reportKey" : "REC_16", + "values" : { + "reportSeverity" : { + "value" : "WARN", + "type" : "SEVERITY" + } + } + }, { + "reportKey" : "REC_17", + "values" : { + "reportSeverity" : { + "value" : "WARN", + "type" : "SEVERITY" + } + } }, { "reportKey" : "REC_245", "values" : { @@ -273,6 +297,9 @@ "REC_11" : "T:NODE2 : transient reactance too low ==> generator ignored", "REC_12" : "T NODE3 : transient reactance too low ==> generator ignored", "REC_13" : "T—NODE4 : transient reactance too low ==> generator ignored", + "REC_15" : "NODE-1 : transient reactance undefined ==> generator ignored", + "REC_16" : "NODE-2 : transient reactance undefined ==> generator ignored", + "REC_17" : "NODE-3 : transient reactance undefined ==> generator ignored", "REC_245" : "Simulating : short-circuits located on nodes with branches contributions", "REC_246" : "Simulating : short-circuit located on node NODE123_0", "REC_274" : "Simulating : short-circuit located on node ABCDEFG_1",