Skip to content

Commit

Permalink
Merge pull request #3 from sternadsoftware/4119
Browse files Browse the repository at this point in the history
Add java time module to tests
  • Loading branch information
KarstenSchnitter authored Oct 8, 2024
2 parents f4b0c60 + b3fe06d commit 1232498
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package org.opensearch.dataprepper.plugins.source.otellogs;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down Expand Up @@ -44,7 +46,7 @@
import static org.hamcrest.Matchers.equalTo;

class OtelLogsSourceConfigTests {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().registerModule(new JavaTimeModule());
private static final String PLUGIN_NAME = "otel_logs_source";
private static final String TEST_KEY_CERT = "test.crt";
private static final String TEST_KEY = "test.key";
Expand Down Expand Up @@ -297,8 +299,8 @@ void testRetryInfoConfig() {


RetryInfoConfig retryInfo = oTelLogsSourceConfig.getRetryInfo();
assertThat(retryInfo.getMaxDelay(), equalTo(100));
assertThat(retryInfo.getMinDelay(), equalTo(50));
assertThat(retryInfo.getMaxDelay(), equalTo(Duration.ofMillis(100)));
assertThat(retryInfo.getMinDelay(), equalTo(Duration.ofMillis(50)));
}

private PluginSetting completePluginSettingForOtelLogsSource(final int requestTimeoutInMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package org.opensearch.dataprepper.plugins.source.otelmetrics;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -31,7 +33,7 @@
import static org.opensearch.dataprepper.plugins.source.otelmetrics.OTelMetricsSourceConfig.DEFAULT_THREAD_COUNT;

class OtelMetricsSourceConfigTests {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().registerModule(new JavaTimeModule());
private static final String PLUGIN_NAME = "otel_metrics_source";
private static final String TEST_KEY_CERT = "test.crt";
private static final String TEST_KEY = "test.key";
Expand Down Expand Up @@ -322,8 +324,8 @@ void testRetryInfoConfig() {
final OTelMetricsSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(customPathPluginSetting.getSettings(), OTelMetricsSourceConfig.class);

RetryInfoConfig retryInfo = otelTraceSourceConfig.getRetryInfo();
assertThat(retryInfo.getMaxDelay(), equalTo(100));
assertThat(retryInfo.getMinDelay(), equalTo(50));
assertThat(retryInfo.getMaxDelay(), equalTo(Duration.ofMillis(100)));
assertThat(retryInfo.getMinDelay(), equalTo(Duration.ofMillis(50)));
}

private PluginSetting completePluginSettingForOtelMetricsSource(final int requestTimeoutInMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensearch.dataprepper.plugins.source.oteltrace;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
Expand Down Expand Up @@ -135,7 +136,7 @@ class OTelTraceSourceTest {
private static final String USERNAME = "test_user";
private static final String PASSWORD = "test_password";
private static final String TEST_PATH = "${pipelineName}/v1/traces";
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().registerModule(new JavaTimeModule());
private static final String TEST_PIPELINE_NAME = "test_pipeline";
private static final RetryInfoConfig TEST_RETRY_INFO = new RetryInfoConfig(Duration.ofMillis(50), Duration.ofMillis(2000));
private static final ExportTraceServiceRequest SUCCESS_REQUEST = ExportTraceServiceRequest.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.opensearch.dataprepper.plugins.codec.CompressionOption;
import org.opensearch.dataprepper.model.configuration.PluginSetting;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.junit.jupiter.api.Test;

import java.time.Duration;
Expand All @@ -31,7 +33,7 @@
import static org.opensearch.dataprepper.plugins.source.oteltrace.OTelTraceSourceConfig.DEFAULT_THREAD_COUNT;

class OtelTraceSourceConfigTests {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().registerModule(new JavaTimeModule());
private static final String PLUGIN_NAME = "otel_trace_source";
private static final String TEST_KEY_CERT = "test.crt";
private static final String TEST_KEY = "test.key";
Expand Down Expand Up @@ -321,8 +323,8 @@ void testRetryInfoConfig() {
final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(customPathPluginSetting.getSettings(), OTelTraceSourceConfig.class);


assertThat(otelTraceSourceConfig.getRetryInfo().getMaxDelay(), equalTo(100));
assertThat(otelTraceSourceConfig.getRetryInfo().getMinDelay(), equalTo(50));
assertThat(otelTraceSourceConfig.getRetryInfo().getMaxDelay(), equalTo(Duration.ofMillis(100)));
assertThat(otelTraceSourceConfig.getRetryInfo().getMinDelay(), equalTo(Duration.ofMillis(50)));
}

private PluginSetting completePluginSettingForOtelTraceSource(final int requestTimeoutInMillis,
Expand Down

0 comments on commit 1232498

Please sign in to comment.