Skip to content

Commit e46b730

Browse files
TeddyCrShaileshParmar11
authored andcommitted
ISSUE #24958 - Handle testSuite Alerts Status (#24959)
* fix: handled testSuite change event when processing testResults from testSuite pipeline * fix: handled potential null pointer errros * fix: handled potential null pointer errros
1 parent ecdde10 commit e46b730

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

openmetadata-service/src/main/java/org/openmetadata/service/events/subscription/AlertsRuleEvaluator.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.openmetadata.service.Entity.PIPELINE;
1313
import static org.openmetadata.service.Entity.TEAM;
1414
import static org.openmetadata.service.Entity.TEST_CASE;
15+
import static org.openmetadata.service.Entity.TEST_SUITE;
1516
import static org.openmetadata.service.Entity.THREAD;
1617
import static org.openmetadata.service.Entity.USER;
1718

@@ -30,6 +31,7 @@
3031
import org.openmetadata.schema.entity.services.ingestionPipelines.PipelineStatusType;
3132
import org.openmetadata.schema.entity.teams.Team;
3233
import org.openmetadata.schema.entity.teams.User;
34+
import org.openmetadata.schema.tests.ResultSummary;
3335
import org.openmetadata.schema.tests.TestCase;
3436
import org.openmetadata.schema.tests.TestSuite;
3537
import org.openmetadata.schema.tests.type.TestCaseResult;
@@ -219,7 +221,8 @@ public boolean matchTestResult(List<String> testResults) {
219221
if (changeEvent == null || changeEvent.getChangeDescription() == null) {
220222
return false;
221223
}
222-
if (!changeEvent.getEntityType().equals(TEST_CASE)) {
224+
if (!changeEvent.getEntityType().equals(TEST_CASE)
225+
&& !changeEvent.getEntityType().equals(TEST_SUITE)) {
223226
// in case the entity is not test case return since the filter doesn't apply
224227
return true;
225228
}
@@ -241,6 +244,19 @@ public boolean matchTestResult(List<String> testResults) {
241244
}
242245
}
243246
}
247+
248+
if (fieldChange.getName().equals("testCaseResultSummary")
249+
&& fieldChange.getNewValue() != null) {
250+
List<ResultSummary> resultSummaries =
251+
JsonUtils.readOrConvertValues(fieldChange.getNewValue(), ResultSummary.class);
252+
253+
for (ResultSummary resultSummary : resultSummaries) {
254+
if (!nullOrEmpty(resultSummary.getStatus())
255+
&& testResults.contains(resultSummary.getStatus().value())) {
256+
return true;
257+
}
258+
}
259+
}
244260
}
245261
return false;
246262
}

0 commit comments

Comments
 (0)