|
20 | 20 | package org.elasticsearch.index;
|
21 | 21 |
|
22 | 22 | import org.elasticsearch.Version;
|
| 23 | +import org.elasticsearch.action.search.SearchTask; |
23 | 24 | import org.elasticsearch.action.search.SearchType;
|
24 | 25 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
25 | 26 | import org.elasticsearch.common.bytes.BytesReference;
|
|
39 | 40 | import org.elasticsearch.threadpool.ThreadPool;
|
40 | 41 |
|
41 | 42 | import java.io.IOException;
|
| 43 | +import java.util.Collections; |
42 | 44 |
|
| 45 | +import static org.hamcrest.Matchers.endsWith; |
43 | 46 | import static org.hamcrest.Matchers.hasToString;
|
44 | 47 | import static org.hamcrest.Matchers.instanceOf;
|
45 | 48 | import static org.hamcrest.Matchers.not;
|
@@ -166,10 +169,12 @@ public void testSlowLogSearchContextPrinterToLog() throws IOException {
|
166 | 169 | SearchContext searchContext = createSearchContext(index);
|
167 | 170 | SearchSourceBuilder source = SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery());
|
168 | 171 | searchContext.request().source(source);
|
| 172 | + searchContext.setTask(new SearchTask(0, "n/a", "n/a", "test", null, Collections.singletonMap("X-Opaque-Id", "my_id"))); |
169 | 173 | SearchSlowLog.SlowLogSearchContextPrinter p = new SearchSlowLog.SlowLogSearchContextPrinter(searchContext, 10);
|
170 | 174 | assertThat(p.toString(), startsWith("[foo][0]"));
|
171 | 175 | // Makes sure that output doesn't contain any new lines
|
172 | 176 | assertThat(p.toString(), not(containsString("\n")));
|
| 177 | + assertThat(p.toString(), endsWith("id[my_id], ")); |
173 | 178 | }
|
174 | 179 |
|
175 | 180 | public void testLevelSetting() {
|
|
0 commit comments