-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NoElasticLogsBackend shouldn't activate
otel.logs.exporter=otlp
(#499)
* NoElasticLogsBackend shouldn't activate `otel.logs.exporter=otlp` * Add unit tests
- Loading branch information
1 parent
386b392
commit 154caf8
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/io/jenkins/plugins/opentelemetry/backend/ElasticBackendTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright The Original Author or Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.jenkins.plugins.opentelemetry.backend; | ||
|
||
import io.jenkins.plugins.opentelemetry.backend.elastic.ElasticLogsBackendWithJenkinsVisualization; | ||
import io.jenkins.plugins.opentelemetry.backend.elastic.ElasticLogsBackendWithoutJenkinsVisualization; | ||
import io.jenkins.plugins.opentelemetry.backend.elastic.NoElasticLogsBackend; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class ElasticBackendTest { | ||
|
||
@Test | ||
public void testNoElasticLogsBackend() { | ||
ElasticBackend elasticBackend = new ElasticBackend(); | ||
elasticBackend.setElasticLogsBackend(new NoElasticLogsBackend()); | ||
Map<String, String> actual = elasticBackend.getOtelConfigurationProperties(); | ||
Map<String, String> expected = Collections.emptyMap(); | ||
Assert.assertEquals(actual, expected); | ||
} | ||
|
||
@Test | ||
public void testElasticLogsBackendWithJenkinsVisualization() { | ||
ElasticBackend elasticBackend = new ElasticBackend(); | ||
elasticBackend.setElasticLogsBackend(new ElasticLogsBackendWithJenkinsVisualization()); | ||
Map<String, String> actual = elasticBackend.getOtelConfigurationProperties(); | ||
Map<String, String> expected = Collections.singletonMap("otel.logs.exporter", "otlp"); | ||
Assert.assertEquals(actual, expected); | ||
} | ||
|
||
@Test | ||
public void testElasticLogsBackendWithoutJenkinsVisualization() { | ||
ElasticBackend elasticBackend = new ElasticBackend(); | ||
elasticBackend.setElasticLogsBackend(new ElasticLogsBackendWithoutJenkinsVisualization()); | ||
Map<String, String> actual = elasticBackend.getOtelConfigurationProperties(); | ||
Map<String, String> expected = Collections.singletonMap("otel.logs.exporter", "otlp"); | ||
Assert.assertEquals(actual, expected); | ||
} | ||
} |