Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QdrantContainer wrapper #374

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ lazy val root = (project in file("."))
moduleMockserver,
moduleNginx,
modulePulsar,
moduleQuadrant,
moduleRabbitmq,
moduleRedis,
moduleToxiproxy,
Expand Down Expand Up @@ -431,6 +432,14 @@ lazy val modulePulsar = (project in file("modules/pulsar"))
libraryDependencies ++= Dependencies.modulePulsar.value
)

lazy val moduleQuadrant = (project in file("modules/quadrant"))
.dependsOn(core % "compile->compile;test->test;provided->provided", scalatest % "test->test")
.settings(commonSettings)
.settings(
name := "testcontainers-scala-quadrant",
libraryDependencies ++= Dependencies.moduleQuadrant.value
)

lazy val moduleRabbitmq = (project in file("modules/rabbitmq"))
.dependsOn(core % "compile->compile;test->test;provided->provided", scalatest % "test->test")
.settings(commonSettings)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.dimafeng.testcontainers

import org.testcontainers.images.builder.Transferable
import org.testcontainers.qdrant.{QdrantContainer => JavaQdrantContainer}
import org.testcontainers.utility.DockerImageName

class QdrantContainer(
underlying: JavaQdrantContainer
) extends SingleContainer[JavaQdrantContainer] { self =>

override val container: JavaQdrantContainer = underlying

def grpcPort: Int = container.getGrpcPort

def grpcHostAddress: String = container.getGrpcHostAddress

}

object QdrantContainer {

val defaultImage = "qdrant/qdrant"
val defaultTag = "v1.12.1"
val defaultDockerImageName = s"$defaultImage:$defaultTag"

case class Def(
dockerImageName: DockerImageName = DockerImageName.parse(QdrantContainer.defaultDockerImageName),
builder: List[JavaQdrantContainer => JavaQdrantContainer] = List.empty
) extends ContainerDef {
override type Container = QdrantContainer

def withApiKey(apiKey: String): Def =
copy(builder = ((_: JavaQdrantContainer).withApiKey(apiKey)) :: builder)

def withConfigFile(configFile: Transferable): Def =
copy(builder = ((_: JavaQdrantContainer).withConfigFile(configFile)) :: builder)

override def createContainer(): QdrantContainer =
new QdrantContainer(
builder
.foldRight(new JavaQdrantContainer(dockerImageName))((f, underlying) => f(underlying))
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.dimafeng.testcontainers

import com.dimafeng.testcontainers.scalatest.TestContainersForAll
import io.qdrant.client.{QdrantClient, QdrantGrpcClient}
import org.scalatest.flatspec.AnyFlatSpec

import java.util.UUID

class QdrantSpec extends AnyFlatSpec with TestContainersForAll {
override type Containers = QdrantContainer

override def startContainers(): QdrantContainer =
QdrantContainer.Def().withApiKey(QdrantSpec.apiKey).start()

"Qdrant container" should "be started" in withContainers { qdrantContainer =>
val client = new QdrantClient(
QdrantGrpcClient
.newBuilder(qdrantContainer.host, qdrantContainer.grpcPort, false)
.withApiKey(QdrantSpec.apiKey)
.build()
)
val healthCheckReply = client.healthCheckAsync().get()

assert(healthCheckReply.getVersion.nonEmpty)
}

}

object QdrantSpec {
val apiKey: String = UUID.randomUUID().toString
}
9 changes: 9 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object Dependencies {
private val jedisVersion = "5.0.0"
private val wireMockTestcontainersVersion = "1.0-alpha-13"
private val milvusSdkVersion = "2.4.1"
private val quadrantClientVersion = "1.12.0"
private val yugabyteJdbcVersion = "42.3.5-yb-6"
private val yugabyteJavaDriverVersion = "4.15.0-yb-2-TESTFIX.0"

Expand Down Expand Up @@ -257,6 +258,14 @@ object Dependencies {
)
)

val moduleQuadrant = Def.setting(
COMPILE(
"org.testcontainers" % "qdrant" % testcontainersVersion
) ++ TEST(
"io.qdrant" % "client" % quadrantClientVersion
)
)

val moduleRabbitmq = Def.setting(
COMPILE(
"org.testcontainers" % "rabbitmq" % testcontainersVersion
Expand Down
Loading