Foo-Foo-MQ / foo-foo-mq

Abstractions around RabbitMQ
MIT License
49 stars 24 forks source link

Failing test when handling a channel failure #53

Open zlintz opened 10 months ago

zlintz commented 10 months ago

See the discussion here https://github.com/Foo-Foo-MQ/foo-foo-mq/pull/16 for context.

In src/connectionFsm.js there is a todo to figure out why the commented out code is causing test failures. It

Failures seen here:

https://github.com/Foo-Foo-MQ/foo-foo-mq/actions/runs/7660491629/job/20877897843#step:8:423

222 passing (14s) 3 failing

1) Adding Queues when the queue does not already exist should error on addQueue in passive mode: AssertionError: expected 'Error: Failed to create queue \'no-qu…' to include 'Failed to create queue \'no-queue-her…' at /home/runner/work/foo-foo-mq/foo-foo-mq/spec/integration/addPassiveQueue.spec.js:2:940 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

2) Bad Connection when attempting a connection should fail to connect: TypeError: Cannot read properties of undefined (reading 'should') at Context. (spec/integration/badConnection.spec.js:2:1022) at process.processImmediate (node:internal/timers:476:21)

3) Bad Connection when attempting a uri connection with an invalid password should fail to connect: TypeError: Cannot read properties of undefined (reading 'should') at Context. (spec/integration/badConnection.spec.js:2:2046) at process.processImmediate (node:internal/timers:476:21)

MartianH commented 7 months ago

@zlintz there is some type of race condition when running the spec/integration tests. I have a separate branch where I rewrote the project in ESM with amqplib: ~0.10.3 and am seeing the same problem. Once you run the tests one by one, they all pass.

Steps should be taken to rewrite the setup and teardown parts to avoid this. As of now, there is a single spec/setup.js that is imported in every test case that provides globals, which is an outdated and ill-advised pattern. I am pretty sure this is where the problem lies.

zlintz commented 2 months ago

You are probably correct. Things (test) are not written to be parallel currently is my conclusion. Do you have a proposal?