Skip to content

Commit 3fea8a5

Browse files
committed
Test: Remove leftover static bwc test case (#26584)
This test case was leftover from the static bwc tests. There was still one use for checking we do not load old indices, but this PR moves the legacy code needed for that directly into the test. I also opened a follow up issue to completely remove the unsupported test: #26583.
1 parent 3ea9f07 commit 3fea8a5

File tree

3 files changed

+60
-100
lines changed

3 files changed

+60
-100
lines changed

core/src/test/java/org/elasticsearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,70 @@
1818
*/
1919
package org.elasticsearch.bwcompat;
2020

21+
import java.io.IOException;
22+
import java.io.InputStream;
23+
import java.nio.file.DirectoryStream;
24+
import java.nio.file.Files;
25+
import java.nio.file.Path;
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import org.apache.lucene.util.LuceneTestCase;
30+
import org.apache.lucene.util.TestUtil;
2131
import org.elasticsearch.common.settings.Settings;
32+
import org.elasticsearch.env.Environment;
33+
import org.elasticsearch.env.NodeEnvironment;
34+
import org.elasticsearch.test.ESIntegTestCase;
2235

2336
import static org.hamcrest.Matchers.containsString;
2437

25-
public class RecoveryWithUnsupportedIndicesIT extends StaticIndexBackwardCompatibilityIT {
38+
@LuceneTestCase.SuppressCodecs("*")
39+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, minNumDataNodes = 0, maxNumDataNodes = 0)
40+
public class RecoveryWithUnsupportedIndicesIT extends ESIntegTestCase {
41+
42+
/**
43+
* Return settings that could be used to start a node that has the given zipped home directory.
44+
*/
45+
protected Settings prepareBackwardsDataDir(Path backwardsIndex, Object... settings) throws IOException {
46+
Path indexDir = createTempDir();
47+
Path dataDir = indexDir.resolve("data");
48+
try (InputStream stream = Files.newInputStream(backwardsIndex)) {
49+
TestUtil.unzip(stream, indexDir);
50+
}
51+
assertTrue(Files.exists(dataDir));
52+
53+
// list clusters in the datapath, ignoring anything from extrasfs
54+
final Path[] list;
55+
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dataDir)) {
56+
List<Path> dirs = new ArrayList<>();
57+
for (Path p : stream) {
58+
if (!p.getFileName().toString().startsWith("extra")) {
59+
dirs.add(p);
60+
}
61+
}
62+
list = dirs.toArray(new Path[0]);
63+
}
64+
65+
if (list.length != 1) {
66+
StringBuilder builder = new StringBuilder("Backwards index must contain exactly one cluster\n");
67+
for (Path line : list) {
68+
builder.append(line.toString()).append('\n');
69+
}
70+
throw new IllegalStateException(builder.toString());
71+
}
72+
Path src = list[0].resolve(NodeEnvironment.NODES_FOLDER);
73+
Path dest = dataDir.resolve(NodeEnvironment.NODES_FOLDER);
74+
assertTrue(Files.exists(src));
75+
Files.move(src, dest);
76+
assertFalse(Files.exists(src));
77+
assertTrue(Files.exists(dest));
78+
Settings.Builder builder = Settings.builder()
79+
.put(settings)
80+
.put(Environment.PATH_DATA_SETTING.getKey(), dataDir.toAbsolutePath());
81+
82+
return builder.build();
83+
}
84+
2685
public void testUpgradeStartClusterOn_0_20_6() throws Exception {
2786
String indexName = "unsupported-0.20.6";
2887

core/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityIT.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.lucene.search.Sort;
2828
import org.apache.lucene.util.IOUtils;
2929
import org.apache.lucene.util.LuceneTestCase;
30-
import org.apache.lucene.util.TestUtil;
3130
import org.elasticsearch.ElasticsearchException;
3231
import org.elasticsearch.ExceptionsHelper;
3332
import org.elasticsearch.action.ActionListener;
@@ -143,7 +142,6 @@
143142
import org.junit.BeforeClass;
144143

145144
import java.io.IOException;
146-
import java.io.InputStream;
147145
import java.lang.annotation.Annotation;
148146
import java.lang.annotation.ElementType;
149147
import java.lang.annotation.Inherited;
@@ -153,7 +151,6 @@
153151
import java.net.InetAddress;
154152
import java.net.InetSocketAddress;
155153
import java.net.URL;
156-
import java.nio.file.DirectoryStream;
157154
import java.nio.file.Files;
158155
import java.nio.file.Path;
159156
import java.util.ArrayList;
@@ -2115,48 +2112,7 @@ protected String routingKeyForShard(String index, int shard) {
21152112
return internalCluster().routingKeyForShard(resolveIndex(index), shard, random());
21162113
}
21172114

2118-
/**
2119-
* Return settings that could be used to start a node that has the given zipped home directory.
2120-
*/
2121-
protected Settings prepareBackwardsDataDir(Path backwardsIndex, Object... settings) throws IOException {
2122-
Path indexDir = createTempDir();
2123-
Path dataDir = indexDir.resolve("data");
2124-
try (InputStream stream = Files.newInputStream(backwardsIndex)) {
2125-
TestUtil.unzip(stream, indexDir);
2126-
}
2127-
assertTrue(Files.exists(dataDir));
2128-
2129-
// list clusters in the datapath, ignoring anything from extrasfs
2130-
final Path[] list;
2131-
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dataDir)) {
2132-
List<Path> dirs = new ArrayList<>();
2133-
for (Path p : stream) {
2134-
if (!p.getFileName().toString().startsWith("extra")) {
2135-
dirs.add(p);
2136-
}
2137-
}
2138-
list = dirs.toArray(new Path[0]);
2139-
}
2140-
2141-
if (list.length != 1) {
2142-
StringBuilder builder = new StringBuilder("Backwards index must contain exactly one cluster\n");
2143-
for (Path line : list) {
2144-
builder.append(line.toString()).append('\n');
2145-
}
2146-
throw new IllegalStateException(builder.toString());
2147-
}
2148-
Path src = list[0].resolve(NodeEnvironment.NODES_FOLDER);
2149-
Path dest = dataDir.resolve(NodeEnvironment.NODES_FOLDER);
2150-
assertTrue(Files.exists(src));
2151-
Files.move(src, dest);
2152-
assertFalse(Files.exists(src));
2153-
assertTrue(Files.exists(dest));
2154-
Settings.Builder builder = Settings.builder()
2155-
.put(settings)
2156-
.put(Environment.PATH_DATA_SETTING.getKey(), dataDir.toAbsolutePath());
21572115

2158-
return builder.build();
2159-
}
21602116

21612117
@Override
21622118
protected NamedXContentRegistry xContentRegistry() {

0 commit comments

Comments
 (0)