11
11
import org .apache .http .client .methods .HttpGet ;
12
12
import org .apache .http .client .methods .HttpPost ;
13
13
import org .apache .http .client .methods .HttpPut ;
14
- import org .apache .lucene .util .LuceneTestCase ;
15
14
import org .elasticsearch .Version ;
16
15
import org .elasticsearch .client .Request ;
17
16
import org .elasticsearch .client .Response ;
34
33
import static org .hamcrest .Matchers .equalTo ;
35
34
import static org .hamcrest .Matchers .notNullValue ;
36
35
37
- @ LuceneTestCase .AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/69705" )
38
36
public class SearchableSnapshotsRollingUpgradeIT extends AbstractUpgradeTestCase {
39
37
40
38
public void testMountFullCopyAndRecoversCorrectly () throws Exception {
@@ -56,18 +54,16 @@ public void testMountPartialCopyAndRecoversCorrectly() throws Exception {
56
54
*/
57
55
private void executeMountAndRecoversCorrectlyTestCase (Storage storage , long numberOfDocs ) throws Exception {
58
56
final String suffix = storage .storageName ().toLowerCase (Locale .ROOT );
57
+ final String repository = "repository_" + suffix ;
58
+ final String snapshot = "snapshot_" + suffix ;
59
59
final String index = "mounted_index_" + suffix ;
60
60
61
61
if (CLUSTER_TYPE .equals (ClusterType .OLD )) {
62
- final String repository = "repository_" + suffix ;
63
- final String snapshot = "snapshot_" + suffix ;
64
-
65
- registerRepository (repository , FsRepository .TYPE , true ,
66
- Settings .builder ().put ("location" , System .getProperty ("tests.path.repo" ) + '/' + repository ).build ());
62
+ registerRepository (repository , FsRepository .TYPE , true , repositorySettings (repository ));
67
63
68
64
final String originalIndex = "logs_" + suffix ;
69
65
createIndex (originalIndex , Settings .builder ()
70
- .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (3 , 5 ))
66
+ .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (1 , 3 ))
71
67
.put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , 0 )
72
68
.build ());
73
69
indexDocs (originalIndex , numberOfDocs );
@@ -81,6 +77,12 @@ private void executeMountAndRecoversCorrectlyTestCase(Storage storage, long numb
81
77
82
78
ensureGreen (index );
83
79
assertHitCount (index , equalTo (numberOfDocs ));
80
+
81
+ if (CLUSTER_TYPE .equals (ClusterType .UPGRADED )) {
82
+ deleteIndex (index );
83
+ deleteSnapshot (repository , snapshot );
84
+ deleteRepository (repository );
85
+ }
84
86
}
85
87
86
88
public void testBlobStoreCacheWithFullCopyInMixedVersions () throws Exception {
@@ -107,8 +109,7 @@ private void executeBlobCacheCreationTestCase(Storage storage, long numberOfDocs
107
109
final String repository = "repository_" + suffix ;
108
110
109
111
if (CLUSTER_TYPE .equals (ClusterType .OLD )) {
110
- registerRepository (repository , FsRepository .TYPE , true ,
111
- Settings .builder ().put ("location" , System .getProperty ("tests.path.repo" ) + '/' + repository ).build ());
112
+ registerRepository (repository , FsRepository .TYPE , true , repositorySettings (repository ));
112
113
113
114
} else if (CLUSTER_TYPE .equals (ClusterType .MIXED )) {
114
115
final int numberOfNodes = 3 ;
@@ -135,7 +136,7 @@ private void executeBlobCacheCreationTestCase(Storage storage, long numberOfDocs
135
136
136
137
final String firstIndex = "first_index_" + suffix ;
137
138
createIndex (firstIndex , Settings .builder ()
138
- .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (3 , 5 ))
139
+ .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (1 , 3 ))
139
140
.put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , 0 )
140
141
.build ());
141
142
indexDocs (firstIndex , numberOfDocs );
@@ -287,8 +288,11 @@ private static void mountSnapshot(
287
288
Settings indexSettings
288
289
) throws IOException {
289
290
final Request request = new Request (HttpPost .METHOD_NAME , "/_snapshot/" + repositoryName + '/' + snapshotName + "/_mount" );
290
- request .addParameter ("storage" , storage .storageName ());
291
- request .addParameter ("wait_for_completion" , "true" );
291
+ if (UPGRADE_FROM_VERSION .onOrAfter (Version .V_7_12_0 )) {
292
+ request .addParameter ("storage" , storage .storageName ());
293
+ } else {
294
+ assertThat ("Parameter 'storage' was introduced in 7.12.0 with " + Storage .SHARED_CACHE , storage , equalTo (Storage .FULL_COPY ));
295
+ }
292
296
request .setJsonEntity ("{" +
293
297
" \" index\" : \" " + indexName + "\" ," +
294
298
" \" renamed_index\" : \" " + renamedIndex + "\" ," +
@@ -311,4 +315,12 @@ private static void assertHitCount(String indexName, Matcher<Long> countMatcher)
311
315
assertThat (((Number ) extractValue ("count" , responseAsMap )).longValue (), countMatcher );
312
316
assertThat (((Number ) extractValue ("_shards.failed" , responseAsMap )).intValue (), equalTo (0 ));
313
317
}
318
+
319
+ private static Settings repositorySettings (String repository ) {
320
+ final String pathRepo = System .getProperty ("tests.path.searchable.snapshots.repo" );
321
+ assertThat ("Searchable snapshots repository path is null" , pathRepo , notNullValue ());
322
+ return Settings .builder ()
323
+ .put ("location" , pathRepo + '/' + repository )
324
+ .build ();
325
+ }
314
326
}
0 commit comments