Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for running the tests #29

Open
arv opened this issue May 3, 2024 · 2 comments
Open

Instructions for running the tests #29

arv opened this issue May 3, 2024 · 2 comments

Comments

@arv
Copy link
Collaborator

arv commented May 3, 2024

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

> [email protected] 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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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.<anonymous> (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
Copy link
Owner

kibae commented May 3, 2024

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.)

services:
postgres:
image: kibaes/postgres-logical-replication-dev:14-dev-20221002
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_DB: playground
ports:
- "54320:5432"

Tests in GitHub Actions are also conducted in a similar environment

services:
postgres:
image: kibaes/postgres-logical-replication-dev:14-dev-20221002
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_DB: playground
ports:
- "5432:5432"
steps:

@arv
Copy link
Collaborator Author

arv commented May 3, 2024

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

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

No branches or pull requests

2 participants