Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-lab-base
Commits
b04885ce
Commit
b04885ce
authored
Jul 25, 2018
by
Ihrig, Arvid Conrad (ari)
Browse files
Integrated Pipeline: TreeParser now rejects non-existent file tree roots gracefully
parent
1dbd28ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
integrated-pipeline/src/main/scala/eu/nomad_lab/integrated_pipeline/TreeParser.scala
View file @
b04885ce
...
...
@@ -20,10 +20,17 @@ trait TreeParser extends MessageProcessor[FileTreeScanTask, FileParsingTaskSigna
final
override
def
processSignal
(
in
:
FileTreeScanTask
)
:
Unit
=
{
if
(
readyForInbound
)
{
eventListener
.
processEvent
(
myId
,
TreeParserEventStart
(
in
))
generator
=
Some
(
createProcessor
(
in
))
request
=
Some
(
in
)
taskCount
=
0
readyForInbound
=
false
if
(
in
.
treeBasePath
.
toFile
.
exists
())
{
generator
=
Some
(
createProcessor
(
in
))
request
=
Some
(
in
)
taskCount
=
0
readyForInbound
=
false
}
else
{
eventListener
.
processEvent
(
myId
,
TreeParserEventTreeFailure
(
in
,
new
IllegalArgumentException
(
s
"file tree root '${in.treeBasePath}' does not exist, ignoring task"
)
))
}
}
else
{
throw
new
IllegalStateException
(
"cannot process message, still digesting previous message"
)
}
...
...
integrated-pipeline/src/test/scala/eu/nomad_lab/integrated_pipeline_end_to_end_tests/UnderDevelopment.scala
View file @
b04885ce
...
...
@@ -21,7 +21,7 @@ class UnderDevelopment extends LoggingTestAsyncWrapper with CustomMatchers {
val
finished
=
Main
.
mainWithFuture
(
f
.
generateConsoleArgumentList
(
Some
(
info
)))
finished
.
map
{
_
=>
atLeast
(
1
,
log
.
messages
())
should
(
startWith
(
"ERROR"
)
and
includeAll
(
"purely-imaginary"
,
"not exist"
,
"
skipping
fil
e tree
"
))
includeAll
(
"purely-imaginary"
,
"not exist"
,
"
encountered
f
a
il
ure"
,
"ignoring task
"
))
}
}
}
...
...
integrated-pipeline/src/test/scala/eu/nomad_lab/integrated_pipeline_tests/TreeParserSpec.scala
View file @
b04885ce
...
...
@@ -18,7 +18,8 @@ class TreeParserSpec extends WordSpec with TestDataBuilders with MockitoSugar
private
def
argsCaptor
()
:
ArgumentCaptor
[
TreeParserEvent
]
=
ArgumentCaptor
.
forClass
(
classOf
[
TreeParserEvent
])
private
val
sampleTreeTask
=
aFileTreeScanTask
().
withBasePath
(
"/foo"
).
build
()
private
val
sampleTreeTask
=
aFileTreeScanTask
().
withBasePath
(
"."
).
build
()
private
val
invalidTreeTask
=
aFileTreeScanTask
().
withBasePath
(
"/imaginary/foo/magic"
).
build
()
class
Fixture
(
sampleData
:
Iterator
[
Either
[
TreeParserEventScanError
,
FileParsingTask
]])
{
val
events
=
mock
[
EventListener
]
...
...
@@ -102,7 +103,26 @@ class TreeParserSpec extends WordSpec with TestDataBuilders with MockitoSugar
f
.
treeParser
.
processSignal
(
sampleTreeTask
)
val
captor
=
argsCaptor
()
verify
(
f
.
events
).
processEvent
(
any
(),
captor
.
capture
())
captor
.
getValue
should
(
be
(
a
[
TreeParserEventStart
])
and
have
(
basePath
(
"/foo"
)))
captor
.
getValue
should
(
be
(
a
[
TreeParserEventStart
])
and
have
(
basePath
(
"."
)))
}
"ignore file tree scan tasks if the tree root does not exist on file-system"
in
{
val
f
=
createFixture
()
f
.
treeParser
.
processSignal
(
invalidTreeTask
)
f
.
treeParser
.
hasSignalToEmit
()
should
be
(
false
)
}
"send an error event to the eventListener if the tree root does not exist on file-system"
in
{
import
MatcherTreeParserEventTreeFailure._
val
f
=
createFixture
()
f
.
treeParser
.
processSignal
(
invalidTreeTask
)
val
captor
=
argsCaptor
()
verify
(
f
.
events
,
atLeastOnce
).
processEvent
(
any
(),
captor
.
capture
())
val
events
=
captor
.
getAllValues
.
asScala
.
collect
{
case
x
:
TreeParserEventTreeFailure
=>
x
}
exactly
(
1
,
events
)
should
have
(
basePath
(
"/imaginary/foo/magic"
),
errorMessage
(
"tree root"
,
"not exist"
)
)
}
}
...
...
@@ -174,7 +194,7 @@ class TreeParserSpec extends WordSpec with TestDataBuilders with MockitoSugar
verify
(
f
.
events
,
Mockito
.
atLeast
(
1
)).
processEvent
(
any
(),
captor
.
capture
())
val
event
=
captor
.
getValue
event
should
be
(
a
[
TreeParserEventEnd
])
event
.
asInstanceOf
[
TreeParserEventEnd
]
should
have
(
basePath
(
"
/foo
"
),
numCandidates
(
3
))
event
.
asInstanceOf
[
TreeParserEventEnd
]
should
have
(
basePath
(
"
.
"
),
numCandidates
(
3
))
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment