Repository navigation
CAMEL-24829: WebsiteInstallerFixture - isolate PSModulePath for install.ps1 on Windows - #26609
Conversation
…stall.ps1 launch cost Every install.ps1 launch in WebsiteInstallTest$WindowsPowerShell pays ~24s before doing any work (46 launches = 99% of the 1206s suite on PR apache#26568), while powershell.exe itself starts in ~0.24s. The prime suspect is the test-only CA block's Add-Type (csc.exe) compile; the second is the environment WebsiteInstallerFixture.run() clears. Add a temporary, continue-on-error step that times, twice each: bare startup and a bare Add-Type (full vs cleared env), and install.ps1 -Version 1.2.3-SNAPSHOT (rejected before any network I/O) across full/cleared env x with/without CAMEL_INSTALL_CA_CERT. The step is to be removed once the cause is confirmed and fixed. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
…stall.ps1 launch cost Round 1 of the diagnostic ruled out the suspected CA seam: install.ps1 -Version 1.2.3-SNAPSHOT takes 0.2-0.5s in the runner's full environment with or without CAMEL_INSTALL_CA_CERT, but 17.6-17.9s in the cleared environment WebsiteInstallerFixture.run() uses, again with or without the CA. A bare powershell.exe start is 0.1s in both; the first cmdlet call (Join-Path, Add-Type) is what costs ~18-24s in the cleared environment. Replace the step with a bisection: a Join-Path probe in the cleared environment with one thing restored at a time (PSModulePath, a shared PSModuleAnalysisCachePath, real LOCALAPPDATA, real USERPROFILE/HOME, ProgramFiles/ProgramData variables, windir/SystemDrive/APPDATA and friends), plus full-environment controls with a real and a fresh home. Still temporary; removed once the cause is fixed. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._
…s1 on Windows WebsiteInstallerFixture.run() clears the child environment. Without PSModulePath, Windows PowerShell's first cmdlet call (install.ps1's Join-Path on line 29) spends ~18s in command discovery on windows-latest, so every install.ps1 run in WebsiteInstallTest$WindowsPowerShell cost ~25s and the suite took 10-20 minutes. Two diagnostic CI rounds on this PR pinned it down: a Join-Path probe in the fixture's cleared environment took 17.7s, and 0.2s with only PSModulePath restored; restoring LOCALAPPDATA, USERPROFILE/HOME, ProgramFiles/ProgramData, windir/SystemDrive/APPDATA or a shared PSModuleAnalysisCachePath each left it at ~18s. The test-only CA Add-Type block added under 0.2s. The per-test HOME/USERPROFILE/ LOCALAPPDATA isolation is unaffected (full env + fresh home: 0.2s). Drop the PSModuleAnalysisCachePath setting added by CAMEL-24485, which the same measurement showed has no effect, and remove the temporary diagnostic step. Production is unaffected: SelfUpdateCommand only clears the installer's environment under its test override. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 0 of 692 tested, 0 compile-only — current: 1 all testedMaveniverse Scalpel detected 1 affected modules (current approach: 1). Skip-tests mode would test 0 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)
|
| Module | Duration | Status |
|---|---|---|
| Camel :: Launcher | 43.7s | SUCCESS |
| Camel :: Launcher :: Container | 0.9s | SUCCESS |
Top 20 slowest modules:
Camel :: Launcher(43.7s)Camel :: Launcher :: Container(0.9s)
…werShell's built-in modules Passing the runner's PSModulePath through did not help: install.ps1 runs in the suite still took ~19.7s (median of 46). The round 2 probe that restored PSModulePath ran under pwsh, which prepends its own module directories to PSModulePath at startup; the tests run from bash, whose PSModulePath does not have them. Set the child's PSModulePath to %SystemRoot%\System32\WindowsPowerShell\v1.0\Modules instead, which holds every cmdlet install.ps1 uses and keeps the suite independent of whatever the runner has installed. A temporary round 3 diagnostic step compares the values on CI. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._
… home's user module directory Round 3 of the diagnostic (run 35418075426), a Join-Path probe in the fixture's cleared environment, launched from bash like the tests: - PSModulePath unset, bash's value, System32 modules only, Program Files modules only, Program Files + System32: 17.4-28.9s - pwsh's value (pwsh's own module directories come first): 0.2s - a single directory without Windows PowerShell's own modules (the Az directory, a nonexistent user directory, the SQL Server directory): 0.2-0.8s, and Join-Path still resolves So the previous commit's System32-only value did not help either (install.ps1 median 19.5s, suite 901s). Program Files\WindowsPowerShell\Modules on windows-latest holds AWSPowerShell, Microsoft.Graph and SqlServer. Point PSModulePath at <per-test USERPROFILE>\Documents\WindowsPowerShell\Modules, the isolated home's own user module directory, which does not exist. Remove the temporary diagnostic steps. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._
gnodet-bot
left a comment
There was a problem hiding this comment.
The fix is empirically sound and well-documented.
The root cause (PSModulePath absent → Windows PowerShell scans all installed modules in Program Files\WindowsPowerShell\Modules including Microsoft.Graph/AWSPowerShell on the first cmdlet call) is accurately identified and validated with three rounds of CI diagnostics. Pointing the child environment at a per-test, nonexistent user module directory is the minimal effective fix — it avoids the scan without affecting correctness, since built-in cmdlets are resolved from $PSHome\Modules regardless of PSModulePath. The 13× speedup (1206s → 90s) on the Windows CI run confirms it.
Ordering of pb.environment().put("PSModulePath", ...) after pb.environment().putAll(env) is correct — ensures the isolation override wins over anything the caller might pass.
Dropping PSModuleAnalysisCachePath is justified by the round-2 measurements (no effect); the constant removal is clean.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Description
Follow-up to CAMEL-24485 (#26568). Fixes CAMEL-24829.
#26568 stopped
windows-validatorfrom killing slow-but-passing runs, but the suite stayed slow: on that PR's own run it took 1206 s. The per-process timing lines #26568 added put 99% of it ininstall.ps1(46 launches, median 25.4 s each), while thepowershell -Commandhelpers the tests also start took about 0.24 s each.Root cause
WebsiteInstallerFixture.run()clears the child environment before launchinginstall.ps1. In that environment, Windows PowerShell's first cmdlet call (Join-Path, line 29 ofinstall.ps1) takes about 18 s onwindows-latest, whilepowershell.exeitself starts in 0.1 s. The value ofPSModulePathdecides it.Three temporary diagnostic rounds on this PR (each case run twice). Rounds 1 and 2 launched the probe from a
pwshstep:Join-PathprobePSModulePath(as pwsh sees it)PSModuleAnalysisCachePathLOCALAPPDATAUSERPROFILE/HOMEProgramFiles/ProgramDatavarswindir/SystemDrive/APPDATA/etc.Round 1 (run 35414270738) ruled out the test-only CA /
Add-Typeblock ininstall.ps1:install.ps1 -Version 1.2.3-SNAPSHOTtook 0.2-0.5 s in the full environment with or withoutCAMEL_INSTALL_CA_CERT, and 17.6-17.9 s in the cleared one, again with or without it. Round 2 is run 35416424791.Two fix attempts did not help. Passing the runner's
PSModulePaththrough (run 35416880642) leftinstall.ps1launches at a median of 19.7 s (suite 934 s), and pinning it toSystem32\WindowsPowerShell\v1.0\Modules(run 35418075426) at 19.5 s (suite 901 s). The round 2 probe ran underpwsh, which prepends its own module directories toPSModulePathat startup; the tests run frombash, whose value lacks them. Round 3, in that same run, launched the probe the way the fixture does, with onlyPSModulePathvaried:PSModulePathfor theJoin-Pathprobebash's value (attempt 1)System32\WindowsPowerShell\v1.0\Modulesonly (attempt 2)Program Files\WindowsPowerShell\Modulesonlypwsh's valueC:\Modules\az_15.6.1onlyJoin-Pathresolves in every case. Onwindows-latest,Program Files\WindowsPowerShell\Modulesholds AWSPowerShell, Microsoft.Graph (40+ modules) and SqlServer.Changes
WebsiteInstallerFixture.run()sets the child'sPSModulePathon Windows to the per-test home's own user module directory (<USERPROFILE>\Documents\WindowsPowerShell\Modules, which does not exist), matching the "nonexistent user module directory" row above. This also keeps the suite independent of whatever the runner has installed. The per-testHOME/USERPROFILE/LOCALAPPDATAisolation is unchanged.PSModuleAnalysisCachePathsetting that CAMEL-24485: windows-validator - stop killing slow-but-passing PowerShell suite runs #26568 added: round 2 shows it has no effect.main, the PR only touchesWebsiteInstallerFixture.java.Production is unaffected:
SelfUpdateCommandonly clears the installer's environment under its test-onlyinstallerEnvironmentOverride, so a realcamel self-updateinherits the user's environment.Testing
WebsiteInstallerFixtureTest(5) passes. The Windows code path is not exercised off Windows.WebsiteInstallTest$WindowsPowerShelltests pass. The suite took 90 s (was 901-1206 s),install.ps1launches a median of 1.96 s each (was 19.5-25.4 s), and the wholewindows-validatorjob 5 min 13 s.WindowsPowerShellsuiteinstall.ps1launches (46), medianpowershell -Commandhelpers (43), medianThe 2700 s fork timeout and 60-minute job cap from #26568 are left as they are; with the suite at 90 s they only bound a genuine hang.
rejectsUnknownParameterpassing for the wrong reason (described in CAMEL-24829) is not addressed here.🤖 Generated with Claude Code on behalf of Adriano Machado (@ammachado)
This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it.