Skip to content

Commit 543e9ba

Browse files
authored
[ML] Add debug logging for tests failing with empty model download (#116263)
1 parent ea441a5 commit 543e9ba

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ tests:
118118
- class: org.elasticsearch.xpack.remotecluster.RemoteClusterSecurityWithApmTracingRestIT
119119
method: testTracingCrossCluster
120120
issue: https://github.com/elastic/elasticsearch/issues/112731
121-
- class: org.elasticsearch.xpack.inference.DefaultEndPointsIT
122-
method: testInferDeploysDefaultElser
123-
issue: https://github.com/elastic/elasticsearch/issues/114913
124121
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
125122
method: test {p0=esql/60_usage/Basic ESQL usage output (telemetry)}
126123
issue: https://github.com/elastic/elasticsearch/issues/115231

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/DefaultEndPointsIT.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.inference;
99

10+
import org.elasticsearch.client.Request;
1011
import org.elasticsearch.inference.TaskType;
1112
import org.elasticsearch.threadpool.TestThreadPool;
1213
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService;
@@ -27,8 +28,15 @@ public class DefaultEndPointsIT extends InferenceBaseRestTest {
2728
private TestThreadPool threadPool;
2829

2930
@Before
30-
public void createThreadPool() {
31+
public void setupTest() throws IOException {
3132
threadPool = new TestThreadPool(DefaultEndPointsIT.class.getSimpleName());
33+
34+
Request loggingSettings = new Request("PUT", "_cluster/settings");
35+
loggingSettings.setJsonEntity("""
36+
{"persistent" : {
37+
"logger.org.elasticsearch.xpack.ml.packageloader" : "DEBUG"
38+
}}""");
39+
client().performRequest(loggingSettings);
3240
}
3341

3442
@After
@@ -64,7 +72,7 @@ private static void assertDefaultElserConfig(Map<String, Object> modelConfig) {
6472
assertThat(
6573
modelConfig.toString(),
6674
adaptiveAllocations,
67-
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 8))
75+
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 32))
6876
);
6977
}
7078

@@ -99,7 +107,7 @@ private static void assertDefaultE5Config(Map<String, Object> modelConfig) {
99107
assertThat(
100108
modelConfig.toString(),
101109
adaptiveAllocations,
102-
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 8))
110+
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 32))
103111
);
104112
}
105113
}

x-pack/plugin/ml-package-loader/src/main/java/org/elasticsearch/xpack/ml/packageloader/action/ModelLoaderUtils.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package org.elasticsearch.xpack.ml.packageloader.action;
99

10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
1012
import org.elasticsearch.ElasticsearchException;
1113
import org.elasticsearch.ElasticsearchStatusException;
1214
import org.elasticsearch.ResourceNotFoundException;
@@ -56,10 +58,12 @@
5658
*/
5759
final class ModelLoaderUtils {
5860

61+
private static final Logger logger = LogManager.getLogger(ModelLoaderUtils.class);
62+
5963
public static String METADATA_FILE_EXTENSION = ".metadata.json";
6064
public static String MODEL_FILE_EXTENSION = ".pt";
6165

62-
private static ByteSizeValue VOCABULARY_SIZE_LIMIT = new ByteSizeValue(20, ByteSizeUnit.MB);
66+
private static final ByteSizeValue VOCABULARY_SIZE_LIMIT = new ByteSizeValue(20, ByteSizeUnit.MB);
6367
private static final String VOCABULARY = "vocabulary";
6468
private static final String MERGES = "merges";
6569
private static final String SCORES = "scores";
@@ -83,6 +87,7 @@ record BytesAndPartIndex(BytesArray bytes, int partIndex) {}
8387
private final AtomicInteger currentPart;
8488
private final int lastPartNumber;
8589
private final byte[] buf;
90+
private final RequestRange range; // TODO debug only
8691

8792
HttpStreamChunker(URI uri, RequestRange range, int chunkSize) {
8893
var inputStream = getHttpOrHttpsInputStream(uri, range);
@@ -91,6 +96,7 @@ record BytesAndPartIndex(BytesArray bytes, int partIndex) {}
9196
this.lastPartNumber = range.startPart() + range.numParts();
9297
this.currentPart = new AtomicInteger(range.startPart());
9398
this.buf = new byte[chunkSize];
99+
this.range = range;
94100
}
95101

96102
// This ctor exists for testing purposes only.
@@ -100,6 +106,7 @@ record BytesAndPartIndex(BytesArray bytes, int partIndex) {}
100106
this.lastPartNumber = range.startPart() + range.numParts();
101107
this.currentPart = new AtomicInteger(range.startPart());
102108
this.buf = new byte[chunkSize];
109+
this.range = range;
103110
}
104111

105112
public boolean hasNext() {
@@ -113,6 +120,7 @@ public BytesAndPartIndex next() throws IOException {
113120
int read = inputStream.read(buf, bytesRead, chunkSize - bytesRead);
114121
// EOF??
115122
if (read == -1) {
123+
logger.debug("end of stream, " + bytesRead + " bytes read");
116124
break;
117125
}
118126
bytesRead += read;
@@ -122,6 +130,7 @@ public BytesAndPartIndex next() throws IOException {
122130
totalBytesRead.addAndGet(bytesRead);
123131
return new BytesAndPartIndex(new BytesArray(buf, 0, bytesRead), currentPart.getAndIncrement());
124132
} else {
133+
logger.warn("Empty part in range " + range + ", current part=" + currentPart.get() + ", last part=" + lastPartNumber);
125134
return new BytesAndPartIndex(BytesArray.EMPTY, currentPart.get());
126135
}
127136
}

0 commit comments

Comments
 (0)