mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 07:07:54 -04:00
improve test for cache difference
This commit is contained in:
parent
27117a345a
commit
838c54879b
3 changed files with 16 additions and 29 deletions
|
@ -570,7 +570,7 @@ public final class CompiledPipelineTest extends RubyEnvTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
public void testCompilerCacheCompiledClasses() throws IOException, InvalidIRException {
|
public void testCacheCompiledClassesWithDifferentId() throws IOException, InvalidIRException {
|
||||||
final FixedPluginFactory pluginFactory = new FixedPluginFactory(
|
final FixedPluginFactory pluginFactory = new FixedPluginFactory(
|
||||||
() -> null,
|
() -> null,
|
||||||
() -> IDENTITY_FILTER,
|
() -> IDENTITY_FILTER,
|
||||||
|
@ -582,20 +582,20 @@ public final class CompiledPipelineTest extends RubyEnvTestCase {
|
||||||
false);
|
false);
|
||||||
final CompiledPipeline cBaselinePipeline = new CompiledPipeline(baselinePipeline, pluginFactory);
|
final CompiledPipeline cBaselinePipeline = new CompiledPipeline(baselinePipeline, pluginFactory);
|
||||||
|
|
||||||
final PipelineIR pipelineWithExtraFilter = ConfigCompiler.configToPipelineIR(
|
final PipelineIR pipelineWithDifferentId = ConfigCompiler.configToPipelineIR(
|
||||||
IRHelpers.toSourceWithMetadataFromPath("org/logstash/config/ir/cache/pipeline2.conf"),
|
IRHelpers.toSourceWithMetadataFromPath("org/logstash/config/ir/cache/pipeline2.conf"),
|
||||||
false);
|
false);
|
||||||
final CompiledPipeline cPipelineWithExtraFilter = new CompiledPipeline(pipelineWithExtraFilter, pluginFactory);
|
final CompiledPipeline cPipelineWithDifferentId = new CompiledPipeline(pipelineWithDifferentId, pluginFactory);
|
||||||
|
|
||||||
// actual test: compiling a pipeline with an extra filter should only create 1 extra class
|
// actual test: compiling a pipeline with an extra filter should only create 1 extra class
|
||||||
ComputeStepSyntaxElement.cleanClassCache();
|
ComputeStepSyntaxElement.cleanClassCache();
|
||||||
cBaselinePipeline.buildExecution();
|
cBaselinePipeline.buildExecution();
|
||||||
final int cachedBefore = ComputeStepSyntaxElement.classCacheSize();
|
final int cachedBefore = ComputeStepSyntaxElement.classCacheSize();
|
||||||
cPipelineWithExtraFilter.buildExecution();
|
cPipelineWithDifferentId.buildExecution();
|
||||||
final int cachedAfter = ComputeStepSyntaxElement.classCacheSize();
|
final int cachedAfter = ComputeStepSyntaxElement.classCacheSize();
|
||||||
|
|
||||||
final String message = String.format("unexpected cache size, cachedAfter: %d, cachedBefore: %d", cachedAfter, cachedBefore);
|
final String message = String.format("unexpected cache size, cachedAfter: %d, cachedBefore: %d", cachedAfter, cachedBefore);
|
||||||
assertEquals(message, 1, cachedAfter - cachedBefore);
|
assertEquals(message, 0, cachedAfter - cachedBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
input {
|
input {
|
||||||
stdin {}
|
stdin { id => "stdin_id_1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
filter {
|
filter {
|
||||||
mutate {
|
mutate {
|
||||||
id => "ppl1_1"
|
id => "mutate_id_1"
|
||||||
rename => ["a_field", "into_another"]
|
rename => ["a_field", "into_another"]
|
||||||
}
|
}
|
||||||
|
|
||||||
mutate {
|
|
||||||
id => "ppl1_2"
|
|
||||||
rename => ["a_field", "into_another"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output {
|
output {
|
||||||
stdout {}
|
stdout { id => "stdout_id_1" }
|
||||||
}
|
}
|
|
@ -1,24 +1,16 @@
|
||||||
|
# pipeline similar to pipeline 1 but with different ids
|
||||||
|
# no extra classes should be generated because of this
|
||||||
input {
|
input {
|
||||||
stdin {}
|
stdin { id => "stdin_id_1" }
|
||||||
}
|
}
|
||||||
|
|
||||||
filter {
|
filter {
|
||||||
mutate {
|
mutate {
|
||||||
id => "ppl2_1"
|
id => "mutate_id_1"
|
||||||
rename => ["a_field", "into_another"]
|
rename => ["a_field", "into_another"]
|
||||||
}
|
}
|
||||||
|
|
||||||
mutate {
|
|
||||||
id => "ppl2_2"
|
|
||||||
rename => ["a_field", "into_another"]
|
|
||||||
}
|
|
||||||
|
|
||||||
mutate {
|
|
||||||
id => "ppl2_3"
|
|
||||||
rename => ["a_field", "into_another"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output {
|
output {
|
||||||
stdout {}
|
stdout { id => "stdout_id_1" }
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue