Skip to content

Commit

Permalink
Integration test to verify that the core HTTP server starts. (opensea…
Browse files Browse the repository at this point in the history
…rch-project#4255)

Signed-off-by: David Venable <dlv@amazon.com>
  • Loading branch information
dlvenable authored Mar 28, 2024
1 parent af8f867 commit 6765098
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.integration;

import com.linecorp.armeria.client.WebClient;
import com.linecorp.armeria.common.HttpMethod;
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.armeria.common.RequestHeaders;
import com.linecorp.armeria.common.SessionProtocol;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opensearch.dataprepper.plugins.InMemorySinkAccessor;
import org.opensearch.dataprepper.plugins.InMemorySourceAccessor;
import org.opensearch.dataprepper.test.framework.DataPrepperTestRunner;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

class CoreHttpServerIT {
private static final String PIPELINE_CONFIGURATION_UNDER_TEST = "minimal-pipeline.yaml";
private DataPrepperTestRunner dataPrepperTestRunner;
private InMemorySourceAccessor inMemorySourceAccessor;
private InMemorySinkAccessor inMemorySinkAccessor;

@BeforeEach
void setUp() {
dataPrepperTestRunner = DataPrepperTestRunner.builder()
.withPipelinesDirectoryOrFile(PIPELINE_CONFIGURATION_UNDER_TEST)
.build();

dataPrepperTestRunner.start();
inMemorySourceAccessor = dataPrepperTestRunner.getInMemorySourceAccessor();
inMemorySinkAccessor = dataPrepperTestRunner.getInMemorySinkAccessor();
}

@AfterEach
void tearDown() {
dataPrepperTestRunner.stop();
}

@Test
void verify_list_api_is_running() {
WebClient.of().execute(RequestHeaders.builder()
.scheme(SessionProtocol.HTTP)
.authority("127.0.0.1:4900")
.method(HttpMethod.GET)
.path("/list")
.build())
.aggregate()
.whenComplete((response, ex) -> {
assertThat("Http Status", response.status(), equalTo(HttpStatus.OK));
})
.join();
}

}

0 comments on commit 6765098

Please sign in to comment.