Tests: Add tests for missing static indexes, and ensure newly added

versions will force indexes to be added.
This commit is contained in:
Ryan Ernst 2015-01-09 13:42:27 -08:00
parent 716cc5fb05
commit 8e864d037e
16 changed files with 63 additions and 18 deletions

View File

@ -37,10 +37,6 @@ except ImportError as e:
print('Can\'t import elasticsearch please install `sudo pip install elasticsearch`')
sys.exit(1)
BLACK_LIST = {'1.2.0' : { 'reason': 'Contains a major bug where routing hashes are not consistent with previous version',
'issue': 'https://github.com/elasticsearch/elasticsearch/pull/6393'},
'1.3.0' : { 'reason': 'Lucene Related bug prevents upgrades from 0.90.7 and some earlier versions ',
'issue' : 'https://github.com/elasticsearch/elasticsearch/pull/7055'}}
# sometimes returns True
def rarely():
return random.randint(0, 10) == 0
@ -179,12 +175,6 @@ def parse_config():
help='The port to use as the minimum port for HTTP communication')
cfg = parser.parse_args()
if cfg.version in BLACK_LIST:
entry = BLACK_LIST[cfg.version]
msg = 'Cannot use version %s\n reason: %s\n issue: %s' % \
(cfg.version, entry['reason'], entry['issue'])
parser.error(msg)
cfg.release_dir = os.path.join(cfg.releases_dir, 'elasticsearch-%s' % cfg.version)
if not os.path.exists(cfg.release_dir):
parser.error('ES version %s does not exist in %s' % (cfg.version, cfg.releases_dir))

View File

@ -117,7 +117,7 @@ public class Version {
public static final int V_0_20_6_ID = /*00*/200699;
public static final Version V_0_20_6 = new Version(V_0_20_6_ID, false, LUCENE_3_EMULATION_VERSION);
public static final int V_0_20_7_ID = /*00*/200799;
public static final Version V_0_20_7 = new Version(V_0_20_7_ID, false, LUCENE_3_EMULATION_VERSION);
public static final Version V_0_20_7 = new Version(V_0_20_7_ID, true, LUCENE_3_EMULATION_VERSION);
public static final int V_0_90_0_Beta1_ID = /*00*/900001;
public static final Version V_0_90_0_Beta1 = new Version(V_0_90_0_Beta1_ID, false, org.apache.lucene.util.Version.LUCENE_4_1);
@ -154,12 +154,12 @@ public class Version {
public static final int V_0_90_13_ID = /*00*/901399;
public static final Version V_0_90_13 = new Version(V_0_90_13_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_0_90_14_ID = /*00*/901499;
public static final Version V_0_90_14 = new Version(V_0_90_14_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final Version V_0_90_14 = new Version(V_0_90_14_ID, true, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_1_0_0_Beta1_ID = 1000001;
public static final Version V_1_0_0_Beta1 = new Version(V_1_0_0_Beta1_ID, false, org.apache.lucene.util.Version.LUCENE_4_5);
public static final int V_1_0_0_Beta2_ID = 1000002;
public static final Version V_1_0_0_Beta2 = new Version(V_1_0_0_Beta2_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final Version V_1_0_0_Beta2 = new Version(V_1_0_0_Beta2_ID, true, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_1_0_0_RC1_ID = 1000051;
public static final Version V_1_0_0_RC1 = new Version(V_1_0_0_RC1_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_1_0_0_RC2_ID = 1000052;
@ -173,7 +173,7 @@ public class Version {
public static final int V_1_0_3_ID = 1000399;
public static final Version V_1_0_3 = new Version(V_1_0_3_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_1_0_4_ID = 1000499;
public static final Version V_1_0_4 = new Version(V_1_0_4_ID, false, org.apache.lucene.util.Version.LUCENE_4_6);
public static final Version V_1_0_4 = new Version(V_1_0_4_ID, true, org.apache.lucene.util.Version.LUCENE_4_6);
public static final int V_1_1_0_ID = 1010099;
public static final Version V_1_1_0 = new Version(V_1_1_0_ID, false, org.apache.lucene.util.Version.LUCENE_4_7);
public static final int V_1_1_1_ID = 1010199;

View File

@ -34,10 +34,18 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.hamcrest.Matchers;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -46,6 +54,9 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
// We have a 0.20.6.zip etc for this.
List<String> indexes = Arrays.asList(
/* skipping 0.90.0.Beta1...fails to load with "java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'XBloomFilter' does not exist" */
"index-0.90.0.RC1.zip",
"index-0.90.0.RC2.zip",
"index-0.90.0.zip",
"index-0.90.1.zip",
"index-0.90.2.zip",
@ -57,9 +68,13 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
"index-0.90.8.zip",
"index-0.90.9.zip",
"index-0.90.10.zip",
/* skipping 0.90.12...ensureGreen always times out while loading the index...*/
"index-0.90.11.zip",
"index-0.90.12.zip",
"index-0.90.13.zip",
"index-1.0.0.Beta1.zip",
"index-1.0.0.Beta2.zip",
"index-1.0.0.RC1.zip",
"index-1.0.0.RC2.zip",
"index-1.0.0.zip",
"index-1.0.1.zip",
"index-1.0.2.zip",
@ -67,17 +82,54 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
"index-1.1.0.zip",
"index-1.1.1.zip",
"index-1.1.2.zip",
/* skipping 1.2.0...there was a major bug with routing, and it is not even downloadable */
"index-1.2.1.zip",
"index-1.2.2.zip",
"index-1.2.3.zip",
"index-1.2.4.zip",
"index-1.3.0.zip",
"index-1.3.1.zip",
"index-1.3.2.zip",
"index-1.3.3.zip",
"index-1.3.4.zip",
"index-1.3.5.zip",
"index-1.3.6.zip",
"index-1.3.7.zip",
"index-1.4.0.Beta1.zip",
"index-1.4.0.zip"
"index-1.4.0.zip",
"index-1.4.1.zip",
"index-1.4.2.zip"
);
public void testAllVersionsTested() throws Exception {
SortedSet<String> expectedVersions = new TreeSet<>();
for (java.lang.reflect.Field field : Version.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == Version.class) {
Version v = (Version)field.get(Version.class);
if (v.snapshot()) continue;
if (v.onOrBefore(Version.V_0_20_6)) continue;
// problematic indexes...see notes above
if (v.equals(Version.V_0_90_0_Beta1) ||
v.equals(Version.V_1_2_0)) continue;
expectedVersions.add("index-" + v.toString() + ".zip");
}
}
for (String index : indexes) {
if (expectedVersions.remove(index) == false) {
logger.warn("Old indexes tests contain extra index: " + index);
}
}
if (expectedVersions.isEmpty() == false) {
StringBuilder msg = new StringBuilder("Old index tests are missing indexes:");
for (String expected : expectedVersions) {
msg.append("\n" + expected);
}
fail(msg.toString());
}
}
public void testOldIndexes() throws Exception {
Collections.shuffle(indexes, getRandom());
@ -99,9 +151,12 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
unloadIndex();
}
Version extractVersion(String index) {
return Version.fromString(index.substring(index.indexOf('-') + 1, index.lastIndexOf('.')));
}
boolean isLatestLuceneVersion(String index) {
String versionStr = index.substring(index.indexOf('-') + 1, index.lastIndexOf('.'));
Version version = Version.fromString(versionStr);
Version version = extractVersion(index);
return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
}