Author: [email protected]
Date: Mon Mar 28 14:54:15 2011
New Revision: 908

Log:
[AMDATU-332] Port nr fixes

Modified:
   
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/analysis/Statistics.java
   
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/AmdatuLauncher.java
   
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/ApplicationContext.java
   
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/JMeterRunner.java

Modified: 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/analysis/Statistics.java
==============================================================================
--- 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/analysis/Statistics.java
        (original)
+++ 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/analysis/Statistics.java
        Mon Mar 28 14:54:15 2011
@@ -50,7 +50,6 @@
 
     public void analyze() throws ParserConfigurationException, SAXException, 
IOException, MathException {
         // Analyze
-        
         for (String sample : getJMeterReports()) {
             File reportX = new File(sample + "X");
             File reportY = new File(sample + "Y");

Modified: 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/AmdatuLauncher.java
==============================================================================
--- 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/AmdatuLauncher.java
     (original)
+++ 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/AmdatuLauncher.java
     Mon Mar 28 14:54:15 2011
@@ -35,8 +35,8 @@
 public class AmdatuLauncher {
     // For now hardcoded, could be read from deploy/org.apache.felix.http.cfg
     private static final String[] CHECK_URLS = new String[] {
-        "http://localhost:8080/dashboard/jsp/dashboard.jsp";,
-        "http://localhost:8080/rest/authorization/status";
+        "http://localhost:${PORT}/dashboard/jsp/dashboard.jsp";,
+        "http://localhost:${PORT}/rest/authorization/status";
     };
 
     private ApplicationContext m_context;
@@ -85,8 +85,9 @@
         long before = System.currentTimeMillis();
         boolean ok = false;
         for (String checkUrl : CHECK_URLS) {
-            System.out.println("Waiting for " + checkUrl + " to return a 200");
-            ok |= waitForURL(new URL(checkUrl), 200, 180000);
+            String url = checkUrl.replace("${PORT}", new 
Integer(m_context.port).toString());
+            System.out.println("Waiting for " + url + " to return a 200");
+            ok |= waitForURL(new URL(url), 200, 180000);
         }
         if (!ok) {
             throw new IllegalStateException("Amdatu could not be launched from 
'" + m_tmpDir + "'. Aborting test.");

Modified: 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/ApplicationContext.java
==============================================================================
--- 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/ApplicationContext.java
 (original)
+++ 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/ApplicationContext.java
 Mon Mar 28 14:54:15 2011
@@ -28,7 +28,7 @@
     public int omit; // Amount of initial results to omit
     public File rootTmpDir; // Root temporary directory
     public int testLoops;
-    public int port = -1;
+    public int port = 8080;
 
     public final static String VERSION_X = "X";
     public final static String VERSION_Y = "Y";

Modified: 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/JMeterRunner.java
==============================================================================
--- 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/JMeterRunner.java
       (original)
+++ 
trunk/etc/performancetest/src/main/java/org/amdatu/test/performance/runtest/JMeterRunner.java
       Mon Mar 28 14:54:15 2011
@@ -61,6 +61,9 @@
 
         for (File jmeterPlan : plans.listFiles()) {
             if (jmeterPlan.isFile() && jmeterPlan.getName().endsWith(".jmx")) {
+                // Update the port number for the http samples in the JMeter 
plans
+                setPlanPortNumbers(jmeterPlan);
+                
                 // Run the JMeter plan!
                 String sampleName = jmeterPlan.getName().replace(".jmx", "") + 
m_context.getSamplesPostFix()+ "." + m_context.currentContextName;
                 m_sampleFile = new File(resultDir, sampleName);
@@ -197,4 +200,17 @@
             fis.close();
         }
     }
+    
+    private void setPlanPortNumbers(File plan) throws IOException {
+        List<String> lines = FileUtils.readLines(plan);
+        List<String> newLines = new ArrayList<String>();
+        for (String line : lines) {
+            if (line.indexOf("name=\"HTTPSampler.port\"") != -1) {
+                newLines.add("<stringProp name=\"HTTPSampler.port\">" + 
m_context.port + "</stringProp>");
+            } else {
+                newLines.add(line);
+            }
+        }
+        FileUtils.writeLines(plan, newLines);
+    }
 }
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to