Skip to content

Commit 56becc5

Browse files
authored
Searchable snapshot upgrade compatibility (elastic#118770)
Added tests for Searchable snapshot upgrade-compatibility
1 parent 9424bd2 commit 56becc5

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.oldrepos.searchablesnapshot;
9+
10+
import org.elasticsearch.test.cluster.util.Version;
11+
12+
public class MountFromVersion5IT extends SearchableSnapshotTestCase {
13+
14+
public MountFromVersion5IT(Version version) {
15+
super(version);
16+
}
17+
18+
public void testSearchableSnapshot() throws Exception {
19+
verifyCompatibility("5");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.oldrepos.searchablesnapshot;
9+
10+
import org.elasticsearch.test.cluster.util.Version;
11+
12+
public class MountFromVersion6IT extends SearchableSnapshotTestCase {
13+
14+
public MountFromVersion6IT(Version version) {
15+
super(version);
16+
}
17+
18+
public void testSearchableSnapshot() throws Exception {
19+
verifyCompatibility("6");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.oldrepos.searchablesnapshot;
9+
10+
import org.elasticsearch.client.Request;
11+
import org.elasticsearch.client.RestClient;
12+
import org.elasticsearch.common.Strings;
13+
import org.elasticsearch.oldrepos.AbstractUpgradeCompatibilityTestCase;
14+
import org.elasticsearch.test.cluster.util.Version;
15+
16+
import static org.elasticsearch.test.rest.ObjectPath.createFromResponse;
17+
18+
/**
19+
* Test suite for Archive indices backward compatibility with N-2 versions.
20+
* The test suite creates a cluster in the N-1 version, where N is the current version.
21+
* Restores snapshots from old-clusters (version 5/6) and upgrades it to the current version.
22+
* Test methods are executed after each upgrade.
23+
*/
24+
public class SearchableSnapshotTestCase extends AbstractUpgradeCompatibilityTestCase {
25+
26+
static {
27+
clusterConfig = config -> config.setting("xpack.license.self_generated.type", "trial");
28+
}
29+
30+
public SearchableSnapshotTestCase(Version version) {
31+
super(version);
32+
}
33+
34+
/**
35+
* Overrides the snapshot-restore operation for archive-indices scenario.
36+
*/
37+
@Override
38+
public void recover(RestClient client, String repository, String snapshot, String index) throws Exception {
39+
var request = new Request("POST", "/_snapshot/" + repository + "/" + snapshot + "/_mount");
40+
request.addParameter("wait_for_completion", "true");
41+
request.addParameter("storage", "full_copy");
42+
request.setJsonEntity(Strings.format("""
43+
{
44+
"index": "%s",
45+
"renamed_index": "%s"
46+
}""", index, index));
47+
createFromResponse(client.performRequest(request));
48+
}
49+
}

0 commit comments

Comments
 (0)