From e7cad31a22522dc6f6bb6521ad402ff9cef0752b Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Tue, 29 Mar 2022 17:41:50 +0000 Subject: [PATCH 1/7] fixed mappings return type based of core changes Signed-off-by: Amit Galitzky --- build.gradle | 10 +- .../AbstractAnomalyDetectorActionHandler.java | 120 +++++++++--------- 2 files changed, 64 insertions(+), 66 deletions(-) diff --git a/build.gradle b/build.gradle index 347076769..47519d3d0 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,13 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask buildscript { ext { opensearch_group = "org.opensearch" - opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT") - // 1.2.0 -> 1.2.0.0, and 1.2.0-SNAPSHOT -> 1.2.0.0-SNAPSHOT - opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2') + opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT") + // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT + version_tokens = opensearch_version.tokenize('-') + opensearch_build = version_tokens[0] + '.0' + for (int j = 1; j < version_tokens.size(); j++) { + opensearch_build = opensearch_build + '-' + version_tokens[j] + } common_utils_version = System.getProperty("common_utils.version", opensearch_build) job_scheduler_version = System.getProperty("job_scheduler.version", opensearch_build) } diff --git a/src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java b/src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java index 144c73545..ee59b55d1 100644 --- a/src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java +++ b/src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java @@ -335,34 +335,31 @@ protected void validateTimeField(boolean indexingDryRun) { // AbstractAnomalyDetectorActionHandler.validateCategoricalField(String, boolean) ActionListener mappingsListener = ActionListener.wrap(getMappingsResponse -> { boolean foundField = false; - Map>> mappingsByIndex = getMappingsResponse - .mappings(); - - for (Map> mappingsByType : mappingsByIndex.values()) { - for (Map mappingsByField : mappingsByType.values()) { - for (Map.Entry field2Metadata : mappingsByField.entrySet()) { - - GetFieldMappingsResponse.FieldMappingMetadata fieldMetadata = field2Metadata.getValue(); - if (fieldMetadata != null) { - // sourceAsMap returns sth like {host2={type=keyword}} with host2 being a nested field - Map fieldMap = fieldMetadata.sourceAsMap(); - if (fieldMap != null) { - for (Object type : fieldMap.values()) { - if (type instanceof Map) { - foundField = true; - Map metadataMap = (Map) type; - String typeName = (String) metadataMap.get(CommonName.TYPE); - if (!typeName.equals(CommonName.DATE_TYPE)) { - listener - .onFailure( - new ADValidationException( - String.format(Locale.ROOT, CommonErrorMessages.INVALID_TIMESTAMP, givenTimeField), - DetectorValidationIssueType.TIMEFIELD_FIELD, - ValidationAspect.DETECTOR - ) - ); - return; - } + Map> mappingsByIndex = getMappingsResponse.mappings(); + + for (Map mappingsByField : mappingsByIndex.values()) { + for (Map.Entry field2Metadata : mappingsByField.entrySet()) { + + GetFieldMappingsResponse.FieldMappingMetadata fieldMetadata = field2Metadata.getValue(); + if (fieldMetadata != null) { + // sourceAsMap returns sth like {host2={type=keyword}} with host2 being a nested field + Map fieldMap = fieldMetadata.sourceAsMap(); + if (fieldMap != null) { + for (Object type : fieldMap.values()) { + if (type instanceof Map) { + foundField = true; + Map metadataMap = (Map) type; + String typeName = (String) metadataMap.get(CommonName.TYPE); + if (!typeName.equals(CommonName.DATE_TYPE)) { + listener + .onFailure( + new ADValidationException( + String.format(Locale.ROOT, CommonErrorMessages.INVALID_TIMESTAMP, givenTimeField), + DetectorValidationIssueType.TIMEFIELD_FIELD, + ValidationAspect.DETECTOR + ) + ); + return; } } } @@ -608,45 +605,42 @@ protected void validateCategoricalField(String detectorId, boolean indexingDryRu boolean foundField = false; // Review why the change from FieldMappingMetadata to GetFieldMappingsResponse.FieldMappingMetadata - Map>> mappingsByIndex = getMappingsResponse - .mappings(); - - for (Map> mappingsByType : mappingsByIndex.values()) { - for (Map mappingsByField : mappingsByType.values()) { - for (Map.Entry field2Metadata : mappingsByField.entrySet()) { - // example output: - // host_nest.host2=FieldMappingMetadata{fullName='host_nest.host2', - // source=org.opensearch.common.bytes.BytesArray@8fb4de08} - - // Review why the change from FieldMappingMetadata to GetFieldMappingsResponse.FieldMappingMetadata - - GetFieldMappingsResponse.FieldMappingMetadata fieldMetadata = field2Metadata.getValue(); - - if (fieldMetadata != null) { - // sourceAsMap returns sth like {host2={type=keyword}} with host2 being a nested field - Map fieldMap = fieldMetadata.sourceAsMap(); - if (fieldMap != null) { - for (Object type : fieldMap.values()) { - if (type != null && type instanceof Map) { - foundField = true; - Map metadataMap = (Map) type; - String typeName = (String) metadataMap.get(CommonName.TYPE); - if (!typeName.equals(CommonName.KEYWORD_TYPE) && !typeName.equals(CommonName.IP_TYPE)) { - listener - .onFailure( - new ADValidationException( - CATEGORICAL_FIELD_TYPE_ERR_MSG, - DetectorValidationIssueType.CATEGORY, - ValidationAspect.DETECTOR - ) - ); - return; - } + Map> mappingsByIndex = getMappingsResponse.mappings(); + + for (Map mappingsByField : mappingsByIndex.values()) { + for (Map.Entry field2Metadata : mappingsByField.entrySet()) { + // example output: + // host_nest.host2=FieldMappingMetadata{fullName='host_nest.host2', + // source=org.opensearch.common.bytes.BytesArray@8fb4de08} + + // Review why the change from FieldMappingMetadata to GetFieldMappingsResponse.FieldMappingMetadata + + GetFieldMappingsResponse.FieldMappingMetadata fieldMetadata = field2Metadata.getValue(); + + if (fieldMetadata != null) { + // sourceAsMap returns sth like {host2={type=keyword}} with host2 being a nested field + Map fieldMap = fieldMetadata.sourceAsMap(); + if (fieldMap != null) { + for (Object type : fieldMap.values()) { + if (type != null && type instanceof Map) { + foundField = true; + Map metadataMap = (Map) type; + String typeName = (String) metadataMap.get(CommonName.TYPE); + if (!typeName.equals(CommonName.KEYWORD_TYPE) && !typeName.equals(CommonName.IP_TYPE)) { + listener + .onFailure( + new ADValidationException( + CATEGORICAL_FIELD_TYPE_ERR_MSG, + DetectorValidationIssueType.CATEGORY, + ValidationAspect.DETECTOR + ) + ); + return; } } } - } + } } } From cf6d320d13ad0b37c0a13be87f50f28b08a43095 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Tue, 29 Mar 2022 18:30:05 +0000 Subject: [PATCH 2/7] fixed tests that used mapping type Signed-off-by: Amit Galitzky --- .../ad/indices/AnomalyDetectionIndices.java | 12 ++++++------ src/test/java/org/opensearch/ad/TestHelpers.java | 9 +++++---- .../org/opensearch/ad/indices/RolloverTests.java | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java index 41fc77c72..157b244cc 100644 --- a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java @@ -533,7 +533,7 @@ public void initAnomalyDetectorIndexIfAbsent(ActionListener */ public void initAnomalyDetectorIndex(ActionListener actionListener) throws IOException { CreateIndexRequest request = new CreateIndexRequest(AnomalyDetector.ANOMALY_DETECTORS_INDEX) - .mapping(AnomalyDetector.TYPE, getAnomalyDetectorMappings(), XContentType.JSON) + .mapping(getAnomalyDetectorMappings()) .settings(settings); adminClient.indices().create(request, markMappingUpToDate(ADIndex.CONFIG, actionListener)); } @@ -597,7 +597,7 @@ public void initAnomalyResultIndexDirectly( ActionListener actionListener ) throws IOException { String mapping = getAnomalyResultMappings(); - CreateIndexRequest request = new CreateIndexRequest(resultIndex).mapping(CommonName.MAPPING_TYPE, mapping, XContentType.JSON); + CreateIndexRequest request = new CreateIndexRequest(resultIndex).mapping(mapping); if (alias != null) { request.alias(new Alias(CommonName.ANOMALY_RESULT_INDEX_ALIAS)); } @@ -617,7 +617,7 @@ public void initAnomalyResultIndexDirectly( public void initAnomalyDetectorJobIndex(ActionListener actionListener) { try { CreateIndexRequest request = new CreateIndexRequest(AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) - .mapping(AnomalyDetector.TYPE, getAnomalyDetectorJobMappings(), XContentType.JSON); + .mapping(getAnomalyDetectorJobMappings()); request .settings( Settings @@ -649,7 +649,7 @@ public void initAnomalyDetectorJobIndex(ActionListener acti public void initDetectionStateIndex(ActionListener actionListener) { try { CreateIndexRequest request = new CreateIndexRequest(CommonName.DETECTION_STATE_INDEX) - .mapping(AnomalyDetector.TYPE, getDetectionStateMappings(), XContentType.JSON) + .mapping(getDetectionStateMappings()) .settings(settings); adminClient.indices().create(request, markMappingUpToDate(ADIndex.STATE, actionListener)); } catch (IOException e) { @@ -672,7 +672,7 @@ public void initCheckpointIndex(ActionListener actionListen throw new EndRunException("", "Cannot find checkpoint mapping file", true); } CreateIndexRequest request = new CreateIndexRequest(CommonName.CHECKPOINT_INDEX_NAME) - .mapping(CommonName.MAPPING_TYPE, mapping, XContentType.JSON); + .mapping(mapping); choosePrimaryShards(request); adminClient.indices().create(request, markMappingUpToDate(ADIndex.CHECKPOINT, actionListener)); } @@ -729,7 +729,7 @@ void rolloverAndDeleteHistoryIndex() { } CreateIndexRequest createRequest = rollOverRequest.getCreateIndexRequest(); - createRequest.index(AD_RESULT_HISTORY_INDEX_PATTERN).mapping(CommonName.MAPPING_TYPE, adResultMapping, XContentType.JSON); + createRequest.index(AD_RESULT_HISTORY_INDEX_PATTERN).mapping(adResultMapping); choosePrimaryShards(createRequest); diff --git a/src/test/java/org/opensearch/ad/TestHelpers.java b/src/test/java/org/opensearch/ad/TestHelpers.java index bf1e98fd9..a6e8e6556 100644 --- a/src/test/java/org/opensearch/ad/TestHelpers.java +++ b/src/test/java/org/opensearch/ad/TestHelpers.java @@ -52,6 +52,7 @@ import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; +import org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse; import org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata; import org.opensearch.action.get.GetResponse; import org.opensearch.action.search.SearchRequest; @@ -1046,7 +1047,7 @@ public static ThreadPool createThreadPool() { } public static CreateIndexResponse createIndex(AdminClient adminClient, String indexName, String indexMapping) { - CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(AnomalyDetector.TYPE, indexMapping, XContentType.JSON); + CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(indexMapping); return adminClient.indices().create(request).actionGet(5_000); } @@ -1211,17 +1212,17 @@ public static DetectorInternalState randomDetectState(String error, Instant last return new DetectorInternalState.Builder().lastUpdateTime(lastUpdateTime).error(error).build(); } - public static Map>> createFieldMappings( + public static Map> createFieldMappings( String index, String fieldName, String fieldType ) throws IOException { - Map>> mappings = new HashMap<>(); + Map> mappings = new HashMap<>(); FieldMappingMetadata fieldMappingMetadata = new FieldMappingMetadata( fieldName, new BytesArray("{\"" + fieldName + "\":{\"type\":\"" + fieldType + "\"}}") ); - mappings.put(index, Collections.singletonMap(CommonName.MAPPING_TYPE, Collections.singletonMap(fieldName, fieldMappingMetadata))); + mappings.put(index, Collections.singletonMap(fieldName, fieldMappingMetadata)); return mappings; } diff --git a/src/test/java/org/opensearch/ad/indices/RolloverTests.java b/src/test/java/org/opensearch/ad/indices/RolloverTests.java index 2cfce8df4..66a50c6be 100644 --- a/src/test/java/org/opensearch/ad/indices/RolloverTests.java +++ b/src/test/java/org/opensearch/ad/indices/RolloverTests.java @@ -129,7 +129,7 @@ private void assertRolloverRequest(RolloverRequest request) { CreateIndexRequest createIndexRequest = request.getCreateIndexRequest(); assertEquals(AnomalyDetectionIndices.AD_RESULT_HISTORY_INDEX_PATTERN, createIndexRequest.index()); - assertTrue(createIndexRequest.mappings().get(CommonName.MAPPING_TYPE).contains("data_start_time")); + assertTrue(createIndexRequest.mappings().contains("data_start_time")); } public void testNotRolledOver() { @@ -169,7 +169,7 @@ private void setUpRolloverSuccess() { CreateIndexRequest createIndexRequest = request.getCreateIndexRequest(); assertEquals(AnomalyDetectionIndices.AD_RESULT_HISTORY_INDEX_PATTERN, createIndexRequest.index()); - assertTrue(createIndexRequest.mappings().get(CommonName.MAPPING_TYPE).contains("data_start_time")); + assertTrue(createIndexRequest.mappings().contains("data_start_time")); listener.onResponse(new RolloverResponse(null, null, Collections.emptyMap(), request.isDryRun(), true, true, true)); return null; }).when(indicesClient).rolloverIndex(any(), any()); From f1aa0f36ea4154251dbae60f3cbfc6dcf7a4ff0b Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 30 Mar 2022 17:52:32 +0000 Subject: [PATCH 3/7] updating jackson-databind to match core and fix CVE Signed-off-by: Amit Galitzky --- build.gradle | 8 ++++---- .../ad/indices/AnomalyDetectionIndices.java | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 47519d3d0..97edbfc58 100644 --- a/build.gradle +++ b/build.gradle @@ -110,7 +110,7 @@ configurations.all { if (it.state != Configuration.State.UNRESOLVED) return resolutionStrategy { force "joda-time:joda-time:${versions.joda}" - force "com.fasterxml.jackson.core:jackson-core:2.12.6" + force "com.fasterxml.jackson.core:jackson-core:2.13.2" force "commons-logging:commons-logging:${versions.commonslogging}" force "org.apache.httpcomponents:httpcore:${versions.httpcore}" force "commons-codec:commons-codec:${versions.commonscodec}" @@ -588,9 +588,9 @@ dependencies { // force Jackson version to avoid version conflict issue implementation 'software.amazon.randomcutforest:randomcutforest-serialization:2.0.1' - implementation "com.fasterxml.jackson.core:jackson-core:2.12.6" - implementation "com.fasterxml.jackson.core:jackson-databind:2.12.6" - implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.6" + implementation "com.fasterxml.jackson.core:jackson-core:2.13.2" + implementation "com.fasterxml.jackson.core:jackson-databind:2.13.2.2" + implementation "com.fasterxml.jackson.core:jackson-annotations:2.13.2" implementation files('lib/randomcutforest-parkservices-2.0.1.jar') implementation files('lib/randomcutforest-core-2.0.1.jar') diff --git a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java index 157b244cc..18cf3ff2e 100644 --- a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java @@ -533,7 +533,7 @@ public void initAnomalyDetectorIndexIfAbsent(ActionListener */ public void initAnomalyDetectorIndex(ActionListener actionListener) throws IOException { CreateIndexRequest request = new CreateIndexRequest(AnomalyDetector.ANOMALY_DETECTORS_INDEX) - .mapping(getAnomalyDetectorMappings()) + .mapping(getAnomalyDetectorMappings(), XContentType.JSON) .settings(settings); adminClient.indices().create(request, markMappingUpToDate(ADIndex.CONFIG, actionListener)); } @@ -597,7 +597,7 @@ public void initAnomalyResultIndexDirectly( ActionListener actionListener ) throws IOException { String mapping = getAnomalyResultMappings(); - CreateIndexRequest request = new CreateIndexRequest(resultIndex).mapping(mapping); + CreateIndexRequest request = new CreateIndexRequest(resultIndex).mapping(mapping, XContentType.JSON); if (alias != null) { request.alias(new Alias(CommonName.ANOMALY_RESULT_INDEX_ALIAS)); } @@ -617,7 +617,7 @@ public void initAnomalyResultIndexDirectly( public void initAnomalyDetectorJobIndex(ActionListener actionListener) { try { CreateIndexRequest request = new CreateIndexRequest(AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) - .mapping(getAnomalyDetectorJobMappings()); + .mapping(getAnomalyDetectorJobMappings(), XContentType.JSON); request .settings( Settings @@ -649,7 +649,7 @@ public void initAnomalyDetectorJobIndex(ActionListener acti public void initDetectionStateIndex(ActionListener actionListener) { try { CreateIndexRequest request = new CreateIndexRequest(CommonName.DETECTION_STATE_INDEX) - .mapping(getDetectionStateMappings()) + .mapping(getDetectionStateMappings(), XContentType.JSON) .settings(settings); adminClient.indices().create(request, markMappingUpToDate(ADIndex.STATE, actionListener)); } catch (IOException e) { @@ -671,8 +671,7 @@ public void initCheckpointIndex(ActionListener actionListen } catch (IOException e) { throw new EndRunException("", "Cannot find checkpoint mapping file", true); } - CreateIndexRequest request = new CreateIndexRequest(CommonName.CHECKPOINT_INDEX_NAME) - .mapping(mapping); + CreateIndexRequest request = new CreateIndexRequest(CommonName.CHECKPOINT_INDEX_NAME).mapping(mapping, XContentType.JSON); choosePrimaryShards(request); adminClient.indices().create(request, markMappingUpToDate(ADIndex.CHECKPOINT, actionListener)); } @@ -729,7 +728,7 @@ void rolloverAndDeleteHistoryIndex() { } CreateIndexRequest createRequest = rollOverRequest.getCreateIndexRequest(); - createRequest.index(AD_RESULT_HISTORY_INDEX_PATTERN).mapping(adResultMapping); + createRequest.index(AD_RESULT_HISTORY_INDEX_PATTERN).mapping(adResultMapping, XContentType.JSON); choosePrimaryShards(createRequest); From f387fff6a04fa42e1955c860c9a15badefc57282 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 30 Mar 2022 18:30:33 +0000 Subject: [PATCH 4/7] updating CI workflow Signed-off-by: Amit Galitzky --- .github/workflows/CI.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8d352ef31..5acbb9d0a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,20 +29,20 @@ jobs: - name: Assemble anomaly-detection run: | - ./gradlew assemble -Dopensearch.version=2.0.0-SNAPSHOT - echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..." - mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT - echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..." + ./gradlew assemble + echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." + mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT + echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." ls ./build/distributions/ - cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT - echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..." - ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT + cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT + echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." + ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT - name: Build and Run Tests run: | - ./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT + ./gradlew build - name: Publish to Maven Local run: | - ./gradlew publishToMavenLocal -Dopensearch.version=2.0.0-SNAPSHOT + ./gradlew publishToMavenLocal - name: Multi Nodes Integration Testing run: | ./gradlew integTest -PnumNodes=3 From f4f3bc8b5cff3d8933fe1a5ce5eb9d24bb86b171 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 30 Mar 2022 19:22:51 +0000 Subject: [PATCH 5/7] changed CI to use gradle's constant Signed-off-by: Amit Galitzky --- .github/workflows/CI.yml | 14 ++++++++------ build.gradle | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5acbb9d0a..ec8411206 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,14 +29,16 @@ jobs: - name: Assemble anomaly-detection run: | + plugin_version=`./gradlew properties -q | grep "opensearch_build:" | awk '{print $2}'` + echo plugin_version $plugin_version ./gradlew assemble - echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." - mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT - echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." + echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version ..." + mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version + echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version ..." ls ./build/distributions/ - cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT - echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT ..." - ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-alpha1-SNAPSHOT + cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version + echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version ..." + ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/$plugin_version - name: Build and Run Tests run: | ./gradlew build diff --git a/build.gradle b/build.gradle index 97edbfc58..ff69c141a 100644 --- a/build.gradle +++ b/build.gradle @@ -319,7 +319,7 @@ String bwcFilePath = "src/test/resources/org/opensearch/ad/bwc/" testClusters { "${baseName}$i" { testDistribution = "ARCHIVE" - versions = ["7.10.2","1.3.0-SNAPSHOT"] + versions = ["7.10.2", "2.0.0-alpha1-SNAPSHOT"] numberOfNodes = 3 plugin(provider(new Callable(){ @Override From 134503ca63e48e939859de4eaf4dfe0b03e18781 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 30 Mar 2022 19:44:53 +0000 Subject: [PATCH 6/7] remove jdk14 support Signed-off-by: Amit Galitzky --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ec8411206..7e7c78a3d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,7 +11,7 @@ jobs: Build-ad: strategy: matrix: - java: [11, 14] + java: [11] fail-fast: false name: Build and Test Anomaly detection Plugin From 6129713803887149712016f5b835e755441d6df7 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 30 Mar 2022 23:05:26 +0000 Subject: [PATCH 7/7] changed version tokenizing Signed-off-by: Amit Galitzky --- build.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ff69c141a..e191fc2a0 100644 --- a/build.gradle +++ b/build.gradle @@ -16,12 +16,17 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask buildscript { ext { opensearch_group = "org.opensearch" + isSnapshot = "true" == System.getProperty("build.snapshot", "true") opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT") + buildVersionQualifier = System.getProperty("build.version_qualifier") // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT version_tokens = opensearch_version.tokenize('-') opensearch_build = version_tokens[0] + '.0' - for (int j = 1; j < version_tokens.size(); j++) { - opensearch_build = opensearch_build + '-' + version_tokens[j] + if (buildVersionQualifier) { + opensearch_build += "-${buildVersionQualifier}" + } + if (isSnapshot) { + opensearch_build += "-SNAPSHOT" } common_utils_version = System.getProperty("common_utils.version", opensearch_build) job_scheduler_version = System.getProperty("job_scheduler.version", opensearch_build)