-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Add explicit isNoOpUpdate() method to MapperService #144113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1930b00
7c93232
2c95b09
e26eedf
490f547
5514f30
60f50db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1113,11 +1113,7 @@ public void testNoopMappingUpdateInfiniteLoopPrevention() throws Exception { | |
| Engine.IndexResult mappingUpdate = new Engine.IndexResult(Mapping.emptyCompressed(), "id"); | ||
|
|
||
| MapperService mapperService = mock(MapperService.class); | ||
| DocumentMapper documentMapper = mock(DocumentMapper.class); | ||
| when(documentMapper.mappingSource()).thenReturn(CompressedXContent.fromJSON("{}")); | ||
| // returning the current document mapper as the merge result to simulate a noop mapping update | ||
| when(mapperService.documentMapper()).thenReturn(documentMapper); | ||
| when(mapperService.merge(any(), any(CompressedXContent.class), any())).thenReturn(documentMapper); | ||
| when(mapperService.isNoOpUpdate(any())).thenReturn(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That behavior already existed, but I think we should remove the mockito framework.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, good idea. There are several tests in here that use Mockito so I think probably it's best done as a follow-up covering all of them, to keep things separate?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should be done in a follow-up pr |
||
|
|
||
| IndexShard shard = mockShard(null, mapperService); | ||
| when(shard.applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean())).thenReturn( | ||
|
|
@@ -1166,11 +1162,7 @@ public void testNoopMappingUpdateSuccessOnRetry() throws Exception { | |
| Engine.IndexResult successfulResult = new FakeIndexResult(1, 1, 10, true, resultLocation, "id"); | ||
|
|
||
| MapperService mapperService = mock(MapperService.class); | ||
| DocumentMapper documentMapper = mock(DocumentMapper.class); | ||
| when(documentMapper.mappingSource()).thenReturn(CompressedXContent.fromJSON("{}")); | ||
| when(mapperService.documentMapper()).thenReturn(documentMapper); | ||
| // returning the current document mapper as the merge result to simulate a noop mapping update | ||
| when(mapperService.merge(any(), any(CompressedXContent.class), any())).thenReturn(documentMapper); | ||
| when(mapperService.isNoOpUpdate(any())).thenReturn(true); | ||
| // on the second invocation, the mapping version is incremented | ||
| // so that the second mapping update attempt doesn't trigger the infinite loop prevention | ||
| when(mapperService.mappingVersion()).thenReturn(0L, 0L, 1L); | ||
|
|
@@ -1217,7 +1209,7 @@ public void testNoopMappingUpdateSuccessOnRetry() throws Exception { | |
| ); | ||
|
|
||
| latch.await(); | ||
| verify(mapperService, times(2)).merge(any(), any(CompressedXContent.class), any()); | ||
| verify(mapperService, times(2)).isNoOpUpdate(any()); | ||
| } | ||
|
|
||
| private IndexShard mockShard(IndexSettings indexSettings, MapperService mapperService) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this
assertenough? Should it be replaced by a runtime check, throwing an exception?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An assertion should be fine I think, MergeReason is entirely internal.