@@ -85,11 +85,20 @@ public void testValidation() throws IOException {
8585 Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , null ));
8686 assertThat (e .getMessage (), equalTo ("leader index [leader_cluster:index1] does not have soft deletes enabled" ));
8787 }
88+ {
89+ // should fail because the follower index does not have soft deletes enabled
90+ IndexMetaData leaderIMD = createIMD ("index1" , 5 , Settings .builder ()
91+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
92+ IndexMetaData followIMD = createIMD ("index2" , 5 , Settings .EMPTY , customMetaData );
93+ Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , null ));
94+ assertThat (e .getMessage (), equalTo ("follower index [index2] does not have soft deletes enabled" ));
95+ }
8896 {
8997 // should fail because the number of primary shards between leader and follow index are not equal
9098 IndexMetaData leaderIMD = createIMD ("index1" , 5 , Settings .builder ()
9199 .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
92- IndexMetaData followIMD = createIMD ("index2" , 4 , Settings .EMPTY , customMetaData );
100+ IndexMetaData followIMD = createIMD ("index2" , 4 ,
101+ Settings .builder ().put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), customMetaData );
93102 Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , null ));
94103 assertThat (e .getMessage (),
95104 equalTo ("leader index primary shards [5] does not match with the number of shards of the follow index [4]" ));
@@ -98,16 +107,17 @@ public void testValidation() throws IOException {
98107 // should fail, because leader index is closed
99108 IndexMetaData leaderIMD = createIMD ("index1" , State .CLOSE , "{}" , 5 , Settings .builder ()
100109 .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
101- IndexMetaData followIMD = createIMD ("index2" , State .OPEN , "{}" , 5 , Settings . builder ()
102- .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), customMetaData );
110+ IndexMetaData followIMD = createIMD ("index2" , State .OPEN , "{}" , 5 ,
111+ Settings . builder () .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), customMetaData );
103112 Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , null ));
104113 assertThat (e .getMessage (), equalTo ("leader and follow index must be open" ));
105114 }
106115 {
107116 // should fail, because index.xpack.ccr.following_index setting has not been enabled in leader index
108117 IndexMetaData leaderIMD = createIMD ("index1" , 1 ,
109118 Settings .builder ().put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
110- IndexMetaData followIMD = createIMD ("index2" , 1 , Settings .EMPTY , customMetaData );
119+ IndexMetaData followIMD = createIMD ("index2" , 1 ,
120+ Settings .builder ().put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), customMetaData );
111121 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (), Settings .EMPTY , "index2" );
112122 mapperService .updateMapping (null , followIMD );
113123 Exception e = expectThrows (IllegalArgumentException .class ,
@@ -120,7 +130,8 @@ public void testValidation() throws IOException {
120130 IndexMetaData leaderIMD = createIMD ("index1" , State .OPEN , "{\" properties\" : {\" field\" : {\" type\" : \" keyword\" }}}" , 5 ,
121131 Settings .builder ().put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
122132 IndexMetaData followIMD = createIMD ("index2" , State .OPEN , "{\" properties\" : {\" field\" : {\" type\" : \" text\" }}}" , 5 ,
123- Settings .builder ().put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true ).build (), customMetaData );
133+ Settings .builder ().put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true )
134+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true ).build (), customMetaData );
124135 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (), Settings .EMPTY , "index2" );
125136 mapperService .updateMapping (null , followIMD );
126137 Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , mapperService ));
@@ -135,6 +146,7 @@ public void testValidation() throws IOException {
135146 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "whitespace" ).build (), null );
136147 IndexMetaData followIMD = createIMD ("index2" , State .OPEN , mapping , 5 , Settings .builder ()
137148 .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true )
149+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true )
138150 .put ("index.analysis.analyzer.my_analyzer.type" , "custom" )
139151 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "standard" ).build (), customMetaData );
140152 Exception e = expectThrows (IllegalArgumentException .class , () -> validate (request , leaderIMD , followIMD , UUIDs , null ));
@@ -144,8 +156,8 @@ public void testValidation() throws IOException {
144156 // should fail because the following index does not have the following_index settings
145157 IndexMetaData leaderIMD = createIMD ("index1" , 5 ,
146158 Settings .builder ().put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
147- Settings followingIndexSettings = randomBoolean () ? Settings . EMPTY :
148- Settings . builder () .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), false ).build ();
159+ Settings followingIndexSettings = Settings . builder (). put ( IndexSettings . INDEX_SOFT_DELETES_SETTING . getKey (), true )
160+ .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), false ).build ();
149161 IndexMetaData followIMD = createIMD ("index2" , 5 , followingIndexSettings , customMetaData );
150162 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (),
151163 followingIndexSettings , "index2" );
@@ -160,6 +172,7 @@ public void testValidation() throws IOException {
160172 IndexMetaData leaderIMD = createIMD ("index1" , 5 , Settings .builder ()
161173 .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ).build (), null );
162174 IndexMetaData followIMD = createIMD ("index2" , 5 , Settings .builder ()
175+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true )
163176 .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true ).build (), customMetaData );
164177 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (), Settings .EMPTY , "index2" );
165178 mapperService .updateMapping (null , followIMD );
@@ -174,6 +187,7 @@ public void testValidation() throws IOException {
174187 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "standard" ).build (), null );
175188 IndexMetaData followIMD = createIMD ("index2" , State .OPEN , mapping , 5 , Settings .builder ()
176189 .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true )
190+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true )
177191 .put ("index.analysis.analyzer.my_analyzer.type" , "custom" )
178192 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "standard" ).build (), customMetaData );
179193 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (),
@@ -191,6 +205,7 @@ public void testValidation() throws IOException {
191205 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "standard" ).build (), null );
192206 IndexMetaData followIMD = createIMD ("index2" , State .OPEN , mapping , 5 , Settings .builder ()
193207 .put (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), true )
208+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true )
194209 .put (IndexSettings .INDEX_REFRESH_INTERVAL_SETTING .getKey (), "10s" )
195210 .put ("index.analysis.analyzer.my_analyzer.type" , "custom" )
196211 .put ("index.analysis.analyzer.my_analyzer.tokenizer" , "standard" ).build (), customMetaData );
0 commit comments