diff --git a/core-shaded/pom.xml b/core-shaded/pom.xml index 54fd959f0c7..37b6edeb459 100644 --- a/core-shaded/pom.xml +++ b/core-shaded/pom.xml @@ -14,4 +14,19 @@ ${project.parent.basedir} + + + + + com.carrotsearch.randomizedtesting + junit4-maven-plugin + + + tests + + + + + + \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml index c46b7ece89a..961041c27e0 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -25,113 +25,6 @@ com.carrotsearch.randomizedtesting junit4-maven-plugin - 2.1.2 - - - tests - test - - junit4 - - - ${project.basedir}/target - ${project.basedir}/target/classes - 20 - pipe,warn - true - - - - - - - - - - - ${tests.jvms} - - - - - - - **/*Tests.class - **/*Test.class - - - **/Abstract*.class - **/*StressTest.class - - - -Xmx${tests.heap.size} - -Xms${tests.heap.size} - -Xss256k - -XX:MaxPermSize=128m - -XX:MaxDirectMemorySize=512m - -Des.logger.prefix= - - ${tests.shuffle} - ${tests.verbose} - ${tests.seed} - ${tests.failfast} - false - - . - - - ${tests.bwc} - ${tests.bwc.path} - ${tests.bwc.version} - ${tests.jvm.argline} - ${tests.processors} - ${tests.appendseed} - ${tests.iters} - ${tests.maxfailures} - ${tests.failfast} - ${tests.class} - ${tests.method} - ${tests.nightly} - ${tests.verbose} - ${tests.badapples} - ${tests.weekly} - ${tests.slow} - ${tests.awaitsfix} - ${tests.slow} - ${tests.timeoutSuite} - ${tests.showSuccess} - ${tests.integration} - ${tests.client.ratio} - ${tests.enable_mock_modules} - ${tests.assertion.disabled} - ${tests.rest} - ${tests.rest.suite} - ${tests.rest.blacklist} - ${tests.rest.spec} - ${tests.network} - ${tests.cluster} - ${tests.heap.size} - ${tests.filter} - ${env.ES_TEST_LOCAL} - ${es.node.mode} - ${es.logger.level} - ${tests.security.manager} - ${tests.compatibility} - true - - - - diff --git a/core/src/main/java/org/elasticsearch/license/core/LicenseVerifier.java b/core/src/main/java/org/elasticsearch/license/core/LicenseVerifier.java index 49273fdebf7..05ca93a857a 100644 --- a/core/src/main/java/org/elasticsearch/license/core/LicenseVerifier.java +++ b/core/src/main/java/org/elasticsearch/license/core/LicenseVerifier.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.license.core.shaded.CryptUtils; import java.io.IOException; -import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.file.Files; import java.nio.file.Path; @@ -115,8 +114,8 @@ public class LicenseVerifier { } private static byte[] getPublicKeyContentFromResource(String resource) { - try (InputStream inputStream = LicenseVerifier.class.getResourceAsStream(resource)) { - return Streams.copyToByteArray(inputStream); + try { + return Streams.copyToBytesFromClasspath(resource); } catch (IOException ex) { throw new IllegalStateException(ex); } diff --git a/core/src/test/java/org/elasticsearch/license/core/TestUtils.java b/core/src/test/java/org/elasticsearch/license/core/TestUtils.java index 1aa1ed50e4b..800affa8831 100644 --- a/core/src/test/java/org/elasticsearch/license/core/TestUtils.java +++ b/core/src/test/java/org/elasticsearch/license/core/TestUtils.java @@ -8,14 +8,12 @@ package org.elasticsearch.license.core; import org.elasticsearch.common.joda.DateMathParser; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.joda.Joda; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentType; import org.hamcrest.MatcherAssert; import java.io.IOException; import java.util.*; +import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import static com.carrotsearch.randomizedtesting.RandomizedTest.*; @@ -59,12 +57,22 @@ public class TestUtils { assertThat(license1.maxNodes(), equalTo(license2.maxNodes())); } - public static String dateMathString(String time, long now) { - return dateTimeFormatter.print(dateMathParser.parse(time, now)); + public static String dateMathString(String time, final long now) { + return dateTimeFormatter.print(dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + })); } - public static long dateMath(String time, long now) { - return dateMathParser.parse(time, now); + public static long dateMath(String time, final long now) { + return dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + }); } public static LicenseSpec generateRandomLicenseSpec() { diff --git a/licensor/pom.xml b/licensor/pom.xml index 8f49df21ee2..f037f97c11e 100644 --- a/licensor/pom.xml +++ b/licensor/pom.xml @@ -34,7 +34,6 @@ maven-assembly-plugin - 2.4 ${project.build.directory}/releases/ @@ -57,7 +56,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 for-exec @@ -78,113 +76,6 @@ com.carrotsearch.randomizedtesting junit4-maven-plugin - 2.1.2 - - - tests - test - - junit4 - - - ${project.basedir}/target - ${project.basedir}/target/classes - 20 - pipe,warn - true - - - - - - - - - - - ${tests.jvms} - - - - - - - **/*Tests.class - **/*Test.class - - - **/Abstract*.class - **/*StressTest.class - - - -Xmx${tests.heap.size} - -Xms${tests.heap.size} - -Xss256k - -XX:MaxPermSize=128m - -XX:MaxDirectMemorySize=512m - -Des.logger.prefix= - - ${tests.shuffle} - ${tests.verbose} - ${tests.seed} - ${tests.failfast} - false - - . - - - ${tests.bwc} - ${tests.bwc.path} - ${tests.bwc.version} - ${tests.jvm.argline} - ${tests.processors} - ${tests.appendseed} - ${tests.iters} - ${tests.maxfailures} - ${tests.failfast} - ${tests.class} - ${tests.method} - ${tests.nightly} - ${tests.verbose} - ${tests.badapples} - ${tests.weekly} - ${tests.slow} - ${tests.awaitsfix} - ${tests.slow} - ${tests.timeoutSuite} - ${tests.showSuccess} - ${tests.integration} - ${tests.client.ratio} - ${tests.enable_mock_modules} - ${tests.assertion.disabled} - ${tests.rest} - ${tests.rest.suite} - ${tests.rest.blacklist} - ${tests.rest.spec} - ${tests.network} - ${tests.cluster} - ${tests.heap.size} - ${tests.filter} - ${env.ES_TEST_LOCAL} - ${es.node.mode} - ${es.logger.level} - ${tests.security.manager} - ${tests.compatibility} - true - - - - diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/AbstractLicensingTestBase.java b/licensor/src/test/java/org/elasticsearch/license/licensor/AbstractLicensingTestBase.java index 6e43f42d45e..1cf7fea6219 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/AbstractLicensingTestBase.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/AbstractLicensingTestBase.java @@ -8,9 +8,9 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.core.DateUtils; import org.elasticsearch.license.core.License; import org.elasticsearch.test.ElasticsearchTestCase; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; -import java.net.URL; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -18,16 +18,22 @@ import java.util.UUID; public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase { - protected static String pubKeyPath = null; - protected static String priKeyPath = null; + protected String pubKeyPath = null; + protected String priKeyPath = null; - @BeforeClass - public static void setup() throws Exception { + @Before + public void setup() throws Exception { pubKeyPath = getResourcePath("/public.key"); priKeyPath = getResourcePath("/private.key"); } - public static Set generateSignedLicenses(List licenseSpecs) throws Exception { + @After + public void cleanUp() { + pubKeyPath = null; + priKeyPath = null; + } + + public static Set generateSignedLicenses(List licenseSpecs, String pubKeyPath, String priKeyPath) throws Exception { LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath); Set unSignedLicenses = new HashSet<>(); for (TestUtils.LicenseSpec spec : licenseSpecs) { @@ -55,11 +61,11 @@ public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase { return signer.sign(unSignedLicenses); } - public static License generateSignedLicense(String feature, TimeValue expiryDuration) throws Exception { - return generateSignedLicense(feature, -1, expiryDuration); + public static License generateSignedLicense(String feature, TimeValue expiryDuration, String pubKeyPath, String priKeyPath) throws Exception { + return generateSignedLicense(feature, -1, expiryDuration, pubKeyPath, priKeyPath); } - public static License generateSignedLicense(String feature, long issueDate, TimeValue expiryDuration) throws Exception { + public static License generateSignedLicense(String feature, long issueDate, TimeValue expiryDuration, String pubKeyPath, String priKeyPath) throws Exception { long issue = (issueDate != -1l) ? issueDate : System.currentTimeMillis(); final License licenseSpec = License.builder() .uid(UUID.randomUUID().toString()) @@ -73,20 +79,19 @@ public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase { .maxNodes(5) .build(); - LicenseSigner signer = new LicenseSigner(getTestPriKeyPath(), getTestPubKeyPath()); + LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath); return signer.sign(licenseSpec); } - public static String getTestPriKeyPath() throws Exception { + public String getTestPriKeyPath() throws Exception { return getResourcePath("/private.key"); } - public static String getTestPubKeyPath() throws Exception { + public String getTestPubKeyPath() throws Exception { return getResourcePath("/public.key"); } - private static String getResourcePath(String resource) throws Exception { - URL url = TestUtils.class.getResource(resource); - return url.toURI().getPath(); + private String getResourcePath(String resource) throws Exception { + return getDataPath(resource).toString(); } } diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/LicenseVerificationTests.java b/licensor/src/test/java/org/elasticsearch/license/licensor/LicenseVerificationTests.java index 64d8844058e..92191464997 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/LicenseVerificationTests.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/LicenseVerificationTests.java @@ -21,21 +21,21 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase { @Test public void testGeneratedLicenses() throws Exception { - License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24)); + License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath); assertThat(LicenseVerifier.verifyLicense(shieldLicense), equalTo(true)); } @Test public void testMultipleFeatureLicenses() throws Exception { - License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24)); - License marvelLicense = generateSignedLicense("marvel", TimeValue.timeValueHours(2 * 24)); + License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath); + License marvelLicense = generateSignedLicense("marvel", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath); assertThat(LicenseVerifier.verifyLicenses(Arrays.asList(shieldLicense, marvelLicense)), equalTo(true)); } @Test public void testLicenseTampering() throws Exception { - License license = generateSignedLicense("shield", TimeValue.timeValueHours(2)); + License license = generateSignedLicense("shield", TimeValue.timeValueHours(2), pubKeyPath, priKeyPath); final License tamperedLicense = License.builder() .fromLicenseSpec(license, license.signature()) @@ -54,7 +54,7 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase { licenseSpecs.add(TestUtils.generateRandomLicenseSpec()); } - Set generatedLicenses = generateSignedLicenses(licenseSpecs); + Set generatedLicenses = generateSignedLicenses(licenseSpecs, pubKeyPath, priKeyPath); assertThat(generatedLicenses.size(), equalTo(n)); for (License generatedLicense: generatedLicenses) { diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/TestUtils.java b/licensor/src/test/java/org/elasticsearch/license/licensor/TestUtils.java index c8b8a86e1e3..e4c28e28f84 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/TestUtils.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/TestUtils.java @@ -19,6 +19,7 @@ import org.hamcrest.MatcherAssert; import java.io.IOException; import java.util.*; +import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; @@ -31,6 +32,9 @@ import static org.junit.Assert.assertThat; public class TestUtils { + public static final String PUBLIC_KEY_RESOURCE = "/public.key"; + public static final String PRIVATE_KEY_RESOURCE = "/private.key"; + private final static FormatDateTimeFormatter formatDateTimeFormatter = Joda.forPattern("yyyy-MM-dd"); private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS); private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer(); @@ -71,12 +75,22 @@ public class TestUtils { return builder.string(); } - public static String dateMathString(String time, long now) { - return dateTimeFormatter.print(dateMathParser.parse(time, now)); + public static String dateMathString(String time, final long now) { + return dateTimeFormatter.print(dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + })); } - public static long dateMath(String time, long now) { - return dateMathParser.parse(time, now); + public static long dateMath(String time, final long now) { + return dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + }); } public static LicenseSpec generateRandomLicenseSpec() { diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/KeyPairGenerationToolTests.java b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/KeyPairGenerationToolTests.java index f099165077d..4b5bf4205c1 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/KeyPairGenerationToolTests.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/KeyPairGenerationToolTests.java @@ -8,13 +8,11 @@ package org.elasticsearch.license.licensor.tools; import org.elasticsearch.common.cli.CliToolTestCase; import org.elasticsearch.common.cli.commons.MissingOptionException; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.license.licensor.tools.KeyPairGeneratorTool.KeyGenerator; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -27,23 +25,20 @@ import static org.hamcrest.core.IsEqual.equalTo; public class KeyPairGenerationToolTests extends CliToolTestCase { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Test public void testParsingMissingPath() throws Exception { KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool(); - File tempFile = temporaryFolder.newFile(); + Path tempFile = createTempFile(); try { keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args( - "--privateKeyPath " + tempFile.getAbsolutePath())); + "--privateKeyPath " + tempFile.toAbsolutePath())); fail("no public key path provided"); } catch (MissingOptionException e) { assertThat(e.getMessage(), containsString("pub")); } try { keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args( - "--publicKeyPath " + tempFile.getAbsolutePath())); + "--publicKeyPath " + tempFile.toAbsolutePath())); fail("no private key path provided"); } catch (MissingOptionException e) { assertThat(e.getMessage(), containsString("pri")); @@ -53,20 +48,21 @@ public class KeyPairGenerationToolTests extends CliToolTestCase { @Test public void testParsingNeverOverrideKey() throws Exception { KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool(); - File tempFile = temporaryFolder.newFile(); - File tempFile2 = temporaryFolder.newFile(); - String nonExistentFilePath = tempFile2.getAbsolutePath(); - assertThat(tempFile2.delete(), equalTo(true)); + Path tempFile = createTempFile(); + Path tempFile2 = createTempFile(); + String nonExistentFilePath = tempFile2.toAbsolutePath().toString(); + Files.delete(tempFile2); + assertThat(Files.exists(tempFile2), equalTo(false)); - Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--privateKeyPath " + tempFile.getAbsolutePath() - + " --publicKeyPath " + nonExistentFilePath)); + Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] {"--privateKeyPath", tempFile.toAbsolutePath().toString(), + "--publicKeyPath", nonExistentFilePath }); assertThat(command, instanceOf(Command.Exit.class)); Command.Exit exitCommand = (Command.Exit) command; assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE)); - command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--publicKeyPath " + tempFile.getAbsolutePath() - + " --privateKeyPath " + nonExistentFilePath)); + command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] {"--publicKeyPath", tempFile.toAbsolutePath().toString(), + "--privateKeyPath", nonExistentFilePath }); assertThat(command, instanceOf(Command.Exit.class)); exitCommand = (Command.Exit) command; @@ -76,18 +72,21 @@ public class KeyPairGenerationToolTests extends CliToolTestCase { @Test public void testToolSimple() throws Exception { KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool(); - File tempFile1 = temporaryFolder.newFile(); - File tempFile2 = temporaryFolder.newFile(); - String publicKeyPath = tempFile1.getAbsolutePath(); - String privateKeyPath = tempFile2.getAbsolutePath(); + Path tempFile1 = createTempFile(); + Path tempFile2 = createTempFile(); + String publicKeyPath = tempFile1.toAbsolutePath().toString(); + String privateKeyPath = tempFile2.toAbsolutePath().toString(); Path publicKeyFilePath = Paths.get(publicKeyPath); Path privateKeyFilePath = Paths.get(privateKeyPath); + Settings settings = ImmutableSettings.builder().put("path.home", createTempDir()).build(); - assertThat(tempFile1.delete(), equalTo(true)); - assertThat(tempFile2.delete(), equalTo(true)); + Files.delete(tempFile1); + Files.delete(tempFile2); + assertThat(Files.exists(tempFile1), equalTo(false)); + assertThat(Files.exists(tempFile2), equalTo(false)); - Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--privateKeyPath " + privateKeyPath - + " --publicKeyPath " + publicKeyPath)); + Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] { "--privateKeyPath", privateKeyPath, + "--publicKeyPath", publicKeyPath }); assertThat(command, instanceOf(KeyGenerator.class)); KeyGenerator keyGenerator = (KeyGenerator) command; @@ -97,7 +96,7 @@ public class KeyPairGenerationToolTests extends CliToolTestCase { assertThat(Files.exists(publicKeyFilePath), equalTo(false)); assertThat(Files.exists(privateKeyFilePath), equalTo(false)); - assertThat(keyGenerator.execute(ImmutableSettings.EMPTY, new Environment(ImmutableSettings.EMPTY)), equalTo(ExitStatus.OK)); + assertThat(keyGenerator.execute(settings, new Environment(settings)), equalTo(ExitStatus.OK)); assertThat(Files.exists(publicKeyFilePath), equalTo(true)); assertThat(Files.exists(privateKeyFilePath), equalTo(true)); diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseGenerationToolTests.java b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseGenerationToolTests.java index 7262566548e..f52ea5f8cf1 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseGenerationToolTests.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseGenerationToolTests.java @@ -12,14 +12,10 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.license.core.License; import org.elasticsearch.license.core.Licenses; -import org.elasticsearch.license.licensor.AbstractLicensingTestBase; import org.elasticsearch.license.licensor.TestUtils; -import org.junit.BeforeClass; -import org.junit.Rule; +import org.junit.Before; import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -36,17 +32,17 @@ import static org.hamcrest.core.IsEqual.equalTo; public class LicenseGenerationToolTests extends CliToolTestCase { - protected static String pubKeyPath = null; - protected static String priKeyPath = null; - - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + protected String pubKeyPath = null; + protected String priKeyPath = null; + protected Path homeDir = null; - @BeforeClass - public static void setup() throws Exception { - pubKeyPath = AbstractLicensingTestBase.getTestPubKeyPath(); - priKeyPath = AbstractLicensingTestBase.getTestPriKeyPath(); + @Before + public void setup() throws Exception { + logger.error("project.basedir [{}]", System.getProperty("project.basedir")); + pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString(); + priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE).toString(); + homeDir = createTempDir(); } @Test @@ -54,18 +50,18 @@ public class LicenseGenerationToolTests extends CliToolTestCase { TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec(); LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool(); Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)) - + " --publicKeyPath " + pubKeyPath.concat("invalid") - + " --privateKeyPath " + priKeyPath)); + new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)), + "--publicKeyPath", pubKeyPath.concat("invalid"), + "--privateKeyPath", priKeyPath }); assertThat(command, instanceOf(Command.Exit.class)); Command.Exit exitCommand = (Command.Exit) command; assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE)); command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)) - + " --privateKeyPath " + priKeyPath.concat("invalid") - + " --publicKeyPath " + pubKeyPath)); + new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)), + "--privateKeyPath", priKeyPath.concat("invalid"), + "--publicKeyPath", pubKeyPath }); assertThat(command, instanceOf(Command.Exit.class)); exitCommand = (Command.Exit) command; @@ -76,8 +72,8 @@ public class LicenseGenerationToolTests extends CliToolTestCase { public void testParsingMissingLicenseSpec() throws Exception { LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool(); Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args(" --publicKeyPath " + pubKeyPath - + " --privateKeyPath " + priKeyPath)); + new String[] { "--publicKeyPath", pubKeyPath, + "--privateKeyPath", priKeyPath }); assertThat(command, instanceOf(Command.Exit.class)); Command.Exit exitCommand = (Command.Exit) command; @@ -91,9 +87,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase { boolean pubKeyMissing = randomBoolean(); try { licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)) - + ((!pubKeyMissing) ? " --publicKeyPath " + pubKeyPath : "") - + ((pubKeyMissing) ? " --privateKeyPath " + priKeyPath : ""))); + new String[] { "--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)), + ((pubKeyMissing) ? "--privateKeyPath" : "--publicKeyPath"), + ((pubKeyMissing) ? priKeyPath : pubKeyPath) }); fail("missing argument: " + ((pubKeyMissing) ? "publicKeyPath" : "privateKeyPath") + " should throw an exception"); } catch (MissingOptionException e) { assertThat(e.getMessage(), containsString((pubKeyMissing) ? "pub" : "pri")); @@ -105,9 +101,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase { TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec(); LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool(); Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)) - + " --publicKeyPath " + pubKeyPath - + " --privateKeyPath " + priKeyPath)); + new String[]{"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)), + "--publicKeyPath", pubKeyPath, + "--privateKeyPath", priKeyPath }); assertThat(command, instanceOf(LicenseGenerator.class)); LicenseGenerator licenseGenerator = (LicenseGenerator) command; @@ -122,14 +118,14 @@ public class LicenseGenerationToolTests extends CliToolTestCase { @Test public void testParsingLicenseFile() throws Exception { TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec(); - File tempFile = temporaryFolder.newFile("license_spec.json"); - Files.write(Paths.get(tempFile.getAbsolutePath()), TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)).getBytes(StandardCharsets.UTF_8)); + Path tempFile = createTempFile(); + Files.write(tempFile, TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)).getBytes(StandardCharsets.UTF_8)); LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool(); Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--licenseFile " + tempFile.getAbsolutePath() - + " --publicKeyPath " + pubKeyPath - + " --privateKeyPath " + priKeyPath)); + new String[] { "--licenseFile", tempFile.toAbsolutePath().toString(), + "--publicKeyPath", pubKeyPath, + "--privateKeyPath", priKeyPath }); assertThat(command, instanceOf(LicenseGenerator.class)); LicenseGenerator licenseGenerator = (LicenseGenerator) command; @@ -151,9 +147,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase { } LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool(); Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME, - args("--license " + TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values())) - + " --publicKeyPath " + pubKeyPath - + " --privateKeyPath " + priKeyPath)); + new String[] { "--license", TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values())), + "--publicKeyPath", pubKeyPath, + "--privateKeyPath", priKeyPath }); assertThat(command, instanceOf(LicenseGenerator.class)); LicenseGenerator licenseGenerator = (LicenseGenerator) command; @@ -191,8 +187,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase { private String runLicenseGenerationTool(Path pubKeyPath, Path priKeyPath, Set licenseSpecs, ExitStatus expectedExitStatus) throws Exception { CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal(); + Settings settings = ImmutableSettings.builder().put("path.home", homeDir).build(); LicenseGenerator licenseGenerator = new LicenseGenerator(outputTerminal, pubKeyPath, priKeyPath, licenseSpecs); - assertThat(execute(licenseGenerator, ImmutableSettings.EMPTY), equalTo(expectedExitStatus)); + assertThat(execute(licenseGenerator, settings), equalTo(expectedExitStatus)); assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1)); return outputTerminal.getTerminalOutput().get(0); } diff --git a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseVerificationToolTests.java b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseVerificationToolTests.java index cf99b2323d4..90521d32019 100644 --- a/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseVerificationToolTests.java +++ b/licensor/src/test/java/org/elasticsearch/license/licensor/tools/LicenseVerificationToolTests.java @@ -15,15 +15,13 @@ import org.elasticsearch.license.licensor.AbstractLicensingTestBase; import org.elasticsearch.license.licensor.TestUtils; import org.elasticsearch.license.core.License; import org.elasticsearch.license.core.Licenses; -import org.junit.Rule; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.*; import static org.elasticsearch.common.cli.CliTool.Command; @@ -36,13 +34,23 @@ import static org.hamcrest.core.IsEqual.equalTo; public class LicenseVerificationToolTests extends CliToolTestCase { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + protected static Path homeDir = null; + + @BeforeClass + public static void setup() throws Exception { + homeDir = createTempDir(); + } + + @AfterClass + public static void cleanUp() throws Exception { + homeDir = null; + } @Test public void testParsingMissingLicense() throws Exception { LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); - Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath())); + Path path = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath " + path)); assertThat(command, instanceOf(Command.Exit.class)); Command.Exit exitCommand = (Command.Exit) command; @@ -51,8 +59,10 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testParsingMissingPublicKeyPath() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1", - TimeValue.timeValueHours(1)); + TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); try { licenseVerificationTool.parse(LicenseVerificationTool.NAME, @@ -65,8 +75,9 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testParsingNonExistentPublicKeyPath() throws Exception { LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); + Path path = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath " - + AbstractLicensingTestBase.getTestPubKeyPath().concat(".invalid"))); + + path.toString().concat(".invalid"))); assertThat(command, instanceOf(Command.Exit.class)); Command.Exit exitCommand = (Command.Exit) command; @@ -75,12 +86,14 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testParsingSimple() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1", - TimeValue.timeValueHours(1)); + TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args("--license " + TestUtils.dumpLicense(inputLicense) - + " --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath())); + + " --publicKeyPath " + getDataPath(TestUtils.PUBLIC_KEY_RESOURCE))); assertThat(command, instanceOf(LicenseVerifier.class)); LicenseVerifier licenseVerifier = (LicenseVerifier) command; assertThat(licenseVerifier.licenses.size(), equalTo(1)); @@ -90,13 +103,15 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testParsingLicenseFile() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1", - TimeValue.timeValueHours(1)); + TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, - args("--licenseFile " + dumpLicenseAsFile(inputLicense) - + " --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath())); + new String[] { "--licenseFile", dumpLicenseAsFile(inputLicense), + "--publicKeyPath", getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString() }); assertThat(command, instanceOf(LicenseVerifier.class)); LicenseVerifier licenseVerifier = (LicenseVerifier) command; assertThat(licenseVerifier.licenses.size(), equalTo(1)); @@ -107,11 +122,14 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testParsingMultipleLicense() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); + int n = randomIntBetween(2, 5); Map inputLicenses = new HashMap<>(); for (int i = 0; i < n; i++) { License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i, - TimeValue.timeValueHours(1)); + TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); inputLicenses.put(license.feature(), license); } @@ -120,7 +138,7 @@ public class LicenseVerificationToolTests extends CliToolTestCase { argsBuilder.append(" --license ") .append(TestUtils.dumpLicense(inputLicense)); } - argsBuilder.append(" --publicKeyPath ").append(AbstractLicensingTestBase.getTestPubKeyPath()); + argsBuilder.append(" --publicKeyPath ").append(getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString()); LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool(); Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(argsBuilder.toString())); @@ -137,15 +155,18 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testToolSimple() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); + int n = randomIntBetween(2, 5); Map inputLicenses = new HashMap<>(); for (int i = 0; i < n; i++) { License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i, - TimeValue.timeValueHours(1)); + TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); inputLicenses.put(license.feature(), license); } - String output = runLicenseVerificationTool(new HashSet<>(inputLicenses.values()), Paths.get(AbstractLicensingTestBase.getTestPubKeyPath()), ExitStatus.OK); + String output = runLicenseVerificationTool(new HashSet<>(inputLicenses.values()), getDataPath(TestUtils.PUBLIC_KEY_RESOURCE), ExitStatus.OK); List outputLicenses = Licenses.fromSource(output.getBytes(StandardCharsets.UTF_8), true); assertThat(outputLicenses.size(), equalTo(inputLicenses.size())); @@ -158,26 +179,29 @@ public class LicenseVerificationToolTests extends CliToolTestCase { @Test public void testToolInvalidLicense() throws Exception { + Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE); + Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE); License signedLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1" - , TimeValue.timeValueHours(1)); + , TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString()); License tamperedLicense = License.builder() .fromLicenseSpec(signedLicense, signedLicense.signature()) .expiryDate(signedLicense.expiryDate() + randomIntBetween(1, 1000)).build(); - runLicenseVerificationTool(Collections.singleton(tamperedLicense), Paths.get(AbstractLicensingTestBase.getTestPubKeyPath()), ExitStatus.DATA_ERROR); + runLicenseVerificationTool(Collections.singleton(tamperedLicense), getDataPath(TestUtils.PUBLIC_KEY_RESOURCE), ExitStatus.DATA_ERROR); } private String dumpLicenseAsFile(License license) throws Exception { - File tempFile = temporaryFolder.newFile(); - Files.write(Paths.get(tempFile.getAbsolutePath()), TestUtils.dumpLicense(license).getBytes(StandardCharsets.UTF_8)); - return tempFile.getAbsolutePath(); + Path tempFile = createTempFile(); + Files.write(tempFile, TestUtils.dumpLicense(license).getBytes(StandardCharsets.UTF_8)); + return tempFile.toAbsolutePath().toString(); } private String runLicenseVerificationTool(Set licenses, Path publicKeyPath, ExitStatus expectedExitStatus) throws Exception { CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal(); + Settings settings = ImmutableSettings.builder().put("path.home", homeDir).build(); LicenseVerifier licenseVerifier = new LicenseVerifier(outputTerminal, licenses, publicKeyPath); - assertThat(execute(licenseVerifier, ImmutableSettings.EMPTY), equalTo(expectedExitStatus)); + assertThat(execute(licenseVerifier, settings), equalTo(expectedExitStatus)); if (expectedExitStatus == ExitStatus.OK) { assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1)); diff --git a/plugin/pom.xml b/plugin/pom.xml index eeef5cf9fff..ba579d18649 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -51,7 +51,6 @@ org.apache.maven.plugins maven-shade-plugin - 2.3 package @@ -94,7 +93,6 @@ maven-assembly-plugin - 2.4 false ${project.build.directory}/releases/ @@ -119,7 +117,6 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.3.1 @@ -149,7 +146,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 for-plugin @@ -164,7 +160,6 @@ com.carrotsearch.randomizedtesting junit4-maven-plugin - 2.1.2 tests @@ -173,101 +168,7 @@ junit4 - ${project.basedir}/target - ${project.basedir}/target/classes - 40 - pipe,warn - true - - - - - - - - - - - ${tests.jvms} - - - - - - - **/*Tests.class - **/*Test.class - - - **/Abstract*.class - **/*StressTest.class - - - -Xmx${tests.heap.size} - -Xms${tests.heap.size} - -Xss256k - -XX:MaxPermSize=128m - -XX:MaxDirectMemorySize=512m - -Des.logger.prefix= - - ${tests.shuffle} - ${tests.verbose} - ${tests.seed} - ${tests.failfast} - false - - . - - - ${tests.bwc} - ${tests.bwc.path} - ${tests.bwc.version} - ${tests.jvm.argline} - ${tests.processors} - ${tests.appendseed} - ${tests.iters} - ${tests.maxfailures} - ${tests.failfast} - ${tests.class} - ${tests.method} - ${tests.nightly} - ${tests.verbose} - ${tests.badapples} - ${tests.weekly} - ${tests.slow} - ${tests.awaitsfix} - ${tests.slow} - ${tests.timeoutSuite} - ${tests.showSuccess} - ${tests.integration} - ${tests.client.ratio} - ${tests.enable_mock_modules} - ${tests.assertion.disabled} - ${tests.rest} - ${tests.rest.suite} - ${tests.rest.blacklist} - ${tests.rest.spec} - ${tests.network} - ${tests.cluster} - ${tests.heap.size} - ${tests.filter} - ${env.ES_TEST_LOCAL} - ${es.node.mode} - ${es.logger.level} - ${tests.security.manager} - ${tests.compatibility} - true - + 40 diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java b/plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java index 6e1a5805f8b..0b9cec87b0d 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java @@ -37,7 +37,7 @@ public class LicensePlugin extends AbstractPlugin { private final boolean isEnabled; static { - MetaData.registerFactory(LicensesMetaData.TYPE, LicensesMetaData.FACTORY); + MetaData.registerPrototype(LicensesMetaData.TYPE, LicensesMetaData.PROTO); } @Inject diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/LicenseVersion.java b/plugin/src/main/java/org/elasticsearch/license/plugin/LicenseVersion.java index 61f433501e0..4e2cad0d5cd 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/LicenseVersion.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/LicenseVersion.java @@ -25,7 +25,7 @@ public class LicenseVersion implements Serializable { public static final int V_1_0_0_ID = /*00*/1000099; public static final int V_2_0_0_ID = /*00*/2000099; public static final LicenseVersion V_1_0_0 = new LicenseVersion(V_1_0_0_ID, false, License.VERSION_START, Version.V_1_4_0_Beta1); - public static final LicenseVersion V_2_0_0 = new LicenseVersion(V_2_0_0_ID, true, License.VERSION_START, Version.V_1_4_0_Beta1); + public static final LicenseVersion V_2_0_0 = new LicenseVersion(V_2_0_0_ID, true, License.VERSION_START, Version.V_2_0_0); public static final LicenseVersion CURRENT = V_2_0_0; diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/DeleteLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/DeleteLicenseAction.java index bf7b7ae5950..c7c8a675f84 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/DeleteLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/DeleteLicenseAction.java @@ -5,10 +5,10 @@ */ package org.elasticsearch.license.plugin.action.delete; -import org.elasticsearch.action.admin.cluster.ClusterAction; -import org.elasticsearch.client.ClusterAdminClient; +import org.elasticsearch.action.Action; +import org.elasticsearch.client.ElasticsearchClient; -public class DeleteLicenseAction extends ClusterAction { +public class DeleteLicenseAction extends Action { public static final DeleteLicenseAction INSTANCE = new DeleteLicenseAction(); public static final String NAME = "cluster:admin/plugin/license/delete"; @@ -23,7 +23,7 @@ public class DeleteLicenseAction extends ClusterAction { +public class DeleteLicenseRequestBuilder extends AcknowledgedRequestBuilder { /** * Creates new get licenses request builder * - * @param clusterAdminClient cluster admin client + * @param client elasticsearch client */ - public DeleteLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) { - super(clusterAdminClient, new DeleteLicenseRequest()); + public DeleteLicenseRequestBuilder(ElasticsearchClient client, DeleteLicenseAction action) { + super(client, action, new DeleteLicenseRequest()); } public DeleteLicenseRequestBuilder setFeatures(Set features) { request.features(features); return this; } - - - @Override - protected void doExecute(ActionListener listener) { - client.execute(DeleteLicenseAction.INSTANCE, request, listener); - } } \ No newline at end of file diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/TransportDeleteLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/TransportDeleteLicenseAction.java index 5e29bdcdfd7..78ec671596a 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/TransportDeleteLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/delete/TransportDeleteLicenseAction.java @@ -29,7 +29,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc @Inject public TransportDeleteLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService, ThreadPool threadPool, ActionFilters actionFilters) { - super(settings, DeleteLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters); + super(settings, DeleteLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteLicenseRequest.class); this.licensesManagerService = licensesManagerService; } @@ -38,11 +38,6 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc return ThreadPool.Names.MANAGEMENT; } - @Override - protected DeleteLicenseRequest newRequest() { - return new DeleteLicenseRequest(); - } - @Override protected DeleteLicenseResponse newResponse() { return new DeleteLicenseResponse(); @@ -50,7 +45,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc @Override protected ClusterBlockException checkBlock(DeleteLicenseRequest request, ClusterState state) { - return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, ""); + return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); } @Override diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/GetLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/GetLicenseAction.java index 6ffa332493a..d426b1b8aab 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/GetLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/GetLicenseAction.java @@ -5,10 +5,10 @@ */ package org.elasticsearch.license.plugin.action.get; -import org.elasticsearch.action.admin.cluster.ClusterAction; -import org.elasticsearch.client.ClusterAdminClient; +import org.elasticsearch.action.Action; +import org.elasticsearch.client.ElasticsearchClient; -public class GetLicenseAction extends ClusterAction { +public class GetLicenseAction extends Action { public static final GetLicenseAction INSTANCE = new GetLicenseAction(); public static final String NAME = "cluster:admin/plugin/license/get"; @@ -23,7 +23,7 @@ public class GetLicenseAction extends ClusterAction { @@ -22,16 +18,4 @@ public class GetLicenseRequest extends MasterNodeReadOperationRequest { +public class GetLicenseRequestBuilder extends MasterNodeReadOperationRequestBuilder { /** * Creates new get licenses request builder * - * @param clusterAdminClient cluster admin client + * @param client elasticsearch client */ - public GetLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) { - super(clusterAdminClient, new GetLicenseRequest()); - } - - - @Override - protected void doExecute(ActionListener listener) { - client.execute(GetLicenseAction.INSTANCE, request, listener); + public GetLicenseRequestBuilder(ElasticsearchClient client, GetLicenseAction action) { + super(client, action, new GetLicenseRequest()); } } \ No newline at end of file diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/TransportGetLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/TransportGetLicenseAction.java index bb163372cf9..177b6c7c85b 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/TransportGetLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/get/TransportGetLicenseAction.java @@ -26,7 +26,7 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA @Inject public TransportGetLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService, ThreadPool threadPool, ActionFilters actionFilters) { - super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters); + super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, GetLicenseRequest.class); this.licensesManagerService = licensesManagerService; } @@ -35,11 +35,6 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA return ThreadPool.Names.MANAGEMENT; } - @Override - protected GetLicenseRequest newRequest() { - return new GetLicenseRequest(); - } - @Override protected GetLicenseResponse newResponse() { return new GetLicenseResponse(); @@ -47,7 +42,7 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA @Override protected ClusterBlockException checkBlock(GetLicenseRequest request, ClusterState state) { - return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, ""); + return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_READ, ""); } @Override diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseAction.java index 554fc4dcb67..e90523b9c1d 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseAction.java @@ -5,10 +5,10 @@ */ package org.elasticsearch.license.plugin.action.put; -import org.elasticsearch.action.admin.cluster.ClusterAction; -import org.elasticsearch.client.ClusterAdminClient; +import org.elasticsearch.action.Action; +import org.elasticsearch.client.ElasticsearchClient; -public class PutLicenseAction extends ClusterAction { +public class PutLicenseAction extends Action { public static final PutLicenseAction INSTANCE = new PutLicenseAction(); public static final String NAME = "cluster:admin/plugin/license/put"; @@ -23,7 +23,7 @@ public class PutLicenseAction extends ClusterAction { try { return licenses(Licenses.fromSource(licenseDefinition)); } catch (IOException e) { - throw new ElasticsearchIllegalArgumentException("failed to parse licenses source", e); + throw new IllegalArgumentException("failed to parse licenses source", e); } } diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseRequestBuilder.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseRequestBuilder.java index fd9e8642ccd..a8d68cf0051 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseRequestBuilder.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/PutLicenseRequestBuilder.java @@ -5,9 +5,8 @@ */ package org.elasticsearch.license.plugin.action.put; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder; -import org.elasticsearch.client.ClusterAdminClient; +import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.license.core.License; import java.util.List; @@ -15,15 +14,15 @@ import java.util.List; /** * Register license request builder */ -public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder { +public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder { /** * Constructs register license request * - * @param clusterAdminClient cluster admin client + * @param client elasticsearch client */ - public PutLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) { - super(clusterAdminClient, new PutLicenseRequest()); + public PutLicenseRequestBuilder(ElasticsearchClient client, PutLicenseAction action) { + super(client, action, new PutLicenseRequest()); } /** @@ -41,9 +40,4 @@ public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder listener) { - client.execute(PutLicenseAction.INSTANCE, request, listener); - } } diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/TransportPutLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/TransportPutLicenseAction.java index 2f643a12778..80ee6fe7930 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/TransportPutLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/action/put/TransportPutLicenseAction.java @@ -29,7 +29,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio @Inject public TransportPutLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService, ThreadPool threadPool, ActionFilters actionFilters) { - super(settings, PutLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters); + super(settings, PutLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, PutLicenseRequest.class); this.licensesManagerService = licensesManagerService; } @@ -39,11 +39,6 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio return ThreadPool.Names.MANAGEMENT; } - @Override - protected PutLicenseRequest newRequest() { - return new PutLicenseRequest(); - } - @Override protected PutLicenseResponse newResponse() { return new PutLicenseResponse(); @@ -51,7 +46,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio @Override protected ClusterBlockException checkBlock(PutLicenseRequest request, ClusterState state) { - return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, ""); + return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, ""); } @Override diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesMetaData.java b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesMetaData.java index e34dd2f3801..a3e18f7afed 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesMetaData.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesMetaData.java @@ -5,11 +5,11 @@ */ package org.elasticsearch.license.plugin.core; +import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.license.core.License; @@ -17,17 +17,18 @@ import org.elasticsearch.license.core.Licenses; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.EnumSet; import java.util.List; /** * Contains metadata about registered licenses */ -public class LicensesMetaData implements MetaData.Custom { +public class LicensesMetaData extends AbstractDiffable implements MetaData.Custom { public static final String TYPE = "licenses"; - public static final Factory FACTORY = new Factory(); + public static final LicensesMetaData PROTO = new LicensesMetaData(Collections.emptyList(), Collections.emptyList()); private final ImmutableList signedLicenses; @@ -68,107 +69,87 @@ public class LicensesMetaData implements MetaData.Custom { return signedLicenses.hashCode() + 31 * trialLicenses.hashCode(); } - /** - * Licenses metadata factory - */ - public static class Factory extends MetaData.Custom.Factory { + @Override + public String type() { + return TYPE; + } - /** - * {@inheritDoc} - */ - @Override - public String type() { - return TYPE; - } - - /** - * {@inheritDoc} - */ - @Override - public LicensesMetaData readFrom(StreamInput in) throws IOException { - List signedLicenses = Licenses.readFrom(in); - int numTrialLicenses = in.readVInt(); - List trialLicenses = new ArrayList<>(numTrialLicenses); - for (int i = 0; i < numTrialLicenses; i++) { - trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(in.readString())); - } - return new LicensesMetaData(signedLicenses, trialLicenses); - } - - /** - * {@inheritDoc} - */ - @Override - public void writeTo(LicensesMetaData licensesMetaData, StreamOutput out) throws IOException { - Licenses.writeTo(licensesMetaData.signedLicenses, out); - out.writeVInt(licensesMetaData.trialLicenses.size()); - for (License trialLicense : licensesMetaData.trialLicenses) { - out.writeString(TrialLicenseUtils.toEncodedTrialLicense(trialLicense)); - } - } - - /** - * {@inheritDoc} - */ - @Override - public LicensesMetaData fromXContent(XContentParser parser) throws IOException { - List trialLicenses = new ArrayList<>(); - List signedLicenses = new ArrayList<>(); - XContentParser.Token token; - while (parser.currentToken() != XContentParser.Token.END_OBJECT) { - token = parser.nextToken(); - if (token == XContentParser.Token.FIELD_NAME) { - String fieldName = parser.text(); - if (fieldName != null) { - if (fieldName.equals(Fields.TRIAL_LICENSES)) { - if (parser.nextToken() == XContentParser.Token.START_ARRAY) { - while (parser.nextToken() != XContentParser.Token.END_ARRAY) { - if (parser.currentToken().isValue()) { - trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(parser.text())); - } + @Override + public LicensesMetaData fromXContent(XContentParser parser) throws IOException { + List trialLicenses = new ArrayList<>(); + List signedLicenses = new ArrayList<>(); + XContentParser.Token token; + while (parser.currentToken() != XContentParser.Token.END_OBJECT) { + token = parser.nextToken(); + if (token == XContentParser.Token.FIELD_NAME) { + String fieldName = parser.text(); + if (fieldName != null) { + if (fieldName.equals(Fields.TRIAL_LICENSES)) { + if (parser.nextToken() == XContentParser.Token.START_ARRAY) { + while (parser.nextToken() != XContentParser.Token.END_ARRAY) { + if (parser.currentToken().isValue()) { + trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(parser.text())); } } } - if (fieldName.equals(Fields.SIGNED_LICENCES)) { - if (parser.nextToken() == XContentParser.Token.START_ARRAY) { - while (parser.nextToken() != XContentParser.Token.END_ARRAY) { - License.Builder builder = License.builder().fromXContent(parser); - signedLicenses.add(builder.build()); - } + } + if (fieldName.equals(Fields.SIGNED_LICENCES)) { + if (parser.nextToken() == XContentParser.Token.START_ARRAY) { + while (parser.nextToken() != XContentParser.Token.END_ARRAY) { + License.Builder builder = License.builder().fromXContent(parser); + signedLicenses.add(builder.build()); } } } } } - return new LicensesMetaData(signedLicenses, trialLicenses); } + return new LicensesMetaData(signedLicenses, trialLicenses); + } - /** - * {@inheritDoc} - */ - @Override - public void toXContent(LicensesMetaData licensesMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException { - builder.startArray(Fields.TRIAL_LICENSES); - for (License trailLicense : licensesMetaData.trialLicenses) { - builder.value(TrialLicenseUtils.toEncodedTrialLicense(trailLicense)); - } - builder.endArray(); + @Override + public EnumSet context() { + return EnumSet.of(MetaData.XContentContext.GATEWAY); + } - builder.startArray(Fields.SIGNED_LICENCES); - for (License license : licensesMetaData.signedLicenses) { - license.toXContent(builder, params); - } - builder.endArray(); - } - - @Override - public EnumSet context() { - return EnumSet.of(MetaData.XContentContext.GATEWAY); - } - - private final static class Fields { - private static final String SIGNED_LICENCES = "signed_licenses"; - private static final String TRIAL_LICENSES = "trial_licenses"; + @Override + public void writeTo(StreamOutput streamOutput) throws IOException { + Licenses.writeTo(signedLicenses, streamOutput); + streamOutput.writeVInt(trialLicenses.size()); + for (License trialLicense : trialLicenses) { + streamOutput.writeString(TrialLicenseUtils.toEncodedTrialLicense(trialLicense)); } } + + @Override + public MetaData.Custom readFrom(StreamInput streamInput) throws IOException { + List signedLicenses = Licenses.readFrom(streamInput); + int numTrialLicenses = streamInput.readVInt(); + List trialLicenses = new ArrayList<>(numTrialLicenses); + for (int i = 0; i < numTrialLicenses; i++) { + trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(streamInput.readString())); + } + return new LicensesMetaData(signedLicenses, trialLicenses); + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startArray(Fields.TRIAL_LICENSES); + for (License trailLicense : trialLicenses) { + builder.value(TrialLicenseUtils.toEncodedTrialLicense(trailLicense)); + } + builder.endArray(); + + builder.startArray(Fields.SIGNED_LICENCES); + for (License license : signedLicenses) { + license.toXContent(builder, params); + } + builder.endArray(); + return builder; + } + + private final static class Fields { + private static final String SIGNED_LICENCES = "signed_licenses"; + private static final String TRIAL_LICENSES = "trial_licenses"; + } } \ No newline at end of file diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java index 6e80656b5e7..70d4aefdf97 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java @@ -37,7 +37,6 @@ import org.elasticsearch.transport.*; import java.io.IOException; import java.util.*; import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -128,7 +127,8 @@ public class LicensesService extends AbstractLifecycleComponent this.transportService = transportService; this.lastObservedLicensesState = new AtomicReference<>(null); if (DiscoveryNode.masterNode(settings)) { - transportService.registerHandler(REGISTER_TRIAL_LICENSE_ACTION_NAME, new RegisterTrialLicenseRequestHandler()); + transportService.registerRequestHandler(REGISTER_TRIAL_LICENSE_ACTION_NAME, RegisterTrialLicenseRequest.class, + ThreadPool.Names.SAME, new RegisterTrialLicenseRequestHandler()); } } @@ -1087,21 +1087,12 @@ public class LicensesService extends AbstractLifecycleComponent /** * Request handler for trial license generation to master */ - private class RegisterTrialLicenseRequestHandler extends BaseTransportRequestHandler { - @Override - public RegisterTrialLicenseRequest newInstance() { - return new RegisterTrialLicenseRequest(); - } + private class RegisterTrialLicenseRequestHandler implements TransportRequestHandler { @Override public void messageReceived(RegisterTrialLicenseRequest request, TransportChannel channel) throws Exception { registerTrialLicense(request); channel.sendResponse(TransportResponse.Empty.INSTANCE); } - - @Override - public String executor() { - return ThreadPool.Names.SAME; - } } } diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesStatus.java b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesStatus.java index 631a3c5dca2..3bd18d58770 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesStatus.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesStatus.java @@ -5,8 +5,6 @@ */ package org.elasticsearch.license.plugin.core; -import org.elasticsearch.ElasticsearchIllegalStateException; - public enum LicensesStatus { VALID((byte) 0), INVALID((byte) 1), @@ -30,7 +28,7 @@ public enum LicensesStatus { } else if (id == 2) { return EXPIRED; } else { - throw new ElasticsearchIllegalStateException("no valid LicensesStatus for id=" + id); + throw new IllegalStateException("no valid LicensesStatus for id=" + id); } } } diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestDeleteLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestDeleteLicenseAction.java index c919ad92995..43ce98e7a9b 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestDeleteLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestDeleteLicenseAction.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.license.plugin.rest; -import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.client.Client; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -34,10 +33,9 @@ public class RestDeleteLicenseAction extends BaseRestHandler { public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] features = Strings.splitStringByCommaToArray(request.param("features")); if (features.length == 0) { - throw new ElasticsearchIllegalArgumentException("no feature specified for license deletion"); + throw new IllegalArgumentException("no feature specified for license deletion"); } DeleteLicenseRequest deleteLicenseRequest = new DeleteLicenseRequest(features); - deleteLicenseRequest.listenerThreaded(false); client.admin().cluster().execute(DeleteLicenseAction.INSTANCE, deleteLicenseRequest, new AcknowledgedRestListener(channel)); } } diff --git a/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestPutLicenseAction.java b/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestPutLicenseAction.java index d0d6d85b1e9..c469d0a0f8c 100644 --- a/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestPutLicenseAction.java +++ b/plugin/src/main/java/org/elasticsearch/license/plugin/rest/RestPutLicenseAction.java @@ -37,7 +37,6 @@ public class RestPutLicenseAction extends BaseRestHandler { @Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { PutLicenseRequest putLicenseRequest = new PutLicenseRequest(); - putLicenseRequest.listenerThreaded(false); putLicenseRequest.licenses(request.content().toUtf8()); client.admin().cluster().execute(PutLicenseAction.INSTANCE, putLicenseRequest, new LicensesAcknowledgedListener(channel)); } diff --git a/plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTests.java b/plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTests.java index f47391aaba7..776921a3189 100644 --- a/plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.core.License; +import org.elasticsearch.license.plugin.action.put.PutLicenseAction; import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.put.PutLicenseResponse; import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService; @@ -32,6 +33,7 @@ import org.elasticsearch.test.InternalTestCluster; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -45,12 +47,22 @@ public abstract class AbstractLicensesIntegrationTests extends ElasticsearchInte private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer(); private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS); - public static String dateMathString(String time, long now) { - return dateTimeFormatter.print(dateMathParser.parse(time, now)); + public static String dateMathString(String time, final long now) { + return dateTimeFormatter.print(dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + })); } - public static long dateMath(String time, long now) { - return dateMathParser.parse(time, now); + public static long dateMath(String time, final long now) { + return dateMathParser.parse(time, new Callable() { + @Override + public Long call() throws Exception { + return now; + } + }); } @Override protected Settings nodeSettings(int nodeOrdinal) { @@ -92,7 +104,7 @@ public abstract class AbstractLicensesIntegrationTests extends ElasticsearchInte protected void putLicense(String feature, TimeValue expiryDuration) throws Exception { License license1 = generateSignedLicense(feature, expiryDuration); - final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster()).setLicense(Lists.newArrayList(license1)).get(); + final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(Lists.newArrayList(license1)).get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); } diff --git a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesMetaDataSerializationTests.java b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesMetaDataSerializationTests.java index 13078b58faa..69a16710d6c 100644 --- a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesMetaDataSerializationTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesMetaDataSerializationTests.java @@ -31,7 +31,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { LicensesMetaData licensesMetaData = new LicensesMetaData(Arrays.asList(license), new ArrayList()); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject("licensesMetaData"); - LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS); + licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); byte[] serializedBytes = builder.bytes().toBytes(); @@ -52,7 +52,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, new ArrayList()); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject("licensesMetaData"); - LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS); + licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); byte[] serializedBytes = builder.bytes().toBytes(); @@ -75,7 +75,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList(), Arrays.asList(trialLicense)); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject("licensesMetaData"); - LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS); + licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); byte[] serializedBytes = builder.bytes().toBytes(); @@ -101,7 +101,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList(), trialLicenses); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject("licensesMetaData"); - LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS); + licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); byte[] serializedBytes = builder.bytes().toBytes(); @@ -131,7 +131,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, trialLicenses); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject("licensesMetaData"); - LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS); + licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); byte[] serializedBytes = builder.bytes().toBytes(); @@ -147,7 +147,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase { final XContentParser parser = XContentFactory.xContent(bytes).createParser(bytes); parser.nextToken(); // consume null parser.nextToken(); // consume "licensesMetaData" - LicensesMetaData licensesMetaDataFromXContent = LicensesMetaData.FACTORY.fromXContent(parser); + LicensesMetaData licensesMetaDataFromXContent = LicensesMetaData.PROTO.fromXContent(parser); parser.nextToken(); // consume endObject assertThat(parser.nextToken(), nullValue()); return licensesMetaDataFromXContent; diff --git a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceClusterTest.java b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceClusterTest.java index 98fc5908ee3..5afb2ef4d42 100644 --- a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceClusterTest.java +++ b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceClusterTest.java @@ -10,8 +10,10 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.core.License; +import org.elasticsearch.license.plugin.action.get.GetLicenseAction; import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.get.GetLicenseResponse; +import org.elasticsearch.license.plugin.action.put.PutLicenseAction; import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.put.PutLicenseResponse; import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin; @@ -20,7 +22,7 @@ import org.elasticsearch.license.plugin.consumer.LazyLicenseRegistrationConsumer import org.elasticsearch.license.plugin.consumer.LazyLicenseRegistrationPluginService; import org.elasticsearch.license.plugin.core.LicensesMetaData; import org.elasticsearch.license.plugin.core.LicensesStatus; -import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.node.Node; import org.junit.Test; import java.util.ArrayList; @@ -57,7 +59,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests .put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2) .put(LazyLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2) .putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName(), LazyLicenseRegistrationConsumerPlugin.class.getName()) - .put(InternalNode.HTTP_ENABLED, true); + .put(Node.HTTP_ENABLED, true); } @Test @@ -124,7 +126,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests for (String feature : FEATURES) { putLicenses.add(generateSignedLicense(feature, TimeValue.timeValueMinutes(1))); } - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(cluster); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(cluster, PutLicenseAction.INSTANCE); putLicenseRequestBuilder.setLicense(putLicenses); ensureGreen(); @@ -138,7 +140,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests private void getAndCheckLicense(List licenses) { ClusterAdminClient cluster = internalCluster().client().admin().cluster(); - final GetLicenseResponse response = new GetLicenseRequestBuilder(cluster).get(); + final GetLicenseResponse response = new GetLicenseRequestBuilder(cluster, GetLicenseAction.INSTANCE).get(); assertThat(response.licenses().size(), equalTo(licenses.size())); TestUtils.isSame(licenses, response.licenses()); diff --git a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java index 59855b10b21..485c2237e8d 100644 --- a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin; import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService; -import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.node.Node; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.junit.annotations.TestLogging; import org.junit.Test; @@ -31,7 +31,7 @@ public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTests { .put(super.nodeSettings(nodeOrdinal)) .put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 60 * 5) .putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName()) - .put(InternalNode.HTTP_ENABLED, true) + .put(Node.HTTP_ENABLED, true) .build(); } diff --git a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java index 3f8412addb2..4a9699a774c 100644 --- a/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java @@ -9,10 +9,13 @@ import org.elasticsearch.action.ActionFuture; import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.core.License; +import org.elasticsearch.license.plugin.action.delete.DeleteLicenseAction; import org.elasticsearch.license.plugin.action.delete.DeleteLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.delete.DeleteLicenseResponse; +import org.elasticsearch.license.plugin.action.get.GetLicenseAction; import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.get.GetLicenseResponse; +import org.elasticsearch.license.plugin.action.put.PutLicenseAction; import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder; import org.elasticsearch.license.plugin.action.put.PutLicenseResponse; import org.elasticsearch.license.plugin.core.LicensesStatus; @@ -39,7 +42,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { @Test public void testEmptyGetLicense() throws Exception { - final ActionFuture getLicenseFuture = new GetLicenseRequestBuilder(client().admin().cluster()).execute(); + final ActionFuture getLicenseFuture = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute(); final GetLicenseResponse getLicenseResponse = getLicenseFuture.get(); assertThat("expected 0 licenses; but got: " + getLicenseResponse.licenses().size(), getLicenseResponse.licenses().size(), equalTo(0)); } @@ -50,14 +53,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Collections.singletonList(signedLicense); // put license - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(1)); @@ -71,14 +74,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { String licenseString = TestUtils.dumpLicense(signedLicense); // put license source - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(licenseString); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(1)); @@ -97,7 +100,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { .validate() .build(); - PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster()); + PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE); builder.setLicense(Collections.singletonList(tamperedLicense)); // try to put license (should be invalid) @@ -105,7 +108,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.INVALID)); // try to get invalid license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses().size(), equalTo(0)); } @@ -114,7 +117,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { License expiredLicense = generateSignedLicense("feature", dateMath("now-10d/d", System.currentTimeMillis()), TimeValue.timeValueMinutes(2)); License signedLicense = generateSignedLicense("feature", TimeValue.timeValueMinutes(2)); - PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster()); + PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE); builder.setLicense(Arrays.asList(signedLicense, expiredLicense)); // put license should return valid (as there is one valid license) @@ -122,7 +125,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get license should not return the expired license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses().size(), equalTo(1)); TestUtils.isSame(getLicenseResponse.licenses().get(0), signedLicense); @@ -135,14 +138,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Arrays.asList(longerSignedLicense, shortedSignedLicense); // put license - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get should return only one license (with longer expiry date) - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(1)); @@ -157,14 +160,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Arrays.asList(marvelLicense, shieldLicense); // put license - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get should return both the licenses - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); // check license @@ -179,14 +182,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Arrays.asList(marvelLicense, shortedSignedLicense, longerSignedLicense); // put license - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get should return both the licenses - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(2)); @@ -201,25 +204,25 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Arrays.asList(marvelLicense, shieldLicense); // put two licenses - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get and check licenses - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(2)); // delete all licenses - DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster()) + DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE) .setFeatures(Sets.newHashSet("shield", "marvel")); DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get(); assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true)); // get licenses (expected no licenses) - getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(0)); } @@ -231,31 +234,31 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests { List actualLicenses = Arrays.asList(marvelLicense, shieldLicense); // put two licenses - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster()) + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE) .setLicense(actualLicenses); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // delete one license - DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster()) + DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE) .setFeatures(Sets.newHashSet("shield")); DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get(); assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true)); // check other license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(1)); // delete another license - deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster()) + deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE) .setFeatures(Sets.newHashSet("marvel")); deleteLicenseResponse = deleteLicenseRequestBuilder.get(); assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true)); // check no license - getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get(); + getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.licenses(), notNullValue()); assertThat(getLicenseResponse.licenses().size(), equalTo(0)); } diff --git a/pom.xml b/pom.xml index c9e0e66fd69..856878adbf6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,6 +4,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.elasticsearch + elasticsearch-parent + 2.0.0-SNAPSHOT + + org.elasticsearch elasticsearch-license pom @@ -16,17 +22,6 @@ - UTF-8 - 1.4.0 - 4.10.2 - auto - true - onerror - ${project.basedir}/backwards - INFO - 512m - 5 - .local-${project.version}-execution-hints.log ${project.basedir} @@ -36,13 +31,11 @@ org.apache.lucene lucene-test-framework - ${lucene.version} test org.elasticsearch elasticsearch - ${elasticsearch.version} test test-jar @@ -61,13 +54,11 @@ com.carrotsearch.randomizedtesting randomizedtesting-runner - 2.1.10 test log4j log4j - 1.2.17 test @@ -75,7 +66,7 @@ org.elasticsearch elasticsearch - ${elasticsearch.version} + provided @@ -85,7 +76,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -107,15 +97,10 @@ org.apache.maven.plugins maven-surefire-plugin - 2.16 - - true - de.thetaphi forbiddenapis - 1.6.1 @@ -200,7 +185,6 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.3.1 enforce-versions @@ -278,7 +262,6 @@ com.carrotsearch.randomizedtesting junit4-maven-plugin - 2.1.2 ${tests.jvm.argline}