Skip to content

Commit e169b63

Browse files
committed
[2026-05-28] Implement depot offline materialization
1 parent 21b1169 commit e169b63

16 files changed

Lines changed: 2953 additions & 24 deletions

src/prj/Eigenverft.Manifested.Package.Test/Eigenverft.Manifested.Package.Package.AcquisitionAndOwnership.Tests.ps1

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,101 @@ Invoke-TestPackageDescribe -Name 'Eigenverft.Manifested.Package Package - acquis
171171
Assert-MockCalled Save-PackageDownloadFile -Times 0
172172
}
173173

174+
It 'uses only depot candidates in Offline mode and skips vendorDownload' {
175+
$rootPath = Join-Path $TestDrive 'offline-depot-hit'
176+
$packageArchive = New-TestPackageArchiveInfo -RootPath (Join-Path $rootPath 'archive') -Version '2.0.0' -ArchiveFileName 'VSCode-win32-x64-2.0.0.zip'
177+
$globalDocument = New-TestPackageGlobalDocument -PackageFileStagingDirectory (Join-Path $rootPath 'workspace') -DefaultPackageDepotDirectory (Join-Path $rootPath 'default-depot')
178+
$release = New-TestPackageRelease -Id 'vsCode-win-x64-stable' -Version '2.0.0' -Architecture 'x64' -ArtifactDistributionVariant 'win32-x64' -FileName 'VSCode-win32-x64-2.0.0.zip' -AcquisitionCandidates @(
179+
@{
180+
kind = 'packageDepot'
181+
searchOrder = 10
182+
verification = @{ mode = 'required'; algorithm = 'sha256'; sha256 = $packageArchive.Sha256 }
183+
},
184+
@{
185+
kind = 'vendorDownload'
186+
sourceId = 'vsCodeUpdateService'
187+
sourcePath = '2.0.0/win32-x64-archive/stable'
188+
searchOrder = 100
189+
verification = @{ mode = 'required'; algorithm = 'sha256'; sha256 = $packageArchive.Sha256 }
190+
}
191+
)
192+
$definitionDocument = New-TestVSCodeDefinitionDocument -Releases @($release) -SharedReadiness (New-TestReadiness -Version '2.0.0')
193+
$definitionDocument.schemaVersion = '1.8'
194+
$definitionDocument.definitionPublication.definitionSignature = @{
195+
kind = 'unsigned'
196+
format = 'embedded-json-rsa-sha256-v1'
197+
signedContent = 'canonicalDefinitionExcludingSignatureValue'
198+
}
199+
$documents = Write-TestPackageDocuments -RootPath $rootPath -GlobalDocument $globalDocument -DefinitionDocument $definitionDocument
200+
Mock Get-PackageConfigPath { $documents.GlobalConfigPath }
201+
Mock Get-PackageDefinitionPath { param($DefinitionId) $documents.DefinitionPath }
202+
Mock Save-PackageDownloadFile { throw 'vendor download should not run in Offline mode' }
203+
204+
$config = Get-PackageConfig -DefinitionId 'VSCodeRuntime'
205+
$result = New-PackageResult -PackageConfig $config -Offline
206+
$result = Resolve-PackagePackage -PackageResult $result
207+
$result = Resolve-PackagePaths -PackageResult $result
208+
$result = Build-PackageAcquisitionPlan -PackageResult $result
209+
210+
$null = New-Item -ItemType Directory -Path (Split-Path -Parent $result.DefaultPackageDepotFilePath) -Force
211+
Copy-Item -LiteralPath $packageArchive.ZipPath -Destination $result.DefaultPackageDepotFilePath -Force
212+
213+
$result = Resolve-PackageInstallFile -PackageResult $result
214+
215+
@($result.AcquisitionPlan.Candidates | ForEach-Object { $_.kind }) | Should -Be @('packageDepot')
216+
$result.AcquisitionPlan.SkippedOfflineVendorCandidateCount | Should -Be 1
217+
$result.PackageFilePreparation.Status | Should -Be 'HydratedFromDefaultPackageDepot'
218+
Assert-MockCalled Save-PackageDownloadFile -Times 0
219+
}
220+
221+
It 'fails closed on Offline depot misses and does not accept package-file staging as a source' {
222+
$rootPath = Join-Path $TestDrive 'offline-depot-miss'
223+
$packageArchive = New-TestPackageArchiveInfo -RootPath (Join-Path $rootPath 'archive') -Version '2.0.0' -ArchiveFileName 'VSCode-win32-x64-2.0.0.zip'
224+
$release = New-TestPackageRelease -Id 'vsCode-win-x64-stable' -Version '2.0.0' -Architecture 'x64' -ArtifactDistributionVariant 'win32-x64' -FileName 'VSCode-win32-x64-2.0.0.zip' -AcquisitionCandidates @(
225+
@{
226+
kind = 'packageDepot'
227+
searchOrder = 10
228+
verification = @{ mode = 'required'; algorithm = 'sha256'; sha256 = $packageArchive.Sha256 }
229+
},
230+
@{
231+
kind = 'download'
232+
sourceId = 'vsCodeUpdateService'
233+
sourcePath = '2.0.0/win32-x64-archive/stable'
234+
searchOrder = 100
235+
verification = @{ mode = 'required'; algorithm = 'sha256'; sha256 = $packageArchive.Sha256 }
236+
},
237+
@{
238+
kind = 'filesystem'
239+
sourceId = 'localShare'
240+
sourcePath = 'VSCode-win32-x64-2.0.0.zip'
241+
searchOrder = 110
242+
verification = @{ mode = 'required'; algorithm = 'sha256'; sha256 = $packageArchive.Sha256 }
243+
}
244+
)
245+
$documents = Write-TestPackageDocuments -RootPath $rootPath -GlobalDocument (New-TestPackageGlobalDocument -PackageFileStagingDirectory (Join-Path $rootPath 'workspace')) -DefinitionDocument (New-TestVSCodeDefinitionDocument -Releases @($release) -SharedReadiness (New-TestReadiness -Version '2.0.0'))
246+
Mock Get-PackageConfigPath { $documents.GlobalConfigPath }
247+
Mock Get-PackageDefinitionPath { param($DefinitionId) $documents.DefinitionPath }
248+
Mock Save-PackageDownloadFile { throw 'download should not run in Offline mode' }
249+
250+
$config = Get-PackageConfig -DefinitionId 'VSCodeRuntime'
251+
$result = New-PackageResult -PackageConfig $config -Offline
252+
$result = Resolve-PackagePackage -PackageResult $result
253+
$result = Resolve-PackagePaths -PackageResult $result
254+
$result = Build-PackageAcquisitionPlan -PackageResult $result
255+
256+
$null = New-Item -ItemType Directory -Path (Split-Path -Parent $result.PackageFilePath) -Force
257+
Copy-Item -LiteralPath $packageArchive.ZipPath -Destination $result.PackageFilePath -Force
258+
259+
$result = Resolve-PackageInstallFile -PackageResult $result
260+
261+
@($result.AcquisitionPlan.Candidates | ForEach-Object { $_.kind }) | Should -Be @('packageDepot')
262+
$result.AcquisitionPlan.SkippedOfflineCandidateCount | Should -Be 2
263+
$result.PackageFilePreparation.Success | Should -BeFalse
264+
$result.PackageFilePreparation.FailureReason | Should -Be 'DepotMiss'
265+
@($result.PackageFilePreparation.Attempts | Where-Object { $_.AttemptType -eq 'ReuseCheck' }).Count | Should -Be 0
266+
Assert-MockCalled Save-PackageDownloadFile -Times 0
267+
}
268+
174269
It 'reconciles a newly added writable mirror depot from an existing depot artifact' {
175270
$rootPath = Join-Path $TestDrive 'mirror-from-depot'
176271
$packageArchive = New-TestPackageArchiveInfo -RootPath (Join-Path $rootPath 'archive') -Version '2.0.0' -ArchiveFileName 'VSCode-win32-x64-2.0.0.zip'

0 commit comments

Comments
 (0)