Test: finish all merges before test returns to side step 'Delete Index failed - not acked' failure

This commit is contained in:
mikemccand 2014-07-29 11:54:45 -04:00
parent dc696e6fc8
commit dbcc4e9255
1 changed files with 36 additions and 18 deletions

View File

@ -331,26 +331,44 @@ public class UpdateSettingsTests extends ElasticsearchIntegrationTest {
) )
.get(); .get();
// Make sure we log the change: try {
assertTrue(mockAppender.sawUpdateSetting);
int i = 0; // Make sure we log the change:
while (true) { assertTrue(mockAppender.sawUpdateSetting);
// Provoke slowish merging by making many unique terms:
StringBuilder sb = new StringBuilder(); int i = 0;
for(int j=0;j<100;j++) { while (true) {
sb.append(' '); // Provoke slowish merging by making many unique terms:
sb.append(termUpto++); StringBuilder sb = new StringBuilder();
for(int j=0;j<100;j++) {
sb.append(' ');
sb.append(termUpto++);
}
client().prepareIndex("test", "type", ""+termUpto).setSource("field" + (i%10), sb.toString()).get();
if (i % 2 == 0) {
refresh();
}
// This time we should see some merges were in fact paused:
if (mockAppender.sawMergeThreadPaused) {
break;
}
i++;
} }
client().prepareIndex("test", "type", ""+termUpto).setSource("field" + (i%10), sb.toString()).get(); } finally {
if (i % 2 == 0) { // Make merges fast again & finish merges before we try to close; else we sometimes get a "Delete Index failed - not acked"
refresh(); // when ElasticsearchIntegrationTest.after tries to remove indices created by the test:
} client()
// This time we should see some merges were in fact paused: .admin()
if (mockAppender.sawMergeThreadPaused) { .indices()
break; .prepareUpdateSettings("test")
} .setSettings(ImmutableSettings.builder()
i++; .put(ConcurrentMergeSchedulerProvider.MAX_THREAD_COUNT, "3")
.put(AbstractIndexStore.INDEX_STORE_THROTTLE_MAX_BYTES_PER_SEC, "20mb")
)
.get();
// Wait for merges to finish
client().admin().indices().prepareOptimize("test").setWaitForMerge(true).get();
} }