Repository navigation
AIX: extract testable parse methods from command readers - #3501
Conversation
Split data acquisition from parsing in the AIX drivers and HAL so the parsing logic can be unit-tested with synthetic fixtures instead of only on a live AIX host. Each public method keeps its acquisition (runNative/getFirstAnswer) and delegates to a parse method taking the already-read input: - driver Uptime.parseUpTime(String), Who.parseBootTime(String) - driver Ls.parseDeviceMajorMinor(List), Lssrad.parseNodesPackages(List) (Lssrad no longer mutates the input list to drop the header) - AixNetworkParams.parseDefaultGateway(List) - AixComputerSystem.parseLsattr(lsattr, lsmcode) -> LsattrStrings (now package-private with accessors) Fixtures are grounded in the real uptime, who -b, ls -l /dev, lssrad -av, netstat -rnf, lsattr -El sys0, and lsmcode -c output. The parse tests run on every platform; the existing AIX-only live smoke tests keep their coverage via per-method @EnabledOnOs(AIX). Note the AIX package is still JaCoCo-excluded, so this is testability groundwork ahead of a future coverage-exclusion revisit.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📜 Recent review details⏰ Context from checks skipped due to timeout. (13)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
🔇 Additional comments (11)
📝 WalkthroughWalkthroughAIX command parsers now accept captured command output, while query methods execute commands and delegate parsing. SRAD header handling, boot-time parsing, accessible computer-system fields, and direct parser tests were added or expanded. ChangesAIX parser refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3501 +/- ##
============================================
+ Coverage 71.83% 76.42% +4.58%
Complexity 76 76
============================================
Files 591 591
Lines 21695 21695
Branches 3611 3611
============================================
+ Hits 15585 16580 +995
+ Misses 4314 3170 -1144
- Partials 1796 1945 +149
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* Extract more testable parse methods from AIX command readers Second batch of AIX parse-seam extractions (after #3501), splitting acquisition from parsing so the parsing is unit-testable with synthetic fixtures: - Lspv: parsePpSize(List) + parsePartitions(List, ppSize, majMinMap), splitting the two-command computeLogicalVolumes - Lscfg.parseModelSerial(List, device) - AixCentralProcessor: parseProcessorId(prtconf) -> Quartet, parseCurrentFreq (pmcycles), parseSbits(proc.h), cachesForPowerVersion(version, cores) - AixOperatingSystem.parseServices(lssrc) (no longer mutates the input list to drop the header) - AixFileSystem.parseOpenFileDescriptors(lsof) + parseMaxFileDescriptorsPerProcess Fixtures are grounded in the real lspv -L/-p, lscfg -vl, prtconf, pmcycles -m, proc.h, lssrc -a, lsof -nl, and /etc/security/limits output. As with #3501 the AIX package is still JaCoCo-excluded, so this is testability groundwork; the existing @EnabledOnOs(AIX) live smoke tests are unaffected. * Guard AIX prtconf and lscfg parsers against short/empty splits Address CodeRabbit review on the AIX parse extraction: - AixCentralProcessor.parseProcessorId: replace split(marker)[1] with substring(marker.length()) after the existing startsWith checks, so a bare marker line with no value (e.g. "Processor Type:") no longer throws ArrayIndexOutOfBounds. - Lscfg.parseModelSerial: check the split length before indexing [1], so a line ending in the device name (which splits to a single element) skips the description fallback instead of throwing. Both paths are covered by new fixture tests. Behavior is otherwise unchanged. * Locate the lscfg device name literally instead of via split Follow-up to the earlier split-length guard: use indexOf/substring with the literal device name in Lscfg.parseModelSerial. split(device) treats the device as a regex and needs a length guard for a trailing-token line; indexOf/substring is clearer and handles the end-of-line case directly (empty remainder -> no model). Behavior is unchanged; covered by the existing fixture tests.
Summary
Continues the parse-seam testability effort (after Linux #3494, FreeBSD #3495, NetBSD/OpenBSD #3496, Solaris #3497/#3498, FileSystem #3499, disk drivers #3500) with the AIX command readers. Each acquire-and-parse method keeps its acquisition and delegates to a package-private/
staticparse method taking the already-read input, so the parsing is unit-testable with synthetic fixtures instead of only on a live AIX host:Uptime.parseUpTime(String),Who.parseBootTime(String)Ls.parseDeviceMajorMinor(List<String>),Lssrad.parseNodesPackages(List<String>)(the latter no longer mutates its input to drop the header)AixNetworkParams.parseDefaultGateway(List<String>)AixComputerSystem.parseLsattr(lsattr, lsmcode)→LsattrStrings(now package-private with accessors)Fixtures are grounded in the real
uptime,who -b,ls -l /dev,lssrad -av,netstat -rnf inet,lsattr -El sys0, andlsmcode -coutput documented in each source. The new parse tests run on every platform; the existing AIX-only live smoke tests keep their coverage via per-method@EnabledOnOs(OS.AIX).Note on coverage
The AIX package is still JaCoCo-excluded (
**/unix/aix/**), the same as NetBSD in #3496, so this lands as testability / regression-safety groundwork rather than an immediate coverage bump — un-excluding AIX is a separate follow-up (it needs its native/JNA paths measured, which the current CI aggregation doesn't do).Testing
oshi-commonfull gate green: spotless, checkstyle, install + forbiddenapis, javadoc; clean full-reactorinstallgreen.No CHANGELOG entry — test/coverage refactor with no user-observable behavior change.
Summary by CodeRabbit
Bug Fixes
Tests