Skip to content

Commit 93677ca

Browse files
committed
M365 Crawler Metric, Buffer, and Unit Test Updates
Signed-off-by: Alex Christensen <alchrisk@amazon.com>
2 parents 047aaa8 + df71eb9 commit 93677ca

189 files changed

Lines changed: 5237 additions & 765 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/data-prepper-aws-secrets-e2e-tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,21 @@ jobs:
2929
ref: ${{ github.event.pull_request.head.sha }}
3030
- name: configure aws credentials
3131
id: creds
32-
uses: aws-actions/configure-aws-credentials@v4
32+
uses: aws-actions/configure-aws-credentials@v5
3333
with:
3434
role-to-assume: ${{ secrets.TEST_IAM_ROLE_ARN }}
3535
aws-region: ${{ secrets.TEST_REGION }}
3636
output-credentials: true
37-
- name: get caller identity 1
38-
run: |
39-
aws sts get-caller-identity
4037
- name: Configure AWS Credentials file
4138
run: |
4239
aws configure set default.region ${{ secrets.TEST_REGION }}
4340
aws configure set default.aws_access_key_id ${{ steps.creds.outputs.aws-access-key-id }}
4441
aws configure set default.aws_secret_access_key ${{ steps.creds.outputs.aws-secret-access-key }}
4542
aws configure set default.aws_session_token ${{ steps.creds.outputs.aws-session-token }}
43+
- name: Fix AWS credentials permissions for Docker
44+
run: |
45+
chmod 644 ~/.aws/credentials ~/.aws/config
46+
ls -la ~/.aws/
4647
- name: Set up JDK 11
4748
uses: actions/setup-java@v1
4849
with:

.github/workflows/kinesis-source-integration-tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ jobs:
3030

3131
- name: configure aws credentials
3232
id: creds
33-
uses: aws-actions/configure-aws-credentials@v4
33+
uses: aws-actions/configure-aws-credentials@v5
3434
with:
3535
role-to-assume: ${{ secrets.TEST_IAM_ROLE_ARN }}
3636
aws-region: ${{ secrets.TEST_REGION }}
3737
output-credentials: true
3838

39-
- name: get caller identity 1
40-
run: |
41-
aws sts get-caller-identity
4239
- name: Configure AWS Credentials file
4340
run: |
4441
aws configure set default.region ${{ secrets.TEST_REGION }}

.github/workflows/opensearch-sink-opensearch-integration-tests.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
java: [11]
23-
opensearch: [1.0.1, 1.1.0, 1.2.4, 1.3.14, 2.0.1, 2.1.0, 2.3.0, 2.5.0, 2.7.0, 2.9.0, 2.11.1]
23+
opensearch: [1.0.1, 1.1.0, 1.2.4, 1.3.14, 2.0.1, 2.1.0, 2.3.0, 2.5.0, 2.7.0, 2.9.0, 2.11.1, 2.12.0, 2.19.3]
2424
fail-fast: false
2525

2626
runs-on: ubuntu-latest
@@ -32,15 +32,22 @@ jobs:
3232
java-version: ${{ matrix.java }}
3333
- name: Checkout Data Prepper
3434
uses: actions/checkout@v2
35+
- name: Set password for OpenSearch version
36+
run: |
37+
if [[ "${{ matrix.opensearch }}" =~ ^2\.(1[2-9]|[2-9][0-9]) ]]; then
38+
echo "PASSWORD=yourStrongPassword123!" >> $GITHUB_ENV
39+
else
40+
echo "PASSWORD=admin" >> $GITHUB_ENV
41+
fi
3542
- name: Run OpenSearch docker
3643
run: |
3744
docker pull opensearchproject/opensearch:${{ matrix.opensearch }}
38-
docker run -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -d opensearchproject/opensearch:${{ matrix.opensearch }}
45+
docker run -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=yourStrongPassword123!" -d opensearchproject/opensearch:${{ matrix.opensearch }}
3946
sleep 90
4047
- name: Run OpenSearch tests
4148
run: |
42-
./gradlew :data-prepper-plugins:opensearch:integrationTest --tests "org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIT" -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin
43-
./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password=admin -Dtests.opensearch.bundle=true -Dtests.opensearch.version=opensearch:${{ matrix.opensearch }}
49+
./gradlew :data-prepper-plugins:opensearch:integrationTest --tests "org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchIT" -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password="$PASSWORD"
50+
./gradlew :data-prepper-plugins:opensearch:integrationTest -Dtests.opensearch.host=localhost:9200 -Dtests.opensearch.user=admin -Dtests.opensearch.password="$PASSWORD" -Dtests.opensearch.bundle=true -Dtests.opensearch.version=opensearch:${{ matrix.opensearch }}
4451
- name: Upload Unit Test Results
4552
if: always()
4653
uses: actions/upload-artifact@v4

data-prepper-api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919
testImplementation project(':data-prepper-test:test-common')
2020
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
2121
testImplementation libs.commons.io
22+
testImplementation 'org.hibernate.validator:hibernate-validator:8.0.1.Final'
2223
}
2324

2425
jacocoTestCoverageVerification {

data-prepper-api/src/main/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersion.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
110
package org.opensearch.dataprepper.model.configuration;
211

312
import java.util.Objects;
413
import java.util.Optional;
14+
import java.util.ServiceLoader;
515
import java.util.regex.Matcher;
616
import java.util.regex.Pattern;
717

818
public class DataPrepperVersion {
9-
private static final String CURRENT_VERSION = "2.13";
10-
1119
private static final String FULL_FORMAT = "%d.%d";
1220
private static final String SHORTHAND_FORMAT = "%d";
13-
private static final String VERSION_PATTERN_STRING = "^((\\d+)(\\.(\\d+))?)$";
14-
private static final Pattern VERSION_PATTERN = Pattern.compile(VERSION_PATTERN_STRING);
21+
private static final Pattern VERSION_PATTERN = Pattern.compile("^((\\d+)(\\.(\\d+))?)$");
22+
private static final Pattern VERSION_FULL_PATTERN = Pattern.compile("^((\\d+)(\\.(\\d+))?(\\.(\\d+))?)(-SNAPSHOT)?$");
1523
private static final int MAJOR_VERSION_PATTERN_POSITION = 2;
1624
private static final int MINOR_VERSION_PATTERN_POSITION = 4;
1725

@@ -20,21 +28,27 @@ public class DataPrepperVersion {
2028

2129
private static DataPrepperVersion instance;
2230

23-
private DataPrepperVersion(int majorVersion, Integer minorVersion) {
31+
private DataPrepperVersion(final int majorVersion, final Integer minorVersion) {
2432
this.minorVersion = minorVersion;
2533
this.majorVersion = majorVersion;
2634
}
2735

28-
public static DataPrepperVersion getCurrentVersion() {
29-
if (Objects.isNull(instance)) {
30-
instance = parse(CURRENT_VERSION);
36+
public static synchronized DataPrepperVersion getCurrentVersion() {
37+
if (instance == null) {
38+
final String versionString = ServiceLoader.load(VersionProvider.class).findFirst()
39+
.orElseThrow(() -> new RuntimeException("No Data Prepper version available."))
40+
.getVersionString();
41+
instance = parse(versionString, VERSION_FULL_PATTERN);
3142
}
3243
return instance;
3344
}
3445

3546
public static DataPrepperVersion parse(final String version) {
47+
return parse(version, VERSION_PATTERN);
48+
}
3649

37-
final Matcher result = VERSION_PATTERN.matcher(version);
50+
private static DataPrepperVersion parse(final String version, final Pattern versionPattern) {
51+
final Matcher result = versionPattern.matcher(version);
3852
if(result.find()) {
3953
String major = result.group(MAJOR_VERSION_PATTERN_POSITION);
4054
final int foundMajorVersion = Integer.parseInt(major);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.dataprepper.model.configuration;
11+
12+
/**
13+
* An interface for providing the current Data Prepper version
14+
* as a Java SPI. This is intended only to be used by Data Prepper
15+
* core or within tests.
16+
*
17+
* @since 2.13
18+
*/
19+
public interface VersionProvider {
20+
/**
21+
* Gets the current Data Prepper version as a string.
22+
* @return The Data Prepper version.
23+
*/
24+
String getVersionString();
25+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.dataprepper.model.constraints;
11+
12+
import jakarta.validation.Constraint;
13+
import jakarta.validation.Payload;
14+
15+
import java.lang.annotation.ElementType;
16+
import java.lang.annotation.Retention;
17+
import java.lang.annotation.RetentionPolicy;
18+
import java.lang.annotation.Target;
19+
20+
/**
21+
* Use this annotation to ensure that the byte count does not exceed
22+
* a specified maximum value.
23+
*
24+
* @since 2.13
25+
*/
26+
@Constraint(validatedBy = {ByteCountMaxValidator.class})
27+
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE_USE})
28+
@Retention(RetentionPolicy.RUNTIME)
29+
public @interface ByteCountMax {
30+
/**
31+
* The maximum value defined as a {@link org.opensearch.dataprepper.model.types.ByteCount}
32+
* string.
33+
*
34+
* @return The byte count string
35+
* @since 2.13
36+
*/
37+
String value();
38+
39+
String message() default "The provided byte count exceeds the maximum allowed value.";
40+
41+
Class<?>[] groups() default {};
42+
43+
Class<? extends Payload>[] payload() default {};
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.dataprepper.model.constraints;
11+
12+
import jakarta.validation.ConstraintValidator;
13+
import jakarta.validation.ConstraintValidatorContext;
14+
import org.opensearch.dataprepper.model.types.ByteCount;
15+
16+
public class ByteCountMaxValidator implements ConstraintValidator<ByteCountMax, ByteCount> {
17+
private ByteCount maxByteCount;
18+
19+
@Override
20+
public void initialize(final ByteCountMax constraint) {
21+
maxByteCount = ByteCount.parse(constraint.value());
22+
}
23+
24+
@Override
25+
public boolean isValid(final ByteCount byteCount, final ConstraintValidatorContext context) {
26+
if (byteCount == null) {
27+
return true;
28+
}
29+
30+
if (byteCount.compareTo(maxByteCount) > 0) {
31+
if (context != null) {
32+
context.disableDefaultConstraintViolation();
33+
context.buildConstraintViolationWithTemplate(
34+
String.format("The provided byte count %s exceeds maximum of %s", byteCount, maxByteCount))
35+
.addConstraintViolation();
36+
}
37+
38+
return false;
39+
}
40+
41+
return true;
42+
}
43+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.dataprepper.model.constraints;
11+
12+
import jakarta.validation.Constraint;
13+
import jakarta.validation.Payload;
14+
15+
import java.lang.annotation.ElementType;
16+
import java.lang.annotation.Retention;
17+
import java.lang.annotation.RetentionPolicy;
18+
import java.lang.annotation.Target;
19+
20+
/**
21+
* Use this annotation to ensure that the byte count is not below
22+
* a specified maximum value.
23+
*
24+
* @since 2.13
25+
*/
26+
@Constraint(validatedBy = {ByteCountMinValidator.class})
27+
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE_USE})
28+
@Retention(RetentionPolicy.RUNTIME)
29+
public @interface ByteCountMin {
30+
/**
31+
* The minimum value defined as a {@link org.opensearch.dataprepper.model.types.ByteCount}
32+
* string.
33+
*
34+
* @return The byte count string
35+
* @since 2.13
36+
*/
37+
String value();
38+
39+
String message() default "The provided byte count is below the minimum allowed value.";
40+
41+
Class<?>[] groups() default {};
42+
43+
Class<? extends Payload>[] payload() default {};
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.dataprepper.model.constraints;
11+
12+
import jakarta.validation.ConstraintValidator;
13+
import jakarta.validation.ConstraintValidatorContext;
14+
import org.opensearch.dataprepper.model.types.ByteCount;
15+
16+
public class ByteCountMinValidator implements ConstraintValidator<ByteCountMin, ByteCount> {
17+
private ByteCount minByteCount;
18+
19+
@Override
20+
public void initialize(final ByteCountMin constraint) {
21+
minByteCount = ByteCount.parse(constraint.value());
22+
}
23+
24+
@Override
25+
public boolean isValid(final ByteCount byteCount, final ConstraintValidatorContext context) {
26+
if (byteCount == null) {
27+
return true;
28+
}
29+
30+
if (byteCount.compareTo(minByteCount) < 0) {
31+
if (context != null) {
32+
context.disableDefaultConstraintViolation();
33+
context.buildConstraintViolationWithTemplate(
34+
String.format("The provided byte count %s is below minimum of %s", byteCount, minByteCount))
35+
.addConstraintViolation();
36+
}
37+
38+
return false;
39+
}
40+
41+
return true;
42+
}
43+
}

0 commit comments

Comments
 (0)