Skip to content

Commit

Permalink
Add integ test env option
Browse files Browse the repository at this point in the history
Signed-off-by: Srikanth Govindarajan <[email protected]>
  • Loading branch information
srikanthjg committed Nov 17, 2024
1 parent 46033fa commit 58514ea
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 268 deletions.
12 changes: 10 additions & 2 deletions data-prepper-plugins/aws-lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ The integration tests for this plugin do not run as part of the Data Prepper bui
The following command runs the integration tests:

```
./gradlew :data-prepper-plugins:aws-lambda:integrationTest -Dtests.processor.lambda.region="us-east-1" -Dtests.processor.lambda.functionName="lambda_test_function" -Dtests.processor.lambda.sts_role_arn="arn:aws:iam::123456789012:role/dataprepper-role
./gradlew :data-prepper-plugins:aws-lambda:integrationTest \
-Dtests.lambda.processor.region="us-east-1" \
-Dtests.lambda.processor.functionName="test-lambda-processor" \
-Dtests.lambda.processor.sts_role_arn="arn:aws:iam::<>:role/lambda-role"
```

Expand Down Expand Up @@ -83,6 +87,10 @@ The integration tests for this plugin do not run as part of the Data Prepper bui
The following command runs the integration tests:

```
./gradlew :data-prepper-plugins:aws-lambda:integrationTest -Dtests.sink.lambda.region="us-east-1" -Dtests.sink.lambda.functionName="lambda_test_function" -Dtests.sink.lambda.sts_role_arn="arn:aws:iam::123456789012:role/dataprepper-role
./gradlew :data-prepper-plugins:aws-lambda:integrationTest \
-Dtests.lambda.processor.region="us-east-1" \
-Dtests.lambda.processor.functionName="test-lambda-processor" \
-Dtests.lambda.processor.sts_role_arn="arn:aws:iam::<>>:role/lambda-role"
```
12 changes: 6 additions & 6 deletions data-prepper-plugins/aws-lambda/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ task integrationTest(type: Test) {
systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
systemProperty 'junit.jupiter.execution.parallel.mode.default', 'concurrent'

systemProperty 'tests.lambda.sink.region', System.getenv('TESTS_LAMBDA_SINK_REGION')
systemProperty 'tests.lambda.sink.functionName', System.getenv('TESTS_LAMBDA_SINK_FUNCTION_NAME')
systemProperty 'tests.lambda.sink.sts_role_arn', System.getenv('TESTS_LAMBDA_SINK_STS_ROLE_ARN')
systemProperty 'tests.lambda.sink.region', System.getProperty('tests.lambda.sink.region')
systemProperty 'tests.lambda.sink.functionName', System.getProperty('tests.lambda.sink.functionName')
systemProperty 'tests.lambda.sink.sts_role_arn', System.getProperty('tests.lambda.sink.sts_role_arn')

systemProperty 'tests.lambda.processor.region', System.getenv('TESTS_LAMBDA_PROCESSOR_REGION')
systemProperty 'tests.lambda.processor.functionName', System.getenv('TESTS_LAMBDA_PROCESSOR_FUNCTION_NAME')
systemProperty 'tests.lambda.processor.sts_role_arn', System.getenv('TESTS_LAMBDA_PROCESSOR_STS_ROLE_ARN')
systemProperty 'tests.lambda.processor.region', System.getProperty('tests.lambda.processor.region')
systemProperty 'tests.lambda.processor.functionName', System.getProperty('tests.lambda.processor.functionName')
systemProperty 'tests.lambda.processor.sts_role_arn', System.getProperty('tests.lambda.processor.sts_role_arn')

filter {
includeTestsMatching '*IT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.dataprepper.plugins.lambda.processor;

import org.junit.jupiter.params.provider.EnumSource;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import org.mockito.junit.jupiter.MockitoSettings;
Expand Down Expand Up @@ -102,12 +103,13 @@ private LambdaProcessor createObjectUnderTest(LambdaProcessorConfig processorCon

@BeforeEach
public void setup() {
// lambdaRegion = System.getProperty("tests.lambda.processor.region");
// functionName = System.getProperty("tests.lambda.processor.functionName");
// role = System.getProperty("tests.lambda.processor.sts_role_arn");
lambdaRegion="us-east-1";
functionName="test-lambda-processor";
role="arn:aws:iam::176893235612:role/osis-lambda-role";
lambdaRegion = System.getProperty("tests.lambda.processor.region");
functionName = System.getProperty("tests.lambda.processor.functionName");
role = System.getProperty("tests.lambda.processor.sts_role_arn");

// lambdaRegion = "us-east-1";
// functionName = "test-lambda-processor";
// role = "arn:aws:iam::176893235612:role/osis-lambda-role";

pluginMetrics = mock(PluginMetrics.class);
when(pluginMetrics.gauge(any(), any(AtomicLong.class))).thenReturn(new AtomicLong());
Expand Down Expand Up @@ -179,7 +181,6 @@ public void testRequestResponseWithMatchingEventsStrictMode(int numRecords) {


@ParameterizedTest
//@ValueSource(ints = {2, 5, 10, 100, 1000})
@ValueSource(ints = {1000})
public void testRequestResponseWithMatchingEventsAggregateMode(int numRecords) {
when(invocationType.getAwsLambdaValue()).thenReturn(InvocationType.REQUEST_RESPONSE.getAwsLambdaValue());
Expand Down Expand Up @@ -222,24 +223,17 @@ public void testRequestResponse_WithMatchingEvents_StrictMode_WithMultipleThread
executorService.shutdown();
}

@ParameterizedTest
@ValueSource(strings = {"RequestResponse", "Event"})
public void testDifferentInvocationTypes(String invocationType) {
when(this.invocationType.getAwsLambdaValue()).thenReturn(invocationType);
when(lambdaProcessorConfig.getResponseEventsMatch()).thenReturn(true);

lambdaProcessor = createObjectUnderTest(lambdaProcessorConfig);
@Test
public void testEventInvocationType() {
when(lambdaProcessorConfig.getInvocationType()).thenReturn(InvocationType.EVENT);
List<Record<Event>> records = createRecords(10);

lambdaProcessor = createObjectUnderTest(lambdaProcessorConfig);

// For "Event" invocation type
when(lambdaProcessorConfig.getResponseEventsMatch()).thenReturn(false);
Collection<Record<Event>> results = lambdaProcessor.doExecute(records);

if (invocationType.equals("RequestResponse")) {
assertThat(results.size(), equalTo(10));
validateStrictModeResults(results);
} else {
// For "Event" invocation type
assertThat(results.size(), equalTo(0));
}
assertThat(results.size(), equalTo(0)); // Changed from 0 to 10
}

@Test
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 58514ea

Please sign in to comment.