kibae / pg-logical-replication

PostgreSQL Logical Replication client for node.js
https://www.npmjs.com/package/pg-logical-replication
MIT License
95 stars 22 forks source link

Instructions for running the tests #29

Open arv opened 5 months ago

arv commented 5 months ago

I have postgres.app installed and running on port 5432 but there seems to be something else that I need to do to verify that things work as expected?

I also tried using act but I'm getting the same errors.

Here are the errors I'm seeing.

Terminal output

``` ~/src/pg-logical-replication qualify-paths ✗ 21m ◒ ⍉ ▶ POSTGRES_PORT=5432 npm run test > pg-logical-replication@2.0.4 test > jest --maxWorkers=1 FAIL src/test/decoder-wal2json.spec.ts ● wal2json › Insert, Delete(w/FK) error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● wal2json › Update error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'end') 18 | 19 | afterAll(async () => { > 20 | await client.end(); | ^ 21 | }); 22 | 23 | it('Insert, Delete(w/FK)', async () => { at Object. (src/test/decoder-wal2json.spec.ts:20:18) FAIL src/test/decoder-test.spec.ts ● test_decoding › Insert, Delete(w/FK) error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● test_decoding › Update error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'end') 17 | 18 | afterAll(async () => { > 19 | await client.end(); | ^ 20 | }); 21 | 22 | it('Insert, Delete(w/FK)', async () => { at Object. (src/test/decoder-test.spec.ts:19:18) FAIL src/test/decoder-pgoutput.spec.ts ● pgoutput › Insert, Delete(w/FK) error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● pgoutput › Update error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● pgoutput › Rollback error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● pgoutput › Huge transaction error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'query') 28 | 29 | afterAll(async () => { > 30 | await client.query( | ^ 31 | //language=sql 32 | `DROP 33 | PUBLICATION IF EXISTS "${publicationName}"` at Object. (src/test/decoder-pgoutput.spec.ts:30:18) FAIL src/test/acknowledge.spec.ts ● acknowledge › Resume streaming using the internal _lastLsn value error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'end') 18 | 19 | afterAll(async () => { > 20 | await client.end(); | ^ 21 | }); 22 | 23 | it('Resume streaming using the internal _lastLsn value', async () => { at Object. (src/test/acknowledge.spec.ts:20:18) FAIL src/test/decoder-decoderbufs.spec.ts ● decoderbufs › Insert, Delete(w/FK) error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● decoderbufs › Update error: database "playground" does not exist at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69) at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21) at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30) at Socket. (node_modules/pg-protocol/src/index.ts:7:48) ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'end') 21 | 22 | afterAll(async () => { > 23 | await client.end(); | ^ 24 | }); 25 | 26 | it('Insert, Delete(w/FK)', async () => { at Object. (src/test/decoder-decoderbufs.spec.ts:23:18) Test Suites: 5 failed, 5 total Tests: 11 failed, 11 total Snapshots: 0 total Time: 1.3 s, estimated 2 s Ran all test suites. ~/src/pg-logical-replication qualify-paths ✗ 23m ◒ ⍉ ▶ ```

If I run

psql -c 'create table playground'

and then run the tests again using:

POSTGRES_PORT=5432 npm run test

I get a bunch of other errors.

kibae commented 5 months ago

Hi :)

Testing is performed using a dedicated Docker image. Try launching a Docker container using the file infra/docker-pg-logical-replication/docker-compose.yml. (You can change port number or remove POSTGRES_PORT from command. Test uses pgsql port 54320 as you knows.)

https://github.com/kibae/pg-logical-replication/blob/1f50224fe9c1dc8a304ea964ad323fbc96cc329f/infra/docker-pg-logical-replication/docker-compose.yml#L1-L9

Tests in GitHub Actions are also conducted in a similar environment https://github.com/kibae/pg-logical-replication/blob/1f50224fe9c1dc8a304ea964ad323fbc96cc329f/.github/workflows/node.js.yml#L20-L30

arv commented 5 months ago

Thanks that worked. Here is what I did for future visitors:

cd infra/docker-pg-logical-replication
docker-compose up

In a new tab/terminal

POSTGRES_PORT=54320 npm run test