Skip to content

Commit

Permalink
Confine solr tests to their own cores (#135)
Browse files Browse the repository at this point in the history
- Extend solr client to list, create and delete cores
- Extend solr client to retrieve the current schema
- Scope solr tests to run in their own core
- Fix `UserAddedProvisioningSpec` that randomly unset the firstname
  • Loading branch information
eikek authored May 24, 2024
1 parent 1a92b2d commit 1e37d34
Show file tree
Hide file tree
Showing 64 changed files with 4,157 additions and 1,392 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ lazy val searchProvision = project
.settings(commonSettings)
.settings(
name := "search-provision",
libraryDependencies ++= Dependencies.ciris,
Test / parallelExecution := false
libraryDependencies ++= Dependencies.ciris
)
.dependsOn(
commons % "compile->compile;test->test",
Expand Down Expand Up @@ -450,6 +449,7 @@ lazy val commonSettings = Seq(
),
Compile / console / scalacOptions := (Compile / scalacOptions).value.filterNot(_ == "-Xfatal-warnings"),
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
// parallel execution would work, but requires a quite powerful solr server
Test / parallelExecution := false,
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision,
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
system = flake-utils.lib.system.x86_64-linux;
modules = [
./nix/services.nix
{
virtualisation.memorySize = 2048;
}
];
};

Expand Down Expand Up @@ -83,6 +86,8 @@
RS_SEARCH_HTTP_SERVER_PORT = "8080";
RS_PROVISION_HTTP_SERVER_PORT = "8082";
RS_METRICS_UPDATE_INTERVAL = "0s";
RS_SOLR_CREATE_CORE_CMD = "cnt-solr-create-core %s";
RS_SOLR_DELETE_CORE_CMD = "cnt-solr-delete-core %s";

#don't start docker container for dbTests
NO_SOLR = "true";
Expand All @@ -106,6 +111,8 @@
RS_SEARCH_HTTP_SERVER_PORT = "8080";
RS_PROVISION_HTTP_SERVER_PORT = "8082";
RS_METRICS_UPDATE_INTERVAL = "0s";
RS_SOLR_CREATE_CORE_CMD = "vm-solr-create-core %s";
RS_SOLR_DELETE_CORE_CMD = "vm-solr-delete-core %s";

#don't start docker container for dbTests
NO_SOLR = "true";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ object UrlPattern:
)
private[common] def splitUrl(url: String): UrlParts = {
def readScheme(s: String): (Option[String], String) =
s.split("://").filter(_.nonEmpty).toList match
case s :: rest :: Nil => (Some(s), rest)
case rest => (None, rest.mkString)
if (!s.contains("://")) (None, s)
else
s.split("://").filter(_.nonEmpty).toList match
case first :: rest :: Nil => (Some(first), rest)
case first => (Some(first.mkString), "")

def readHostPort(s: String): (List[String], Option[String]) =
s.split(':').toList match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package io.renku.search

import io.renku.logging.LoggingSetup

trait LoggingConfigure extends munit.FunSuite:
trait LoggingConfigure extends munit.Suite:

def defaultVerbosity: Int = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class UrlPatternSpec extends ScalaCheckSuite:
)

test("fromString"):
assertEquals(
UrlPattern.fromString("http://"),
UrlPattern.all.copy(scheme = Some(Segment.Literal("http")))
)
assertEquals(
UrlPattern.fromString("http"),
UrlPattern.all.copy(host = List(Segment.Literal("http")))
)
assertEquals(UrlPattern.fromString("*"), UrlPattern.all)
assertEquals(UrlPattern.fromString(""), UrlPattern.all)
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object ConfigValues extends ConfigDecoders:
renv("CLIENT_ID").default(default.value).as[ClientId]

val solrConfig: ConfigValue[Effect, SolrConfig] = {
val url = renv("SOLR_URL").default("http://localhost:8983/solr").as[Uri]
val url = renv("SOLR_URL").default("http://localhost:8983").as[Uri]
val core = renv("SOLR_CORE").default("search-core-test")
val maybeUser =
(renv("SOLR_USER").default("admin"), renv("SOLR_PASS"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.time.Instant
import java.time.temporal.ChronoUnit

import io.renku.events.v1.ProjectAuthorizationAdded
import io.renku.search.GeneratorSyntax.*
import io.renku.search.events.*
import io.renku.search.model.Id
import io.renku.search.model.MemberRole
Expand Down Expand Up @@ -315,11 +316,11 @@ object EventsGenerators:

def v1UserAddedGen(
prefix: String,
firstName: Gen[FirstName] = ModelGenerators.userFirstNameGen
firstName: Gen[Option[FirstName]] = ModelGenerators.userFirstNameGen.asOption
): Gen[v1.UserAdded] =
for
id <- Gen.uuid.map(_.toString)
firstName <- Gen.option(firstName.map(_.value))
firstName <- firstName.map(_.map(_.value))
lastName <- alphaStringGen(max = 5).map(v => s"$prefix-$v")
email <- Gen.option(stringGen(max = 5).map(host => s"$lastName@$host.com"))
yield v1.UserAdded(
Expand All @@ -331,11 +332,11 @@ object EventsGenerators:

def v2UserAddedGen(
prefix: String,
firstName: Gen[FirstName] = ModelGenerators.userFirstNameGen
firstName: Gen[Option[FirstName]] = ModelGenerators.userFirstNameGen.asOption
): Gen[v2.UserAdded] =
for
id <- Gen.uuid.map(_.toString)
firstName <- Gen.option(firstName.map(_.value))
firstName <- firstName.map(_.map(_.value))
lastName <- alphaStringGen(max = 5).map(v => s"$prefix-$v")
email <- Gen.option(stringGen(max = 5).map(host => s"$lastName@$host.com"))
ns <- ModelGenerators.namespaceGen
Expand All @@ -349,7 +350,7 @@ object EventsGenerators:

def userAddedGen(
prefix: String,
firstName: Gen[FirstName] = ModelGenerators.userFirstNameGen
firstName: Gen[Option[FirstName]] = ModelGenerators.userFirstNameGen.asOption
): Gen[UserAdded] =
Gen.oneOf(
v1UserAddedGen(prefix, firstName).map(UserAdded.V1.apply),
Expand Down
Loading

0 comments on commit 1e37d34

Please sign in to comment.