Repository navigation
test(core): guard the framework against plugin imports - #9277
Merged
Merged
Conversation
The dependency direction is plugins -> core/helpers, never the reverse. Nothing enforced it, and two test files had already crossed the line: helpers/e2ehelper imported plugins/gitlab and server/services imported plugins/org. Compiling plugins into the server binary makes the rule load-bearing: a single framework->plugin import links that plugin and its whole dependency tree into the core payload and defeats subset builds. Add TestFrameworkDoesNotImportPlugins, which reads the import graph of core/, helpers/ and server/ (including _test.go files) via `go list` and fails on any plugins/ edge. server/ may only link the generated plugins/all registry, which is encoded as one explicit exception. Make the two offending tests plugin-agnostic: the e2ehelper example now uses local fixtures, and the blueprint test builds its mocked org task option locally.
GetPrimarykeyColumnNames has qualified every column with its table name since 8e915cd ("feat: set project mapping by plugin org"), so the result can be dropped into a join condition without colliding with a reserved identifier. Callers that want the bare name strip the prefix themselves (helpers/e2ehelper/data_flow_tester.go:316, and helpers/srvhelper/scope_config_service_helper.go:74 checks the suffix). The test still expected the unqualified names, so it had been failing. It went unnoticed because scripts/unit-test-go.sh filters out every package path matching `e2e`, which covers helpers/e2ehelper; the package needs a live E2E_DB_URL, so it stays out of the DB-less unit-test job.
6 of 12 tasks
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.
Summary
Nothing enforced the dependency direction between the framework and the plugins, and two test files had already crossed it:
helpers/e2ehelper/data_flow_tester_test.goimportedplugins/gitlab/{models,tasks}server/services/blueprint_makeplan_v200_test.goimportedplugins/org/tasksThis adds
backend/core/layering_test.go, which reads the import graph ofcore/...,helpers/...andserver/...— including_test.gofiles — withgo listand fails on anyplugins/edge.The only tolerated edge is the composition root:
servermay import the generatedplugins/allregistry, never an individual plugin. That is one explicit map entry, so any new exception has to be argued for in review.The rule becomes load-bearing once plugins are compiled into the server binary by default (#9276): a single framework→plugin import links that plugin and its whole dependency tree into the core payload and defeats subset builds.
The two offending tests are made plugin-agnostic rather than allowlisted:
e2ehelperexample now uses local fixtures instead of gitlab'sA third, long-failing assertion in the same package is corrected in the second commit.
Does this close any open issues?
Does not close #9276; it is the first prerequisite of it.
Refs #9276.
Screenshots
N/A
Other Information
Two deliberate choices worth a reviewer's attention:
depguardrule..golangci.yamlsetsrun.tests: false, so lint would not have seen either violation that actually existed — both were in_test.gofiles.go test ./corewould replay a cached PASS: I verified that adding a violation underhelpers/still reported(cached) okfor thecorepackage before this was added.The guard runs as part of
make unit-test, becausescripts/unit-test-go.shalready includes thecorepackage.The second commit fixes
TestGetTableMetaData/dal_get_pk_column_names:GetPrimarykeyColumnNameshas returned qualifiedtable.columnnames since 8e915cd, and callers strip the prefix themselves (helpers/e2ehelper/data_flow_tester.go:316,helpers/srvhelper/scope_config_service_helper.go:74). The stale assertion went unnoticed becausescripts/unit-test-go.shfilters out every package path matchinge2e, which covershelpers/e2ehelper; that package needs a liveE2E_DB_URLand therefore stays out of the DB-less unit-test job.Verification: