Added new paramter for registry tester to be able to override the ant target used to launch a bureau
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5073 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -23,7 +23,6 @@ package com.threerings.bureau.server;
|
||||
|
||||
import com.samskivert.util.OneLineLogFormatter;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collections;
|
||||
import com.threerings.bureau.data.AgentObject;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -87,10 +86,14 @@ public class RegistryTester
|
||||
_createChance = intProp("createChance", 70);
|
||||
_minDelay = intProp("minDelay", 500);
|
||||
_maxDelay = intProp("maxDelay", 2000);
|
||||
_clientTarget = System.getProperty("clientTarget");
|
||||
if (_clientTarget == null) {
|
||||
_clientTarget = "bureau-runclient";
|
||||
}
|
||||
|
||||
// stop the tests when the server shuts down
|
||||
// TODO: this is not called on Ctrl-C, need a way to shut down gracefully
|
||||
_server.registerShutdowner(new TestServer.Shutdowner() {
|
||||
TestServer.registerShutdowner(new TestServer.Shutdowner() {
|
||||
public void shutdown () {
|
||||
TestServer.log.info("Shutting down tests");
|
||||
_stop = true;
|
||||
@@ -103,6 +106,8 @@ public class RegistryTester
|
||||
*/
|
||||
public void start ()
|
||||
{
|
||||
TestServer.setClientTarget(_clientTarget);
|
||||
|
||||
Thread thread = new Thread("Registry test thread") {
|
||||
public void run () {
|
||||
TestServer.log.info(getName() + " started");
|
||||
@@ -161,14 +166,14 @@ public class RegistryTester
|
||||
}
|
||||
|
||||
// create or destroy some agents
|
||||
_server.omgr.postRunnable(createOrDestroyAgents);
|
||||
TestServer.omgr.postRunnable(createOrDestroyAgents);
|
||||
}
|
||||
|
||||
// clean up
|
||||
_server.omgr.postRunnable(new Runnable() {
|
||||
TestServer.omgr.postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
for (AgentObject obj : _agents) {
|
||||
_server.breg.destroyAgent(obj);
|
||||
TestServer.breg.destroyAgent(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -184,7 +189,7 @@ public class RegistryTester
|
||||
(size != 0 && _rng1.nextInt(100) >= _createChance)) {
|
||||
AgentObject toRemove = _agents.remove(_rng1.nextInt(size));
|
||||
TestServer.log.info("Removing agent " + toRemove.getOid());
|
||||
_server.breg.destroyAgent(toRemove);
|
||||
TestServer.breg.destroyAgent(toRemove);
|
||||
}
|
||||
else {
|
||||
AgentObject added = create(_rng1.nextInt(_numBureaus) + 1);
|
||||
@@ -201,7 +206,7 @@ public class RegistryTester
|
||||
AgentObject obj = new AgentObject();
|
||||
obj.bureauType = "test";
|
||||
obj.bureauId = "test-" + bureau;
|
||||
_server.breg.startAgent(obj);
|
||||
TestServer.breg.startAgent(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -228,4 +233,7 @@ public class RegistryTester
|
||||
|
||||
// maximum delay between batches of requests
|
||||
protected int _maxDelay;
|
||||
|
||||
// ant target to use to kick off new bureaus
|
||||
protected String _clientTarget;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,8 @@
|
||||
|
||||
package com.threerings.bureau.server;
|
||||
|
||||
import com.threerings.bureau.data.AgentObject;
|
||||
import com.threerings.presents.server.PresentsServer;
|
||||
import com.samskivert.util.OneLineLogFormatter;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -61,6 +55,7 @@ public class TestServer extends PresentsServer
|
||||
final TestServer server = new TestServer();
|
||||
try {
|
||||
server.init();
|
||||
setClientTarget("bureau-runclient");
|
||||
server.run();
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -75,8 +70,17 @@ public class TestServer extends PresentsServer
|
||||
{
|
||||
super.init();
|
||||
breg = new BureauRegistry("localhost:47624", invmgr, omgr, invoker);
|
||||
|
||||
breg.setCommandGenerator("test", new BureauRegistry.CommandGenerator() {
|
||||
}
|
||||
|
||||
static public void setClientTarget (String target)
|
||||
{
|
||||
breg.setCommandGenerator("test", antCommandGenerator(target));
|
||||
}
|
||||
|
||||
static public BureauRegistry.CommandGenerator antCommandGenerator (
|
||||
final String target)
|
||||
{
|
||||
return new BureauRegistry.CommandGenerator() {
|
||||
public String[] createCommand (
|
||||
String serverNameAndPort,
|
||||
String bureauId,
|
||||
@@ -88,10 +92,10 @@ public class TestServer extends PresentsServer
|
||||
"-DserverPort=" + serverNameAndPort.substring(colon + 1),
|
||||
"-DbureauId=" + bureauId,
|
||||
"-Dtoken=" + token,
|
||||
"bureau-runclient"};
|
||||
target};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user