Skip to content

Commit

Permalink
Upgrade to work with kairosdb 1.3.0 (#128)
Browse files Browse the repository at this point in the history
* Upgrade to work with kairosdb 1.3.0
Major bump as some endpoints where removed, so removed corresponding methods
(see kairosdb/kairosdb@877c53e)
  • Loading branch information
brunoballekens authored Apr 24, 2023
1 parent 3cc47a8 commit eff54bb
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 147 deletions.
10 changes: 5 additions & 5 deletions src/it/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM java:8-alpine
FROM openjdk:8u342-slim-buster

RUN apk upgrade libssl1.0 --update-cache && \
apk add wget ca-certificates bash
RUN apt-get update
RUN apt-get -y upgrade libssl1.0 && \
apt-get -y install wget ca-certificates bash
RUN wget -O /tmp/kairosdb.tar.gz \
# https://github.com/kairosdb/kairosdb/releases/download/v1.1.3/kairosdb-1.1.3-1.tar.gz
https://github.com/kairosdb/kairosdb/releases/download/v1.2.0/kairosdb-1.2.0-1.tar.gz
https://github.com/kairosdb/kairosdb/releases/download/v1.3.0/kairosdb-1.3.0-1.tar.gz

RUN mkdir -p /opt/ && \
cd /opt/ && \
Expand Down
3 changes: 1 addition & 2 deletions src/it/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#
# build the KairosDB image

#VERSION=1.1.3-1
VERSION=1.2.0-1
VERSION=1.3.0-1

all: build

Expand Down
1 change: 1 addition & 0 deletions src/it/resources/conf/auth/auth.props
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test: test
6 changes: 6 additions & 0 deletions src/it/resources/conf/auth/basicAuth.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
basicAuth {
org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required
debug="true"
//The line below should point to your .props file which lists your users and their passwords.
file="conf/auth/auth.props";
};
2 changes: 0 additions & 2 deletions src/it/resources/conf/kairosdb.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,18 @@ class AddAndQueryDataPointsIntegrationSpec extends IntegrationSpec {
(Instant.parse("1970-01-04T00:00:00Z"), KNumber(555)
))
))))))
case ("KairosDB 1.3.0-1.20210808220820", results) =>
results must be(QueryResponse.Response(Seq(ResponseQuery(2, Seq(
Result("my.new.metric", Seq(GroupBy.GroupByType("number")), Seq(TagResult("aoeu", Seq("snth"))), Seq(
(Instant.parse("1970-01-01T00:00:00Z"), KNull),
(Instant.parse("1970-01-02T00:00:00Z"), KNumber(555)),
(Instant.parse("1970-01-03T00:00:00Z"), KNull),
(Instant.parse("1970-01-04T00:00:00Z"), KNumber(555)),
(Instant.parse("1970-01-05T00:00:00Z"), KNull)
)
))))))
case other =>
fail("Unknown kairos version")
fail(s"Unknown kairos version ${other._1}")
}
}
}
Expand Down
29 changes: 12 additions & 17 deletions src/it/scala/integration/AuthSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,25 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.collection.immutable.Seq

class AuthSpec extends IntegrationSpec {

// TODO enabling auth by providing env variables, when kairosdb 1.1.2 is released
// // same as KairosDB Main.java
// def toEnvVarName(propName: String) = {
// propName.toUpperCase().replace('.', '_')
// }
//
// override lazy val dockerEnv = Seq(
// toEnvVarName("kairosdb.jetty.basic_auth.user") + "=test",
// toEnvVarName("kairosdb.jetty.basic_auth.password") + "=test"
// )

// enabling auth by providing a properties file
override lazy val volumes = Seq(
HostConfig.Bind
.from(Paths.get("src/it/resources/conf").toAbsolutePath.toString)
.to("/opt/kairosdb/conf")
.from(Paths.get("src/it/resources/conf/auth").toAbsolutePath.toString)
.to("/opt/kairosdb/conf/auth")
.build()
)

override lazy val env: Seq[String] = Seq(
"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"
)


"The health status" should {
"fail without auth" in {
val kairosDB = new KairosDB(wsClient, KairosDBConfig(port = kairosPort), global)
val res = kairosDB.healthStatus.failed.futureValue
val res = kairosDB.version.failed.futureValue

res mustBe an[KairosDBResponseException]
res must be(KairosDBResponseException(401, "Unauthorized", Seq.empty))
Expand All @@ -47,9 +42,9 @@ class AuthSpec extends IntegrationSpec {
password = Some("test")
)
val kairosDB = new KairosDB(wsClient, kairosConfig, global)
val res = kairosDB.healthStatus.futureValue
val res = kairosDB.version.futureValue

res must be(HealthStatusResults(Seq("JVM-Thread-Deadlock: OK", "Datastore-Query: OK")))
res must startWith("KairosDB")
}
}
}
4 changes: 2 additions & 2 deletions src/it/scala/integration/IntegrationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait IntegrationSpec extends AnyWordSpec with Matchers with ScalaFutures with S
lazy val env = Seq.empty[String]
lazy val volumes = Seq.empty[HostConfig.Bind]

val kairosdbContainer = ContainerSpec("brunoballekens/kairosdb-scala-driver-it:1.2.0-1")
val kairosdbContainer = ContainerSpec("brunoballekens/kairosdb-scala-driver-it:1.3.0-1")
.withEnv(env:_*)
// broken with the spotify client
.withVolumeBindings(volumes:_*)
Expand All @@ -37,7 +37,7 @@ trait IntegrationSpec extends AnyWordSpec with Matchers with ScalaFutures with S
.getOrElse(throw new IllegalStateException(s"Missing container mapped port for $DefaultKairosDbPort"))
}

implicit val pc = PatienceConfig(Span(20, Seconds), Span(1, Second))
implicit val pc = PatienceConfig(Span(2000, Seconds), Span(1, Second))
//override def dockerInitPatienceInterval = PatienceConfig(scaled(Span(30, Seconds)), scaled(Span(10, Millis)))

override val managedContainers: ContainerGroup = ContainerGroup(Seq(kairosdbContainer.toContainer))
Expand Down
27 changes: 0 additions & 27 deletions src/it/scala/integration/ListTagNamesIntegrationSpec.scala

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/scala/io/waylay/kairosdb/driver/KairosDB.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,6 @@ class KairosDB(wsClient: StandaloneWSClient, config: KairosDBConfig, executionCo
.map(_.map(MetricName))
}

def listTagNames: Future[Seq[String]] = {
wsClient
.url((url / "api" / "v1" / "tagnames").toString())
.applyKairosDBAuth
.get()
.map {
wsRepsonseToResult(json => (json \ "results").validate[Seq[String]])
}
}

def listTagValues: Future[Seq[String]] = {
wsClient
.url((url / "api" / "v1" / "tagvalues").toString())
.applyKairosDBAuth
.get()
.map(
wsRepsonseToResult(json => (json \ "results").validate[Seq[String]])
)
}

def healthStatus: Future[HealthStatusResults] = {
wsClient
.url((url / "api" / "v1" / "health" / "status").toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ object Formats {
.getOrElse(Json.obj()) ++
rangeAgg.align
.map {
case AlignStartTime => Json.obj("align_start_time" -> true)
// see https://github.com/kairosdb/kairosdb/issues/675
case AlignStartTime => Json.obj("align_start_time" -> true, "align_sampling" -> false)
case AlignSampling => Json.obj("align_sampling" -> true)
}
.getOrElse(Json.obj()) ++
Expand All @@ -288,7 +289,8 @@ object Formats {
.getOrElse(Json.obj()) ++
percentileAgg.align
.map {
case AlignStartTime => Json.obj("align_start_time" -> true)
// see https://github.com/kairosdb/kairosdb/issues/675
case AlignStartTime => Json.obj("align_start_time" -> true, "align_sampling" -> false)
case AlignSampling => Json.obj("align_sampling" -> true)
}
.getOrElse(Json.obj()) ++
Expand Down
2 changes: 2 additions & 0 deletions src/test/scala/unit/AggregatorWritesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AggregatorWritesSpec extends Specification {
Json.toJson(aggregator) should be equalTo Json.obj(
"name" -> "avg",
"align_start_time" -> true,
"align_sampling"->false,
"sampling" -> Json.obj(
"value" -> "1",
"unit" -> "minutes"
Expand Down Expand Up @@ -275,6 +276,7 @@ class AggregatorWritesSpec extends Specification {
),
"start_time" -> 1469778777L,
"align_start_time" -> true,
"align_sampling"->false,
"time_zone" -> "Africa/Banjul"
)
}
Expand Down
34 changes: 0 additions & 34 deletions src/test/scala/unit/ListTagNamesSpec.scala

This file was deleted.

34 changes: 0 additions & 34 deletions src/test/scala/unit/ListTagValuesSpec.scala

This file was deleted.

2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "5.0.1-SNAPSHOT"
ThisBuild / version := "6.0.0-SNAPSHOT"

0 comments on commit eff54bb

Please sign in to comment.