Skip to content

Commit 333cd31

Browse files
Reverting back the secure testing flag, refactor BWC tests
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
1 parent 040e32e commit 333cd31

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

qa/rolling-upgrade/src/test/java/org/opensearch/neuralsearch/bwc/rolling/AbstractRollingUpgradeTestCase.java

+25
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
import java.nio.file.Path;
99
import java.util.Locale;
1010
import java.util.Optional;
11+
import java.util.Set;
12+
1113
import org.junit.Before;
1214
import org.opensearch.common.settings.Settings;
15+
import org.opensearch.ml.common.model.MLModelState;
1316
import org.opensearch.neuralsearch.BaseNeuralSearchIT;
1417
import static org.opensearch.neuralsearch.util.TestUtils.NEURAL_SEARCH_BWC_PREFIX;
1518
import static org.opensearch.neuralsearch.util.TestUtils.OLD_CLUSTER;
@@ -23,6 +26,8 @@
2326

2427
public abstract class AbstractRollingUpgradeTestCase extends BaseNeuralSearchIT {
2528

29+
private static final Set<MLModelState> READY_FOR_INFERENCE_STATES = Set.of(MLModelState.LOADED, MLModelState.DEPLOYED);
30+
2631
@Before
2732
protected String getIndexNameForTest() {
2833
// Creating index name by concatenating "neural-bwc-" prefix with test method name
@@ -159,4 +164,24 @@ protected void createPipelineForTextChunkingProcessor(String pipelineName) throw
159164
);
160165
createPipelineProcessor(requestBody, pipelineName, "", null);
161166
}
167+
168+
protected boolean isModelReadyForInference(final MLModelState mlModelState) throws Exception {
169+
return READY_FOR_INFERENCE_STATES.contains(mlModelState);
170+
}
171+
172+
protected void waitForModelToLoad(String modelId) throws Exception {
173+
int maxAttempts = 30; // Maximum number of attempts
174+
int waitTimeInSeconds = 2; // Time to wait between attempts
175+
176+
for (int attempt = 0; attempt < maxAttempts; attempt++) {
177+
MLModelState state = getModelState(modelId);
178+
if (isModelReadyForInference(state)) {
179+
logger.info("Model {} is now loaded after {} attempts", modelId, attempt + 1);
180+
return;
181+
}
182+
logger.info("Waiting for model {} to load. Current state: {}. Attempt {}/{}", modelId, state, attempt + 1, maxAttempts);
183+
Thread.sleep(waitTimeInSeconds * 1000);
184+
}
185+
throw new RuntimeException("Model " + modelId + " failed to load after " + maxAttempts + " attempts");
186+
}
162187
}

qa/rolling-upgrade/src/test/java/org/opensearch/neuralsearch/bwc/rolling/BatchIngestionIT.java

-17
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class BatchIngestionIT extends AbstractRollingUpgradeTestCase {
2121
private static final String SPARSE_PIPELINE = "BatchIngestionIT_sparse_pipeline_rolling";
2222
private static final String TEXT_FIELD_NAME = "passage_text";
2323
private static final String EMBEDDING_FIELD_NAME = "passage_embedding";
24-
private static final Set<MLModelState> READY_FOR_INFERENCE_STATES = Set.of(MLModelState.LOADED, MLModelState.DEPLOYED);
2524

2625
public void testBatchIngestion_SparseEncodingProcessor_E2EFlow() throws Exception {
2726
waitForClusterHealthGreen(NODES_BWC_CLUSTER, 90);
@@ -93,20 +92,4 @@ public void testBatchIngestion_SparseEncodingProcessor_E2EFlow() throws Exceptio
9392
throw new IllegalStateException("Unexpected value: " + getClusterType());
9493
}
9594
}
96-
97-
private void waitForModelToLoad(String modelId) throws Exception {
98-
int maxAttempts = 30; // Maximum number of attempts
99-
int waitTimeInSeconds = 2; // Time to wait between attempts
100-
101-
for (int attempt = 0; attempt < maxAttempts; attempt++) {
102-
MLModelState state = getModelState(modelId);
103-
if (READY_FOR_INFERENCE_STATES.contains(state)) {
104-
logger.info("Model {} is now loaded after {} attempts", modelId, attempt + 1);
105-
return;
106-
}
107-
logger.info("Waiting for model {} to load. Current state: {}. Attempt {}/{}", modelId, state, attempt + 1, maxAttempts);
108-
Thread.sleep(waitTimeInSeconds * 1000);
109-
}
110-
throw new RuntimeException("Model " + modelId + " failed to load after " + maxAttempts + " attempts");
111-
}
11295
}

0 commit comments

Comments
 (0)