Skip to content

Commit 9628f0f

Browse files
Fix and add new tests
Signed-off-by: Prudhvi Godithi <[email protected]>
1 parent d7dbfa1 commit 9628f0f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

server/src/internalClusterTest/java/org/opensearch/action/admin/indices/scale/searchonly/ScaleIndexIT.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Settings indexSettings() {
5555
* scaling search replicas while in search-only mode, verifying cluster health in
5656
* various states, and then scaling back up to normal mode.
5757
*/
58-
public void testFullSearchOnlyLifecycleWithReplicaScaling() throws Exception {
58+
public void testFullSearchOnlyReplicasFullLifecycle() throws Exception {
5959
internalCluster().startClusterManagerOnlyNode();
6060
internalCluster().startDataOnlyNodes(2);
6161
internalCluster().startSearchOnlyNodes(3);
@@ -94,6 +94,22 @@ public void testFullSearchOnlyLifecycleWithReplicaScaling() throws Exception {
9494
GetSettingsResponse settingsResponse = client().admin().indices().prepareGetSettings(TEST_INDEX).get();
9595
assertTrue(settingsResponse.getSetting(TEST_INDEX, IndexMetadata.INDEX_BLOCKS_SEARCH_ONLY_SETTING.getKey()).equals("true"));
9696

97+
// Verify that write operations are blocked during scale-down
98+
assertBusy(() -> {
99+
try {
100+
// Attempt to index a document while scale-down is in progress
101+
client().prepareIndex(TEST_INDEX)
102+
.setId("sample-write-after-search-only-block")
103+
.setSource("field1", "value1")
104+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
105+
.get();
106+
fail("Write operation should be blocked during scale-down");
107+
} catch (Exception e) {
108+
assertTrue("Exception should indicate index scaled down",
109+
e.getMessage().contains("blocked by: [FORBIDDEN/20/index scaled down]"));
110+
}
111+
}, 10, TimeUnit.SECONDS);
112+
97113
ensureGreen(TEST_INDEX);
98114

99115
// Verify search still works on all search nodes

server/src/test/java/org/opensearch/indices/replication/RemoteStoreReplicationSourceTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void testGetCheckpointMetadataEmpty() throws ExecutionException, Interrup
174174
replicationSource.getCheckpointMetadata(REPLICATION_ID, checkpoint, res3);
175175
ExecutionException exception = assertThrows(ExecutionException.class, () -> res3.get());
176176
assertTrue(exception.getCause() instanceof IllegalStateException);
177-
assertTrue(exception.getCause().getMessage().contains("Remote metadata file can't be null for active regular replica"));
177+
assertTrue(exception.getCause().getMessage().contains("Remote metadata file can't be null if shard is active"));
178178
}
179179

180180
private void buildIndexShardBehavior(IndexShard mockShard, IndexShard indexShard) {

0 commit comments

Comments
 (0)