@@ -1084,6 +1084,55 @@ public void testConcurrentGetAndFlush() throws Exception {
1084
1084
latestGetResult .get ().close ();
1085
1085
}
1086
1086
1087
+ public void testUpdateOperationForAppendOnlyIndex () throws Exception {
1088
+ Settings .Builder settings = Settings .builder ()
1089
+ .put (defaultSettings .getSettings ())
1090
+ .put (IndexMetadata .INDEX_APPEND_ONLY_ENABLED_SETTING .getKey (), "true" );
1091
+ final IndexMetadata indexMetadata = IndexMetadata .builder (defaultSettings .getIndexMetadata ()).settings (settings ).build ();
1092
+ final IndexSettings indexSettings = IndexSettingsModule .newIndexSettings (indexMetadata );
1093
+ final AtomicLong globalCheckpoint = new AtomicLong (SequenceNumbers .NO_OPS_PERFORMED );
1094
+ try (
1095
+ Store store = createStore ();
1096
+ InternalEngine engine = createUpdateOnlyEngine (
1097
+ config (indexSettings , store , createTempDir (), newMergePolicy (), null , null , globalCheckpoint ::get )
1098
+ )
1099
+ ) {
1100
+ engine .refresh ("warm_up" );
1101
+ Engine .Searcher searchResult = engine .acquireSearcher ("test" );
1102
+ searchResult .close ();
1103
+
1104
+ final BiFunction <String , Engine .SearcherScope , Engine .Searcher > searcherFactory = engine ::acquireSearcher ;
1105
+
1106
+ // create a document
1107
+ Document document = testDocumentWithTextField ();
1108
+ document .add (new Field (SourceFieldMapper .NAME , BytesReference .toBytes (B_1 ), SourceFieldMapper .Defaults .FIELD_TYPE ));
1109
+ ParsedDocument doc = testParsedDocument ("1" , null , document , B_1 , null );
1110
+ expectThrows (AlreadyClosedException .class , () -> engine .index (indexForDoc (doc )));
1111
+ }
1112
+ }
1113
+
1114
+ private InternalEngine createUpdateOnlyEngine (EngineConfig config ) throws IOException {
1115
+ final Store store = config .getStore ();
1116
+ final Directory directory = store .directory ();
1117
+ if (Lucene .indexExists (directory ) == false ) {
1118
+ store .createEmpty (config .getIndexSettings ().getIndexVersionCreated ().luceneVersion );
1119
+ final String translogUuid = Translog .createEmptyTranslog (
1120
+ config .getTranslogConfig ().getTranslogPath (),
1121
+ SequenceNumbers .NO_OPS_PERFORMED ,
1122
+ shardId ,
1123
+ primaryTerm .get ()
1124
+ );
1125
+ store .associateIndexWithNewTranslog (translogUuid );
1126
+ }
1127
+
1128
+ return new InternalEngine (config ) {
1129
+ @ Override
1130
+ protected IndexingStrategy indexingStrategyForOperation (Index index ) throws IOException {
1131
+ return IndexingStrategy .processNormally (false , 0 , 0 );
1132
+ }
1133
+ };
1134
+ }
1135
+
1087
1136
public void testSimpleOperations () throws Exception {
1088
1137
engine .refresh ("warm_up" );
1089
1138
Engine .Searcher searchResult = engine .acquireSearcher ("test" );
0 commit comments