-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DockerClickhouseService to facilitate clickhouse integration in d…
…ocker (#152)
- Loading branch information
1 parent
306cdbb
commit 6ad2022
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
samples/src/main/scala/com/whisk/docker/testkit/DockerClickhouseService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.whisk.docker.testkit | ||
|
||
import com.spotify.docker.client.messages.PortBinding | ||
import com.whisk.docker.testkit.scalatest.DockerTestKitForAll | ||
import org.scalatest.Suite | ||
|
||
import scala.concurrent.duration._ | ||
|
||
trait DockerClickhouseService extends DockerTestKitForAll { self: Suite => | ||
override val dockerTestTimeouts: DockerTestTimeouts = DockerTestTimeouts(pull = 10.minutes, init = 10.minutes, stop = 1.minutes) | ||
|
||
def ClickhouseAdvertisedPort = 8123 | ||
def ClickhouseExposedPort = 8123 | ||
|
||
val ClickhouseUser = "default" | ||
val ClickhousePassword = "" | ||
|
||
val clickhouseContainer = ContainerSpec("clickhouse/clickhouse-server:23.6") | ||
.withEnv(s"CLICKHOUSE_USER=$ClickhouseUser", s"CLICKHOUSE_PASSWORD=$ClickhousePassword") | ||
.withPortBindings((ClickhouseAdvertisedPort, PortBinding.of("0.0.0.0", ClickhouseExposedPort))) | ||
.withReadyChecker( | ||
DockerReadyChecker | ||
.Jdbc( | ||
driverClass = "com.clickhouse.jdbc.ClickHouseDriver", | ||
user = ClickhouseUser, | ||
password = Some(ClickhousePassword) | ||
) | ||
.looped(15, 1.second) | ||
) | ||
.toContainer | ||
|
||
override val managedContainers: ManagedContainers = clickhouseContainer.toManagedContainer | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/src/test/scala/com/whisk/docker/testkit/test/ClickhouseServiceTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.whisk.docker.testkit.test | ||
|
||
import com.whisk.docker.testkit.{ContainerState, DockerClickhouseService} | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class ClickhouseServiceTest extends AnyFunSuite with DockerClickhouseService { | ||
test("test container started") { | ||
assert(clickhouseContainer.state().isInstanceOf[ContainerState.Ready], "clickhouse is ready") | ||
assert(clickhouseContainer.mappedPortOpt(ClickhouseAdvertisedPort) === Some(ClickhouseExposedPort), | ||
"clickhouse port exposed") | ||
} | ||
} |