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

chore: make it possible to debug integration tests with sbt or IDE #2327

Merged
merged 8 commits into from Dec 9, 2022
6 changes: 3 additions & 3 deletions build.sbt
Expand Up @@ -199,9 +199,9 @@ lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
IntegrationTest / testForkedParallel := false, // not run forked tests in parallel
IntegrationTest / parallelExecution := false, // not run non-forked tests in parallel
// Global / concurrentRestrictions += Tags.limit(Tags.Test, 1), // restrict the number of concurrently executing tests in all projects
IntegrationTest / javaOptions += "-Dconfig.resource=fuseki.conf",
// Test / javaOptions ++= Seq("-Dakka.log-config-on-start=on"), // prints out akka config
// Test / javaOptions ++= Seq("-Dconfig.trace=loads"), // prints out config locations
// IntegrationTest / javaOptions ++= Seq("-Dakka.log-config-on-start=on"), // prints out akka config
// IntegrationTest / javaOptions ++= Seq("-Dconfig.trace=loads"), // prints out config locations
// IntegrationTest / javaOptions += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005", // starts sbt with debug port
Comment on lines -203 to +204
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find those commented-out lines a bit irritating. If they have to stay there, please add a comment why/how/what for they are needed, otherwise I'd suggest removing them

Copy link
Collaborator Author

@seakayone seakayone Dec 9, 2022

Choose a reason for hiding this comment

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

In general I agree that commented out code should be removed. Those Java options are documented and seemed useful for me in case we would like to debug the integration tests so I kept them.

IntegrationTest / testOptions += Tests.Argument("-oDF"), // show full stack traces and test case durations
// add test framework for running zio-tests
IntegrationTest / testFrameworks ++= Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
Expand Down
15 changes: 12 additions & 3 deletions docs/05-internals/development/testing.md
Expand Up @@ -37,7 +37,7 @@ You might need to create an integration test because:
In this case create it in the `src/it` source set of our projects.

.NOTE
_Currently only the `webapi` project supports integration tests_
_Currently only the `webapi` project supports integration tests._

Run all integration tests from the terminal.

Expand All @@ -46,5 +46,14 @@ make integration-test
```

.NOTE
_The integration tests currently depend on a locally published Sipi container. That is why we need to start
the `make` command and not `sbt it`._
_The integration tests currently depend on a locally published Sipi container, the make target helps you with that._

## Debugging

You can debug unit test directly in your IDE.
seakayone marked this conversation as resolved.
Show resolved Hide resolved

For debugging the integration test locally with `sbt` or you IDE you need to have a fresh SIPI container build:
seakayone marked this conversation as resolved.
Show resolved Hide resolved

```shell
make docker-build-sipi-image
```
2 changes: 0 additions & 2 deletions webapi/src/it/resources/test.conf
@@ -1,5 +1,3 @@
include "application"

akka {
log-config-on-start = false
loggers = ["akka.event.slf4j.Slf4jLogger"]
Expand Down
Expand Up @@ -454,7 +454,7 @@ case class TriplestoreServiceHttpConnectorImpl(
// to the parent folder where the files can be found
val inputFile = Paths.get("..", elem.path)
if (!Files.exists(inputFile)) {
throw BadRequestException(s"File ${inputFile} does not exist")
throw BadRequestException(s"File ${inputFile.toAbsolutePath} does not exist")
}
val fileEntity =
new FileEntity(inputFile.toFile, ContentType.create(mimeTypeTextTurtle, "UTF-8"))
Expand Down