Author: toad
Date: 2008-02-09 15:53:53 +0000 (Sat, 09 Feb 2008)
New Revision: 17762

Modified:
   trunk/freenet/src/freenet/node/NodeStarter.java
   trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
Log:
Fix bad logging threshold problem with some of the tests.
Mass delete at beginning of RoutingTest.

Modified: trunk/freenet/src/freenet/node/NodeStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStarter.java     2008-02-09 15:20:42 UTC 
(rev 17761)
+++ trunk/freenet/src/freenet/node/NodeStarter.java     2008-02-09 15:53:53 UTC 
(rev 17762)
@@ -271,7 +271,7 @@
      * Not Node-specific; many nodes may be created later.
      * @param testName The name of the test instance.
      */
-       public static RandomSource globalTestInit(String testName, boolean 
enablePlug) throws InvalidThresholdException {
+       public static RandomSource globalTestInit(String testName, boolean 
enablePlug, int logThreshold, String details) throws InvalidThresholdException {

                File dir = new File(testName);
                if((!dir.mkdir()) && ((!dir.exists()) || (!dir.isDirectory()))) 
{
@@ -279,7 +279,7 @@
                        System.exit(NodeInitException.EXIT_TEST_ERROR);
                }

-        Logger.setupStdoutLogging(Logger.MINOR, "");
+        Logger.setupStdoutLogging(logThreshold, details);

        // set Java's DNS cache not to cache forever, since many people
        // use dyndns hostnames

Modified: 
trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java   
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java   
2008-02-09 15:53:53 UTC (rev 17762)
@@ -61,9 +61,7 @@
         String wd = "realNodeNetworkColorTest";
         new File(wd).mkdir();
         //NOTE: globalTestInit returns in ignored random source
-        NodeStarter.globalTestInit(wd, false);
-               Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeNetworkColoringTest:normal,freenet.node.NetworkIDManager:normal");
-               Logger.globalSetThreshold(Logger.ERROR);
+        NodeStarter.globalTestInit(wd, false, Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeNetworkColoringTest:normal,freenet.node.NetworkIDManager:normal");

         DummyRandomSource random = new DummyRandomSource();
         //DiffieHellman.init(random);

Modified: trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java      
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java      
2008-02-09 15:53:53 UTC (rev 17762)
@@ -30,7 +30,7 @@
 public class RealNodePingTest {

     public static void main(String[] args) throws FSParseException, 
PeerParseException, InterruptedException, 
ReferenceSignatureVerificationException, NodeInitException, 
InvalidThresholdException {
-        RandomSource random = NodeStarter.globalTestInit("pingtest", false);
+        RandomSource random = NodeStarter.globalTestInit("pingtest", false, 
Logger.ERROR, "");
         // Create 2 nodes
         Executor executor = new PooledExecutor();
         Node node1 = NodeStarter.createTestNode(5001, "pingtest", false, 
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true);

Modified: 
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2008-02-09 15:53:53 UTC (rev 17762)
@@ -43,10 +43,7 @@
         String wd = "realNodeRequestInsertTest";
         new File(wd).mkdir();
         //NOTE: globalTestInit returns in ignored random source
-        NodeStarter.globalTestInit(wd, false);
-        // Don't clobber nearby nodes!
-        Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeRoutingTest:normal"
 
/*"freenet.store:minor,freenet.node.LocationManager:debug,freenet.node.FNPPacketManager:normal,freenet.io.comm.MessageCore:debug"*/);
-        Logger.globalSetThreshold(Logger.ERROR);
+        NodeStarter.globalTestInit(wd, false, Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeRoutingTest:normal"
 
/*"freenet.store:minor,freenet.node.LocationManager:debug,freenet.node.FNPPacketManager:normal,freenet.io.comm.MessageCore:debug"*/);
         System.out.println("Insert/retrieve test");
         System.out.println();
         DummyRandomSource random = new DummyRandomSource();

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java   
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java   
2008-02-09 15:53:53 UTC (rev 17762)
@@ -17,6 +17,7 @@
 import freenet.support.Logger;
 import freenet.support.PooledExecutor;
 import freenet.support.LoggerHook.InvalidThresholdException;
+import freenet.support.io.FileUtil;
 import freenet.support.math.BootstrappingDecayingRunningAverage;
 import freenet.support.math.RunningAverage;
 import freenet.support.math.SimpleRunningAverage;
@@ -30,27 +31,31 @@
  */
 public class RealNodeRoutingTest extends RealNodeTest {

-    static final int NUMBER_OF_NODES = 50;
-    static final int DEGREE = 5;
-    static final short MAX_HTL = (short)7;
+    static final int NUMBER_OF_NODES = 500;
+    static final int DEGREE = 10;
+    static final short MAX_HTL = (short)10;

-    public static void main(String[] args) throws FSParseException, 
PeerParseException, InvalidThresholdException, NodeInitException, 
ReferenceSignatureVerificationException {
-        Logger.setupStdoutLogging(Logger.NORMAL, 
"freenet.node.CPUAdjustingSwapRequestInterval:minor" 
/*"freenet.node.LocationManager:debug,freenet.node.FNPPacketManager:normal,freenet.io.comm.MessageCore:debug"*/);
-        Logger.globalSetThreshold(Logger.ERROR);
+    public static void main(String[] args) throws FSParseException, 
PeerParseException, InvalidThresholdException, NodeInitException, 
ReferenceSignatureVerificationException, InterruptedException {
         System.out.println("Routing test using real nodes:");
         System.out.println();
-        String wd = "realNodeRequestInsertTest";
-        new File(wd).mkdir();
+        String dir = "realNodeRequestInsertTest";
+        File wd = new File(dir);
+        if(!FileUtil.removeAll(wd)) {
+               System.err.println("Mass delete failed, test may not be 
accurate.");
+               System.exit(EXIT_CANNOT_DELETE_OLD_DATA);
+        }
+        wd.mkdir();
         //NOTE: globalTestInit returns in ignored random source
-        NodeStarter.globalTestInit(wd, false);
+        NodeStarter.globalTestInit(dir, false, Logger.ERROR, "");
         DummyRandomSource random = new DummyRandomSource();
         //DiffieHellman.init(random);
         Node[] nodes = new Node[NUMBER_OF_NODES];
         Logger.normal(RealNodeRoutingTest.class, "Creating nodes...");
         Executor executor = new PooledExecutor();
         for(int i=0;i<NUMBER_OF_NODES;i++) {
+               System.err.println("Creating node "+i);
             nodes[i] = 
-               NodeStarter.createTestNode(5001+i, wd, false, true, true, 
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES, 
65536, true);
+               NodeStarter.createTestNode(5001+i, dir, false, true, true, 
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES, 
65536, true);
             Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
         }
         Logger.normal(RealNodeRoutingTest.class, "Created "+NUMBER_OF_NODES+" 
nodes");
@@ -59,9 +64,13 @@

         Logger.normal(RealNodeRoutingTest.class, "Added random links");

-        for(int i=0;i<NUMBER_OF_NODES;i++)
+        for(int i=0;i<NUMBER_OF_NODES;i++) {
+               System.err.println("Starting node "+i);
             nodes[i].start(false);
+        }

+        waitForAllConnected(nodes);
+        
         // Now sit back and watch the fireworks!
         int cycleNumber = 0;
         int lastSwaps = 0;

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java        
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java        
2008-02-09 15:53:53 UTC (rev 17762)
@@ -54,9 +54,7 @@
         String wd = "realNodeSecretPingTest";
         new File(wd).mkdir();
         //NOTE: globalTestInit returns in ignored random source
-        NodeStarter.globalTestInit(wd, false);
-               Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeSecretPingTest:normal,freenet.node.NetworkIDManager:normal");
-               Logger.globalSetThreshold(Logger.ERROR);
+        NodeStarter.globalTestInit(wd, false, Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeSecretPingTest:normal,freenet.node.NetworkIDManager:normal");

         DummyRandomSource random = new DummyRandomSource();
         //DiffieHellman.init(random);

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeTest.java  2008-02-09 
15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeTest.java  2008-02-09 
15:53:53 UTC (rev 17762)
@@ -7,6 +7,7 @@
 import freenet.node.FSParseException;
 import freenet.node.Location;
 import freenet.node.Node;
+import freenet.node.NodeInitException;
 import freenet.node.PeerNode;
 import freenet.support.Logger;

@@ -18,6 +19,9 @@
  */
 public class RealNodeTest {

+       static final int EXIT_BASE = NodeInitException.EXIT_NODE_UPPER_LIMIT;
+       static final int EXIT_CANNOT_DELETE_OLD_DATA = EXIT_BASE + 3;
+       
        /*
         Borrowed from mrogers simulation code (February 6, 2008)
         */

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-09 15:20:42 UTC (rev 17761)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-09 15:53:53 UTC (rev 17762)
@@ -49,7 +49,6 @@
        static final int EXIT_BASE = NodeInitException.EXIT_NODE_UPPER_LIMIT;
        static final int EXIT_KEY_EXISTS = EXIT_BASE + 1;
        static final int EXIT_UNKNOWN_ERROR_CHECKING_KEY_NOT_EXIST = EXIT_BASE 
+ 2;
-       static final int EXIT_CANNOT_DELETE_OLD_DATA = EXIT_BASE + 3;
        static final int EXIT_TEST_FAILED = EXIT_BASE + 4;

     static final int NUMBER_OF_NODES = 10;
@@ -61,8 +60,6 @@
     public static void main(String[] args) throws FSParseException, 
PeerParseException, CHKEncodeException, InvalidThresholdException, 
NodeInitException, ReferenceSignatureVerificationException, 
KeyCollisionException, SSKEncodeException, IOException, InterruptedException, 
SSKVerifyException {
         System.err.println("ULPR test");
         System.err.println();
-        Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeRoutingTest:normal"
 
/*"freenet.store:minor,freenet.node.LocationManager:debug,freenet.node.FNPPacketManager:normal,freenet.io.comm.MessageCore:debug"*/);
-        Logger.globalSetThreshold(Logger.ERROR);
        String testName = "realNodeULPRTest";
         File wd = new File(testName);
         if(!FileUtil.removeAll(wd)) {
@@ -74,7 +71,7 @@
         DummyRandomSource random = new DummyRandomSource();

         //NOTE: globalTestInit returns in ignored random source
-        NodeStarter.globalTestInit(testName, false);
+        NodeStarter.globalTestInit(testName, false, Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeRoutingTest:normal"
 
/*"freenet.store:minor,freenet.node.LocationManager:debug,freenet.node.FNPPacketManager:normal,freenet.io.comm.MessageCore:debug"*/);
         Node[] nodes = new Node[NUMBER_OF_NODES];
         Logger.normal(RealNodeRoutingTest.class, "Creating nodes...");
         Executor executor = new PooledExecutor();


Reply via email to