From d502e33c7ff7e3f3d7e3789817607ae6b9cf739a Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Sat, 10 May 2008 00:51:57 +0000 Subject: [PATCH] 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 --- .../bureau/server/RegistryTester.java | 22 +++++++++++------ .../threerings/bureau/server/TestServer.java | 24 +++++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/tests/src/java/com/threerings/bureau/server/RegistryTester.java b/tests/src/java/com/threerings/bureau/server/RegistryTester.java index 77db2a2a3..f27d08ac2 100644 --- a/tests/src/java/com/threerings/bureau/server/RegistryTester.java +++ b/tests/src/java/com/threerings/bureau/server/RegistryTester.java @@ -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; } diff --git a/tests/src/java/com/threerings/bureau/server/TestServer.java b/tests/src/java/com/threerings/bureau/server/TestServer.java index ae9045fd2..c246f64f9 100644 --- a/tests/src/java/com/threerings/bureau/server/TestServer.java +++ b/tests/src/java/com/threerings/bureau/server/TestServer.java @@ -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; } - }); + }; } }