Repository navigation
Conversation
…all so forks dont havbe this workflow failing
…eave stale binaries and plugins' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…tion so Init() call remains just a read call and does not change anything (support of validate and print commands)
…or go and web engineers
…le different modes of operation -- running different containers on demand
…packages -- ANTLR
* Add fork CI (stan-ci) * make step blocking --------- Co-authored-by: Stan Babourine <2166030+babourine@users.noreply.github.com>
…ng tags required on commands, clusters and jobs
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Malformed request bodies still bypass decoding and can persist zero-value statuses instead of returning HTTP 400.
4 open issues
1 file not reviewed
web/pnpm-lock.yaml: Generated file
What changed in this PR
Adds opt-in Postgres integration tests for Heimdall’s data layer and fixes the validation, persistence, and HTTP error handling they exposed. The stacked diff also includes build tooling and API tests from #197 and #198.
Changes:
- Adds database, API, and unit coverage with repeatable schema deployment.
- Requires explicit routing tags and corrects cluster updates and error responses.
- Adds Make-based workflows, configuration redaction, and container updates.
| File | Description |
|---|---|
| web/src/components/ListPage/__snapshots__/ListPage.test.tsx.snap | Refreshes list-page snapshots. |
| web/src/components/DetailPage/__snapshots__/DetailPage.test.tsx.snap | Refreshes detail-page snapshots. |
| web/Makefile | Adds web development targets. |
| test/pkg/testdb/testdb.go | Adds shared schema-deployment helper. |
| test/e2e/want_test.go | Records deferred behavior tests. |
| test/e2e/sync_test.go | Tests synchronous jobs. |
| test/e2e/routing_test.go | Tests routing and missing resources. |
| test/e2e/jobs_list_test.go | Tests filters, pagination, and cursors. |
| test/e2e/job_test.go | Tests asynchronous job lifecycle. |
| test/e2e/health_test.go | Tests cluster health endpoints. |
| test/e2e/client_test.go | Adds HTTP test helpers. |
| test/e2e/catalog_test.go | Tests catalog reads and statuses. |
| test/e2e/cancel_test.go | Tests cancellation and conflicts. |
| test/e2e/admin_test.go | Tests catalog registration and updates. |
| scripts/ci/smoke.sh | Adds stack smoke checks. |
| scripts/ci/coverage.sh | Adds coverage reporting and checks. |
| scripts/ci/coverage-baseline.txt | Records coverage baseline. |
| README.md | Documents Make and CLI usage. |
| pkg/plugin/auth.go | Documents authentication contract. |
| pkg/object/status/status_test.go | Tests object status serialization. |
| pkg/object/object.go | Adds required-tag validation helper. |
| pkg/object/object_test.go | Tests object initialization. |
| pkg/object/job/status/status_test.go | Tests job status serialization. |
| pkg/object/job/job.go | Validates routing criteria. |
| pkg/object/job/job_test.go | Tests initialization and criteria validation. |
| pkg/object/command/command.go | Requires command routing tags. |
| pkg/object/command/command_test.go | Tests caller rules and tags. |
| pkg/object/cluster/cluster.go | Requires cluster routing tags. |
| pkg/object/cluster/cluster_test.go | Tests required cluster tags. |
| pkg/duration/duration_test.go | Tests duration parsing and serialization. |
| pkg/context/context.go | Redacts YAML context output. |
| pkg/context/context_test.go | Tests redaction and secret preservation. |
| Makefile | Adds build, test, and development workflows. |
| internal/pkg/server/server.go | Adds request-body limit setting. |
| internal/pkg/rbac/ranger/print_test.go | Tests Ranger password redaction. |
| internal/pkg/rbac/ranger/client.go | Redacts passwords in YAML. |
| internal/pkg/object/command/starrocks/job_context.go | Removes a blank line. |
| internal/pkg/object/command/starrocks/backend_client_pool.go | Adds deprecation lint suppression. |
| internal/pkg/object/command/starrocks/arrow_types.go | Adds deprecation lint suppression. |
| internal/pkg/object/command/sparkeks/sparkeks.go | Adds upload deprecation suppressions. |
| internal/pkg/object/command/spark/spark.go | Adds upload deprecation suppressions. |
| internal/pkg/object/command/postgres/postgres.go | Removes unused mutex and wraps errors. |
| internal/pkg/object/command/ecs/ecs.go | Removes unused client field and import. |
| internal/pkg/janitor/stale_jobs_test.go | Uses database test helper. |
| internal/pkg/heimdall/validate_test.go | Tests startup routing validation. |
| internal/pkg/heimdall/stdout_test.go | Adds output and metric test helpers. |
| internal/pkg/heimdall/queries/cluster/upsert.sql | Updates version during cluster upsert. |
| internal/pkg/heimdall/print_test.go | Tests printed configuration redaction. |
| internal/pkg/heimdall/keepalive.go | Relocates default constant. |
| internal/pkg/heimdall/job.go | Validates routing and classifies job errors. |
| internal/pkg/heimdall/job_dal.go | Marks invalid cursors as client errors. |
| internal/pkg/heimdall/job_dal_test.go | Tests job persistence and pagination. |
| internal/pkg/heimdall/job_cursor_test.go | Tests cursor and seek helpers. |
| internal/pkg/heimdall/heimdall.go | Refactors CLI lifecycle and exact routing. |
| internal/pkg/heimdall/health.go | Classifies disabled checks as client errors. |
| internal/pkg/heimdall/handler.go | Adds body limits and error mapping. |
| internal/pkg/heimdall/handler_test.go | Tests parameter precedence and error statuses. |
| internal/pkg/heimdall/dal_helpers_test.go | Adds database fixture helpers. |
| internal/pkg/heimdall/command_dal.go | Validates tags before command writes. |
| internal/pkg/heimdall/command_dal_test.go | Tests command persistence. |
| internal/pkg/heimdall/cluster_dal.go | Validates tags before cluster writes. |
| internal/pkg/heimdall/cluster_dal_test.go | Tests cluster persistence. |
| internal/pkg/heimdall/auth.go | Rejects authentication plugin errors. |
| internal/pkg/database/redact.go | Redacts database connection passwords. |
| internal/pkg/database/redact_test.go | Tests connection-string redaction. |
| internal/pkg/database/filter.go | Removes shared template parsing state. |
| internal/pkg/database/filter_test.go | Tests rendering and concurrent use. |
| internal/pkg/database/deploy_test.go | Tests repeatable schema deployment. |
| internal/pkg/aws/s3.go | Adds upload deprecation suppression. |
| internal/pkg/auth/auth.go | Adjusts import grouping. |
| go.mod | Updates Go and dependencies. |
| entrypoint.sh | Uses new binary paths and server command. |
| Dockerfile | Builds through Make targets. |
| docker-compose.yaml | Adds health checks and build metadata. |
| configs/local.yaml | Updates plugin paths and test fixtures. |
| configs/local-cli.yaml | Adds host-based development configuration. |
| cmd/heimdall/heimdall.go | Delegates CLI execution to Heimdall. |
| .github/workflows/build.yml | Uses Make checks, builds, and tests. |
Review effort: Balanced
| @@ -84,7 +111,7 @@ func payloadHandler[T any](fn func(context.Context, *T) (any, error)) http.Handl | |||
| var payload T | |||
| if len(data) > 2 { | |||
| } | ||
| if body == nil { | ||
| writeAPIError(w, fmt.Errorf(formatFileNotFound, filename), nil) | ||
| writeAPIError(w, fmt.Errorf("%w: %s", ErrFileNotFound, filename), nil) |
Comment on lines
+310
to
+311
| for i, createdAt := range []int{100, 100, 100, 200, 200, 300, 300} { | ||
| id := string(rune('a' + i)) |
Comment on lines
+32
to
+52
| deployErr error | ||
| ) | ||
|
|
||
| // Open returns the test database, deploying the schema on the first call in this test binary. | ||
| // It skips the test when HEIMDALL_TEST_DATABASE is not set. | ||
| func Open(t *testing.T) *database.Database { | ||
|
|
||
| t.Helper() | ||
|
|
||
| connectionString := os.Getenv(envVar) | ||
| if connectionString == `` { | ||
| t.Skipf("%s is not set (run `make test-integration`)", envVar) | ||
| } | ||
|
|
||
| db := &database.Database{ConnectionString: connectionString} | ||
| deployOnce.Do(func() { deployErr = deploySchema(db) }) | ||
| if deployErr != nil { | ||
| t.Fatalf("deploy schema: %v", deployErr) | ||
| } | ||
|
|
||
| return db |
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.


What this does
It gives the data layer real tests: each test runs against a fresh Postgres database. Then it fixes what those tests turned up. Every fix lands with the test that proves it, so each commit can be reviewed on its own, in order.
Before you deploy: one behaviour change needs a config check
Routing tags are now required. That covers
tagsandcluster_tagson commands,tagson clusters, andcommand_criteriaandcluster_criteriaon jobs.An empty set used to match everything. Then it failed in one of three ways: a SQL syntax error (500), a panic (when the tags were left out entirely), or, for a sync job, the job ran but was never recorded. Routing should be intentional. If you really want "any cluster", give every cluster the same tag.
command ping-0.0.1: routing tags are required: cluster_tags.Please run
heimdall validate -conf <your config>on production configs before deploying. It runs the same check the server runs at startup.Running the tests
make db-up # compose Postgres on :5433
make test-integration # drops and recreates heimdall_test, then runs every test against it
HEIMDALL_TEST_DATABASEis set. Somake go-testand plaingo testbehave exactly as before.PKG=./internal/pkg/heimdall/...limits the run.heimdall_test.build.ymlhas no job for them. Happy to add one as a follow-up; it needs a Postgres service and onemakecall.Commits
Test infrastructure
make test-integrationand atest/pkg/testdbhelper.go test ./...runs packages in parallel against one database.created_at;Fixes (each turns a skipped
TestWant…into a regular test)TestMalformedBodyReturns400, e2eTestBadCursorReturns400TestMissingRoutingTagsReturn400,TestValidateRejectsUntaggedCatalogTestClusterUpsertTestNotFoundReturns404TestCancelFinishedJobConflictsTestUnroutableJobReturns400TestClusterHealthTestStatusForErrorpins the full error-to-status mapping. Client-side errors now start withbad request:, as cursor errors already did. Nothing in the repo, including the UI, matches on the old messages.Still open (skipped
TestWant…tests, each with the proposed fix in its comment)TestWantSubmitJobIgnoresClientStatus: a client can submit a job with"status": 6and it's stored as SUCCEEDED.TestWantCancelOnlyByOwner: any caller can cancel any job.TestWantSyncJobRecordedBeforeReturn: a sync job is inserted in a goroutine after submit returns, and an insert error is dropped.TestWantWrongMethodReturns405: a wrong method returns 404.TestWantPayloadLatencyPerRequest: thepayload_handlerlatency metric doesn't measure each request.TestWantSensitiveKeysConcurrentSafe: the sensitive-keys registry isn't safe for concurrent use.TestWantRedactsCommonSecretNames: redaction doesn't cover common secret names such as*_password,*_token,*_secretand*_key.