Skip to content

Spoc-505: Fix Codacy issues and rewrite golang tests with the built-in PostgreSQL infrastructure#36

Merged
mason-sharp merged 3 commits intomainfrom
spoc-505
Apr 15, 2026
Merged

Spoc-505: Fix Codacy issues and rewrite golang tests with the built-in PostgreSQL infrastructure#36
mason-sharp merged 3 commits intomainfrom
spoc-505

Conversation

@danolivo
Copy link
Copy Markdown
Contributor

Purpose

Branch spoc-505 removes the Go test suite from lolor as part of the
ongoing effort to eliminate Go infrastructure from the repository. Before
anything could be deleted, the three large-object operations that only the
Go tests exercised — lo_lseek, lo_tell, and lo_truncate — needed
coverage in the native PostgreSQL test suite.

Changes

Add regression and TAP tests for lo_lseek, lo_tell, lo_truncate

sql/lolor.sql and expected/lolor.out gain three new sections that
exercise each operation in isolation: seeking to an offset and overwriting
partial content, tracking cursor position before and after a write, and
truncating an object to a shorter length.

t/005_logical_replication.pl is extended with the same three operations
in a publisher/subscriber scenario. After each mutating step the test
waits for subscriber catchup and asserts the correct content on both nodes.
Two catalog-consistency checks are also added, confirming that
lolor.pg_largeobject_metadata and lolor.pg_largeobject row counts match
between nodes after all operations.

Remove Go test suite and infrastructure

tests/go/ (main_test.go, go.mod, test.properties, README),
docker/test-configs/test.properties.go, and the Golang section of
docker/run-tests.sh are deleted. The golang:1.22.4 base image in
docker/Dockerfile.tester is replaced with debian:bookworm, which
provides the same OS environment without the Go toolchain.

The Go-based test suite covered three large-object operations —
lo_lseek, lo_tell, and lo_truncate — that had no equivalent in the
SQL regression or TAP tests.  Add coverage for all three before the
Go tests are removed.

sql/lolor.sql and expected/lolor.out: three new sections exercise
lo_lseek (seek to offset 15, overwrite 11 bytes, read back and verify
the splice), lo_tell (confirm cursor is at 0 on a fresh open and at 11
after a lowrite of 11 bytes), and lo_truncate (write 36 bytes, truncate
to 10, verify only the prefix survives).

t/005_logical_replication.pl: extend the logical-replication scenario
with the same three operations on the publisher side, wait for subscriber
catchup after each mutating step, and assert the correct content on both
nodes.  Also add catalog-consistency checks that confirm
lolor.pg_largeobject_metadata and lolor.pg_largeobject row counts match
between publisher and subscriber after all operations.~
The Go tests covered lo_lseek, lo_tell, and lo_truncate operations that
were not tested elsewhere.  Those gaps have now been filled by SQL
regression tests and TAP tests, making the Go suite redundant.

Remove tests/go/ (main_test.go, go.mod, test.properties, README),
docker/test-configs/test.properties.go, the Golang section from
docker/run-tests.sh, and replace the golang:1.22.4 Docker base image
in docker/Dockerfile.tester with debian:bookworm, which provides the
same OS environment without the Go toolchain.
@danolivo danolivo self-assigned this Apr 14, 2026
@danolivo danolivo added the enhancement New feature or request label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@danolivo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 10 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 33 minutes and 10 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a03eb2e1-5f99-4497-a5c9-81fe117002d5

📥 Commits

Reviewing files that changed from the base of the PR and between f412035 and 9c82c73.

📒 Files selected for processing (1)
  • t/005_logical_replication.pl
📝 Walkthrough

Walkthrough

This pull request removes the Go-based test suite and migrates testing to SQL and Perl-based approaches. The changes eliminate Go toolchain dependencies, remove Go test files and configuration, and add comprehensive SQL regression checks for large-object operations with logical replication coverage.

Changes

Cohort / File(s) Summary
Go Testing Infrastructure Removal
docker/Dockerfile.tester, docker/run-tests.sh, tests/go/go.mod, tests/go/README.md, tests/go/main_test.go
Removed Go test execution pipeline, including Docker base image change from golang:1.22.4 to debian:bookworm, eliminated Go test runner block, and deleted all Go test files and their dependencies.
Test Configuration Cleanup
docker/test-configs/test.properties.go, tests/go/test.properties
Removed Go-specific test property files containing database connection URLs and node configuration mappings.
SQL Test Enhancements
sql/lolor.sql, t/005_logical_replication.pl
Added comprehensive SQL regression tests for large-object cursor/position operations (lo_lseek, lo_tell, lo_truncate) and logical replication validation with cross-node catalog consistency checks.

Poem

🐰 A Go test suite hops away,
SQL takes over the test day!
Cursors seek, positions tell,
Large objects replicate well,
In Perl and SQL we now play! 🗄️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective: removing Go tests and rewriting them using PostgreSQL infrastructure, with a specific issue reference (Spoc-505).
Description check ✅ Passed The description clearly explains the purpose and changes: removing Go test infrastructure after providing equivalent coverage in PostgreSQL test suites for three large-object operations (lo_lseek, lo_tell, lo_truncate).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spoc-505

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 14, 2026

Up to standards ✅

🟢 Issues 5 high

Results:
5 new issues

Category Results
Compatibility 5 high

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docker/Dockerfile.tester (1)

11-19: Consider running the container as a non-root user.

The Dockerfile creates the pgedge user but never switches to it. The container will run as root, which violates security best practices. Since this user is already created and the test scripts appear to work under /home/pgedge, adding a USER directive should be straightforward.

🔒 Proposed fix to run as non-root user
 WORKDIR /home/pgedge/lolor/tests
+USER pgedge
 CMD /home/pgedge/run-tests.sh

Static analysis hint: Trivy DS-0002 - "Image user should not be 'root'. Specify at least 1 USER command in Dockerfile with non-root user as argument."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker/Dockerfile.tester` around lines 11 - 19, The Dockerfile creates the
pgedge user and copies run-tests.sh but never switches away from root; update
the Dockerfile to run the container as the non-root user by adding a USER pgedge
directive after setting ownership/permissions (ensure /home/pgedge/run-tests.sh
is chowned to pgedge and made executable and the WORKDIR
/home/pgedge/lolor/tests is owned by pgedge) so that CMD
/home/pgedge/run-tests.sh executes as the pgedge user rather than root;
reference the pgedge user, run-tests.sh, WORKDIR and CMD instructions when
applying the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@t/005_logical_replication.pl`:
- Around line 103-129: The test currently writes 11 bytes to large object 4 on
$publisher using lowrite but never waits for replication or asserts the
subscriber state; add a replication wait and a subscriber-side assertion: after
the publisher block that calls lowrite(:fd) and lo_close(:fd), call
wait_for_catchup(...) to ensure the subscriber has applied the change, then run
the same lo_open/lo_tell/lo_close sequence against $subscriber (using
$subscriber->safe_psql) and assert the lo_tell result is '11'. Reference the
existing symbols: $publisher, $subscriber, lowrite, lo_tell, lo_open, lo_close,
and wait_for_catchup to locate where to insert the wait and the subscriber
verification.

---

Nitpick comments:
In `@docker/Dockerfile.tester`:
- Around line 11-19: The Dockerfile creates the pgedge user and copies
run-tests.sh but never switches away from root; update the Dockerfile to run the
container as the non-root user by adding a USER pgedge directive after setting
ownership/permissions (ensure /home/pgedge/run-tests.sh is chowned to pgedge and
made executable and the WORKDIR /home/pgedge/lolor/tests is owned by pgedge) so
that CMD /home/pgedge/run-tests.sh executes as the pgedge user rather than root;
reference the pgedge user, run-tests.sh, WORKDIR and CMD instructions when
applying the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61b02868-7a57-4ce6-a6fb-8bc8bed5effc

📥 Commits

Reviewing files that changed from the base of the PR and between 2fdbdba and f412035.

⛔ Files ignored due to path filters (1)
  • expected/lolor.out is excluded by !**/*.out
📒 Files selected for processing (9)
  • docker/Dockerfile.tester
  • docker/run-tests.sh
  • docker/test-configs/test.properties.go
  • sql/lolor.sql
  • t/005_logical_replication.pl
  • tests/go/README.md
  • tests/go/go.mod
  • tests/go/main_test.go
  • tests/go/test.properties
💤 Files with no reviewable changes (6)
  • tests/go/test.properties
  • docker/run-tests.sh
  • docker/test-configs/test.properties.go
  • tests/go/go.mod
  • tests/go/README.md
  • tests/go/main_test.go

Comment thread t/005_logical_replication.pl
@danolivo danolivo requested a review from mason-sharp April 14, 2026 10:19
@mason-sharp mason-sharp merged commit f8e7c0f into main Apr 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants