Search in sources :

Example 21 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class StringPrepperTests method testStringPrepperLowerCase.

@Test
public void testStringPrepperLowerCase() {
    configuration.setUpperCase(false);
    final StringPrepper stringPrepper = createObjectUnderTest();
    final List<Record<Event>> modifiedRecords = (List<Record<Event>>) stringPrepper.execute(TEST_RECORDS);
    stringPrepper.shutdown();
    final List<Event> modifiedRecordEvents = modifiedRecords.stream().map(Record::getData).collect(Collectors.toList());
    assertThat(modifiedRecordEvents.size(), equalTo(2));
    final Event firstEvent = modifiedRecordEvents.get(0);
    final Event secondEvent = modifiedRecordEvents.get(1);
    assertTrue(firstEvent.containsKey(TEST_KEY));
    assertThat(firstEvent.getMetadata().getEventType(), equalTo(TEST_EVENT_TYPE));
    assertThat(firstEvent.get(TEST_KEY, String.class), equalTo(UPPERCASE_TEST_STRING));
    assertTrue(secondEvent.containsKey(TEST_KEY));
    assertThat(secondEvent.getMetadata().getEventType(), equalTo(TEST_EVENT_TYPE));
    assertThat(secondEvent.get(TEST_KEY, String.class), equalTo(LOWERCASE_TEST_STRING.toLowerCase()));
}
Also used : Event(com.amazon.dataprepper.model.event.Event) JacksonEvent(com.amazon.dataprepper.model.event.JacksonEvent) Record(com.amazon.dataprepper.model.record.Record) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 22 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class BlockingBufferTests method testBufferIsNotEmpty.

@Test
public void testBufferIsNotEmpty() throws Exception {
    final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
    final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
    Record<String> record = new Record<>("TEST");
    blockingBuffer.write(record, TEST_WRITE_TIMEOUT);
    assertFalse(blockingBuffer.isEmpty());
}
Also used : Record(com.amazon.dataprepper.model.record.Record) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 23 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class BlockingBufferTests method testCreationUsingPluginSetting.

@Test
public void testCreationUsingPluginSetting() {
    final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
    final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
    assertThat(blockingBuffer, notNullValue());
}
Also used : Record(com.amazon.dataprepper.model.record.Record) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 24 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PipelineTests method testGetSource.

@Test
public void testGetSource() {
    final Source<Record<String>> testSource = new TestSource();
    final TestSink testSink = new TestSink();
    final Pipeline testPipeline = new Pipeline(TEST_PIPELINE_NAME, testSource, new BlockingBuffer(TEST_PIPELINE_NAME), Collections.emptyList(), Collections.singletonList(testSink), TEST_PROCESSOR_THREADS, TEST_READ_BATCH_TIMEOUT);
    assertEquals(testSource, testPipeline.getSource());
}
Also used : TestSource(com.amazon.dataprepper.plugins.TestSource) BlockingBuffer(com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer) Record(com.amazon.dataprepper.model.record.Record) TestSink(com.amazon.dataprepper.plugins.TestSink) Test(org.junit.Test)

Example 25 with Record

use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.

the class PipelineTests method testExecuteFailingSource.

@Test
public void testExecuteFailingSource() {
    final Source<Record<String>> testSource = new TestSource(true);
    final TestSink testSink = new TestSink();
    try {
        final Pipeline testPipeline = new Pipeline(TEST_PIPELINE_NAME, testSource, new BlockingBuffer(TEST_PIPELINE_NAME), Collections.emptyList(), Collections.singletonList(testSink), TEST_PROCESSOR_THREADS, TEST_READ_BATCH_TIMEOUT);
        testPipeline.execute();
    } catch (Exception ex) {
        assertThat("Incorrect exception message", ex.getMessage().contains("Source is expected to fail"));
        assertThat("Exception while starting the source should have pipeline.isStopRequested to false", !testPipeline.isStopRequested());
    }
}
Also used : TestSource(com.amazon.dataprepper.plugins.TestSource) BlockingBuffer(com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer) Record(com.amazon.dataprepper.model.record.Record) TestSink(com.amazon.dataprepper.plugins.TestSink) Test(org.junit.Test)

Aggregations

Record (com.amazon.dataprepper.model.record.Record)103 Test (org.junit.Test)43 Measurement (io.micrometer.core.instrument.Measurement)35 StringJoiner (java.util.StringJoiner)35 PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)33 ArrayList (java.util.ArrayList)31 Map (java.util.Map)30 Test (org.junit.jupiter.api.Test)30 HashMap (java.util.HashMap)29 List (java.util.List)28 Event (com.amazon.dataprepper.model.event.Event)23 ExportTraceServiceRequest (io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest)20 ResourceSpans (io.opentelemetry.proto.trace.v1.ResourceSpans)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 JacksonEvent (com.amazon.dataprepper.model.event.JacksonEvent)14 ByteString (com.google.protobuf.ByteString)13 ExecutorService (java.util.concurrent.ExecutorService)13 Resource (io.opentelemetry.proto.resource.v1.Resource)12 Channel (io.grpc.Channel)11 MetricNames (com.amazon.dataprepper.metrics.MetricNames)10