Filter for APM property file in APM tests#144350
Conversation
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
| Path configPath; | ||
| try (var files = Files.list(tempDir)) { | ||
| configPath = files.findFirst().orElseThrow(() -> new AssertionError("expected temp APM config file")); | ||
| configPath = files.filter(p -> p.getFileName().toString().matches("\\.elstcapm\\..*\\.tmp")) |
There was a problem hiding this comment.
This regex seems a bit obfuscated. If I understand, it corresponds roughly to this glob:
.elstcapm.*.tmp
(Except the regex allows for slashes where a glob * does not.)
Could we use the following? It seems a little more readable than an escaped regex.
files.filter(p -> p.startsWith(".elstcapm") && p.endsWith(".tmp"))
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change modifies the file selection logic in APMJvmOptionsTests to use a more specific filtering criterion. Instead of selecting any arbitrary file from a temporary directory, the code now filters files to match those with names starting with ".elstcapm" and ending with ".tmp". If no matching files are found, it raises the same assertion error as before. This targeted filtering ensures the test selects the correct configuration file instead of potentially picking a directory. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
Inside the tempDir created to store APM properties, there are possibly other files/folders.
Tightening the filter in the test to reduce flakiness.
Closes: #144338