{"id":13416522,"url":"https://github.com/whisklabs/docker-it-scala","last_synced_at":"2025-05-16T12:07:06.955Z","repository":{"id":26432464,"uuid":"29883033","full_name":"whisklabs/docker-it-scala","owner":"whisklabs","description":"Docker integration testing kit with Scala","archived":false,"fork":false,"pushed_at":"2024-02-14T12:56:54.000Z","size":443,"stargazers_count":432,"open_issues_count":26,"forks_count":91,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-12T06:12:48.566Z","etag":null,"topics":["docker","docker-container","integration-testing","scala","testing"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whisklabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-26T21:41:31.000Z","updated_at":"2025-03-18T01:57:23.000Z","dependencies_parsed_at":"2024-06-19T01:53:12.493Z","dependency_job_id":null,"html_url":"https://github.com/whisklabs/docker-it-scala","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisklabs%2Fdocker-it-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisklabs%2Fdocker-it-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisklabs%2Fdocker-it-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisklabs%2Fdocker-it-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whisklabs","download_url":"https://codeload.github.com/whisklabs/docker-it-scala/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-container","integration-testing","scala","testing"],"created_at":"2024-07-30T21:01:00.119Z","updated_at":"2025-04-12T06:12:55.580Z","avatar_url":"https://github.com/whisklabs.png","language":"Scala","funding_links":[],"categories":["Development with Docker"],"sub_categories":["API Client"],"readme":"docker-it-scala\n=============\n\n[![CI](https://github.com/whisklabs/docker-it-scala/actions/workflows/ci.yaml/badge.svg)](https://github.com/whisklabs/docker-it-scala/actions/workflows/ci.yaml)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.whisk/docker-testkit-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.whisk/docker-testkit-core_2.12)\n[![Join the chat at https://gitter.im/whisklabs/docker-it-scala](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/whisklabs/docker-it-scala?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nSet of utility classes to make integration testing with dockerised services in Scala easy.\n\nYou can read about reasoning behind it at [Finely Distributed](https://finelydistributed.io/integration-testing-with-docker-and-scala-85659d037740#.8mbrg311p).\n\n## Setup\n\ndocker-it-scala works with Spotify's docker-client to communicate to docker engine through *REST API* or *unix socket*.\n- [Spotify's docker-client](https://github.com/spotify/docker-client) (used in Whisk)\n\n```scala\nlibraryDependencies ++= Seq(\n  \"com.whisk\" %% \"docker-testkit-scalatest\" % \"0.11.0\" % \"test\"\n```\n\n### Configuration\n\nYou should be able to provide configuration purely through environment variables.\n\nExamples:\n\n```\nexport DOCKER_HOST=tcp://127.0.0.1:2375\n```\n\n```\nexport DOCKER_HOST=unix:///var/run/docker.sock\n```\n\n\n# Sample Services\n\n- [Elasticsearch](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerElasticsearchService.scala)\n- [Mongodb](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerMongodbService.scala)\n- [MySQL](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerMysqlService.scala)\n- [Postgres](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerPostgresService.scala)\n- [Clickhouse](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerClickhouseService.scala)\n- [Multi container test](https://github.com/whisklabs/docker-it-scala/blob/master/tests/src/test/scala/com/whisk/docker/testkit/test/MultiContainerTest.scala)\n# Defining Containers\n\nThere are two ways to define a docker container.\n\nCode based definitions and via `typesafe-config`.\n\n## Code based definitions\n\n```scala\nimport com.whisk.docker.testkit.scalatest.DockerTestKitForAll\nimport org.scalatest.Suite\n\ntrait DockerMongodbService extends DockerTestKitForAll {\n  self: Suite =\u003e\n\n  val DefaultMongodbPort = 27017\n\n  val mongodbContainer = ContainerSpec(\"mongo:3.4.8\")\n    .withExposedPorts(DefaultMongodbPort)\n    .withReadyChecker(DockerReadyChecker.LogLineContains(\"waiting for connections on port\"))\n    .toContainer\n\n  override val managedContainers: ManagedContainers = mongodbContainer.toManagedContainer\n}\n```\n\nYou can check [usage example](https://github.com/whisklabs/docker-it-scala/blob/master/tests/src/test/scala/com/whisk/docker/testkit/test/MongodbServiceTest.scala)\n\n### Container Paths\n\n- Elasticsearch =\u003e `docker.elasticsearch`\n- Mongodb =\u003e `docker.mongo`\n- Neo4j =\u003e `docker.mysql`\n- Postgres =\u003e `docker.postgres`\n- Clickhouse =\u003e `docker.clickhouse`\n### Fields\n\n- `image-name` required  (String)\n- `container-name` optional (String)\n- `command` optional (Array of Strings)\n- `entrypoint` optional (Array of Strings)\n- `environmental-variables` optional (Array of Strings)\n- `ready-checker` optional structure\n  - `log-line` optional (String)\n  - `http-response-code`\n    - `code` optional (Int - defaults to `200`)\n    - `port` required (Int)\n\t- `path` optional (String - defaults to `/`)\n\t- `within` optional (Int)\n\t- `looped` optional structure\n      - `attempts` required (Int)\n      - `delay` required (Int)\n- `port-maps` optional structure (list of structures)\n  - `SOME_MAPPING_NAME`\n    - `internal` required (Int)\n    - `external` optional (Int)\n- `volume-maps` optional structure (list of structures)\n  - `container` required (String)\n  - `host`      required (String)\n  - `rw`        optional (Boolean - default:false)\n- `memory` optional (Long)\n- `memory-reservation` optional (Long)\n\n# Testkit\n\nThere are two testkits available -- one for `scalatest` and one for\n`specs2`.\n\nBoth set up the necessary docker containers and check that they are\nready **BEFORE** any test is run, and doesn't close the container\nuntil **ALL** the tests are run.\n\n\n## Using in ScalaTest:\n\n```scala\nclass MyMongoSpec extends FlatSpec with Matchers with DockerMongodbService {\n  ...\n}\n```\n\n### With Multiple containers:\n\n```scala\nclass MultiContainerTest\n  extends AnyFunSuite\n    with DockerElasticsearchService\n    with DockerMongodbService {\n\n  override val managedContainers: ContainerGroup =\n    ContainerGroup.of(elasticsearchContainer, mongodbContainer)\n\n  test(\"both containers should be ready\") {\n    assert(\n      elasticsearchContainer.state().isInstanceOf[ContainerState.Ready],\n      \"elasticsearch container is ready\"\n    )\n    assert(elasticsearchContainer.mappedPortOpt(9200).nonEmpty, \"elasticsearch port is exposed\")\n\n    assert(mongodbContainer.state().isInstanceOf[ContainerState.Ready], \"mongodb is ready\")\n    assert(mongodbContainer.mappedPortOpt(27017).nonEmpty, \"port 2017 is exposed\")\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhisklabs%2Fdocker-it-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhisklabs%2Fdocker-it-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhisklabs%2Fdocker-it-scala/lists"}