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

move to test containers, some updates of components #203

Merged
merged 4 commits into from
Jul 9, 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
45 changes: 22 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import sbt.Keys.thisProjectRef

ThisBuild / organization := "io.waylay.kairosdb"

val playWsVersion = "3.0.3"
val playJsonVersion = "3.0.3"
val specs2Version = "4.20.6"
val playWsVersion = "3.0.3"
val playJsonVersion = "3.0.4"
val specs2Version = "4.20.8"

val dockerTestkitVersion = "0.12.0"
val scalaTestVersion = "3.2.18"
val playVersion = "3.0.3" // test only
val testContainersVersion = "0.41.4"
val scalaTestVersion = "3.2.19"
val playVersion = "3.0.4" // test only

val scala2_13 = "2.13.14"

Expand All @@ -28,30 +28,29 @@ val exclusions = Seq(

lazy val root = (project in file("."))
.settings(
name := "kairosdb-scala",
Test / fork := true,
name := "kairosdb-scala",
Test / fork := true,
IntegrationTest / parallelExecution := false,
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.1",
"org.playframework" %% "play-json" % playJsonVersion,
"org.playframework" %% "play-ws-standalone" % playWsVersion,
"org.playframework" %% "play-ws-standalone-json" % playWsVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"io.lemonlabs" %% "scala-uri" % "4.0.3",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.1",
"org.playframework" %% "play-json" % playJsonVersion,
"org.playframework" %% "play-ws-standalone" % playWsVersion,
"org.playframework" %% "play-ws-standalone-json" % playWsVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"io.lemonlabs" %% "scala-uri" % "4.0.3",
// TEST
"org.specs2" %% "specs2-core" % specs2Version % Test,
"org.specs2" %% "specs2-junit" % specs2Version % Test,
"de.leanovate.play-mockws" %% "play-mockws-3-0" % "3.0.4" % Test,
"org.playframework" %% "play-ahc-ws" % playVersion % TestAndIntegrationTest, // neede for play-mockws
"org.specs2" %% "specs2-core" % specs2Version % Test,
"org.specs2" %% "specs2-junit" % specs2Version % Test,
"de.leanovate.play-mockws" %% "play-mockws-3-0" % "3.0.5" % Test,
"org.playframework" %% "play-ahc-ws" % playVersion % TestAndIntegrationTest, // neede for play-mockws
"org.playframework" %% "play-test" % playVersion % TestAndIntegrationTest, // play-mockws depends on some types in this dependency
"org.playframework" %% "play-ahc-ws-standalone" % playWsVersion % TestAndIntegrationTest,
// INTEGRATION TESTS
// TODO investigate if we can do this with specs2
"org.scalatest" %% "scalatest-wordspec" % scalaTestVersion % TestAndIntegrationTest,
"org.scalatest" %% "scalatest-mustmatchers" % scalaTestVersion % TestAndIntegrationTest,

"com.whisk" %% "docker-testkit-scalatest" % dockerTestkitVersion % TestAndIntegrationTest excludeAll (exclusions: _*)
"org.scalatest" %% "scalatest-wordspec" % scalaTestVersion % TestAndIntegrationTest,
"org.scalatest" %% "scalatest-mustmatchers" % scalaTestVersion % TestAndIntegrationTest,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testContainersVersion % TestAndIntegrationTest
),
scalacOptions ++= Seq(
"-feature",
Expand Down
40 changes: 23 additions & 17 deletions examples/src/main/scala/Example.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.ActorMaterializer
import io.waylay.kairosdb.driver.KairosDB
import io.waylay.kairosdb.driver.Implicits._
import io.waylay.kairosdb.driver.models.KairosCompatibleType.KNumber
Expand All @@ -15,31 +15,37 @@ import scala.collection.immutable.Seq

object Example extends App {

implicit val actorSystem = ActorSystem()
implicit val actorSystem = ActorSystem()
implicit val actorMaterializer = ActorMaterializer()
val wsClient = StandaloneAhcWSClient()
val kairosDB = new KairosDB(wsClient, KairosDBConfig(), global)
val wsClient = StandaloneAhcWSClient()
val kairosDB = new KairosDB(wsClient, KairosDBConfig(), global)

val res = for {
version <- kairosDB.version
names <- kairosDB.listMetricNames
_ <- kairosDB.addDataPoint(DataPoint("kairosdbscala.test", 9001, tags = Tag("awesome", "yes")))
names <- kairosDB.listMetricNames
_ <- kairosDB.addDataPoint(DataPoint("kairosdbscala.test", 9001, tags = Tag("awesome", "yes")))

// same as above, but without implicit conversions
_ <- kairosDB.addDataPoint(DataPoint(MetricName("kairosdbscala.test"), KNumber(9001), tags = Seq(Tag("awesome", "yes"))))
_ <- kairosDB.addDataPoint(
DataPoint(MetricName("kairosdbscala.test"), KNumber(9001), tags = Seq(Tag("awesome", "yes")))
)

qr <- kairosDB.queryMetrics(
QueryMetrics(
Query("kairosscala.test", tags = QueryTag("awesome" -> "yes")), 5.minutes.ago.startTime
)
)
QueryMetrics(
Query("kairosscala.test", tags = QueryTag("awesome" -> "yes")),
5.minutes.ago.startTime
)
)

// same as above, but without implicits
_ <- kairosDB.queryMetrics(
QueryMetrics(Seq(
Query(MetricName("kairosscala.test"), tags = Seq(QueryTag("awesome", Seq("yes", "true"))))
), TimeSpan(RelativeStartTime(5.minutes)))
)
QueryMetrics(
Seq(
Query(MetricName("kairosscala.test"), tags = Seq(QueryTag("awesome", Seq("yes", "true"))))
),
TimeSpan(RelativeStartTime(5.minutes))
)
)
} yield {

println(s"The KairosDB version is $version.")
Expand All @@ -53,7 +59,7 @@ object Example extends App {
Try(actorSystem.terminate())
}

res.onComplete{
res.onComplete {
case Success(_) => println("done")
case Failure(e) => e.printStackTrace()
}
Expand Down
14 changes: 7 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
addSbtPlugin("com.github.sbt" % "sbt-site" % "1.7.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
addSbtPlugin("com.github.sbt" % "sbt-ghpages" % "0.8.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("com.github.sbt" % "sbt-site" % "1.7.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
addSbtPlugin("com.github.sbt" % "sbt-ghpages" % "0.8.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")

// scala-xml issues
// TODO remove when everything has migrated to scala-xml 2.x
// https://github.com/scala/bug/issues/12632
ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
)
12 changes: 12 additions & 0 deletions src/it/resources/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:

kairosdb:
image: brunoballekens/kairosdb-scala-driver-it:1.3.0-1
volumes:
- ./conf/auth:/opt/kairosdb/conf/auth
expose:
- 8080
environment:
- JAVA_OPTS=-Djava.security.auth.login.config=/opt/kairosdb/conf/auth/basicAuth.conf -Dkairosdb.jetty.auth_module_name=basicAuth -Dkairosdb.jetty.basic_auth.user=test -Dkairosdb.jetty.basic_auth.password=test
Loading
Loading