Skip to content

feat(e2e): add Postgres DB layer e2e test suite - #1477

Open
adityavshinde wants to merge 1 commit into
tektoncd:mainfrom
adityavshinde:test/postgres-e2e-db-layer
Open

feat(e2e): add Postgres DB layer e2e test suite#1477
adityavshinde wants to merge 1 commit into
tektoncd:mainfrom
adityavshinde:test/postgres-e2e-db-layer

Conversation

@adityavshinde

Copy link
Copy Markdown
Contributor

Changes

Add Postgres-specific e2e test suite (test/e2e/db/) that exercises database
behavior the SQLite-backed unit tests cannot reach: pgconn.PgError SQLSTATE
error mapping, jsonb column types and operators, CEL -> SQL filter/sort/pagination
on real Postgres, FK cascade, and schema correctness.

Tests run against the deployed API server in the kind cluster and its live
Postgres instance via gRPC - not an in-process server or throwaway database.

What's included:

  • Error mapping tests (unique violation, FK violation, stale etag, NotFound, cascade delete)
  • Schema validation (column types, PKs, unique indexes, FKs, jsonb @>)
  • Lister contract tests (filter, order, pagination with pageSize≥5, ListRecords)
  • Placeholder stubs with t.Skip for future stories (labels, migrations, relationships, retention)
  • Shared client config extracted to test/e2e/client/config.go (eliminates duplication between e2e_test.go and db_test.go)
  • CI wiring in e2e.sh: port-forward on 15432, DB_URL env var, password suppressed from traces, cleanup on failure
  • test/e2e/README.md and test/e2e/db/README.md updated/created

/kind feature

Submitter Checklist

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Tested your changes locally (if this is a code change)
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user-facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contain the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesnt merit a release note. labels Sep 2, 2026
@tekton-robot
tekton-robot requested review from enarha and khrm September 2, 2026 09:58
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign khrm after the PR has been reviewed.
You can assign the PR to them by writing /assign @khrm in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 2, 2026
@adityavshinde adityavshinde changed the title test harness for postgres e2e db layer feat(e2e): add Postgres DB layer e2e test suite Sep 2, 2026
Comment thread test/e2e/client/config.go Fixed
@adityavshinde
adityavshinde force-pushed the test/postgres-e2e-db-layer branch 2 times, most recently from f610774 to debdf91 Compare September 2, 2026 11:52
- Add DB layer e2e tests (error mapping, schema validation, lister
  behavior) under test/e2e/db/ with build tag e2e
- Fix seedResults in lister_test.go: lowercase status names to match
  API name regex, populate mandatory Summary.Record and Summary.Type
- Remove InsecureSkipVerify TLS fallback in test/e2e/client/config.go
  to resolve CodeQL critical alert; fail explicitly on missing certs
- Add run_db_tests function in e2e.sh with port-forward and DB_URL
  setup; exclude db tests from main e2e run
- Fix stale variable reference in e2e_gcs_test.go:
  allNamespacesReadAccessTokenFile to allNamespacesReadAccessToken

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several assertions can produce false positives and do not fully validate the advertised database behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds PostgreSQL-specific end-to-end coverage against the deployed API server and live database.

Changes:

  • Adds schema, error-mapping, filtering, sorting, and pagination tests.
  • Centralizes e2e client configuration.
  • Wires database tests and PostgreSQL port-forwarding into CI.
File summaries
File Description
test/e2e/README.md Documents database tests.
test/e2e/e2e.sh Runs database tests against port-forwarded PostgreSQL.
test/e2e/e2e_test.go Uses shared client configuration.
test/e2e/e2e_gcs_test.go Updates shared token usage.
test/e2e/client/config.go Adds reusable client environment and TLS configuration.
test/e2e/db/README.md Documents database suite setup and scope.
test/e2e/db/db_test.go Initializes API clients and database connection.
test/e2e/db/error_mapping_test.go Tests PostgreSQL error translation and cascades.
test/e2e/db/lister_test.go Tests filtering, ordering, and pagination.
test/e2e/db/schema_test.go Validates live PostgreSQL schema behavior.
test/e2e/db/labels_test.go Adds future label-test placeholders.
test/e2e/db/migrations_test.go Adds future migration-test placeholders.
test/e2e/db/relationships_test.go Adds future relationship-test placeholders.
test/e2e/db/retention_test.go Adds future retention-test placeholder.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +323 to +327
for _, r := range resp.Results {
if r.Summary.Status != pb.RecordSummary_SUCCESS {
t.Errorf("filter leaked non-SUCCESS result: %s (status=%v)", r.Name, r.Summary.Status)
}
successNames = append(successNames, r.Name)
Comment on lines +234 to +237
err = rawDB.Raw(
`SELECT count(*) FROM results WHERE annotations @> ?`,
`{"env":"production"}`,
).Scan(&count).Error
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 8, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

@adityavshinde: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesnt merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants