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

Remove TestDbSuites. Run Query and Route tests directly. #276

Merged
merged 4 commits into from
Jan 9, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import akka.http.scaladsl.testkit.RouteTestTimeout
import akka.http.scaladsl.testkit.ScalatestRouteTest
import akka.pattern.after
import eu.icoscp.envri.Envri
import org.scalatest.DoNotDiscover
import org.scalatest.BeforeAndAfterAll
import org.scalatest.compatible.Assertion
import org.scalatest.funspec.AsyncFunSpec
import se.lu.nateko.cp.meta.SparqlServerConfig
Expand All @@ -20,19 +20,21 @@ import se.lu.nateko.cp.meta.core.data.EnvriConfig
import se.lu.nateko.cp.meta.core.data.EnvriConfigs
import se.lu.nateko.cp.meta.routes.SparqlRoute
import se.lu.nateko.cp.meta.services.sparql.Rdf4jSparqlServer
import se.lu.nateko.cp.meta.test.services.sparql.TestDbFixture

import java.net.URI
import scala.concurrent.Await
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unused import from before.

import scala.concurrent.Future

import concurrent.duration.DurationInt
import se.lu.nateko.cp.meta.test.services.sparql.regression.TestDb

@DoNotDiscover
class SparqlRouteTests extends AsyncFunSpec with ScalatestRouteTest with TestDbFixture:
class SparqlRouteTests extends AsyncFunSpec with ScalatestRouteTest with BeforeAndAfterAll:

import system.{log}

val db = new TestDb("sparqlRoutingTesting")

override protected def afterAll(): Unit = db.cleanup()

val numberOfParallelQueries = 2
private val reqOrigin = "https://example4567.icos-cp.eu"
val sparqlConfig = new SparqlServerConfig(5, 2, 2, numberOfParallelQueries, 0, 10, 8388608, Seq("[email protected]"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ import org.eclipse.rdf4j.model.vocabulary.XSD
import org.eclipse.rdf4j.query.BindingSet
import org.scalatest
import org.scalatest.BeforeAndAfterAll
import org.scalatest.DoNotDiscover
import org.scalatest.Informer
import org.scalatest.compatible.Assertion
import org.scalatest.funspec.AsyncFunSpec
import se.lu.nateko.cp.meta.api.CloseableIterator
import se.lu.nateko.cp.meta.test.services.sparql.TestDbFixture
import se.lu.nateko.cp.meta.utils.rdf4j.createDateTimeLiteral
import se.lu.nateko.cp.meta.utils.rdf4j.createLiteral
Comment on lines -14 to -16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this change, but these imports are unused.


import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters.IterableHasAsScala

@DoNotDiscover
class QueryTests extends AsyncFunSpec with TestDbFixture {
class QueryTests extends AsyncFunSpec with BeforeAndAfterAll {

val db = new TestDb("sparqlRegrTesting")

override protected def afterAll(): Unit = db.cleanup()

def timedExecution[T](f: Future[T], executedFunction: String, info: Informer)(using ExecutionContext) = {
val start = System.currentTimeMillis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ import java.nio.file.Files
import scala.collection.concurrent.TrieMap
import scala.concurrent.Future

class TestDb {
class TestDb(name: String) {

private val metaConf = se.lu.nateko.cp.meta.ConfigLoader.default
val akkaConf = ConfigFactory.defaultReference()
.withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("INFO"))
private given system: ActorSystem = ActorSystem("sparqlRegrTesting", akkaConf)
private given system: ActorSystem = ActorSystem(name, akkaConf)
import system.{dispatcher, log}

val dir = Files.createTempDirectory("sparqlRegrTesting").toAbsolutePath
val dir = Files.createTempDirectory(name).toAbsolutePath

def runSparql(query: String): Future[CloseableIterator[BindingSet]] =
repo.map(new Rdf4jSparqlRunner(_).evaluateTupleQuery(SparqlQuery(query)))
Expand Down Expand Up @@ -143,5 +143,3 @@ object TestDb:
("http://meta.icos-cp.eu/ontologies/stationentry/" -> "stationEntry.owl") +
("http://meta.icos-cp.eu/collections/" -> "collections.rdf") +
("http://meta.icos-cp.eu/documents/" -> "icosdocs.rdf")

lazy val instance = new TestDb
Loading