1 7 package org.jboss.remoting.performance; 8 9 import org.jboss.dtf.DistributedTestCase; 10 import org.jgroups.Address; 11 12 import java.io.IOException ; 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 20 public abstract class PerformanceTest extends DistributedTestCase 21 { 22 public static final int NUM_OF_THREADS = 10; 23 public static final int NUM_OF_CALLS = 500; 24 25 private List results = new ArrayList (); 26 protected String transport = "socket"; 27 protected int port = 4555; 28 29 public PerformanceTest(String name) 30 { 31 super(name); 32 } 33 34 protected void setUp() throws Exception 35 { 36 transport = System.getProperty("remoting.transport", transport); 37 port = Integer.valueOf(System.getProperty("remoting.port", String.valueOf(port))).intValue(); 38 39 String clientFQN = getClientFQN(); 40 String serverFQN = getServerFQN(); 41 42 String clientcmd = "java -cp " + System.getProperty("java.class.path") + 43 " " + clientFQN + " " + transport + " " + port + " 3"; 45 System.out.println("clientcmd: " + clientcmd); 46 String svrcmd = "java -cp " + System.getProperty("java.class.path") + 47 " " + serverFQN + " " + transport + " " + port + " 3"; 49 System.out.println("svrcmd: " + svrcmd); 50 51 final Process local = Runtime.getRuntime().exec(clientcmd); 52 final Process remote = Runtime.getRuntime().exec(svrcmd); 53 } 54 55 public abstract String getClientFQN(); 56 57 public abstract String getServerFQN(); 58 59 protected void tearDown() throws Exception 60 { 61 } 63 64 public void testInvokers() 65 { 66 try 67 { 68 startup(3); 69 System.out.println("startup() called"); 70 shutdown(); 71 System.out.println("shutdown() called"); 72 } 73 catch(Exception e) 74 { 75 e.printStackTrace(); 76 try 77 { 78 PerformanceReporter.writeReport("Error in test. Instances either failed to start or stop.", 0, 0, null); 79 } 80 catch(IOException e1) 81 { 82 e1.printStackTrace(); 83 } 84 assertTrue("Problem starting or stopping client/server processes.", false); 85 } 86 finally 87 { 88 try 90 { 91 Thread.currentThread().sleep(10000); 92 } 93 catch(InterruptedException e) 94 { 95 e.printStackTrace(); 96 } 97 System.out.println("results.size() = " + results.size()); 98 if(results.size() > 0) 99 { 100 Iterator itr = results.iterator(); 101 while(itr.hasNext()) 102 { 103 String message = (String ) itr.next(); 104 assertTrue(message, false); 105 } 106 } 107 else 108 { 109 assertTrue("No test failures or errors.", true); 110 } 111 112 } 113 } 114 115 120 public void receiveAssert(Address source, String message) 121 { 122 super.receiveAssert(source, message); 123 results.add("Assert source: " + source + "\tmessage: " + message); 124 } 125 126 } 127 | Popular Tags |