Skip to content

Commit

Permalink
Simplify test class hierarchy in old-repository-versions-compatibility (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
javanna authored Jan 8, 2025
1 parent 17353fa commit 9fdfc79
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ public abstract class AbstractUpgradeCompatibilityTestCase extends ESRestTestCas
private static boolean upgradeFailed = false;

private final Version clusterVersion;
private final String indexCreatedVersion;

public AbstractUpgradeCompatibilityTestCase(@Name("cluster") Version clusterVersion) {
public AbstractUpgradeCompatibilityTestCase(@Name("cluster") Version clusterVersion, String indexCreatedVersion) {
this.clusterVersion = clusterVersion;
this.indexCreatedVersion = indexCreatedVersion;
}

@ParametersFactory
Expand Down Expand Up @@ -208,4 +210,8 @@ private static void unzip(Path zipFilePath, Path outputDir) throws IOException {
}
}
}

public final void testArchiveIndex() throws Exception {
verifyCompatibility(indexCreatedVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
* when deployed ES version 5/6. The cluster then upgrades to version 9, verifying that the archive index
* is successfully restored.
*/
public class ArchiveIndexTestCase extends AbstractUpgradeCompatibilityTestCase {
abstract class ArchiveIndexTestCase extends AbstractUpgradeCompatibilityTestCase {

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

public ArchiveIndexTestCase(Version version) {
super(version);
protected ArchiveIndexTestCase(Version version, String indexCreatedVersion) {
super(version, indexCreatedVersion);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
public class RestoreFromVersion5IT extends ArchiveIndexTestCase {

public RestoreFromVersion5IT(Version version) {
super(version);
}

public void testArchiveIndex() throws Exception {
verifyCompatibility("5");
super(version, "5");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
public class RestoreFromVersion6IT extends ArchiveIndexTestCase {

public RestoreFromVersion6IT(Version version) {
super(version);
}

public void testArchiveIndex() throws Exception {
verifyCompatibility("6");
super(version, "6");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
public class MountFromVersion5IT extends SearchableSnapshotTestCase {

public MountFromVersion5IT(Version version) {
super(version);
}

public void testSearchableSnapshot() throws Exception {
verifyCompatibility("5");
super(version, "5");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
public class MountFromVersion6IT extends SearchableSnapshotTestCase {

public MountFromVersion6IT(Version version) {
super(version);
}

public void testSearchableSnapshot() throws Exception {
verifyCompatibility("6");
super(version, "6");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* Restores snapshots from old-clusters (version 5/6) and upgrades it to the current version.
* Test methods are executed after each upgrade.
*/
public class SearchableSnapshotTestCase extends AbstractUpgradeCompatibilityTestCase {
abstract class SearchableSnapshotTestCase extends AbstractUpgradeCompatibilityTestCase {

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

public SearchableSnapshotTestCase(Version version) {
super(version);
protected SearchableSnapshotTestCase(Version version, String indexCreatedVersion) {
super(version, indexCreatedVersion);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.io.IOException;

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

0 comments on commit 9fdfc79

Please sign in to comment.