This is an automated email from the ASF dual-hosted git repository. eolivelli pushed a commit to branch 2.7.2_ds_tmp in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 0550df69efcb0524387f403a5869ca74a7d30a6d Author: Enrico Olivelli <eolive...@gmail.com> AuthorDate: Sun Mar 14 03:13:57 2021 +0100 More fixes about running tests on JDK11 (#9893) When you are running tests on JDK11 you encounter a lot of issues. This patch includes a list of minor fixes that can be grouped. Master issue #9578 - Upgrade Mockito to latest version - Add "--add-opens java.base/jdk.internal.loader=ALL-UNNAMED" in order to allow PowerMock to work - add JAXB into jcloud provider (we already have it on the classpath in production, it is only in order to let tests run) - Upgrade HDFS minicluster to 3.3.0 - Pin netty-codec-http dependency to the same version of netty (inherited from HDFS client) - Use the same version of Jetty for hdfs-offload (old version does not work with JDK11) --- pom.xml | 13 ++++++++++- pulsar-client/pom.xml | 6 +++++ .../pulsar/client/impl/PulsarClientImplTest.java | 7 +++--- tiered-storage/file-system/pom.xml | 12 +++++++--- tiered-storage/jcloud/pom.xml | 26 ++++++++++++++++++++++ 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 44ec252..52bbd0d 100644 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,7 @@ <testcontainers.version>1.14.3</testcontainers.version> <kerby.version>1.1.1</kerby.version> <testng.version>7.3.0</testng.version> - <mockito.version>3.0.0</mockito.version> + <mockito.version>3.8.0</mockito.version> <powermock.version>2.0.9</powermock.version> <javassist.version>3.25.0-GA</javassist.version> <failsafe.version>2.3.1</failsafe.version> @@ -1096,6 +1096,7 @@ -Dpulsar.allocator.leak_detection=Advanced -Dpulsar.allocator.exit_on_oom=false -Dlog4j.configurationFile=log4j2.xml + ${test.additional.args} </argLine> <reuseForks>${testReuseFork}</reuseForks> <forkCount>${testForkCount}</forkCount> @@ -1490,6 +1491,15 @@ <profiles> <profile> + <id>jdk11-tests</id> + <activation> + <jdk>[11,)</jdk> + </activation> + <properties> + <test.additional.args> --add-opens java.base/jdk.internal.loader=ALL-UNNAMED </test.additional.args> + </properties> + </profile> + <profile> <id>coverage</id> <build> <plugins> @@ -1614,6 +1624,7 @@ <id>main</id> <activation> <activeByDefault>true</activeByDefault> + <jdk>[8,)</jdk> </activation> <modules> <module>buildtools</module> diff --git a/pulsar-client/pom.xml b/pulsar-client/pom.xml index 24920fc..cefece2 100644 --- a/pulsar-client/pom.xml +++ b/pulsar-client/pom.xml @@ -162,6 +162,12 @@ <version>${skyscreamer.version}</version> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </dependency> + </dependencies> <build> diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/PulsarClientImplTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/PulsarClientImplTest.java index d712c26..1dac09b 100644 --- a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/PulsarClientImplTest.java +++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/PulsarClientImplTest.java @@ -27,7 +27,6 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotSame; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; - import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -56,8 +55,8 @@ import org.apache.pulsar.common.naming.NamespaceName; import org.apache.pulsar.common.naming.TopicName; import org.apache.pulsar.common.partition.PartitionedTopicMetadata; import org.apache.pulsar.common.util.netty.EventLoopUtil; -import org.mockito.internal.util.reflection.FieldSetter; import org.mockito.Mockito; +import org.powermock.reflect.Whitebox; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -118,8 +117,8 @@ public class PulsarClientImplTest { .thenReturn(CompletableFuture.completedFuture(mock(ProducerResponse.class))); when(pool.getConnection(any(InetSocketAddress.class), any(InetSocketAddress.class))) .thenReturn(CompletableFuture.completedFuture(cnx)); - FieldSetter.setField(clientImpl, clientImpl.getClass().getDeclaredField("cnxPool"), pool); - FieldSetter.setField(clientImpl, clientImpl.getClass().getDeclaredField("lookup"), lookup); + Whitebox.setInternalState(clientImpl, "cnxPool", pool); + Whitebox.setInternalState(clientImpl, "lookup", lookup); List<ConsumerBase<byte[]>> consumers = new ArrayList<>(); /** diff --git a/tiered-storage/file-system/pom.xml b/tiered-storage/file-system/pom.xml index df50d1d..2e201d9 100644 --- a/tiered-storage/file-system/pom.xml +++ b/tiered-storage/file-system/pom.xml @@ -71,22 +71,28 @@ </exclusion> </exclusions> </dependency> + + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-codec-http</artifactId> + </dependency> + <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> - <version>${org.eclipse.jetty-hdfs-offload}</version> + <version>${jetty.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-servlet</artifactId> - <version>${org.eclipse.jetty-hdfs-offload}</version> + <version>${jetty.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</artifactId> - <version>${org.eclipse.jetty-hdfs-offload}</version> + <version>${jetty.version}</version> <scope>test</scope> </dependency> </dependencies> diff --git a/tiered-storage/jcloud/pom.xml b/tiered-storage/jcloud/pom.xml index 35fcc54..852cb61 100644 --- a/tiered-storage/jcloud/pom.xml +++ b/tiered-storage/jcloud/pom.xml @@ -87,6 +87,32 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.jclouds</groupId> + <artifactId>jclouds-blobstore</artifactId> + <version>${jclouds.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <exclusions> + <exclusion> + <groupId>javax.activation</groupId> + <artifactId>javax.activation-api</artifactId> + </exclusion> + </exclusions> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>javax.activation</artifactId> + <scope>runtime</scope> + </dependency> + </dependencies> <build> <plugins>