Skip to content

Commit 9fdfc79

Browse files
authored
Simplify test class hierarchy in old-repository-versions-compatibility (#119670)
The test method does not need to be repeated in every test class, and the two base test classes can be abstract. Meanwhile I also corrected javadocs on DocValueOnlyFieldsIT that were outdated.
1 parent 17353fa commit 9fdfc79

File tree

8 files changed

+18
-28
lines changed

8 files changed

+18
-28
lines changed

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/AbstractUpgradeCompatibilityTestCase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ public abstract class AbstractUpgradeCompatibilityTestCase extends ESRestTestCas
7373
private static boolean upgradeFailed = false;
7474

7575
private final Version clusterVersion;
76+
private final String indexCreatedVersion;
7677

77-
public AbstractUpgradeCompatibilityTestCase(@Name("cluster") Version clusterVersion) {
78+
public AbstractUpgradeCompatibilityTestCase(@Name("cluster") Version clusterVersion, String indexCreatedVersion) {
7879
this.clusterVersion = clusterVersion;
80+
this.indexCreatedVersion = indexCreatedVersion;
7981
}
8082

8183
@ParametersFactory
@@ -208,4 +210,8 @@ private static void unzip(Path zipFilePath, Path outputDir) throws IOException {
208210
}
209211
}
210212
}
213+
214+
public final void testArchiveIndex() throws Exception {
215+
verifyCompatibility(indexCreatedVersion);
216+
}
211217
}

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/archiveindex/ArchiveIndexTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
* when deployed ES version 5/6. The cluster then upgrades to version 9, verifying that the archive index
2626
* is successfully restored.
2727
*/
28-
public class ArchiveIndexTestCase extends AbstractUpgradeCompatibilityTestCase {
28+
abstract class ArchiveIndexTestCase extends AbstractUpgradeCompatibilityTestCase {
2929

3030
static {
3131
clusterConfig = config -> config.setting("xpack.license.self_generated.type", "trial");
3232
}
3333

34-
public ArchiveIndexTestCase(Version version) {
35-
super(version);
34+
protected ArchiveIndexTestCase(Version version, String indexCreatedVersion) {
35+
super(version, indexCreatedVersion);
3636
}
3737

3838
/**

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/archiveindex/RestoreFromVersion5IT.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
public class RestoreFromVersion5IT extends ArchiveIndexTestCase {
1313

1414
public RestoreFromVersion5IT(Version version) {
15-
super(version);
16-
}
17-
18-
public void testArchiveIndex() throws Exception {
19-
verifyCompatibility("5");
15+
super(version, "5");
2016
}
2117
}

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/archiveindex/RestoreFromVersion6IT.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
public class RestoreFromVersion6IT extends ArchiveIndexTestCase {
1313

1414
public RestoreFromVersion6IT(Version version) {
15-
super(version);
16-
}
17-
18-
public void testArchiveIndex() throws Exception {
19-
verifyCompatibility("6");
15+
super(version, "6");
2016
}
2117
}

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/searchablesnapshot/MountFromVersion5IT.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
public class MountFromVersion5IT extends SearchableSnapshotTestCase {
1313

1414
public MountFromVersion5IT(Version version) {
15-
super(version);
16-
}
17-
18-
public void testSearchableSnapshot() throws Exception {
19-
verifyCompatibility("5");
15+
super(version, "5");
2016
}
2117
}

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/searchablesnapshot/MountFromVersion6IT.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
public class MountFromVersion6IT extends SearchableSnapshotTestCase {
1313

1414
public MountFromVersion6IT(Version version) {
15-
super(version);
16-
}
17-
18-
public void testSearchableSnapshot() throws Exception {
19-
verifyCompatibility("6");
15+
super(version, "6");
2016
}
2117
}

x-pack/qa/repository-old-versions-compatibility/src/javaRestTest/java/org/elasticsearch/oldrepos/searchablesnapshot/SearchableSnapshotTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
* Restores snapshots from old-clusters (version 5/6) and upgrades it to the current version.
2222
* Test methods are executed after each upgrade.
2323
*/
24-
public class SearchableSnapshotTestCase extends AbstractUpgradeCompatibilityTestCase {
24+
abstract class SearchableSnapshotTestCase extends AbstractUpgradeCompatibilityTestCase {
2525

2626
static {
2727
clusterConfig = config -> config.setting("xpack.license.self_generated.type", "trial");
2828
}
2929

30-
public SearchableSnapshotTestCase(Version version) {
31-
super(version);
30+
protected SearchableSnapshotTestCase(Version version, String indexCreatedVersion) {
31+
super(version, indexCreatedVersion);
3232
}
3333

3434
/**

x-pack/qa/repository-old-versions/src/test/java/org/elasticsearch/oldrepos/DocValueOnlyFieldsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.io.IOException;
3131

3232
/**
33-
* Tests doc-value-based searches against indices imported from clusters older than N-1.
33+
* Tests doc-value-based searches against archive indices, imported from clusters older than N-2.
3434
* We reuse the YAML tests in search/390_doc_values_search.yml but have to do the setup
3535
* manually here as the setup is done on the old cluster for which we have to use the
3636
* low-level REST client instead of the YAML set up that only knows how to talk to

0 commit comments

Comments
 (0)