Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ void testStartWithEmptyBuffer() {
assertThrows(IllegalStateException.class, () -> source.start(null));
}

@Test
void start_withoutHttpPath_doesNotThrowNPE() {
final OTelLogsSourceConfig config = createDefaultConfigBuilder()
.path("/test-pipeline/v1/logs")
.build();
final OTelLogsSource source = new OTelLogsSource(config, pluginMetrics, pluginFactory,
certificateProviderFactory, pipelineDescription);
source.start(buffer);
source.stop();
}

@Test
void testStartWithServerExecutionExceptionNoCause() throws ExecutionException, InterruptedException {
// Prepare
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createConfigBuilderWithBasicAuth;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createDefaultConfig;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createDefaultConfigBuilder;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createJsonHttpPayload;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createBuilderForConfigWithSsl;
Expand Down Expand Up @@ -175,7 +174,7 @@ public void afterEach() {
}

private void configureSource() {
configureSource(createDefaultConfig());
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).build());
}

private void configureSource(OTelLogsSourceConfig config) {
Expand Down Expand Up @@ -213,7 +212,7 @@ void httpRequest_writesToBuffer_returnsSuccessfulResponse(String givenPath, Stri

@Test
void httpsRequest_requestIsProcessed_writesToBufferAndReturnsSuccessfulResponse() throws Exception {
configureSource(createBuilderForConfigWithSsl().build());
configureSource(createBuilderForConfigWithSsl().httpPath(CONFIG_HTTP_PATH).build());
SOURCE.start(buffer);
ExportLogsServiceRequest request = createExportLogsRequest();

Expand Down Expand Up @@ -256,7 +255,7 @@ void httpRequest_oneConnectionIsEstablished_metricsReflectCorrectConnectionCount

@Test
void httpRequest_payloadIsCompressed_returns200() throws IOException {
configureSource( createDefaultConfigBuilder().compression(CompressionOption.GZIP).build());
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).compression(CompressionOption.GZIP).build());
SOURCE.start(buffer);

WebClient.of().execute(getDefaultRequestHeadersBuilder()
Expand All @@ -272,9 +271,8 @@ void httpRequest_payloadIsCompressed_returns200() throws IOException {
@MethodSource("getBasicAuthTestData")
void httpRequest_withBasicAuth_returnsAppropriateResponse(String givenUsername, String givenPassword, HttpStatus expectedStatus, VerificationMode expectedBufferWrites) throws Exception {
final HttpBasicAuthenticationConfig basicAuthConfig = new HttpBasicAuthenticationConfig(BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD);
final HttpBasicArmeriaHttpAuthenticationProvider authProvider = new HttpBasicArmeriaHttpAuthenticationProvider(basicAuthConfig);
when(pluginFactory.loadPlugin(eq(ArmeriaHttpAuthenticationProvider.class), any(PluginSetting.class))).thenReturn(authProvider);
configureSource(createConfigBuilderWithBasicAuth().build());
when(pluginFactory.loadPlugin(eq(GrpcAuthenticationProvider.class), any(PluginSetting.class))).thenReturn(new GrpcBasicAuthenticationProvider(basicAuthConfig));
configureSource(createConfigBuilderWithBasicAuth().httpPath(CONFIG_HTTP_PATH).build());
SOURCE.start(buffer);

final String encodedCredentials = Base64.getEncoder().encodeToString(String.format("%s:%s", givenUsername, givenPassword).getBytes(StandardCharsets.UTF_8));
Expand All @@ -299,7 +297,7 @@ private static Stream<Arguments> getBasicAuthTestData() {
@ParameterizedTest
@MethodSource("getHealthCheckParams")
void healthCheckRequest_requestIsProcesses_returnsStatusCodeAccordingToConfig(boolean givenHealthCheckConfig, HttpStatus expectedStatus) throws IOException {
configureSource(createDefaultConfigBuilder().healthCheck(givenHealthCheckConfig).build());
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).healthCheck(givenHealthCheckConfig).build());
SOURCE.start(buffer);

WebClient.of().execute(getDefaultRequestHeadersBuilder()
Expand Down Expand Up @@ -347,7 +345,7 @@ void httpRequest_writingToBufferThrowsAnException_correctHttpStatusIsReturned(

@Test
void httpRequest_requestBodyIsTooLarge_returns413() throws InvalidProtocolBufferException {
configureSource(createDefaultConfigBuilder().maxRequestLength(ByteCount.ofBytes(4)).build());
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).maxRequestLength(ByteCount.ofBytes(4)).build());
SOURCE.start(buffer);

WebClient.of()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import static org.opensearch.dataprepper.plugins.source.otellogs.OTelLogsSourceConfig.DEFAULT_REQUEST_TIMEOUT_MS;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.BASIC_AUTH_PASSWORD;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.BASIC_AUTH_USERNAME;
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.CONFIG_HTTP_PATH;

import java.util.Map;

Expand Down Expand Up @@ -42,7 +41,6 @@ public static OTelLogsSourceConfig createDefaultConfig() {
public static OTelLogsSourceConfig.OTelLogsSourceConfigBuilder createDefaultConfigBuilder() {
return OTelLogsSourceConfig.builder()
.healthCheck(true)
.httpPath(CONFIG_HTTP_PATH)
.port(DEFAULT_PORT)
.enableUnframedRequests(false)
.ssl(false)
Expand Down
Loading