Skip to content

Commit cd98727

Browse files
committed
Included both before and before test
1 parent 536d326 commit cd98727

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import org.elasticsearch.common.settings.Settings;
99
import org.elasticsearch.common.xcontent.support.XContentMapValues;
10+
import org.junit.Before;
11+
import org.junit.BeforeClass;
1012

1113
import java.io.IOException;
1214
import java.util.Map;
@@ -20,6 +22,28 @@
2022
*/
2123
public class SemanticTextEISDefaultIT extends BaseMockEISAuthServerTest {
2224

25+
@Before
26+
public void setUp() throws Exception {
27+
super.setUp();
28+
// Ensure the mock EIS server has an authorized response ready before each test
29+
mockEISServer.enqueueAuthorizeAllModelsResponse();
30+
}
31+
32+
/**
33+
* This is done before the class because I've run into issues where another class that extends {@link BaseMockEISAuthServerTest}
34+
* results in an authorization response not being queued up for the new Elasticsearch Node in time. When the node starts up, it
35+
* retrieves authorization. If the request isn't queued up when that happens the tests will fail. From my testing locally it seems
36+
* like the base class's static functionality to queue a response is only done once and not for each subclass.
37+
*
38+
* My understanding is that the @Before will be run after the node starts up and wouldn't be sufficient to handle
39+
* this scenario. That is why this needs to be @BeforeClass.
40+
*/
41+
@BeforeClass
42+
public static void init() {
43+
// Ensure the mock EIS server has an authorized response ready
44+
mockEISServer.enqueueAuthorizeAllModelsResponse();
45+
}
46+
2347
public void testDefaultInferenceIdForSemanticText() throws IOException {
2448
String indexName = "semantic-index";
2549
String mapping = """

0 commit comments

Comments
 (0)