Skip to content

Commit 5c35bff

Browse files
authored
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 c0c5d54 commit 5c35bff

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;
@@ -141,7 +140,6 @@
141140
import org.junit.BeforeClass;
142141

143142
import java.io.IOException;
144-
import java.io.InputStream;
145143
import java.lang.annotation.Annotation;
146144
import java.lang.annotation.ElementType;
147145
import java.lang.annotation.Inherited;
@@ -151,7 +149,6 @@
151149
import java.net.InetAddress;
152150
import java.net.InetSocketAddress;
153151
import java.net.URL;
154-
import java.nio.file.DirectoryStream;
155152
import java.nio.file.Files;
156153
import java.nio.file.Path;
157154
import java.util.ArrayList;
@@ -2113,48 +2110,7 @@ protected String routingKeyForShard(String index, int shard) {
21132110
return internalCluster().routingKeyForShard(resolveIndex(index), shard, random());
21142111
}
21152112

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

2156-
return builder.build();
2157-
}
21582114

21592115
@Override
21602116
protected NamedXContentRegistry xContentRegistry() {

0 commit comments

Comments
 (0)