Database Packaging#1121
Conversation
isc-jili
left a comment
There was a problem hiding this comment.
Looks great @isc-dchui ! I left some comments!
| } | ||
|
|
||
| /// Remaps the namespace's routines to newDBName, then dismounts the old routines DB. | ||
| /// Remap-before-dismount avoids a window where the namespace has no mounted routines DB. |
There was a problem hiding this comment.
Small nit: given that there is a nearly identical comment less than 10 lines down, suggest either removing that comment or removing this section from method description
| // Resolve all module dirs before switching namespace (^UnitTestRoot only in original NS) | ||
| set depDir = ..GetModuleDir("db-packaging", "dependency-module") | ||
| set simpleDir = ..GetModuleDir("db-packaging", "simple-module") | ||
| set depsDir = ..GetModuleDir("db-packaging", "module-with-deps") |
There was a problem hiding this comment.
nit: suggest renaming depDir and depsDir to be more distinctive as currently their names are a bit confusing
| // Extract and verify contents | ||
| set extractDir = ##class(%File).NormalizeDirectory(..PackageOutputDir _ "extract") | ||
| do ##class(%File).CreateDirectory(extractDir) | ||
| set sc = ##class(%IPM.General.Archive).Extract(packageFile, extractDir, .extractOutput) |
There was a problem hiding this comment.
Question: is there any info that needs to be checked in extractOutput? I don't see it being checked below. If it doesn't need to get checked, is there any value in storing it in a variable then?
| set sc = ##class(%IPM.Main).Shell("package-database simple-db-module -path " _ ..PackageOutputDir) | ||
|
|
||
| // Restore original module.xml unconditionally before asserting, so a failure doesn't leave | ||
| // the shared NS in a broken state for subsequent tests |
There was a problem hiding this comment.
Question: if we want to restore module.xml unconditionally, would it be safer to have the following in a try/catch block in case the package-database fails?
| set $namespace = installNS2 | ||
|
|
||
| set sc = ##class(%IPM.Main).Shell("load " _ tamperedPackage _ " -swap-db") | ||
| do $$$AssertStatusNotOK(sc, "Tampered IRIS.DAT rejected by checksum validation") |
There was a problem hiding this comment.
Would it be more accurate to check for a substring of the expected error that is thrown as opposed to just the status not being OK? Since what if the status is not OK for a different reason than expected?
| write:verbose !, "Computing SHA-256 checksum..." | ||
| set irisDAT = tempDBPath _ "IRIS.DAT" | ||
| set checksumHex = ..ComputeSHA256Hex(irisDAT) | ||
| write !, " Checksum: ", checksumHex |
There was a problem hiding this comment.
Question: I'm noticing for print statements some are verbose and some are always printed. Just want to double check that this is the intent.
It seems that currently this is the state of print statements:
- invoke warnings: always printed
- checksum: always printed
- package path: always printed
- many progress steps: verbose-only
| @@ -0,0 +1,1050 @@ | |||
| Include %syPrompt | |||
There was a problem hiding this comment.
Does anything in this class use %syPrompt?
| Method ExportGeneratedResources( | ||
| ns As %String, | ||
| includeTestResources As %Boolean, | ||
| ByRef params, |
There was a problem hiding this comment.
Nit: ExportGeneratedResources() takes ByRef params, but I don’t think the method actually uses it?
| /// Throws on any failure. Does not modify any state. | ||
| Method ValidateBeforeSwap( | ||
| packageDir As %String, | ||
| ns As %String) [ Private ] |
There was a problem hiding this comment.
nit: param ns seems to be unused
| /// Dismounts the temp DB, remaps the namespace back to oldDBName, remounts it, | ||
| /// and removes the temp database config entry. | ||
| /// Logs warnings on partial failures but always attempts full restoration. | ||
| ClassMethod RestoreRoutinesDB( |
There was a problem hiding this comment.
The new methods in this new class could all benefit from params documented in the method comments as well!
Description
Resolves #986
Overview
Key Details
swap-db, only installs source-packaged modules. If none exist, but database-packaged module(s) exist, informs user. When installing withswap-db, only installs database-packaged modules.com.intersystems.ipm.packagingmanifest annotation to "database" (for backwards compatibility, source packaged modules will not have this annotation) and use<module-version>_database__<IRIS-version>tagTesting
load -swap-db→ classes callable, module in list and historylist-include-test-resourcesincludes Scope=test (TestHelper) and UnitTest (Test) classes; default packaging excludes both-use-current-dbcompletes without error and produces a package filedeps/directory each fail validationupdate -path -swap-db; Packaging changes to "database"; backup confirms DB swap occurredlist; backup preserved; compiled classes gone from namespace-no-export-python-deps; lune importable after install. module-with-requirements: packaging wheel included by default, excluded with flag<Invoke After="Compile">skipped during database install;<Invoke After="Activate">runs; global markers confirm each%Activateoverride-swap-db) → Packaging=module; database install (-swap-db) → Packaging=database; main-with-deps install resolves dep as source; after unpublishing source tag, install without-swap-dbfails with hint to use-swap-dbpackage-databaseoverwrites a stale IRIS version in<SystemRequirements>with the current versionNot Yet Handled
Checklist
mainbranch rebased or merged.zpm test -only) and integration tests (zpm verify -only) pass.