Repository navigation
Tests: import data/loinc-testing.db into its own file and rename it into place; suites copy it - #393
Merged
grahamegrieve merged 1 commit intoNov 14, 2026
Conversation
…amed into place (HealthIntersections#384) 4 suites in 4 jest workers, 10 runs: 0/10 passed before (cs-worker-readonly and cluster-worker-readonly copied a half-written file: "no such table: Codes"), 10/10 after. - tests/loinc-testing-db.js: importLoincTestingDb imports to a temporary file next to data/loinc-testing.db, sets journal_mode DELETE, renames it into place; loincTestingDbCopy copies it, importing first if it's missing - cs-loinc.test.js imports through it (no longer deleting the file first) and opens it read-only; its provider tests use a copy - cs-loinc-classtype, cs-worker-readonly, cluster-worker-readonly, ancestors-of and closure-providers use copies: a provider loading the shared file set WAL and made indexes in it while others copied it - the import goes to the repository's data/ (where every reader looked), not FHIRSMITH_DATA_DIR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #384, where you found that
cs-loinc.test.jsre-importsdata/loinc-testing.dbwhilecs-loinc-classtype,cs-worker-readonlyandcluster-worker-readonlycopy it.I ran those four suites together in 4 jest workers (
npx jest -w 4 ...), 10 times on each side:cs-worker-readonlyandcluster-worker-readonlyevery time (4 tests,SQLITE_ERROR: no such table: Codes/Languages). They copied the file while it was deleted or half re-imported.In the main runs the file already existed from an earlier run. On a fresh checkout, the first main run also failed
cs-loinc-classtype, because the file didn't exist yet. On this branch the first run started with nodata/directory, and it passed.The change
New
tests/loinc-testing-db.js:importLoincTestingDb()imports the test subset into a temporary file next todata/loinc-testing.db, setsjournal_mode = DELETEso the whole database is in that one file, and renames it into place. A suite copying it then gets the old database or the new one, never part of one. It also removes any-wal/-shmthat an older run left next to the file.loincTestingDbCopy(dir)copies the file intodir, importing it first if no suite has done so yet. Any suite can therefore run alone, or first.The suites:
cs-loinc.test.jsimports through the helper. It no longer deletes the file first, and it opens the file read-only for its table checks. Its provider tests (LOINC Provider) now run on a copy.cs-loinc-classtype,cs-worker-readonlyandcluster-worker-readonlyget their copies from the helper.ancestors-ofandclosure-providersused to open the shared file in place. They now use copies too, which they delete afterwards. Loading a LOINC provider read-write sets WAL and creates indexes, so it was writing to the file while other suites copied it.data/, where every reader already looked. Before,cs-loinc.test.jswrote toFHIRSMITH_DATA_DIRwhen that was set, and the readers then found a stale file or none. With it set, main'stests/csrun failscs-loinc,cs-loinc-classtypeandcs-worker-readonly.jest has no
globalSetuphere (maxWorkers: 1,setupFilesAfterEnvonly), so I made the import lazy rather than adding a global step to every run.Runs (on 38d3ffe)
tests/cs+tests/tx+tests/server/cluster-worker-readonly.test.js, except the test cases, withFHIRSMITH_DATA_DIRset: 3,240 passed, 87 skipped, 38 failed. Main has 116 failures in that harness. The 78 tests that pass now are incs-loinc(71),cs-worker-readonly(4) andcs-loinc-classtype(3). The 38 failures are on main too:cs-ndc(37) has the same data-directory mismatch forndc-testing.db, which I left alone.cs-rxnorm-archive-index(1) expects a chmod'ed file to be read-only, which it isn't under the harness'sunshare -ruser namespace.tests/tx/test-cases.test.js: 5,251 of 5,251 passed, with validator 7.0.5.🤖 Generated with Claude Code