Skip to content

Commit f063913

Browse files
committed
Add test
1 parent 6847ead commit f063913

File tree

14 files changed

+45
-98
lines changed

14 files changed

+45
-98
lines changed

.idea/eclipseCodeFormatter.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.idea/externalDependencies.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.idea/runConfigurations/Debug_Elasticsearch.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.idea/runConfigurations/Debug_Elasticsearch__node_2_.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.idea/runConfigurations/Debug_Elasticsearch__node_3_.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.idea/scopes/Production_minus_fixtures.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.idea/scopes/llrc.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.idea/scopes/x_pack.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

server/src/internalClusterTest/java/org/elasticsearch/indices/IndexingMemoryControllerIT.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Optional;
3030

3131
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
32+
import static org.hamcrest.Matchers.greaterThan;
3233
import static org.hamcrest.Matchers.lessThanOrEqualTo;
3334

3435
public class IndexingMemoryControllerIT extends ESSingleNodeTestCase {
@@ -37,7 +38,9 @@ public class IndexingMemoryControllerIT extends ESSingleNodeTestCase {
3738
protected Settings nodeSettings() {
3839
return Settings.builder()
3940
.put(super.nodeSettings())
40-
// small indexing buffer so that we can trigger refresh after buffering 100 deletes
41+
// small indexing buffer so that
42+
// 1. We can trigger refresh after buffering 100 deletes
43+
// 2. Indexing memory Controller writes indexing buffers in sync with indexing on the indexing thread
4144
.put("indices.memory.index_buffer_size", "1kb")
4245
.build();
4346
}
@@ -111,4 +114,21 @@ public void testDeletesAloneCanTriggerRefresh() throws Exception {
111114
}
112115
assertThat(shard.getEngineOrNull().getIndexBufferRAMBytesUsed(), lessThanOrEqualTo(ByteSizeUnit.KB.toBytes(1)));
113116
}
117+
118+
/* When there is memory pressure, we write indexing buffers to disk on the same thread as the indexing thread,
119+
* @see org.elasticsearch.indices.IndexingMemoryController.
120+
* This test verifies that we update the stats that capture the combined time for indexing + writing the
121+
* indexing buffers.
122+
*/
123+
public void testIndexingUpdatesRelevantStats() throws Exception {
124+
IndexService indexService = createIndex("index", indexSettings(1, 0).put("index.refresh_interval", -1).build());
125+
IndexShard shard = indexService.getShard(0);
126+
for (int i = 0; i < 100; i++) {
127+
prepareIndex("index").setId(Integer.toString(i)).setSource("field", "value").get();
128+
}
129+
assertThat(
130+
shard.indexingStats().getTotal().getTotalIndexExecutionTimeInMillis(),
131+
greaterThan(shard.indexingStats().getTotal().getIndexTime().getMillis())
132+
);
133+
}
114134
}

0 commit comments

Comments
 (0)