diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c964c6adf..160ff5810 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,7 +41,7 @@ jobs: ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version - name: Build and Run Tests run: | - ./gradlew build + ./gradlew build -Dtest.logs=true - name: Publish to Maven Local run: | ./gradlew publishToMavenLocal diff --git a/build.gradle b/build.gradle index 90a373ff7..a03f1801b 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,10 @@ buildscript { 'opendistro-anomaly-detection/opendistro-anomaly-detection-1.13.0.0.zip' bwcOpenDistroJSDownload = 'https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elasticsearch-plugins/' + 'opendistro-job-scheduler/opendistro-job-scheduler-1.13.0.0.zip' + // gradle build won't print logs during test by default unless there is a failure. + // It is useful to record intermediately information like prediction precision and recall. + // This option turn on log printing during tests. + printLogs = "true" == System.getProperty("test.logs", "false") } repositories { @@ -269,6 +273,12 @@ integTest { jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' } + if (printLogs) { + testLogging { + showStandardStreams = true + outputs.upToDateWhen {false} + } + } } testClusters.integTest { @@ -779,3 +789,13 @@ validateNebulaPom.enabled = false tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' } + +// show test results so that we can record information like precion/recall results of correctness testing. +if (printLogs) { + test { + testLogging { + showStandardStreams = true + outputs.upToDateWhen {false} + } + } +} diff --git a/release-notes/opensearch-anomaly-detection.release-notes-2.1.0.0.md b/release-notes/opensearch-anomaly-detection.release-notes-2.1.0.0.md index 47546c74c..7828924e7 100644 --- a/release-notes/opensearch-anomaly-detection.release-notes-2.1.0.0.md +++ b/release-notes/opensearch-anomaly-detection.release-notes-2.1.0.0.md @@ -7,6 +7,7 @@ Compatible with OpenSearch 2.1.0 * bump rcf to 3.0-rc3 ([#568](https://github.com/opensearch-project/anomaly-detection/pull/568)) * Disable interpolation in HCAD cold start ([#575](https://github.com/opensearch-project/anomaly-detection/pull/575)) +* Expose model accuracy metrics in tests ([#600](https://github.com/opensearch-project/anomaly-detection/pull/600)) ### Bug Fixes diff --git a/src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java b/src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java index ace1fd546..f862d92cf 100644 --- a/src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java +++ b/src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java @@ -122,6 +122,7 @@ private void verifyTestResults( assertTrue(recall >= minRecall); assertTrue(errors <= maxError); + LOG.info("Precision: {}, Window recall: {}", precision, recall); } private int isAnomaly(Instant time, List> labels) { diff --git a/src/test/java/org/opensearch/ad/ml/EntityColdStarterTests.java b/src/test/java/org/opensearch/ad/ml/EntityColdStarterTests.java index 215c15304..685d569ac 100644 --- a/src/test/java/org/opensearch/ad/ml/EntityColdStarterTests.java +++ b/src/test/java/org/opensearch/ad/ml/EntityColdStarterTests.java @@ -853,6 +853,7 @@ public int compare(Entry p1, Entry p2) { assertTrue("precision is " + prec, prec >= precisionThreshold); assertTrue("recall is " + recall, recall >= recallThreshold); + LOG.info("Interval {}, Precision: {}, recall: {}", detectorIntervalMins, prec, recall); } public int searchInsert(long[] timestamps, long target) {