mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-29 19:35:56 +00:00
Fix: test case indexing -- remove changeDescription from testSuites list (#17083)
* fix: test case indexing -- remove changeDescription from testSuites list * fix: change type to interface * style: ran java linting
This commit is contained in:
parent
bc49f9e843
commit
13daa3668a
@ -15,7 +15,7 @@ import org.openmetadata.service.search.SearchIndexUtils;
|
||||
import org.openmetadata.service.search.models.SearchSuggest;
|
||||
|
||||
public record TestCaseIndex(TestCase testCase) implements SearchIndex {
|
||||
private static final Set<String> excludeFields = Set.of("testSuites.changeDescription");
|
||||
private static final Set<String> excludeFields = Set.of("changeDescription");
|
||||
|
||||
@Override
|
||||
public Object getEntity() {
|
||||
@ -23,8 +23,12 @@ public record TestCaseIndex(TestCase testCase) implements SearchIndex {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getExcludedFields() {
|
||||
return excludeFields;
|
||||
public void removeNonIndexableFields(Map<String, Object> esDoc) {
|
||||
SearchIndex.super.removeNonIndexableFields(esDoc);
|
||||
List<Map<String, Object>> testSuites = (List<Map<String, Object>>) esDoc.get("testSuites");
|
||||
for (Map<String, Object> testSuite : testSuites) {
|
||||
SearchIndexUtils.removeNonIndexableFields(testSuite, excludeFields);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
@ -96,6 +96,7 @@ import org.openmetadata.service.resources.EntityResourceTest;
|
||||
import org.openmetadata.service.resources.databases.TableResourceTest;
|
||||
import org.openmetadata.service.resources.feeds.FeedResourceTest;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser;
|
||||
import org.openmetadata.service.search.indexes.TestCaseIndex;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
import org.openmetadata.service.util.ResultList;
|
||||
import org.openmetadata.service.util.TestUtils;
|
||||
@ -2026,6 +2027,30 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
() -> createEntity(invalidTestCaseMixedTypes, ADMIN_AUTH_HEADERS), BAD_REQUEST, "Value");
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_testCaseEsDocCleanUp(TestInfo testInfo) {
|
||||
TestCase testCase =
|
||||
new TestCase()
|
||||
.withId(UUID.randomUUID())
|
||||
.withChangeDescription(new ChangeDescription())
|
||||
.withTestSuites(
|
||||
List.of(
|
||||
new TestSuite()
|
||||
.withId(UUID.randomUUID())
|
||||
.withChangeDescription(new ChangeDescription()),
|
||||
new TestSuite()
|
||||
.withId(UUID.randomUUID())
|
||||
.withChangeDescription(new ChangeDescription())));
|
||||
|
||||
Map<String, Object> doc = JsonUtils.convertValue(testCase, Map.class);
|
||||
|
||||
TestCaseIndex testCaseIndex = new TestCaseIndex(testCase);
|
||||
testCaseIndex.removeNonIndexableFields(doc);
|
||||
assertNull(doc.get("changeDescription"));
|
||||
List<Map<String, Object>> testSuites = (List<Map<String, Object>>) doc.get("testSuites");
|
||||
assertNull(testSuites.get(0).get("changeDescription"));
|
||||
}
|
||||
|
||||
public void deleteTestCaseResult(String fqn, Long timestamp, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
WebTarget target = getCollection().path("/" + fqn + "/testCaseResult/" + timestamp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user