changed version number to the new scheme
- lowercase `beta` and `rc` - replaced `.betaXXX` and `.rcXXXX` suffix with `-betaXXX` and `-rcXXX` Original commit: elastic/x-pack-elasticsearch@843d01c647
This commit is contained in:
parent
d302b04256
commit
b4342d6bd4
|
@ -82,7 +82,7 @@ public class ShieldVersion implements Serializable {
|
||||||
return ShieldVersion.CURRENT;
|
return ShieldVersion.CURRENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = version.split("\\.");
|
String[] parts = version.split("\\.|\\-");
|
||||||
if (parts.length < 3 || parts.length > 4) {
|
if (parts.length < 3 || parts.length > 4) {
|
||||||
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build");
|
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build");
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,10 @@ public class ShieldVersion implements Serializable {
|
||||||
int build = 99;
|
int build = 99;
|
||||||
if (parts.length == 4) {
|
if (parts.length == 4) {
|
||||||
String buildStr = parts[3];
|
String buildStr = parts[3];
|
||||||
if (buildStr.startsWith("Beta")) {
|
if (buildStr.startsWith("beta")) {
|
||||||
build = Integer.parseInt(buildStr.substring(4));
|
build = Integer.parseInt(buildStr.substring(4));
|
||||||
}
|
}
|
||||||
if (buildStr.startsWith("RC")) {
|
if (buildStr.startsWith("rc")) {
|
||||||
build = Integer.parseInt(buildStr.substring(2)) + 50;
|
build = Integer.parseInt(buildStr.substring(2)) + 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,9 +191,9 @@ public class ShieldVersion implements Serializable {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(major).append('.').append(minor).append('.').append(revision);
|
sb.append(major).append('.').append(minor).append('.').append(revision);
|
||||||
if (build < 50) {
|
if (build < 50) {
|
||||||
sb.append(".Beta").append(build);
|
sb.append("-beta").append(build);
|
||||||
} else if (build < 99) {
|
} else if (build < 99) {
|
||||||
sb.append(".RC").append(build - 50);
|
sb.append("-rc").append(build - 50);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
|
*/
|
||||||
|
package org.elasticsearch.shield;
|
||||||
|
|
||||||
|
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ShieldVersionTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStrings() throws Exception {
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
boolean beta = randomBoolean();
|
||||||
|
int buildNumber = beta ? randomIntBetween(0, 49) : randomIntBetween(0, 48);
|
||||||
|
int major = randomIntBetween(0, 20);
|
||||||
|
int minor = randomIntBetween(0, 20);
|
||||||
|
int revision = randomIntBetween(0, 20);
|
||||||
|
|
||||||
|
String build = buildNumber == 0 ? "" :
|
||||||
|
beta ? "-beta" + buildNumber : "-rc" + buildNumber;
|
||||||
|
|
||||||
|
|
||||||
|
String versionName = new StringBuilder()
|
||||||
|
.append(major)
|
||||||
|
.append(".").append(minor)
|
||||||
|
.append(".").append(revision)
|
||||||
|
.append(build).toString();
|
||||||
|
ShieldVersion version = ShieldVersion.fromString(versionName);
|
||||||
|
|
||||||
|
logger.info("version: {}", versionName);
|
||||||
|
|
||||||
|
assertThat(version.major, is((byte) major));
|
||||||
|
assertThat(version.minor, is((byte) minor));
|
||||||
|
assertThat(version.revision, is((byte) revision));
|
||||||
|
if (buildNumber == 0) {
|
||||||
|
assertThat(version.build, is((byte) 99));
|
||||||
|
} else if (beta) {
|
||||||
|
assertThat(version.build, is((byte) buildNumber));
|
||||||
|
} else {
|
||||||
|
assertThat(version.build, is((byte) (buildNumber + 50)));
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(version.number(), equalTo(versionName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue