1919import org .opensearch .dataprepper .test .plugins .PluginConfigurationFile ;
2020import org .opensearch .dataprepper .test .plugins .junit .BaseDataPrepperPluginStandardTestSuite ;
2121
22+ import java .util .ArrayList ;
2223import java .util .Collection ;
2324import java .util .LinkedList ;
2425import java .util .List ;
2526import java .util .Map ;
2627import java .util .UUID ;
2728import java .util .stream .Collectors ;
29+ import java .util .concurrent .atomic .AtomicInteger ;
2830
2931import static org .hamcrest .CoreMatchers .equalTo ;
3032import static org .hamcrest .CoreMatchers .notNullValue ;
3133import static org .hamcrest .MatcherAssert .assertThat ;
3234
3335@ DataPrepperPluginTest (pluginName = "drop_events" , pluginType = Processor .class )
3436class DropEventsProcessorIT extends BaseDataPrepperPluginStandardTestSuite {
35- @ Test
36- void drops_records_when_value_is_empty_string (
37- @ PluginConfigurationFile ("drop_when_value_is_empty_string.yaml" ) final Processor <Record <Event >, Record <Event >> objectUnderTest ,
38- final EventFactory eventFactory ) {
37+ private static final int MAX_THREADS = 5 ;
3938
39+ private void createEventsAndExecute (final Processor <Record <Event >, Record <Event >> objectUnderTest ,
40+ final EventFactory eventFactory ) {
4041 final List <Event > allEvents = new LinkedList <>();
4142 final List <Event > expectedEventsAfterProcessor = new LinkedList <>();
4243 for (int i = 0 ; i < 5 ; i ++) {
@@ -69,4 +70,33 @@ void drops_records_when_value_is_empty_string(
6970
7071 assertThat (outputEvents , equalTo (expectedEventsAfterProcessor ));
7172 }
72- }
73+
74+ @ Test
75+ void drops_records_when_value_is_empty_string (
76+ @ PluginConfigurationFile ("drop_when_value_is_empty_string.yaml" ) final Processor <Record <Event >, Record <Event >> objectUnderTest ,
77+ final EventFactory eventFactory ) {
78+ createEventsAndExecute (objectUnderTest , eventFactory );
79+ }
80+
81+ @ Test
82+ void drops_records_when_value_is_empty_string_with_multiple_threads (
83+ @ PluginConfigurationFile ("drop_when_value_is_empty_string.yaml" ) final Processor <Record <Event >, Record <Event >> objectUnderTest ,
84+ final EventFactory eventFactory ) throws Exception {
85+
86+ AtomicInteger numSuccess = new AtomicInteger (0 );
87+ List <Thread > threads = new ArrayList <>();
88+ for (int i = 0 ; i < MAX_THREADS ; i ++) {
89+ threads .add (new Thread (() -> {
90+ createEventsAndExecute (objectUnderTest , eventFactory );
91+ numSuccess .incrementAndGet ();
92+ }));
93+ }
94+ for (int i = 0 ; i < MAX_THREADS ; i ++) {
95+ threads .get (i ).start ();
96+ }
97+ for (int i = 0 ; i < MAX_THREADS ; i ++) {
98+ threads .get (i ).join ();
99+ }
100+ assertThat (numSuccess .get (), equalTo (MAX_THREADS ));
101+ }
102+ }
0 commit comments