From 8e5372a4fee9fa265083d115c6e023e0de4b70f0 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 30 Dec 2024 11:47:56 -0500 Subject: [PATCH 1/3] Fix NPE by getting request once and defaulting to empty list --- .../xpack/application/OpenAiServiceUpgradeIT.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java index 7b43a5b86e619..0af485722a733 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java @@ -16,6 +16,8 @@ import org.junit.BeforeClass; import java.io.IOException; +import java.util.Collection; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -139,9 +141,11 @@ public void testOpenAiCompletions() throws IOException { assertCompletionInference(oldClusterId); } else if (isMixedCluster()) { - var configs = (List>) get(testTaskType, oldClusterId).get("endpoints"); + List> configs = new LinkedList<>(); + var request = get(testTaskType, oldClusterId); + configs.addAll((Collection>) request.getOrDefault("endpoints", List.of())); if (oldClusterHasFeature("gte_v" + MODELS_RENAMED_TO_ENDPOINTS) == false) { - configs.addAll((List>) get(testTaskType, oldClusterId).get(old_cluster_endpoint_identifier)); + configs.addAll((List>) request.getOrDefault(old_cluster_endpoint_identifier, List.of())); // in version 8.15, there was a breaking change where "models" was renamed to "endpoints" } assertEquals("openai", configs.get(0).get("service")); From cc0de43d2803a60ad814efab52473df576484351 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 30 Dec 2024 12:18:47 -0500 Subject: [PATCH 2/3] Fix error in OpenAIUpgrade test which used the wrong field name for certain versions --- .../xpack/application/OpenAiServiceUpgradeIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java index 0af485722a733..ed0adfa8f50cc 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java @@ -85,8 +85,9 @@ public void testOpenAiEmbeddings() throws IOException { assertEquals("openai", configs.get(0).get("service")); var serviceSettings = (Map) configs.get(0).get("service_settings"); var taskSettings = (Map) configs.get(0).get("task_settings"); - var modelIdFound = serviceSettings.containsKey("model_id") || taskSettings.containsKey("model_id"); - assertTrue("model_id not found in config: " + configs.toString(), modelIdFound); + var modelIdFound = serviceSettings.containsKey("model_id") || (taskSettings.containsKey("model") && + getOldClusterTestVersion().onOrBefore(OPEN_AI_EMBEDDINGS_MODEL_SETTING_MOVED)); + assertTrue("model_id not found in config: " + configs, modelIdFound); assertEmbeddingInference(oldClusterId); } else if (isUpgradedCluster()) { From 12116c1c19bb49a4c69fd6c4e5af2ecc451179fb Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Mon, 30 Dec 2024 17:29:33 +0000 Subject: [PATCH 3/3] [CI] Auto commit changes from spotless --- .../xpack/application/OpenAiServiceUpgradeIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java index ed0adfa8f50cc..b6dcfcb84a77f 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java @@ -85,8 +85,8 @@ public void testOpenAiEmbeddings() throws IOException { assertEquals("openai", configs.get(0).get("service")); var serviceSettings = (Map) configs.get(0).get("service_settings"); var taskSettings = (Map) configs.get(0).get("task_settings"); - var modelIdFound = serviceSettings.containsKey("model_id") || (taskSettings.containsKey("model") && - getOldClusterTestVersion().onOrBefore(OPEN_AI_EMBEDDINGS_MODEL_SETTING_MOVED)); + var modelIdFound = serviceSettings.containsKey("model_id") + || (taskSettings.containsKey("model") && getOldClusterTestVersion().onOrBefore(OPEN_AI_EMBEDDINGS_MODEL_SETTING_MOVED)); assertTrue("model_id not found in config: " + configs, modelIdFound); assertEmbeddingInference(oldClusterId);