Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kieker Trace Diagnosis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kieker
Kieker Trace Diagnosis
Commits
fa3440e7
Commit
fa3440e7
authored
10 years ago
by
Nils Christian Ehmke
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring
parent
9fc5e591
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/kieker/diagnosis/common/model/importer/stages/TraceReconstructorTest.java
+87
-75
87 additions, 75 deletions
.../common/model/importer/stages/TraceReconstructorTest.java
with
87 additions
and
75 deletions
src/test/java/kieker/diagnosis/common/model/importer/stages/TraceReconstructorTest.java
+
87
−
75
View file @
fa3440e7
...
...
@@ -16,6 +16,9 @@
package
kieker.diagnosis.common.model.importer.stages
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
collection
.
IsCollectionWithSize
.
hasSize
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -26,54 +29,41 @@ import kieker.common.record.flow.trace.operation.AfterOperationFailedEvent;
import
kieker.common.record.flow.trace.operation.BeforeOperationEvent
;
import
kieker.diagnosis.common.domain.OperationCall
;
import
kieker.diagnosis.common.domain.Trace
;
import
kieker.diagnosis.common.model.importer.stages.TraceReconstructor
;
import
org.hamcrest.Matchers
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
teetime.framework.Analysis
;
import
teetime.framework.AnalysisConfiguration
;
import
teetime.framework.pipe.IPipeFactory
;
import
teetime.framework.pipe.SingleElementPipeFactory
;
import
teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering
;
import
teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication
;
import
teetime.stage.CollectorSink
;
import
teetime.stage.IterableProducer
;
public
final
class
TraceReconstructorTest
{
private
List
<
Trace
>
traceCollectorList
;
private
TraceReconstructor
reconstructorUnderTest
;
private
CollectorSink
<
Trace
>
traceCollector
;
@Before
public
void
initializeTraceReconstructor
()
{
this
.
traceCollectorList
=
new
ArrayList
<>();
this
.
reconstructorUnderTest
=
new
TraceReconstructor
();
this
.
traceCollector
=
new
CollectorSink
<>(
this
.
traceCollectorList
);
final
IPipeFactory
pipeFactory
=
new
SingleElementPipeFactory
();
pipeFactory
.
create
(
this
.
reconstructorUnderTest
.
getOutputPort
(),
this
.
traceCollector
.
getInputPort
());
}
@Test
public
void
reconstructionOfSingleTraceShouldWork
()
{
final
IFlowRecord
[]
records
=
new
IFlowRecord
[
9
]
;
records
[
0
]
=
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
);
records
[
1
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"
main()"
,
"Main"
);
records
[
2
]
=
new
Before
OperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
);
records
[
3
]
=
new
After
OperationEvent
(
1
,
1
,
1
,
"
Bookstore()"
,
"Bookstore"
);
records
[
4
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"C
atalog
()"
,
"C
atalog"
);
records
[
5
]
=
new
Before
OperationEvent
(
1
,
1
,
1
,
"CRM()"
,
"CRM"
);
records
[
6
]
=
new
AfterOperationEvent
(
1
,
1
,
1
,
"C
RM
()"
,
"C
RM"
);
records
[
7
]
=
new
AfterOperationEvent
(
1
,
1
,
1
,
"
Catalog()"
,
"Catalog"
);
records
[
8
]
=
new
AfterOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
f
or
(
final
IFlowRecord
record
:
records
)
{
this
.
reconstructorUnderTest
.
execute
(
record
);
}
Assert
.
assertThat
(
this
.
traceCollectorList
,
Matchers
.
hasSize
(
1
));
final
Trace
trace
=
this
.
traceCollectorList
.
get
(
0
);
final
List
<
IFlowRecord
>
input
=
new
ArrayList
<>()
;
input
.
add
(
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
)
);
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"
Bookstore()"
,
"Bookstore"
)
);
input
.
add
(
new
After
OperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
)
)
;
input
.
add
(
new
Before
OperationEvent
(
1
,
1
,
1
,
"
Catalog()"
,
"Catalog"
)
);
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"C
RM
()"
,
"C
RM"
)
);
input
.
add
(
new
After
OperationEvent
(
1
,
1
,
1
,
"CRM()"
,
"CRM"
)
)
;
input
.
add
(
new
AfterOperationEvent
(
1
,
1
,
1
,
"C
atalog
()"
,
"C
atalog"
)
);
input
.
add
(
new
AfterOperationEvent
(
1
,
1
,
1
,
"
main()"
,
"Main"
)
);
final
ReconstructionConfiguration
configuration
=
new
ReconstructionConfiguration
(
input
);
f
inal
Analysis
analysis
=
new
Analysis
(
configuration
);
analysis
.
start
(
);
Assert
.
assertThat
(
configuration
.
getOutput
(),
hasSize
(
1
));
final
Trace
trace
=
configuration
.
getOutput
()
.
get
(
0
);
final
OperationCall
rootCall
=
trace
.
getRootOperationCall
();
Assert
.
assertThat
(
rootCall
.
getOperation
(),
Matchers
.
is
(
"main()"
));
Assert
.
assertThat
(
rootCall
.
getChildren
(),
Matchers
.
hasSize
(
2
));
...
...
@@ -85,22 +75,22 @@ public final class TraceReconstructorTest {
@Test
public
void
reconstructionOfInterleavedTracesShouldWork
()
{
final
IFlowRecord
[]
records
=
new
IFlowRecord
[
9
];
final
List
<
IFlowRecord
>
input
=
new
ArrayList
<>();
input
.
add
(
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
));
input
.
add
(
new
TraceMetadata
(
2
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
2
,
1
,
"Bookstore()"
,
"Bookstore"
));
input
.
add
(
new
AfterOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
));
input
.
add
(
new
AfterOperationEvent
(
1
,
2
,
1
,
"Bookstore()"
,
"Bookstore"
));
records
[
0
]
=
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
);
records
[
1
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
records
[
2
]
=
new
TraceMetadata
(
2
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
);
records
[
3
]
=
new
BeforeOperationEvent
(
1
,
2
,
1
,
"Bookstore()"
,
"Bookstore"
);
records
[
4
]
=
new
AfterOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
records
[
5
]
=
new
AfterOperationEvent
(
1
,
2
,
1
,
"Bookstore()"
,
"Bookstore"
);
final
ReconstructionConfiguration
configuration
=
new
ReconstructionConfiguration
(
input
);
final
Analysis
analysis
=
new
Analysis
(
configuration
);
analysis
.
start
();
for
(
final
IFlowRecord
record
:
records
)
{
this
.
reconstructorUnderTest
.
execute
(
record
);
}
Assert
.
assertThat
(
this
.
traceCollectorList
,
Matchers
.
hasSize
(
2
));
Assert
.
assertThat
(
configuration
.
getOutput
(),
hasSize
(
2
));
final
Trace
fstTrace
=
this
.
traceCollectorList
.
get
(
0
);
final
Trace
sndTrace
=
this
.
traceCollectorList
.
get
(
1
);
final
Trace
fstTrace
=
configuration
.
getOutput
()
.
get
(
0
);
final
Trace
sndTrace
=
configuration
.
getOutput
()
.
get
(
1
);
Assert
.
assertThat
(
fstTrace
.
getRootOperationCall
().
getOperation
(),
Matchers
.
is
(
"main()"
));
Assert
.
assertThat
(
sndTrace
.
getRootOperationCall
().
getOperation
(),
Matchers
.
is
(
"Bookstore()"
));
...
...
@@ -108,20 +98,20 @@ public final class TraceReconstructorTest {
@Test
public
void
reconstructionOfCompleteFailedTraceShouldWork
()
{
final
IFlowRecord
[]
records
=
new
IFlowRecord
[
9
];
final
List
<
IFlowRecord
>
input
=
new
ArrayList
<>();
input
.
add
(
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
));
input
.
add
(
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
,
"NullPointerException"
));
input
.
add
(
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
,
"IllegalArgumentException"
));
records
[
0
]
=
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
);
records
[
1
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
records
[
2
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
);
records
[
3
]
=
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
,
"NullPointerException"
);
records
[
8
]
=
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
,
"IllegalArgumentException"
);
final
ReconstructionConfiguration
configuration
=
new
ReconstructionConfiguration
(
input
);
final
Analysis
analysis
=
new
Analysis
(
configuration
);
analysis
.
start
();
for
(
final
IFlowRecord
record
:
records
)
{
this
.
reconstructorUnderTest
.
execute
(
record
);
}
Assert
.
assertThat
(
this
.
traceCollectorList
,
Matchers
.
hasSize
(
1
));
Assert
.
assertThat
(
configuration
.
getOutput
(),
hasSize
(
1
));
final
Trace
trace
=
this
.
traceCollectorList
.
get
(
0
);
final
Trace
trace
=
configuration
.
getOutput
()
.
get
(
0
);
final
OperationCall
rootCall
=
trace
.
getRootOperationCall
();
Assert
.
assertThat
(
rootCall
.
isFailed
(),
Matchers
.
is
(
true
));
Assert
.
assertThat
(
rootCall
.
getFailedCause
(),
Matchers
.
is
(
"IllegalArgumentException"
));
...
...
@@ -131,25 +121,47 @@ public final class TraceReconstructorTest {
@Test
public
void
reconstructionOfPartialFailedTraceShouldWork
()
{
final
IFlowRecord
[]
records
=
new
IFlowRecord
[
9
];
final
List
<
IFlowRecord
>
input
=
new
ArrayList
<>();
input
.
add
(
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
));
input
.
add
(
new
BeforeOperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
));
input
.
add
(
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
,
"NullPointerException"
));
input
.
add
(
new
AfterOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
));
records
[
0
]
=
new
TraceMetadata
(
1
,
1
,
TraceMetadata
.
NO_SESSION_ID
,
TraceMetadata
.
NO_HOSTNAME
,
TraceMetadata
.
NO_PARENT_TRACEID
,
TraceMetadata
.
NO_PARENT_ORDER_INDEX
);
records
[
1
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
records
[
2
]
=
new
BeforeOperationEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
);
records
[
3
]
=
new
AfterOperationFailedEvent
(
1
,
1
,
1
,
"Bookstore()"
,
"Bookstore"
,
"NullPointerException"
);
records
[
8
]
=
new
AfterOperationEvent
(
1
,
1
,
1
,
"main()"
,
"Main"
);
final
ReconstructionConfiguration
configuration
=
new
ReconstructionConfiguration
(
input
);
final
Analysis
analysis
=
new
Analysis
(
configuration
);
analysis
.
start
();
for
(
final
IFlowRecord
record
:
records
)
{
this
.
reconstructorUnderTest
.
execute
(
record
);
}
Assert
.
assertThat
(
this
.
traceCollectorList
,
Matchers
.
hasSize
(
1
));
Assert
.
assertThat
(
configuration
.
getOutput
(),
hasSize
(
1
));
final
Trace
trace
=
this
.
traceCollectorList
.
get
(
0
);
final
Trace
trace
=
configuration
.
getOutput
()
.
get
(
0
);
final
OperationCall
rootCall
=
trace
.
getRootOperationCall
();
Assert
.
assertThat
(
rootCall
.
isFailed
(),
Matchers
.
is
(
false
));
Assert
.
assertThat
(
rootCall
.
containsFailure
(),
Matchers
.
is
(
true
));
Assert
.
assertThat
(
rootCall
.
getChildren
().
get
(
0
).
isFailed
(),
Matchers
.
is
(
true
));
Assert
.
assertThat
(
rootCall
.
getChildren
().
get
(
0
).
getFailedCause
(),
Matchers
.
is
(
"NullPointerException"
));
Assert
.
assertThat
(
rootCall
.
isFailed
(),
is
(
false
));
Assert
.
assertThat
(
rootCall
.
containsFailure
(),
is
(
true
));
Assert
.
assertThat
(
rootCall
.
getChildren
().
get
(
0
).
isFailed
(),
is
(
true
));
Assert
.
assertThat
(
rootCall
.
getChildren
().
get
(
0
).
getFailedCause
(),
is
(
"NullPointerException"
));
}
private
static
class
ReconstructionConfiguration
extends
AnalysisConfiguration
{
private
final
List
<
Trace
>
traceCollectorList
=
new
ArrayList
<>();
public
ReconstructionConfiguration
(
final
List
<
IFlowRecord
>
input
)
{
final
IterableProducer
<
List
<
IFlowRecord
>,
IFlowRecord
>
producer
=
new
IterableProducer
<>(
input
);
final
TraceReconstructor
reconstructor
=
new
TraceReconstructor
();
final
CollectorSink
<
Trace
>
collector
=
new
CollectorSink
<>(
this
.
traceCollectorList
);
final
IPipeFactory
pipeFactory
=
AnalysisConfiguration
.
PIPE_FACTORY_REGISTRY
.
getPipeFactory
(
ThreadCommunication
.
INTRA
,
PipeOrdering
.
ARBITRARY
,
false
);
pipeFactory
.
create
(
producer
.
getOutputPort
(),
reconstructor
.
getInputPort
());
pipeFactory
.
create
(
reconstructor
.
getOutputPort
(),
collector
.
getInputPort
());
this
.
addThreadableStage
(
producer
);
}
public
List
<
Trace
>
getOutput
()
{
return
this
.
traceCollectorList
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment