Skip to content

Commit eea2da0

Browse files
committed
test(otel_logs_source): invert default httpPath in test config fixture (opensearch-project#6575)
Signed-off-by: Hai Yan <oeyh@amazon.com> (cherry picked from commit 0660318)
1 parent a92f710 commit eea2da0

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceGrpcTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ void testStartWithEmptyBuffer() {
344344
@Test
345345
void start_withoutHttpPath_doesNotThrowNPE() {
346346
final OTelLogsSourceConfig config = createDefaultConfigBuilder()
347-
.httpPath(null)
348347
.path("/test-pipeline/v1/logs")
349348
.build();
350349
final OTelLogsSource source = new OTelLogsSource(config, pluginMetrics, pluginFactory,

data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceHttpTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import static org.mockito.Mockito.verify;
3636
import static org.mockito.Mockito.when;
3737
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createConfigBuilderWithBasicAuth;
38-
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createDefaultConfig;
3938
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createDefaultConfigBuilder;
4039
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createJsonHttpPayload;
4140
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigFixture.createBuilderForConfigWithSsl;
@@ -173,7 +172,7 @@ public void afterEach() {
173172
}
174173

175174
private void configureSource() {
176-
configureSource(createDefaultConfig());
175+
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).build());
177176
}
178177

179178
private void configureSource(OTelLogsSourceConfig config) {
@@ -211,7 +210,7 @@ void httpRequest_writesToBuffer_returnsSuccessfulResponse(String givenPath, Stri
211210

212211
@Test
213212
void httpsRequest_requestIsProcessed_writesToBufferAndReturnsSuccessfulResponse() throws Exception {
214-
configureSource(createBuilderForConfigWithSsl().build());
213+
configureSource(createBuilderForConfigWithSsl().httpPath(CONFIG_HTTP_PATH).build());
215214
SOURCE.start(buffer);
216215
ExportLogsServiceRequest request = createExportLogsRequest();
217216

@@ -254,7 +253,7 @@ void httpRequest_oneConnectionIsEstablished_metricsReflectCorrectConnectionCount
254253

255254
@Test
256255
void httpRequest_payloadIsCompressed_returns200() throws IOException {
257-
configureSource( createDefaultConfigBuilder().compression(CompressionOption.GZIP).build());
256+
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).compression(CompressionOption.GZIP).build());
258257
SOURCE.start(buffer);
259258

260259
WebClient.of().execute(getDefaultRequestHeadersBuilder()
@@ -271,7 +270,7 @@ void httpRequest_payloadIsCompressed_returns200() throws IOException {
271270
void httpRequest_withBasicAuth_returnsAppropriateResponse(String givenUsername, String givenPassword, HttpStatus expectedStatus, VerificationMode expectedBufferWrites) throws Exception {
272271
final HttpBasicAuthenticationConfig basicAuthConfig = new HttpBasicAuthenticationConfig(BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD);
273272
when(pluginFactory.loadPlugin(eq(GrpcAuthenticationProvider.class), any(PluginSetting.class))).thenReturn(new GrpcBasicAuthenticationProvider(basicAuthConfig));
274-
configureSource(createConfigBuilderWithBasicAuth().build());
273+
configureSource(createConfigBuilderWithBasicAuth().httpPath(CONFIG_HTTP_PATH).build());
275274
SOURCE.start(buffer);
276275

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

302301
WebClient.of().execute(getDefaultRequestHeadersBuilder()
@@ -344,7 +343,7 @@ void httpRequest_writingToBufferThrowsAnException_correctHttpStatusIsReturned(
344343

345344
@Test
346345
void httpRequest_requestBodyIsTooLarge_returns413() throws InvalidProtocolBufferException {
347-
configureSource(createDefaultConfigBuilder().maxRequestLength(ByteCount.ofBytes(4)).build());
346+
configureSource(createDefaultConfigBuilder().httpPath(CONFIG_HTTP_PATH).maxRequestLength(ByteCount.ofBytes(4)).build());
348347
SOURCE.start(buffer);
349348

350349
WebClient.of()

data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceConfigFixture.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import static org.opensearch.dataprepper.plugins.source.otellogs.OTelLogsSourceConfig.DEFAULT_REQUEST_TIMEOUT_MS;
1515
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.BASIC_AUTH_PASSWORD;
1616
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.BASIC_AUTH_USERNAME;
17-
import static org.opensearch.dataprepper.plugins.source.otellogs.OtelLogsSourceConfigTestData.CONFIG_HTTP_PATH;
1817

1918
import java.util.Map;
2019

@@ -42,7 +41,6 @@ public static OTelLogsSourceConfig createDefaultConfig() {
4241
public static OTelLogsSourceConfig.OTelLogsSourceConfigBuilder createDefaultConfigBuilder() {
4342
return OTelLogsSourceConfig.builder()
4443
.healthCheck(true)
45-
.httpPath(CONFIG_HTTP_PATH)
4644
.port(DEFAULT_PORT)
4745
.enableUnframedRequests(false)
4846
.ssl(false)

0 commit comments

Comments
 (0)