NO-JIRA fixing NettySecurityClientTest

This commit is contained in:
Clebert Suconic 2017-04-18 12:43:58 -04:00
parent 1f82c783a7
commit c82ac631b8
7 changed files with 33 additions and 16 deletions

View File

@ -18,20 +18,28 @@
package org.apache.activemq.artemis.core.remoting.impl.netty;
import org.apache.activemq.artemis.utils.Env;
import org.jboss.logging.Logger;
/**
* Tells if <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is supported.
*/
public final class Epoll {
private static final boolean IS_AVAILABLE_EPOLL;
private static final Logger logger = Logger.getLogger(Epoll.class);
private static final boolean IS_AVAILABLE_EPOLL = isIsAvailableEpoll();
static {
if (Env.is64BitJvm() && Env.isLinuxOs()) {
IS_AVAILABLE_EPOLL = io.netty.channel.epoll.Epoll.isAvailable();
} else {
IS_AVAILABLE_EPOLL = false;
private static boolean isIsAvailableEpoll() {
try {
if (Env.is64BitJvm() && Env.isLinuxOs()) {
return io.netty.channel.epoll.Epoll.isAvailable();
} else {
return false;
}
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
return false;
}
}
private Epoll() {

View File

@ -164,7 +164,7 @@ public class JournalCrashTest extends ActiveMQTestBase {
*/
private void runExternalProcess(final String tempDir, final int start, final int end) throws Exception {
System.err.println("running external process...");
Process process = SpawnedVMSupport.spawnVM(this.getClass().getCanonicalName(), "-Xms128m", "-Xmx128m", new String[]{}, true, true, tempDir, Integer.toString(start), Integer.toString(end));
Process process = SpawnedVMSupport.spawnVM(this.getClass().getCanonicalName(), "-Xms128m", "-Xmx128m", new String[]{}, true, true, true, tempDir, Integer.toString(start), Integer.toString(end));
Assert.assertEquals(100, process.waitFor());
}

View File

@ -45,7 +45,7 @@ public class RealNodeManagerTest extends NodeManagerTest {
public void performWork(NodeManagerAction... actions) throws Exception {
List<Process> processes = new ArrayList<>();
for (NodeManagerAction action : actions) {
Process p = SpawnedVMSupport.spawnVM(NodeManagerAction.class.getName(), "-Xms512m", "-Xmx512m", new String[0], true, true, action.getWork());
Process p = SpawnedVMSupport.spawnVM(NodeManagerAction.class.getName(), "-Xms512m", "-Xmx512m", new String[0], true, true, true, action.getWork());
processes.add(p);
}
for (Process process : processes) {

View File

@ -66,14 +66,13 @@ public class NettySecurityClientTest extends ActiveMQTestBase {
// spawn a JVM that creates a client with a security manager which sends and receives a
// test message
Process p = SpawnedVMSupport.spawnVM(SimpleClient.class.getName(), "-Xms512m", "-Xmx512m", vmargs, false, true, new String[]{NETTY_CONNECTOR_FACTORY});
Process p = SpawnedVMSupport.spawnVM(SimpleClient.class.getName(), "-Xms512m", "-Xmx512m", vmargs, true, true, false, new String[]{NETTY_CONNECTOR_FACTORY});
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
//System.out.println(line);
line = line.replace('|', '\n');
if (line.startsWith("Listening")) {
continue;

View File

@ -37,12 +37,14 @@ final class SimpleClient {
if (args.length != 1) {
throw new Exception("require 1 argument: connector factory class name");
}
System.out.println("I'm here");
String connectorFactoryClassName = args[0];
String queueName = RandomUtil.randomString();
String messageText = RandomUtil.randomString();
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorFactoryClassName));
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorFactoryClassName)).setReconnectAttempts(1).setInitialConnectAttempts(1);
try {
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
@ -77,6 +79,7 @@ final class SimpleClient {
locator.close();
}
} catch (Throwable t) {
t.printStackTrace(System.out);
String allStack = t.getMessage() + "|";
StackTraceElement[] stackTrace = t.getStackTrace();

View File

@ -29,6 +29,9 @@ grant {
permission java.util.PropertyPermission "activemq.artemis.client.global.thread.pool.max.size", "read";
permission java.util.PropertyPermission "activemq.artemis.client.global.scheduled.thread.pool.core.size", "read";
permission java.util.PropertyPermission "io.netty.eventLoopThreads", "read";
permission java.util.PropertyPermission "io.netty.maxThreadLocalCharBufferSize", "read";
permission java.util.PropertyPermission "io.netty.batch.bytes", "read";
permission java.util.PropertyPermission "com.ibm.vm.bitmode", "read";
permission java.util.PropertyPermission "io.netty.noUnsafe", "read";
permission java.util.PropertyPermission "io.netty.tryUnsafe", "read";
permission java.util.PropertyPermission "org.jboss.netty.tryUnsafe", "read";

View File

@ -57,7 +57,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final String... args) throws Exception {
return SpawnedVMSupport.spawnVM(className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args);
return SpawnedVMSupport.spawnVM(className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, true, args);
}
public static Process spawnVMWithLogMacher(String wordMatch,
@ -66,7 +66,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final String... args) throws Exception {
return SpawnedVMSupport.spawnVM(wordMatch, runnable, className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args);
return SpawnedVMSupport.spawnVM(wordMatch, runnable, className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, true, args);
}
public static Process spawnVM(final String className,
@ -75,8 +75,9 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final boolean logErrorOutput,
final boolean useLogging,
final String... args) throws Exception {
return spawnVM(null, null, className, memoryArg1, memoryArg2, vmargs, logOutput, logErrorOutput, args);
return spawnVM(null, null, className, memoryArg1, memoryArg2, vmargs, logOutput, logErrorOutput, useLogging, args);
}
public static Process spawnVM(final String wordMatch,
@ -87,6 +88,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final boolean logErrorOutput,
final boolean useLogging,
final String... args) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
final String javaPath = Paths.get(System.getProperty("java.home"), "bin", "java").toAbsolutePath().toString();
@ -102,8 +104,10 @@ public final class SpawnedVMSupport {
}
// The logs will be huge if you don't set this
commandList.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
commandList.add("-Dlogging.configuration=file:../config/logging.properties");
if (useLogging) {
commandList.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
commandList.add("-Dlogging.configuration=file:../config/logging.properties");
}
commandList.add("-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir", "./tmp"));
commandList.add("-Djava.library.path=" + System.getProperty("java.library.path", "./native/bin"));