Commit 1dbd28ef authored by Ihrig, Arvid Conrad (ari)'s avatar Ihrig, Arvid Conrad (ari)
Browse files

Integrated Pipeline: added event for TreeParser processing failures that...

Integrated Pipeline: added event for TreeParser processing failures that invalidate entire file trees
parent 46684492
......@@ -44,6 +44,11 @@ trait EventLogger extends EventListener with Logging {
s"[TreeParser ${reporter.name}] scanning failure in file tree " +
s"'${x.treeTask.treeBasePath}' at '${x.relativePath}' (${x.error.toString})"
)
case x: TreeParserEventTreeFailure => logger.error(
baseMarker,
s"[TreeParser ${reporter.name}] encountered failure while processing file tree " +
s"'${x.treeTask.treeBasePath}', aborting: ${x.error.toString}"
)
}
super.processEvent(reporter, message)
}
......
......@@ -29,6 +29,11 @@ case class TreeParserEventScanError(
error: Throwable
) extends TreeParserEvent
case class TreeParserEventTreeFailure(
treeTask: FileTreeScanTask,
error: Throwable
) extends TreeParserEvent
case class TreeParserEventEnd(
treeTask: FileTreeScanTask,
numCandidates: Long
......
......@@ -22,6 +22,7 @@ trait TestDataBuilders {
def aTreeParserEventStart() = BuilderTreeParserEventStart()
def aTreeParserEventCandidate() = BuilderTreeParserEventCandidate()
def aTreeParserEventEnd() = BuilderTreeParserEventEnd()
def aTreeParserEventTreeFailure() = BuilderTreeParserEventTreeFailure()
def aCalculationParserEventStart() = BuilderCalculationParserEventStart()
def aCalculationParserEventEnd() = BuilderCalculationParserEventEnd()
......@@ -41,6 +42,7 @@ trait TestDataBuilders {
implicit def build(x: BuilderTreeParserEventStart): TreeParserEventStart = x.build()
implicit def build(x: BuilderTreeParserEventCandidate): TreeParserEventCandidate = x.build()
implicit def build(x: BuilderTreeParserEventEnd): TreeParserEventEnd = x.build()
implicit def build(x: BuilderTreeParserEventTreeFailure): TreeParserEventTreeFailure = x.build()
implicit def build(x: BuilderCalculationParserEventStart): CalculationParserEventStart = x.build()
implicit def build(x: BuilderCalculationParserEventEnd): CalculationParserEventEnd = x.build()
......@@ -223,6 +225,23 @@ object EventBuilders {
)
}
case class BuilderTreeParserEventTreeFailure(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val error: Throwable = defaultError
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventTreeFailure = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withError(newError: Throwable) = copy(error = newError)
def build() = TreeParserEventTreeFailure(
treeTask = treeTask,
error = error
)
}
case class BuilderCalculationParserEventStart(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
......
......@@ -84,6 +84,15 @@ class EventLoggerSpec extends LoggingTestWrapper with MockitoSugar with EventLis
exactly(1, log.messages()) should (startWith("INFO") and
includeAll("/foo/bar", "Directory", "42 candidate files", "finished"))
}
"log file tree failure events as error messages" in { log =>
val f = createFixture()
val message = aTreeParserEventTreeFailure().withBasePath("/foo/bar").
withError(new IllegalArgumentException("test crash"))
f.logger.processEvent(f.treeParserId.get, message)
exactly(1, log.messages()) should (startWith("ERROR") and
includeAll("/foo/bar", "encountered failure", "aborting", "test crash"))
}
}
"having received a registration from a CalculationParsingEngine" should {
......
......@@ -2,7 +2,7 @@ package eu.nomad_lab.integrated_pipeline_tests.matchers
import java.nio.file.{ Path, Paths }
import eu.nomad_lab.integrated_pipeline.messages.{ TreeParserEvent, TreeParserEventCandidate, TreeParserEventEnd, TreeParserEventScanError }
import eu.nomad_lab.integrated_pipeline.messages._
import org.scalatest.matchers.HavePropertyMatcher
trait MatcherTreeParserEvent {
......@@ -74,3 +74,15 @@ object MatcherTreeParserEventEnd extends MatcherTreeParserEvent {
)
}
object MatcherTreeParserEventTreeFailure extends MatcherTreeParserEvent {
def errorMessage(first: String, other: String*): HavePropertyMatcher[TreeParserEventTreeFailure, String] =
MatcherHelpers.subStringPropertyMatcher(
propertyName = "error message content",
expected = first +: other,
test = (x: TreeParserEventTreeFailure) => x.error.getMessage,
display = (x: TreeParserEventTreeFailure) => x.error.toString
)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment