diff --git a/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java b/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java index dceb26bc33aa7..63b994968ce91 100644 --- a/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java @@ -313,19 +313,16 @@ public boolean isThrottled() { @Override public IndexResult index(Index index) { - assert false : "this should not be called"; throw new UnsupportedOperationException("indexing is not supported on a read-only engine"); } @Override public DeleteResult delete(Delete delete) { - assert false : "this should not be called"; throw new UnsupportedOperationException("deletes are not supported on a read-only engine"); } @Override public NoOpResult noOp(NoOp noOp) { - assert false : "this should not be called"; throw new UnsupportedOperationException("no-ops are not supported on a read-only engine"); } diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreService.java b/server/src/main/java/org/opensearch/snapshots/RestoreService.java index 60c01d0b04639..8bf1bfead155e 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreService.java @@ -1227,6 +1227,7 @@ private static IndexMetadata addSnapshotToIndexSettings(IndexMetadata metadata, .put(IndexSettings.SEARCHABLE_SNAPSHOT_ID_UUID.getKey(), snapshot.getSnapshotId().getUUID()) .put(IndexSettings.SEARCHABLE_SNAPSHOT_ID_NAME.getKey(), snapshot.getSnapshotId().getName()) .put(IndexSettings.SEARCHABLE_SNAPSHOT_INDEX_ID.getKey(), indexId.getId()) + .put(IndexMetadata.APIBlock.READ_ONLY_ALLOW_DELETE.settingName(), true) .put(metadata.getSettings()) .build(); return IndexMetadata.builder(metadata).settings(newSettings).build(); diff --git a/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java b/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java index 7a3bd0ef6c302..30638be506861 100644 --- a/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java @@ -33,7 +33,6 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.Version; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; @@ -218,9 +217,7 @@ public void testReadOnly() throws IOException { EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, globalCheckpoint::get); store.createEmpty(Version.CURRENT.luceneVersion); try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null, new TranslogStats(), true, Function.identity(), true)) { - Class expectedException = LuceneTestCase.TEST_ASSERTS_ENABLED - ? AssertionError.class - : UnsupportedOperationException.class; + Class expectedException = UnsupportedOperationException.class; expectThrows(expectedException, () -> readOnlyEngine.index(null)); expectThrows(expectedException, () -> readOnlyEngine.delete(null)); expectThrows(expectedException, () -> readOnlyEngine.noOp(null));