sadadw1 opened a new pull request, #694: URL: https://github.com/apache/ozhera/pull/694
### Ⅰ. Describe what this PR did Running the full unit test suite on a clean machine fails in 13 test classes across 4 modules. This PR fixes the root causes so mvn test is green without any external infrastructure. One real product bug found by the tests: - MonitorFile.filePattern is a derived Pattern field (recomputed from monitorFileExpress in the constructor). DefaultFileMonitorListener.newMonitorDirectories logs it via gson.toJson(monitorPathList); on JDK 16+ Pattern internals are strongly encapsulated, so Gson reflection throws JsonIOException and the log statement breaks the method at runtime on JDK 21. Marking the field transient fixes both the test and the runtime bug. Two broken tests / templates: - PathUtilsTest.test00 asserted two constants against each other (assertEquals(expected, logPattern)), so it could never pass. It now asserts against watches.get(0), matching the other tests in the class. - eventflow.ftl used an HTML comment header. FreeMarker leaves HTML comments in the output, so FreeMarkerUtil.getContent could not parse the rendered text as JSON. The comment is now a FreeMarker comment, consistent with jvmScrapeJob.ftl and friends. Twelve integration test classes that require external services are marked @Ignore with the reason in the annotation (Dubbo registry, Doris plus the MariaDB JDBC driver, or a fully wired IoC stack with Elasticsearch/Doris/Nacos). They never ran in CI (CI only runs mvn compile) and fail on every clean machine. ### Ⅱ. Does this pull request fix one issue? No. ### Ⅲ. Why not add test cases (unit test/integration test)? This PR is about making the existing tests reliable. The MonitorFile change is covered by the previously failing InodeChangeDetectionTest, which now passes. ### Ⅳ. Describe how to verify it Run mvn test on JDK 21 on a machine with no Nacos, Doris, Elasticsearch or Dubbo available: - Before: BUILD FAILURE in log-common, ozhera-metrics-sdk, ozhera-monitor-service, log-agent, log-agent-server, log-manager and log-stream. - After: BUILD SUCCESS, 227 tests run, 0 failures, 0 errors, 13 skipped (the @Ignore integration classes). ### Ⅴ. Special notes for reviews The 13 skipped classes are integration tests in disguise. A follow-up could move them behind a failsafe profile or an integration-tests module so they can run against a real environment in a scheduled job. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
