|
23 | 23 | import org.elasticsearch.test.ESIntegTestCase;
|
24 | 24 | import org.elasticsearch.test.junit.annotations.TestLogging;
|
25 | 25 | import org.elasticsearch.threadpool.ThreadPool;
|
| 26 | +import org.elasticsearch.threadpool.ThreadPoolStats; |
26 | 27 |
|
27 | 28 | import java.util.Arrays;
|
28 | 29 | import java.util.Collection;
|
@@ -121,8 +122,32 @@ private void assertThreadPoolsBlocked() {
|
121 | 122 | () -> client().prepareIndex(USER_INDEX).setSource(Map.of("foo", "bar")).get()
|
122 | 123 | );
|
123 | 124 | assertThat(e1.getMessage(), startsWith("rejected execution of TimedRunnable"));
|
124 |
| - var e2 = expectThrows(EsRejectedExecutionException.class, () -> client().prepareGet(USER_INDEX, "id").get()); |
125 |
| - assertThat(e2.getMessage(), startsWith("rejected execution of ActionRunnable")); |
| 125 | + |
| 126 | + final var getFuture = client().prepareGet(USER_INDEX, "id").execute(); |
| 127 | + // response handling is force-executed on GET pool, so we must |
| 128 | + // (a) wait for that task to be enqueued, expanding the queue beyond its configured limit, and |
| 129 | + // (b) check for the exception in the background |
| 130 | + |
| 131 | + try { |
| 132 | + assertTrue(waitUntil(() -> { |
| 133 | + if (getFuture.isDone()) { |
| 134 | + return true; |
| 135 | + } |
| 136 | + for (ThreadPool threadPool : internalCluster().getInstances(ThreadPool.class)) { |
| 137 | + for (ThreadPoolStats.Stats stats : threadPool.stats().stats()) { |
| 138 | + if (stats.name().equals(ThreadPool.Names.GET) && stats.queue() > 1) { |
| 139 | + return true; |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + return false; |
| 144 | + })); |
| 145 | + } catch (Exception e) { |
| 146 | + fail(e); |
| 147 | + } |
| 148 | + |
| 149 | + new Thread(() -> expectThrows(EsRejectedExecutionException.class, () -> getFuture.actionGet(SAFE_AWAIT_TIMEOUT))).start(); |
| 150 | + |
126 | 151 | // intentionally commented out this test until https://github.com/elastic/elasticsearch/issues/97916 is fixed
|
127 | 152 | // var e3 = expectThrows(
|
128 | 153 | // SearchPhaseExecutionException.class,
|
|
0 commit comments