Skip to content

Commit

Permalink
Merge pull request #374 from victornguen/qdrant-wrapper
Browse files Browse the repository at this point in the history
Add QdrantContainer wrapper
  • Loading branch information
dimafeng authored Nov 1, 2024
2 parents f8dfa9c + 974c104 commit 5fbed8d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
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

0 comments on commit 5fbed8d

Please sign in to comment.