Skip to content

Add test coverage for Postgres audit log functionality#45

Merged
rbjornstad merged 3 commits intopostgres-auditfrom
copilot/sub-pr-44
Feb 4, 2026
Merged

Add test coverage for Postgres audit log functionality#45
rbjornstad merged 3 commits intopostgres-auditfrom
copilot/sub-pr-44

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 4, 2026

Addresses gaps in test coverage for the Postgres audit logging feature introduced in the parent PR.

Changes

  • FakeClients signature: Changed from hardcoded "prod" environment to accept envName parameter, matching reconciler lookup pattern via env.EnvironmentName

    // Before
    func FakeClients(objects ...runtime.Object) K8sClients {
        clientSets["prod"] = clients{...}
    }
    
    // After
    func FakeClients(envName string, objects ...runtime.Object) K8sClients {
        clientSets[envName] = clients{...}
    }
  • TestGeneratePostgresLogSinkName: Added coverage parallel to existing TestGenerateLogSinkName for simple names, hyphenated names, and truncation/hashing for names exceeding 100 characters

  • TestPostgresAuditEnabled: Added three test cases:

    • Postgres cluster with audit.enabled: false → no sink created
    • k8sClients: nil → graceful handling without errors
    • Postgres cluster with audit.enabled: true → sink creation attempted

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • logging.googleapis.com
    • Triggering command: /tmp/go-build2238488704/b001/audit.test /tmp/go-build2238488704/b001/audit.test -test.testlogfile=/tmp/go-build2238488704/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=TestGeneratePostgresLogSinkName|TestPostgresAuditEnabled pimachinery@v0.3-ifaceassert ep/bin/linux-x64/rg --gdwarf-5 ions/policy/v1be-l mpile ep/bin/linux-x64internal/reconcilers/google/audit/sql.go -o dDuleILOr .cfg 0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet -p cilers/google/au-o mpile 0.1-go1.25.6.lin-importcfg (dns block)
    • Triggering command: /tmp/go-build3375315084/b001/audit.test /tmp/go-build3375315084/b001/audit.test -test.testlogfile=/tmp/go-build3375315084/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=TestGeneratePostgresLogSinkName|TestPostgresAuditEnabled om/go-openapi/sw-ifaceassert ep/bin/linux-x64/rg -p ions/storage/v1a-l mpile ep/bin/linux-x64internal/reconcilers/google/audit/iam.go -o en8D88-EN .cfg 0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet -p enapi/swag/jsonu-atomic mpile cilers/google/au-buildtags (dns block)
    • Triggering command: /tmp/go-build1234764806/b001/audit.test /tmp/go-build1234764806/b001/audit.test -test.testlogfile=/tmp/go-build1234764806/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2238488704/b831/vet.cfg g_.a pi@v0.35.0/apiserverinternal/v1a-ifaceassert 0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet -p d/autoscaling/v2-l mpile 0.1-go1.25.6.lininternal/reconcilers/google/audit/log_buckets.go -w v-guQjFeh .cfg ux-amd64/pkg/tool/linux_amd64/vet -c v1 mpile ux-amd64/pkg/too-buildtags (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Feb 4, 2026
Copilot AI changed the title [WIP] Add Postgres audit support for Kubernetes testing Add test coverage for Postgres audit functionality Feb 4, 2026
Copilot AI requested a review from rbjornstad February 4, 2026 15:25
@rbjornstad rbjornstad marked this pull request as ready for review February 4, 2026 15:33
- Updated FakeClients to accept environment name parameter
- Updated all existing test calls to FakeClients with environment parameter
- Added TestGeneratePostgresLogSinkName with coverage for simple names, names with hyphens, and long names requiring truncation
- Added TestPostgresAuditEnabled with three test cases:
  * Verifies no sink created when Postgres cluster has audit disabled
  * Verifies no error when k8s clients unavailable
  * Verifies sink creation attempted when Postgres cluster has audit enabled

Co-authored-by: rbjornstad <2776430+rbjornstad@users.noreply.github.com>
Copilot AI requested a review from a team as a code owner February 4, 2026 15:49
Replace incorrect check for hyphens with proper validation that the truncated name differs from the natural name when it exceeds length limit.

Co-authored-by: rbjornstad <2776430+rbjornstad@users.noreply.github.com>
Copilot AI changed the title Add test coverage for Postgres audit functionality Add test coverage for Postgres audit log functionality Feb 4, 2026
@rbjornstad rbjornstad merged commit 891536c into postgres-audit Feb 4, 2026
9 checks passed
@rbjornstad rbjornstad deleted the copilot/sub-pr-44 branch February 4, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants