From 776bb288b56fc11a71e33fdfbb7fe0507b857c8c Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 13 Nov 2015 00:56:39 -0500 Subject: [PATCH] fix gradle check under jigsaw closes #14726 Squashed commit of the following: commit 5b591e98570e3fa481b2816a44063b98bff36ddf Author: Robert Muir Date: Fri Nov 13 00:54:08 2015 -0500 add assumption for self-signing in PluginManagerTests commit ed11e5371b6f71591dc41c6f60d033502cfcf029 Author: Robert Muir Date: Fri Nov 13 00:20:59 2015 -0500 show error output from integ test startup commit d8b187a10e95d89a0e775333dcbe1aaa903fb376 Author: Robert Muir Date: Thu Nov 12 22:14:11 2015 -0500 fix gradle check under jigsaw --- .../gradle/test/ClusterFormationTasks.groovy | 9 --------- .../org/elasticsearch/ESExceptionTests.java | 9 ++------- .../ExceptionSerializationTests.java | 15 ++++++--------- .../elasticsearch/index/store/StoreTests.java | 4 ++-- .../plugins/PluginManagerTests.java | 11 +++++++++-- .../org/elasticsearch/test/ESTestCase.java | 18 ++++++++++++++++++ 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 77f85be06a3..847de12b995 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -264,16 +264,7 @@ class ClusterFormationTasks { args esExecutable args esProps environment esEnv - errorOutput = new ByteArrayOutputStream() doLast { - if (errorOutput.toString().isEmpty() == false) { - logger.error(errorOutput.toString()) - File logFile = new File(home, "logs/${clusterName}.log") - if (logFile.exists()) { - logFile.eachLine { line -> logger.error(line) } - } - throw new GradleException('Failed to start elasticsearch') - } esPostStartActions(ant, logger) } } diff --git a/core/src/test/java/org/elasticsearch/ESExceptionTests.java b/core/src/test/java/org/elasticsearch/ESExceptionTests.java index 5aeaf9601ef..91be1f339dd 100644 --- a/core/src/test/java/org/elasticsearch/ESExceptionTests.java +++ b/core/src/test/java/org/elasticsearch/ESExceptionTests.java @@ -336,16 +336,11 @@ public class ESExceptionTests extends ESTestCase { } else { assertEquals(e.getCause().getClass(), NotSerializableExceptionWrapper.class); } - // TODO: fix this test - // on java 9, expected: - // but was: - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - assertArrayEquals(e.getStackTrace(), ex.getStackTrace()); - } + assertArrayEquals(e.getStackTrace(), ex.getStackTrace()); assertTrue(e.getStackTrace().length > 1); ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), t); ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), ex); ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), e); } } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 55dc2e42113..6e04de80c81 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -561,15 +561,12 @@ public class ExceptionSerializationTests extends ESTestCase { } Throwable deserialized = serialize(t); assertTrue(deserialized instanceof NotSerializableExceptionWrapper); - // TODO: fix this test for more java 9 differences - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace()); - assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length); - if (t.getSuppressed().length > 0) { - assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper); - assertArrayEquals(t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace()); - assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException); - } + assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace()); + assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length); + if (t.getSuppressed().length > 0) { + assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper); + assertArrayEquals(t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace()); + assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException); } } } diff --git a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java index 557ea1d9239..86a94056c77 100644 --- a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java +++ b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java @@ -1387,7 +1387,7 @@ public class StoreTests extends ESTestCase { } catch (CorruptIndexException e) { assertEquals(ex.getMessage(), e.getMessage()); assertEquals(ex.toString(), e.toString()); - assertEquals(ExceptionsHelper.stackTrace(ex), ExceptionsHelper.stackTrace(e)); + assertArrayEquals(ex.getStackTrace(), e.getStackTrace()); } store.removeCorruptionMarker(); @@ -1399,7 +1399,7 @@ public class StoreTests extends ESTestCase { fail("should be corrupted"); } catch (CorruptIndexException e) { assertEquals("foobar (resource=preexisting_corruption)", e.getMessage()); - assertEquals(ExceptionsHelper.stackTrace(ioe), ExceptionsHelper.stackTrace(e.getCause())); + assertArrayEquals(ioe.getStackTrace(), e.getCause().getStackTrace()); } store.close(); } diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/plugins/PluginManagerTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/plugins/PluginManagerTests.java index 23dae876210..b6323df7931 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/plugins/PluginManagerTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/plugins/PluginManagerTests.java @@ -661,9 +661,14 @@ public class PluginManagerTests extends ESIntegTestCase { SSLSocketFactory defaultSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); ServerBootstrap serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory()); - SelfSignedCertificate ssc = new SelfSignedCertificate("localhost"); + SelfSignedCertificate ssc = null; try { + try { + ssc = new SelfSignedCertificate("localhost"); + } catch (Exception e) { + assumeNoException("self signing shenanigans not supported by this JDK", e); + } // Create a trust manager that does not validate certificate chains: SSLContext sc = SSLContext.getInstance("SSL"); @@ -700,7 +705,9 @@ public class PluginManagerTests extends ESIntegTestCase { } finally { HttpsURLConnection.setDefaultSSLSocketFactory(defaultSocketFactory); serverBootstrap.releaseExternalResources(); - ssc.delete(); + if (ssc != null) { + ssc.delete(); + } } } diff --git a/test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java index c5e87f4a689..b0841033a99 100644 --- a/test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -36,6 +36,7 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; import org.apache.lucene.util.TestRuleMarkFailure; import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TimeUnits; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.bootstrap.BootstrapForTesting; import org.elasticsearch.cache.recycler.MockPageCacheRecycler; @@ -616,4 +617,21 @@ public abstract class ESTestCase extends LuceneTestCase { public static TestRuleMarkFailure getSuiteFailureMarker() { return suiteFailureMarker; } + + /** Compares two stack traces, ignoring module (which is not yet serialized) */ + public static void assertArrayEquals(StackTraceElement expected[], StackTraceElement actual[]) { + assertEquals(expected.length, actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals(expected[i], actual[i]); + } + } + + /** Compares two stack trace elements, ignoring module (which is not yet serialized) */ + public static void assertEquals(StackTraceElement expected, StackTraceElement actual) { + assertEquals(expected.getClassName(), actual.getClassName()); + assertEquals(expected.getMethodName(), actual.getMethodName()); + assertEquals(expected.getFileName(), actual.getFileName()); + assertEquals(expected.getLineNumber(), actual.getLineNumber()); + assertEquals(expected.isNativeMethod(), actual.isNativeMethod()); + } }