diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java index 178d2efcb760f6331c7ef10ee1d46b113370b927..78aacde9c3cb2d9a60c3fcb88ae22a192fa592d0 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java @@ -565,8 +565,8 @@ public class IndexerServiceImpl implements IndexerService { .filter(record -> Objects.equals(record.getKind(), schema.getKind())) .toList(); for (Record schemaRecord : schemaRecords) { - this.jobStatus.addOrUpdateRecordStatus(schemaRecord.getId(), IndexingStatus.WARN, e.getStatus(), String.format("Error while mapping schema in elasticsearch: %s", e.getMessage())); - schemaRecord.setData(null); + this.jobStatus.addOrUpdateRecordStatus(schemaRecord.getId(), IndexingStatus.FAIL, e.getStatus(), String.format("Error reconciling index mapping with kind schema from schema-service: %s", e.getMessage())); + schemaRecord.setData(Collections.emptyMap()); } } continue; diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/exception/ElasticsearchMappingException.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/exception/ElasticsearchMappingException.java index ad9f92ef7fdb17f86a62bdeb1213b8d601d85ffb..e3309d913f24f84ac114d51b2de4dc8e6bb0c6a4 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/exception/ElasticsearchMappingException.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/exception/ElasticsearchMappingException.java @@ -1,3 +1,18 @@ +/* + * Copyright © Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.opengroup.osdu.indexer.service.exception; import lombok.Getter; diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java index c7952963334b0b83bf378f0619e19636e34bca16..1949f8268e775c2afd365871edf974e13430ffaf 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java @@ -206,20 +206,23 @@ public class IndexerServiceImplTest { // validate assertEquals(5, jobStatus.getStatusesList().size()); - assertEquals(2, jobStatus.getIdsByIndexingStatus(IndexingStatus.WARN).size()); - assertEquals(1, jobStatus.getIdsByIndexingStatus(IndexingStatus.FAIL).size()); + assertEquals(1, jobStatus.getIdsByIndexingStatus(IndexingStatus.WARN).size()); + assertEquals(2, jobStatus.getIdsByIndexingStatus(IndexingStatus.FAIL).size()); assertEquals(2, jobStatus.getIdsByIndexingStatus(IndexingStatus.SUCCESS).size()); verify(restHighLevelClient, times(2)).bulk(any(), any()); - verify(this.auditLogger).indexStarted(Arrays.asList("id=opendes:doc:test1 kind=opendes:testindexer1:well:1.0.0 operationType=update", + verify(this.auditLogger).indexStarted(Arrays.asList( + "id=opendes:doc:test1 kind=opendes:testindexer1:well:1.0.0 operationType=update", "id=opendes:doc:test2 kind=opendes:testindexer2:well:1.0.0 operationType=create", "id=opendes:doc:test3 kind=opendes:testindexer2:well:1.0.0 operationType=create", "id=opendes:doc:test4 kind=osdu:wks:reference-data--IndexPropertyPathConfiguration:1.0.0 operationType=create", "id=opendes:doc:test5 kind=opendes:testindexer4:well:1.0.0 operationType=create")); - verify(this.auditLogger).indexCreateRecordSuccess(Arrays.asList("RecordStatus(id=opendes:doc:test2, kind=opendes:testindexer2:well:1.0.0, operationType=create, status=SUCCESS)", - "RecordStatus(id=opendes:doc:test4, kind=osdu:wks:reference-data--IndexPropertyPathConfiguration:1.0.0, operationType=create, status=SUCCESS)")); - verify(this.auditLogger).indexCreateRecordFail(singletonList("RecordStatus(id=opendes:doc:test3, kind=opendes:testindexer2:well:1.0.0, operationType=create, status=FAIL, message=null)")); - verify(this.auditLogger).indexCreateRecordPartialSuccess(singletonList("RecordStatus(id=opendes:doc:test5, kind=opendes:testindexer4:well:1.0.0, operationType=create, status==PARTIAL_SUCCESS, message=Indexed Successfully)")); + verify(this.auditLogger).indexCreateRecordSuccess(Arrays.asList( + "RecordStatus(id=opendes:doc:test2, kind=opendes:testindexer2:well:1.0.0, operationType=create, status=SUCCESS)", + "RecordStatus(id=opendes:doc:test4, kind=osdu:wks:reference-data--IndexPropertyPathConfiguration:1.0.0, operationType=create, status=SUCCESS)")); + verify(this.auditLogger).indexCreateRecordFail(Arrays.asList( + "RecordStatus(id=opendes:doc:test3, kind=opendes:testindexer2:well:1.0.0, operationType=create, status=FAIL, message=null)", + "RecordStatus(id=opendes:doc:test5, kind=opendes:testindexer4:well:1.0.0, operationType=create, status=FAIL, message=Indexed Successfully)")); verify(this.auditLogger).indexUpdateRecordPartialSuccess(singletonList("RecordStatus(id=opendes:doc:test1, kind=opendes:testindexer1:well:1.0.0, operationType=update, status==PARTIAL_SUCCESS, message=Indexed Successfully)")); } catch (Exception e) { fail("Should not throw this exception" + e.getMessage());