Skip to content

Commit f346459

Browse files
committed
Remove old information from readme file
1 parent a3e9225 commit f346459

File tree

1 file changed

+35
-105
lines changed

1 file changed

+35
-105
lines changed

README.md

Lines changed: 35 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,14 @@ You can read about reasoning behind it at [Finely Distributed](https://finelydis
1111

1212
## Setup
1313

14-
docker-it-scala can work with two underlying libraries to communicate to docker engine through *REST API* or *unix socket*.
14+
docker-it-scala works with Spotify's docker-client to communicate to docker engine through *REST API* or *unix socket*.
1515
- [Spotify's docker-client](https://github.com/spotify/docker-client) (used in Whisk)
16-
- [docker-java](https://github.com/docker-java/docker-java)
17-
18-
*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*.
19-
20-
There are separate artifacts available for these libraries:
21-
22-
**Spotify's docker-client**
2316

2417
```scala
2518
libraryDependencies ++= Seq(
26-
"com.whisk" %% "docker-testkit-scalatest" % "0.11.0" % "test",
27-
"com.whisk" %% "docker-testkit-impl-spotify" % "0.11.0" % "test")
19+
"com.whisk" %% "docker-testkit-scalatest" % "0.11.0" % "test"
2820
```
2921

30-
**docker-java**
31-
32-
```scala
33-
libraryDependencies ++= Seq(
34-
"com.whisk" %% "docker-testkit-scalatest" % "0.11.0" % "test",
35-
"com.whisk" %% "docker-testkit-impl-docker-java" % "0.11.0" % "test")
36-
```
37-
38-
You don't necessarily have to use `scalatest` dependency as demonstrated above.
39-
You can create your custom bindings into your test environment, whether you use different initialisation technique or different framework.
40-
Have a look at [this specific trait](https://github.com/whisklabs/docker-it-scala/blob/master/scalatest/src/main/scala/com/whisk/docker/scalatest/DockerTestKit.scala)
41-
42-
43-
### Overriding execution environment
44-
45-
If you need to have a custom environment setup, you need to override `dockerFactory` field, providing `DockerClient` instance
46-
47-
```scala
48-
import com.spotify.docker.client.{DefaultDockerClient, DockerClient}
49-
import com.whisk.docker.{DockerFactory, DockerKit}
50-
51-
trait MyCustomDockerKitSpotify extends DockerKit {
52-
53-
private val client: DockerClient = DefaultDockerClient.fromEnv().build()
54-
55-
override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(client)
56-
}
57-
58-
```
59-
60-
Check [docker-client](https://github.com/spotify/docker-client) library project for configuration options.
61-
6222
### Configuration
6323

6424
You should be able to provide configuration purely through environment variables.
@@ -76,12 +36,11 @@ export DOCKER_HOST=unix:///var/run/docker.sock
7636

7737
# Sample Services
7838

79-
- [Cassandra](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerCassandraService.scala)
80-
- [Elasticsearch](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerElasticsearchService.scala)
81-
- [Kafka](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerKafkaService.scala)
82-
- [Mongodb](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerMongodbService.scala)
83-
- [Neo4j](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerNeo4jService.scala)
84-
- [Postgres](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerPostgresService.scala)
39+
- [Elasticsearch](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerElasticsearchService.scala)
40+
- [Mongodb](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerMongodbService.scala)
41+
- [MySQL](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerMysqlService.scala)
42+
- [Postgres](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/testkit/DockerPostgresService.scala)
43+
- [Multi container test](https://github.com/whisklabs/docker-it-scala/blob/master/tests/src/test/scala/com/whisk/docker/testkit/test/MultiContainerTest.scala)
8544

8645
# Defining Containers
8746

@@ -92,63 +51,30 @@ Code based definitions and via `typesafe-config`.
9251
## Code based definitions
9352

9453
```scala
95-
import com.whisk.docker.{DockerContainer, DockerKit, DockerReadyChecker}
54+
import com.whisk.docker.testkit.scalatest.DockerTestKitForAll
55+
import org.scalatest.Suite
9656

97-
trait DockerMongodbService extends DockerKit {
57+
trait DockerMongodbService extends DockerTestKitForAll {
58+
self: Suite =>
9859

9960
val DefaultMongodbPort = 27017
10061

101-
val mongodbContainer = DockerContainer("mongo:3.0.6")
102-
.withPorts(DefaultMongodbPort -> None)
62+
val mongodbContainer = ContainerSpec("mongo:3.4.8")
63+
.withExposedPorts(DefaultMongodbPort)
10364
.withReadyChecker(DockerReadyChecker.LogLineContains("waiting for connections on port"))
104-
.withCommand("mongod", "--nojournal", "--smallfiles", "--syncdelay", "0")
65+
.toContainer
10566

106-
abstract override def dockerContainers: List[DockerContainer] =
107-
mongodbContainer :: super.dockerContainers
67+
override val managedContainers: ManagedContainers = mongodbContainer.toManagedContainer
10868
}
10969
```
11070

111-
You can check [usage example](https://github.com/whisklabs/docker-it-scala/blob/master/scalatest/src/test/scala/com/whisk/docker/MongodbServiceSpec.scala)
112-
113-
## Typesafe Configuration
114-
115-
`docker-testkit-config` enables you to use a typesafe config to
116-
define your docker containers. Just put an `application.conf` file in
117-
your classpath.
118-
119-
The container definitions are nested in the structure of name `docker`
120-
121-
```conf
122-
docker {
123-
...
124-
...
125-
}
126-
```
127-
128-
See
129-
[application.conf](https://github.com/whisklabs/docker-it-scala/blob/master/config/src/test/resources/application.conf)
130-
for more examples.
131-
132-
Usage in code
133-
134-
```scala
135-
trait DockerMongodbService extends DockerKitConfig {
136-
137-
val mongodbContainer = configureDockerContainer("docker.mongodb")
138-
139-
abstract override def dockerContainers: List[DockerContainer] =
140-
mongodbContainer :: super.dockerContainers
141-
}
142-
143-
```
71+
You can check [usage example](https://github.com/whisklabs/docker-it-scala/blob/master/tests/src/test/scala/com/whisk/docker/testkit/test/MongodbServiceTest.scala)
14472

14573
### Container Paths
14674

147-
- Cassandra => `docker.cassandra`
14875
- Elasticsearch => `docker.elasticsearch`
149-
- Kafka => `docker.kafka`
15076
- Mongodb => `docker.mongo`
151-
- Neo4j => `docker.neo4j`
77+
- Neo4j => `docker.mysql`
15278
- Postgres => `docker.postgres`
15379

15480
### Fields
@@ -200,19 +126,23 @@ class MyMongoSpec extends FlatSpec with Matchers with DockerMongodbService {
200126
### With Multiple containers:
201127

202128
```scala
203-
class AllAtOnceSpec extends FlatSpec with Matchers with BeforeAndAfterAll with GivenWhenThen with ScalaFutures
204-
with DockerElasticsearchService with DockerCassandraService with DockerNeo4jService with DockerMongodbService {
205-
206-
implicit val pc: PatienceConfig = PatienceConfig(Span(20, Seconds), Span(1, Second))
207-
208-
"all containers" should "be ready at the same time" in {
209-
dockerContainers.map(_.image).foreach(println)
210-
dockerContainers.forall(_.isReady().futureValue) shouldBe true
129+
class MultiContainerTest
130+
extends AnyFunSuite
131+
with DockerElasticsearchService
132+
with DockerMongodbService {
133+
134+
override val managedContainers: ContainerGroup =
135+
ContainerGroup.of(elasticsearchContainer, mongodbContainer)
136+
137+
test("both containers should be ready") {
138+
assert(
139+
elasticsearchContainer.state().isInstanceOf[ContainerState.Ready],
140+
"elasticsearch container is ready"
141+
)
142+
assert(elasticsearchContainer.mappedPortOpt(9200).nonEmpty, "elasticsearch port is exposed")
143+
144+
assert(mongodbContainer.state().isInstanceOf[ContainerState.Ready], "mongodb is ready")
145+
assert(mongodbContainer.mappedPortOpt(27017).nonEmpty, "port 2017 is exposed")
211146
}
212147
}
213-
```
214-
215-
## Using in Specs2
216-
217-
Examples can be found in
218-
[the specs2 module's tests](https://github.com/whisklabs/docker-it-scala/tree/master/specs2/src/test/scala/com/whisk/docker)
148+
```

0 commit comments

Comments
 (0)