All Projects → whisklabs → Docker It Scala

whisklabs / Docker It Scala

Licence: mit
Docker integration testing kit with Scala

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Docker It Scala

Stubby4j
An HTTP stub server for testing application interactions with web services (REST, etc) & external system stubbing for easy testing
Stars: ✭ 300 (-29.74%)
Mutual labels:  integration-testing
Go Txdb
Immutable transaction isolated sql driver for golang
Stars: ✭ 348 (-18.5%)
Mutual labels:  integration-testing
Awesome Docker
🐳 A curated list of Docker resources and projects
Stars: ✭ 20,870 (+4787.59%)
Mutual labels:  docker-container
Arquillian Core
Arquillian provides a component model for integration tests, which includes dependency injection and container life cycle management. Instead of managing a runtime in your test, Arquillian brings your test to the runtime.
Stars: ✭ 315 (-26.23%)
Mutual labels:  integration-testing
Mockttp
Powerful friendly HTTP mock server & proxy
Stars: ✭ 346 (-18.97%)
Mutual labels:  integration-testing
Appium Docker Android
Appium Server setup to automate android testing on real devices
Stars: ✭ 360 (-15.69%)
Mutual labels:  docker-container
Cli
✨ A powerful CLI for the Create Go App project. Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!
Stars: ✭ 292 (-31.62%)
Mutual labels:  docker-container
Jmockit1
Advanced Java library for integration testing, mocking, faking, and code coverage
Stars: ✭ 400 (-6.32%)
Mutual labels:  integration-testing
Chronos
📊 📊 📊 Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.
Stars: ✭ 347 (-18.74%)
Mutual labels:  docker-container
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+782.9%)
Mutual labels:  integration-testing
Portainer
Making Docker and Kubernetes management easy.
Stars: ✭ 20,434 (+4685.48%)
Mutual labels:  docker-container
Swirl
A web UI for Docker, focused on swarm cluster.
Stars: ✭ 332 (-22.25%)
Mutual labels:  docker-container
Docker Pi Hole
Pi-hole in a docker container
Stars: ✭ 4,288 (+904.22%)
Mutual labels:  docker-container
Dockercheatsheet
🐋 Docker Cheat Sheet 🐋
Stars: ✭ 3,301 (+673.07%)
Mutual labels:  docker-container
Venom
🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Stars: ✭ 384 (-10.07%)
Mutual labels:  integration-testing
Aws Es Kibana
AWS ElasticSearch Kibana Proxy
Stars: ✭ 297 (-30.44%)
Mutual labels:  docker-container
Nbomber
Modern and flexible load testing framework for Pull and Push scenarios, designed to test any system regardless a protocol (HTTP/WebSockets/AMQP etc) or a semantic model (Pull/Push).
Stars: ✭ 354 (-17.1%)
Mutual labels:  integration-testing
Greenmail
Official master for the Greenmail project
Stars: ✭ 424 (-0.7%)
Mutual labels:  integration-testing
Gnomock
Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻
Stars: ✭ 398 (-6.79%)
Mutual labels:  integration-testing
Dockerspawner
Spawns JupyterHub single user servers in Docker containers
Stars: ✭ 368 (-13.82%)
Mutual labels:  docker-container

docker-it-scala

Build Status Maven Central Join the chat at https://gitter.im/whisklabs/docker-it-scala

Set of utility classes to make integration testing with dockerised services in Scala easy.

You can read about reasoning behind it at Finely Distributed.

Setup

docker-it-scala can work with two underlying libraries to communicate to docker engine through REST API or unix socket.

Note: there is no specific recommendation to use one of them, over the other, but we hear people using Spotify's one more often, so you might get better support for it.

There are separate artifacts available for these libraries:

Spotify's docker-client

libraryDependencies ++= Seq(
  "com.whisk" %% "docker-testkit-scalatest" % "0.9.9" % "test",
  "com.whisk" %% "docker-testkit-impl-spotify" % "0.9.9" % "test")

docker-java

libraryDependencies ++= Seq(
  "com.whisk" %% "docker-testkit-scalatest" % "0.9.9" % "test",
  "com.whisk" %% "docker-testkit-impl-docker-java" % "0.9.9" % "test")

You don't necessarily have to use scalatest dependency as demonstrated above. You can create your custom bindings into your test environment, whether you use different initialisation technique or different framework. Have a look at this specific trait

Overriding execution environment

If you need to have a custom environment setup, you need to override dockerFactory field, providing DockerClient instance

import com.spotify.docker.client.{DefaultDockerClient, DockerClient}
import com.whisk.docker.{DockerFactory, DockerKit}

trait MyCustomDockerKitSpotify extends DockerKit {

  private val client: DockerClient = DefaultDockerClient.fromEnv().build()

  override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(client)
}

Check docker-client library project for configuration options.

Configuration

You should be able to provide configuration purely through environment variables.

Examples:

export DOCKER_HOST=tcp://127.0.0.1:2375
export DOCKER_HOST=unix:///var/run/docker.sock

Sample Services

Defining Containers

There are two ways to define a docker container.

Code based definitions and via typesafe-config.

Code based definitions

import com.whisk.docker.{DockerContainer, DockerKit, DockerReadyChecker}

trait DockerMongodbService extends DockerKit {

  val DefaultMongodbPort = 27017

  val mongodbContainer = DockerContainer("mongo:3.0.6")
    .withPorts(DefaultMongodbPort -> None)
    .withReadyChecker(DockerReadyChecker.LogLineContains("waiting for connections on port"))
    .withCommand("mongod", "--nojournal", "--smallfiles", "--syncdelay", "0")

  abstract override def dockerContainers: List[DockerContainer] =
    mongodbContainer :: super.dockerContainers
}

You can check usage example

Typesafe Configuration

docker-testkit-config enables you to use a typesafe config to define your docker containers. Just put an application.conf file in your classpath.

The container definitions are nested in the structure of name docker

docker {
...
...
}

See application.conf for more examples.

Usage in code

trait DockerMongodbService extends DockerKitConfig {

  val mongodbContainer = configureDockerContainer("docker.mongodb")

  abstract override def dockerContainers: List[DockerContainer] =
    mongodbContainer :: super.dockerContainers
}

Container Paths

  • Cassandra => docker.cassandra
  • Elasticsearch => docker.elasticsearch
  • Kafka => docker.kafka
  • Mongodb => docker.mongo
  • Neo4j => docker.neo4j
  • Postgres => docker.postgres

Fields

  • image-name required (String)
  • environmental-variables optional (Array of Strings)
  • ready-checker optional structure
    • log-line optional (String)
    • http-response-code
      • code optional (Int - defaults to 200)
      • port required (Int)
      • path optional (String - defaults to /)
      • within optional (Int)
      • looped optional structure
        • attempts required (Int)
        • delay required (Int)
  • port-maps optional structure (list of structures)
    • SOME_MAPPING_NAME
      • internal required (Int)
      • external optional (Int)
  • volume-maps optional structure (list of structures)
    • container required (String)
    • host required (String)
    • rw optional (Boolean - default:false)

Testkit

There are two testkits available -- one for scalatest and one for specs2.

Both set up the necessary docker containers and check that they are ready BEFORE any test is run, and doesn't close the container until ALL the tests are run.

Using in ScalaTest:

class MyMongoSpec extends FlatSpec with Matchers with DockerMongodbService {
  ...
}

With Multiple containers:

class AllAtOnceSpec extends FlatSpec with Matchers with BeforeAndAfterAll with GivenWhenThen with ScalaFutures
    with DockerElasticsearchService with DockerCassandraService with DockerNeo4jService with DockerMongodbService {

  implicit val pc = PatienceConfig(Span(20, Seconds), Span(1, Second))

  "all containers" should "be ready at the same time" in {
    dockerContainers.map(_.image).foreach(println)
    dockerContainers.forall(_.isReady().futureValue) shouldBe true
  }
}

Using in Specs2

Examples can be found in the specs2 module's tests

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].