8067316: TEST_BUG: update RMI test library with better test.timeout.factor handling
Reviewed-by: lancea
This commit is contained in:
parent
3ad1d2a580
commit
457488c158
jdk/test/java/rmi
activation
Activatable
checkActivateRef
checkAnnotations
checkRegisterInLog
createPrivateActivable
downloadParameterClass
elucidateNoSuchMethod
extLoadedImpl
forceLogSnapshot
inactiveGroup
nestedActivate
nonExistentActivatable
restartCrashedService
restartLatecomer
restartService
shutdownGracefully
unregisterInactive
ActivateFailedException/activateFails
ActivationGroup/downloadActivationGroup
ActivationSystem
modifyDescriptor
stubClassesPermitted
unregisterGroup
CommandEnvironment
server
RMISocketFactory/useSocketFactory/activatable
RemoteServer/setLogPermission
testlibrary
@ -4,8 +4,8 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
|
||||
permission java.lang.RuntimePermission "getClassLoader";
|
||||
};
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* security policy used by activation groups.
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept";
|
||||
|
||||
// allow exporting object with non-public remote interface
|
||||
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* security policy used activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
|
||||
// allow exporting object with non-public remote interface
|
||||
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,14 +1,15 @@
|
||||
/*
|
||||
* security policy used exec'ed activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
|
||||
// need to load custom security manager and activation group from a new codebase
|
||||
permission java.io.FilePermission ".${/}codebase1", "read,write,delete";
|
||||
permission java.io.FilePermission ".${/}codebase1${/}-", "read,write";
|
||||
permission java.io.FilePermission ".${/}codebase2", "read,write,delete";
|
||||
permission java.io.FilePermission ".${/}codebase2${/}-", "read,write,delete";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
};
|
||||
|
@ -1,12 +1,13 @@
|
||||
/*
|
||||
* security policy used activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
|
||||
// Needed because of bug#: 4182104
|
||||
permission java.lang.RuntimePermission "modifyThreadGroup";
|
||||
permission java.lang.RuntimePermission "modifyThread";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* security policy used exec'ed activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -3,9 +3,7 @@
|
||||
*/
|
||||
|
||||
grant {
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
|
||||
// allow exporting object with non-public remote interface
|
||||
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
|
||||
// allow exporting object with non-public remote interface
|
||||
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* security policy used by test activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
|
||||
// allow exporting of non-public remote interface
|
||||
permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* security policy used by test activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
// test needs to communicate with the activation system
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
grant {
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
grant {
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* security policy used activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// allow remote objects to be exported on arbitrary ports.
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* security policy used activation groups
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
// test needs to communicate with the activation system
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* security policy used by downloaded activation group
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
};
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// accomodate property used by this test.
|
||||
permission java.util.PropertyPermission "test.message", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* security policy used by activation groups.
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// give the group permission to create a class that the main test process can not create
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.provider";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.provider";
|
||||
};
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "unregisterGroup.port", "read";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* security policy used by activation groups.
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
// test needs to communicate with the activation system
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* security policy used by the rmid process exec'ed by a running
|
||||
* instance of the test.
|
||||
* security policy used by activation groups
|
||||
*/
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
// test needs to communicate with the activation system
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,7 @@
|
||||
* The RemoteServer.setLog method requires
|
||||
* java.util.log.LoggingPermission("control").
|
||||
* @author Ann Wollrath
|
||||
* @run main/othervm/policy=java.policy SetLogPermission
|
||||
* @run main/othervm/policy=security.policy SetLogPermission
|
||||
*/
|
||||
|
||||
import java.rmi.server.RemoteServer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,20 +40,6 @@ import java.rmi.registry.LocateRegistry;
|
||||
* objects.
|
||||
*/
|
||||
public class ActivationLibrary {
|
||||
/** time safeDestroy should wait before failing on shutdown rmid */
|
||||
private static final int SAFE_WAIT_TIME;
|
||||
static {
|
||||
int slopFactor = 1;
|
||||
try {
|
||||
slopFactor = Integer.valueOf(
|
||||
TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
|
||||
} catch (NumberFormatException ignore) {}
|
||||
SAFE_WAIT_TIME = 60000 * slopFactor;
|
||||
}
|
||||
|
||||
private static final String SYSTEM_NAME =
|
||||
ActivationSystem.class.getName();
|
||||
|
||||
private static void mesg(Object mesg) {
|
||||
System.err.println("ACTIVATION_LIBRARY: " + mesg.toString());
|
||||
}
|
||||
@ -63,20 +49,19 @@ public class ActivationLibrary {
|
||||
*/
|
||||
public static void deactivate(Remote remote,
|
||||
ActivationID id) {
|
||||
// We do as much as 50 deactivation trials, each separated by
|
||||
// at least 100 milliseconds sleep time (max sleep time of 5 secs).
|
||||
final long deactivateSleepTime = 100;
|
||||
long stopTime = System.currentTimeMillis() + deactivateSleepTime * 50;
|
||||
while (System.currentTimeMillis() < stopTime) {
|
||||
final long POLLTIME_MS = 100L;
|
||||
final long DEACTIVATE_TIME_MS = 30_000L;
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
long deadline = TestLibrary.computeDeadline(startTime, DEACTIVATE_TIME_MS);
|
||||
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
try {
|
||||
if (Activatable.inactive(id) == true) {
|
||||
mesg("inactive successful");
|
||||
return;
|
||||
} else {
|
||||
mesg("inactive trial failed. Sleeping " +
|
||||
deactivateSleepTime +
|
||||
" milliseconds before next trial");
|
||||
Thread.sleep(deactivateSleepTime);
|
||||
Thread.sleep(POLLTIME_MS);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@ -95,7 +80,8 @@ public class ActivationLibrary {
|
||||
}
|
||||
}
|
||||
|
||||
mesg("unable to inactivate after several attempts");
|
||||
mesg("unable to inactivate after " +
|
||||
(System.currentTimeMillis() - startTime) + "ms.");
|
||||
mesg("unexporting object forcibly instead");
|
||||
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -194,7 +194,7 @@ public class JavaVM {
|
||||
throws InterruptedException, TimeoutException {
|
||||
if (vm == null)
|
||||
throw new IllegalStateException("can't wait for JavaVM that isn't running");
|
||||
long deadline = computeDeadline(System.currentTimeMillis(), timeout);
|
||||
long deadline = TestLibrary.computeDeadline(System.currentTimeMillis(), timeout);
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
@ -218,21 +218,4 @@ public class JavaVM {
|
||||
start();
|
||||
return waitFor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a deadline from a timestamp and a timeout value.
|
||||
* Maximum timeout (before multipliers are applied) is one hour.
|
||||
*/
|
||||
public static long computeDeadline(long timestamp, long timeout) {
|
||||
final long MAX_TIMEOUT_MS = 3_600_000L;
|
||||
|
||||
if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
|
||||
throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
|
||||
}
|
||||
|
||||
// TODO apply test.timeout.factor (and possibly jcov.sleep.multiplier)
|
||||
// here instead of upstream
|
||||
|
||||
return timestamp + timeout;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,15 +249,15 @@ public class RMID extends JavaVM {
|
||||
mesg("Starting rmid on port " + port + ".");
|
||||
super.start();
|
||||
|
||||
int slopFactor = 1;
|
||||
try {
|
||||
slopFactor = Integer.valueOf(
|
||||
TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
|
||||
} catch (NumberFormatException ignore) {}
|
||||
waitTime = waitTime * slopFactor;
|
||||
// int slopFactor = 1;
|
||||
// try {
|
||||
// slopFactor = Integer.valueOf(
|
||||
// TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
|
||||
// } catch (NumberFormatException ignore) {}
|
||||
// waitTime = waitTime * slopFactor;
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
long deadline = computeDeadline(startTime, waitTime);
|
||||
long deadline = TestLibrary.computeDeadline(startTime, waitTime);
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -135,7 +135,8 @@ public class TestLibrary {
|
||||
*/
|
||||
|
||||
public static boolean checkIfRegistryRunning(int port, int msTimeout) {
|
||||
long stopTime = System.currentTimeMillis() + msTimeout;
|
||||
final long POLLTIME_MS = 100L;
|
||||
long stopTime = computeDeadline(System.currentTimeMillis(), msTimeout);
|
||||
do {
|
||||
try {
|
||||
Registry r = LocateRegistry.getRegistry(port);
|
||||
@ -145,12 +146,12 @@ public class TestLibrary {
|
||||
} catch (RemoteException e) {
|
||||
// problem - not ready ? Try again
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(POLLTIME_MS);
|
||||
} catch (InterruptedException ie) {
|
||||
// not expected
|
||||
}
|
||||
}
|
||||
} while (stopTime > System.currentTimeMillis());
|
||||
} while (System.currentTimeMillis() < stopTime);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -169,6 +170,31 @@ public class TestLibrary {
|
||||
}
|
||||
}
|
||||
|
||||
public static double getTimeoutFactor() {
|
||||
String prop = getProperty("test.timeout.factor", "1.0");
|
||||
double timeoutFactor = 1.0;
|
||||
|
||||
try {
|
||||
timeoutFactor = Double.parseDouble(prop);
|
||||
} catch (NumberFormatException ignore) { }
|
||||
|
||||
return timeoutFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a deadline from a timestamp and a timeout value.
|
||||
* Maximum timeout (before multipliers are applied) is one hour.
|
||||
*/
|
||||
public static long computeDeadline(long timestamp, long timeout) {
|
||||
final long MAX_TIMEOUT_MS = 3_600_000L;
|
||||
|
||||
if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
|
||||
throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
|
||||
}
|
||||
|
||||
return timestamp + (long)(timeout * getTimeoutFactor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Property mutators
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user