Note: I'm raising this retrospectively having investigated and found a solution. I'll raise a PR to illustrate how to resolve this issue.
Describe the bug
The kafka template for the nodejs-express stack creates a producer and consumer and tries to connect to a Kafka server based on the KAFKA_BOOTSTRAP_SERVERS env var.
If a Kafka is reachable, then the producer and consumer will connect when the app is initialized during the stack tests. When the stack tests complete, they will call close on the HTTP server, however because there are still Kafka clients connected, the test process will never terminate.
To Reproduce
You can do a straightforward recreate as follows:
mkdir testkafka && cd testkafka && appsody init nodejs-express kafka
appsody test
As there is no local kafka running, this will eventually terminate as the kafka broker connections time out.
If you stand up a local kafka and then run, it'll hang:
docker-compose up -d
appsody test --network testkafka_default --docker-options "--env KAFKA_BOOTSTRAP_SERVERS=kafka:9092"
Expected behavior
Tests should pass, and then the appsody test command should complete.
Actual behaviour
Tests pass, but then appsody test hangs (never completes).
Note: I'm raising this retrospectively having investigated and found a solution. I'll raise a PR to illustrate how to resolve this issue.
Describe the bug The
kafka
template for thenodejs-express
stack creates a producer and consumer and tries to connect to a Kafka server based on theKAFKA_BOOTSTRAP_SERVERS
env var.If a Kafka is reachable, then the producer and consumer will connect when the app is initialized during the stack tests. When the stack tests complete, they will call
close
on the HTTP server, however because there are still Kafka clients connected, the test process will never terminate.To Reproduce You can do a straightforward recreate as follows:
As there is no local kafka running, this will eventually terminate as the kafka broker connections time out. If you stand up a local kafka and then run, it'll hang:
Expected behavior Tests should pass, and then the
appsody test
command should complete.Actual behaviour Tests pass, but then
appsody test
hangs (never completes).