diff --git a/.gitignore b/.gitignore index 05c1fab..5071ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ release build *.swp *~ + +# test +docker-compose.dockest-generated.yml +dockest-error.json \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cccf297..04230b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.8' services: kafka: # https://hub.docker.com/r/confluentinc/cp-kafka @@ -32,3 +32,5 @@ services: avro_tools: # https://hub.docker.com/r/coderfi/avro-tools image: coderfi/avro-tools:1.7.7 + ports: + - '9999:9999' \ No newline at end of file diff --git a/dockest.ts b/dockest.ts index 7cfa0c0..125823d 100644 --- a/dockest.ts +++ b/dockest.ts @@ -1,51 +1,30 @@ -import { default as Dockest, runners, logLevel } from 'dockest' +import { Dockest, sleepWithLog, logLevel } from 'dockest' +import { DockestService } from 'dockest/dist/@types' -const { ZooKeeperRunner, SimpleRunner, KafkaRunner } = runners - -const zooKeeperRunner = new ZooKeeperRunner({ - service: 'zooKeeper', - ports: { - [ZooKeeperRunner.DEFAULT_PORT]: ZooKeeperRunner.DEFAULT_PORT, - }, -}) - -/** - * Debug SchemaRegistry with CURL: https://docs.confluent.io/2.0.0/schema-registry/docs/intro.html - */ -const schemaRegistryRunner = new SimpleRunner({ - service: 'schemaRegistry', - image: 'confluentinc/cp-schema-registry:5.5.3', - ports: { - '8982': '8081', - }, - environment: { - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: `${zooKeeperRunner.runnerConfig.service}:${ZooKeeperRunner.DEFAULT_PORT}`, - SCHEMA_REGISTRY_HOST_NAME: 'localhost', - }, -}) - -const kafkaRunner = new KafkaRunner({ - service: 'kafka', - image: 'confluentinc/cp-kafka:5.5.3', - dependsOn: [zooKeeperRunner], - ports: { - [KafkaRunner.DEFAULT_PORT_PLAINTEXT]: KafkaRunner.DEFAULT_PORT_PLAINTEXT, +const dockest = new Dockest({ + composeFile: 'docker-compose.yml', + dumpErrors: true, + jestLib: require('jest'), + jestOpts: { + updateSnapshot: true, }, + logLevel: logLevel.DEBUG, }) -const dockest = new Dockest({ - runners: [kafkaRunner, schemaRegistryRunner], - jest: { - lib: require('jest'), - verbose: true, +const dockestServices: DockestService[] = [ + { + serviceName: 'zooKeeper', + dependents: [ + { + serviceName: 'kafka', + readinessCheck: () => sleepWithLog(10, `Sleeping for Kafka`), + }, + ], }, - opts: { - logLevel: logLevel.DEBUG, - afterSetupSleep: 35, - dev: { - debug: process.argv[2] === 'debug' || process.argv[2] === 'dev', - }, + { + serviceName: 'schemaRegistry', + readinessCheck: () => sleepWithLog(35, `Sleeping for Schema Registry`), }, -}) +] -dockest.run() +dockest.run(dockestServices) \ No newline at end of file diff --git a/package.json b/package.json index 719cf85..1b37c64 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@typescript-eslint/eslint-plugin": "^2.1.0", "@typescript-eslint/parser": "^2.1.0", "@typescript-eslint/typescript-estree": "^2.1.0", - "dockest": "^1.0.3", + "dockest": "^2.1.0", "eslint": "^6.3.0", "eslint-config-prettier": "^6.1.0", "eslint-plugin-no-only-tests": "^2.3.1",