Skip to content

Commit 4bc6bb0

Browse files
Fix bug in InferenceUpgradeTestCase.getConfigsWithBreakingChangeHandling (#118624) (#118664)
We need to load the two fields from the same response. Otherwise, we can have a sort of race where we load "endpoints" from pre-8.15 as empty and then load "models" from a post-8.15 node also empty, resulting in an empty list because we took the wrong info from either response. closes #118163 Co-authored-by: Max Hniebergall <[email protected]>
1 parent 7abbaf0 commit 4bc6bb0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.LinkedList;
2020
import java.util.List;
2121
import java.util.Map;
22-
import java.util.Objects;
2322

2423
import static org.elasticsearch.core.Strings.format;
2524

@@ -112,13 +111,10 @@ protected void put(String inferenceId, String modelConfig, TaskType taskType) th
112111
@SuppressWarnings("unchecked")
113112
// in version 8.15, there was a breaking change where "models" was renamed to "endpoints"
114113
LinkedList<Map<String, Object>> getConfigsWithBreakingChangeHandling(TaskType testTaskType, String oldClusterId) throws IOException {
115-
114+
var response = get(testTaskType, oldClusterId);
116115
LinkedList<Map<String, Object>> configs;
117-
configs = new LinkedList<>(
118-
(List<Map<String, Object>>) Objects.requireNonNullElse((get(testTaskType, oldClusterId).get("endpoints")), List.of())
119-
);
120-
configs.addAll(Objects.requireNonNullElse((List<Map<String, Object>>) get(testTaskType, oldClusterId).get("models"), List.of()));
121-
116+
configs = new LinkedList<>((List<Map<String, Object>>) response.getOrDefault("endpoints", List.of()));
117+
configs.addAll((List<Map<String, Object>>) response.getOrDefault("models", List.of()));
122118
return configs;
123119
}
124120
}

0 commit comments

Comments
 (0)