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

SIGNREQUEST when using DockerComposeEnvironment #346

Closed
TheTFo opened this issue Apr 8, 2022 · 12 comments
Closed

SIGNREQUEST when using DockerComposeEnvironment #346

TheTFo opened this issue Apr 8, 2022 · 12 comments
Labels
triage Investigation required

Comments

@TheTFo
Copy link

TheTFo commented Apr 8, 2022

Expected Behaviour
Jest + Test Containers exits cleanly

Actual Behaviour
Receiving error "SIGNREQUEST"

Testcontainer Logs

~ git:(main) ✗ DEBUG=testcontainers yarn test:e2
e
yarn run v1.22.17
$ NODE_ENV=development jest --config=e2e/jest.config.js --runInBand --bail --verbose --logHeapUsage --detectOpenHandles --forceExit
  testcontainers DEBUG Found applicable Docker client strategy: UnixSocketStrategy +0ms
  testcontainers DEBUG Testing Docker client strategy URI: unix:///var/run/docker.sock +95ms
  testcontainers INFO  Starting DockerCompose environment: testcontainers-5681f3752d1331ef19b5998b9bfc2895 +7ms
  testcontainers DEBUG Creating new Reaper for session: cbcff6ec75188efa029d6c4e83c5133c +0ms
  testcontainers INFO  Using Docker client strategy: UnixSocketStrategy, Docker host: localhost +7ms
  testcontainers DEBUG No registry auth locator found for registry: "https://index.docker.io/v1/" +6ms
  testcontainers DEBUG Not pulling image as it already exists: testcontainers/ryuk:0.3.2 +110ms
  testcontainers INFO  Creating container for image: testcontainers/ryuk:0.3.2 +2ms
  testcontainers INFO  Starting container testcontainers/ryuk:0.3.2 with ID: 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +73ms
  testcontainers DEBUG System diagnostics: {"node":{"version":"v17.3.0","architecture":"x64","platform":"linux"},"docker":{"serverVersion":"20.10.12","operatingSystem":"Ubuntu 20.04.4 LTS","operatingSystemType":"linux","architecture":"x86_64","cpus":16,"memory":33377583104},"dockerCompose":{"version":"1.25.0"}} +175ms
  testcontainers DEBUG Waiting for container to be ready: 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +161ms
  testcontainers DEBUG Waiting for host port 49176 for 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +1ms
  testcontainers DEBUG Waiting for internal port 8080 for 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +2ms
  testcontainers DEBUG Host port 49176 ready for 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +12ms
  testcontainers DEBUG Internal port 8080 ready for 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +227ms
  testcontainers INFO  Container is ready +1ms
  testcontainers DEBUG Connecting to Reaper 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed on localhost:49176 +0ms
  testcontainers DEBUG Connected to Reaper 982fe6ac5cc7526090f75273aad1b3e6c8ee9fe39fcd109f2efd8a09e91f9fed +1ms
  testcontainers INFO  Upping DockerCompose environment +1ms
  testcontainers INFO  Upped DockerCompose environment +1s
  testcontainers INFO  Started the following containers: /kafka, /schemaregistry, /zookeeper +9ms
  testcontainers INFO  Waiting for container schemaregistry to be ready +23ms
  testcontainers DEBUG Waiting for host port 8085 for 41200224c7b5f66d2bf863b029b8f95213aca2ae9c596cb6bbb8afa8961dacfa +2ms
  testcontainers DEBUG Waiting for internal port 8085 for 41200224c7b5f66d2bf863b029b8f95213aca2ae9c596cb6bbb8afa8961dacfa +2ms
  testcontainers INFO  Waiting for container kafka to be ready +13ms
  testcontainers DEBUG Waiting for host port 29092 for 99cf386a165da6ea51a93a86b7aca90c2b51bdeebc2a7153ee022ca451bdd514 +1ms
  testcontainers DEBUG Waiting for internal port 29092 for 99cf386a165da6ea51a93a86b7aca90c2b51bdeebc2a7153ee022ca451bdd514 +2ms
  testcontainers DEBUG Host port 8085 ready for 41200224c7b5f66d2bf863b029b8f95213aca2ae9c596cb6bbb8afa8961dacfa +12ms
  testcontainers DEBUG Host port 29092 ready for 99cf386a165da6ea51a93a86b7aca90c2b51bdeebc2a7153ee022ca451bdd514 +1ms
  testcontainers INFO  Waiting for container zookeeper to be ready +25ms
  testcontainers DEBUG Waiting for host port 2181 for 17276708ce16b913b87e0a78611a6f2ce06326e47ac1db713425d47f71a8b8f8 +0ms
  testcontainers DEBUG Waiting for internal port 2181 for 17276708ce16b913b87e0a78611a6f2ce06326e47ac1db713425d47f71a8b8f8 +2ms
  testcontainers DEBUG Host port 2181 ready for 17276708ce16b913b87e0a78611a6f2ce06326e47ac1db713425d47f71a8b8f8 +8ms
  testcontainers DEBUG Internal port 2181 ready for 17276708ce16b913b87e0a78611a6f2ce06326e47ac1db713425d47f71a8b8f8 +4s
  testcontainers INFO  Container zookeeper is ready +0ms
  testcontainers DEBUG Internal port 29092 ready for 99cf386a165da6ea51a93a86b7aca90c2b51bdeebc2a7153ee022ca451bdd514 +2s
  testcontainers INFO  Container kafka is ready +1ms
  testcontainers DEBUG Internal port 8085 ready for 41200224c7b5f66d2bf863b029b8f95213aca2ae9c596cb6bbb8afa8961dacfa +3s
  testcontainers INFO  Container schemaregistry is ready +0ms
  testcontainers INFO  DockerCompose environment started: kafka, schemaregistry, zookeeper +0ms
  testcontainers INFO  Stopping DockerCompose environment +17ms
  testcontainers INFO  Stopped DockerCompose environment +5s
  testcontainers INFO  Downing DockerCompose environment +1ms
  testcontainers INFO  Downed DockerCompose environment +502ms
 PASS  e2e/testcontainers.e2e.ts (17.598 s, 186 MB heap size)
  GenericContainer
    ✓ works (15 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        17.658 s

Jest has detected the following 2 open handles potentially keeping Jest from exiting:

  ●  SIGNREQUEST

      1 | import path from "path";
    > 2 | import {
        | ^
      3 |   DockerComposeEnvironment,
      4 |   StartedDockerComposeEnvironment,
      5 | } from "testcontainers";

      at node_modules/ssh2/lib/protocol/constants.js:22:20
      at Object.<anonymous> (node_modules/ssh2/lib/protocol/constants.js:29:3)
      at Object.<anonymous> (node_modules/ssh2/lib/protocol/keyParser.js:24:46)
      at Object.<anonymous> (node_modules/ssh2/lib/agent.js:9:35)
      at Object.<anonymous> (node_modules/ssh2/lib/index.js:10:5)
      at Object.<anonymous> (node_modules/docker-modem/lib/ssh.js:1:96)
      at Object.<anonymous> (node_modules/docker-modem/lib/modem.js:6:9)
      at Object.<anonymous> (node_modules/dockerode/lib/docker.js:2:11)
      at Object.<anonymous> (node_modules/testcontainers/dist/docker/docker-client.js:16:37)
      at Object.<anonymous> (node_modules/testcontainers/dist/reaper.js:17:25)
      at Object.<anonymous> (node_modules/testcontainers/dist/generic-container/generic-container.js:21:18)
      at Object.<anonymous> (node_modules/testcontainers/dist/index.js:4:27)
      at Object.<anonymous> (e2e/testcontainers.e2e.ts:2:1)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (node_modules/@jest/core/build/runJest.js:404:19)
      at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
      at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)


  ●  SIGNREQUEST

      1 | import path from "path";
    > 2 | import {
        | ^
      3 |   DockerComposeEnvironment,
      4 |   StartedDockerComposeEnvironment,
      5 | } from "testcontainers";

      at node_modules/ssh2/lib/protocol/constants.js:23:25
      at Object.<anonymous> (node_modules/ssh2/lib/protocol/constants.js:29:3)
      at Object.<anonymous> (node_modules/ssh2/lib/protocol/keyParser.js:24:46)
      at Object.<anonymous> (node_modules/ssh2/lib/agent.js:9:35)
      at Object.<anonymous> (node_modules/ssh2/lib/index.js:10:5)
      at Object.<anonymous> (node_modules/docker-modem/lib/ssh.js:1:96)
      at Object.<anonymous> (node_modules/docker-modem/lib/modem.js:6:9)
      at Object.<anonymous> (node_modules/dockerode/lib/docker.js:2:11)
      at Object.<anonymous> (node_modules/testcontainers/dist/docker/docker-client.js:16:37)
      at Object.<anonymous> (node_modules/testcontainers/dist/reaper.js:17:25)
      at Object.<anonymous> (node_modules/testcontainers/dist/generic-container/generic-container.js:21:18)
      at Object.<anonymous> (node_modules/testcontainers/dist/index.js:4:27)
      at Object.<anonymous> (e2e/testcontainers.e2e.ts:2:1)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (node_modules/@jest/core/build/runJest.js:404:19)
      at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
      at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)

Done in 18.25s.

Steps to Reproduce
Note: Using docker-compose for this, and not the pre-built kafka container, because I also want schema registry

Using docker-compose

version: "3.0"

# Borrowed from https://github.com/confluentinc/schema-registry-workshop

services:
  zookeeper:
    image: confluentinc/cp-zookeeper:5.1.2
    container_name: zookeeper
    restart: always
    environment:
      ZOOKEEPER_SERVER_ID: 1
      ZOOKEEPER_CLIENT_PORT: "2181"
      ZOOKEEPER_TICK_TIME: "2000"
      ZOOKEEPER_SERVERS: "zookeeper:22888:23888"
    ports:
      - "2181:2181"

  kafka1:
    image: confluentinc/cp-enterprise-kafka:5.1.2
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      # Exposes 29092 for external connections to the broker
      # Use kafka1:9092 for connections internal on the docker network
      # See https://rmoff.net/2018/08/02/kafka-listeners-explained/ for details
      - "29092:29092"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_BROKER_ID: 1
      KAFKA_BROKER_RACK: "r1"
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_DELETE_TOPIC_ENABLE: "true"
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
      KAFKA_SCHEMA_REGISTRY_URL: "schemaregistry:8085"
      KAFKA_JMX_PORT: 9991

  schemaregistry:
    image: confluentinc/cp-schema-registry:5.1.2
    container_name: schemaregistry
    restart: always
    depends_on:
      - zookeeper
    environment:
      SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: "zookeeper:2181"
      SCHEMA_REGISTRY_HOST_NAME: schemaregistry
      SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8085"
    ports:
      - 8085:8085

With this test file

import path from "path";
import {
  DockerComposeEnvironment,
  StartedDockerComposeEnvironment,
} from "testcontainers";

import { createKafkaClient, Producer } from "../packages/events-core";

function startupDockerComposeEnvironment() {
  return new DockerComposeEnvironment(
    path.resolve(__dirname),
    "docker-compose.yml"
  ).up();
}

describe("GenericContainer", () => {
  jest.setTimeout(1000 * 60 * 5);

  let environment: StartedDockerComposeEnvironment;
  beforeAll(async () => {
    environment = await startupDockerComposeEnvironment();
  });

  afterAll(async () => {
    await environment.stop();
    await environment.down();
  });

  it("works", async () => {
    const kafkaClient = createKafkaClient({
      brokers: [`localhost:29092`],
      clientId: "myClient",
    });
    const producer = new Producer(kafkaClient);
    await producer.connect();
    await producer.disconnect();
  });
});

Started with: NODE_ENV=development jest --config=e2e/jest.config.js --runInBand --bail --verbose --logHeapUsage --detectOpenHandles --forceExit

Environment Information

  • Operating System: Ubuntu 20.04.4 LTS
  • Docker Version: 20.10.12, build e91ed57
  • Node version: v16.13.2 (also tested in 17.3.0)
  • Testcontainers version: 8.6.1
@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Apr 10, 2022

Relates to #310, @SkySails were you able to find the issue?

@SkySails
Copy link

Unfortunately not, I'm still seeing this occasionally unless I add manual timeouts!

@cristianrgreco
Copy link
Collaborator

@TheTFo could you pls share the version of Jest you are using?

@TheTFo
Copy link
Author

TheTFo commented Apr 12, 2022 via email

@cristianrgreco cristianrgreco added the triage Investigation required label Apr 12, 2022
@TheTFo
Copy link
Author

TheTFo commented Apr 12, 2022

I'm using Jest 27.5.1 with ts-jest 27.1.4. Hope that helps!

I should add, I've removed the CLI args indicating open handles for now and things seem to be running fine. I generally like to run with it with TestContainers as it's pretty easy to leave them open.

@jondot
Copy link

jondot commented Apr 25, 2022

Try something like this:

const l = await redisContainer.logs()
l.destroy()
await sleep(500)

@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Apr 29, 2022

FYI I've raised an issue with ssh2 and jest (jestjs/jest#12775), will be tracking that for more information/progress. From what I've checked so far I don't see any way to circumvent it while keeping --detectOpenHandles enabled.

@cristianrgreco
Copy link
Collaborator

The PR for jest has been merged (jestjs/jest#12789). Waiting for the next release to confirm and close this issue.

@cristianrgreco
Copy link
Collaborator

Should be fixed in Jest v28.1.0, could anyone please confirm?

@SkySails
Copy link

SkySails commented May 6, 2022

@cristianrgreco Can confirm, I can't reproduce the issue using my steps from #310 ! Thanks a lot for looking into and fixing this!

@cristianrgreco
Copy link
Collaborator

Great! And thank you @SkySails for bringing this issue to my attention and for your help in resolving it! 🙂

@TheTFo
Copy link
Author

TheTFo commented Oct 11, 2022 via email

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

No branches or pull requests

4 participants