Changeset 4199

Show
Ignore:
Timestamp:
04/18/08 13:45:30 (8 months ago)
Author:
jani.laakso@…
Message:

Warn only if email sending fails.

Testcase execution time is more accurate, now only one decimal for execution time shown on results.

Location:
ToolkitAutomatedTesting
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • ToolkitAutomatedTesting/config.xml

    r4174 r4199  
    2424        <!-- Define alerts, what triggers email sending --> 
    2525        <alert> 
    26                 <!--  alert if memory consumption for subsequent testruns changes more than 5% --> 
    27                 <memconsumptionchangepercent>0.05</memconsumptionchangepercent> 
    28                 <!--  alert if execution time for subsequent testcases changes more than 5% --> 
    29                 <exectimechangepercent>0.05</exectimechangepercent> 
     26                <!--  alert if memory consumption for subsequent testruns changes more than 10% --> 
     27                <memconsumptionchangepercent>0.1</memconsumptionchangepercent> 
     28                <!--  alert if execution time for subsequent testcases changes more than 10% --> 
     29                <exectimechangepercent>0.1</exectimechangepercent> 
    3030        </alert> 
    3131 
     
    157157                                <testcase> 
    158158                                        <script>robustness-complex.txt</script> 
    159                                         <timeout>300</timeout> 
     159                                        <timeout>200</timeout> 
    160160                                        <target>3</target> 
    161161                                        <host>0</host> 
  • ToolkitAutomatedTesting/src/com/itmill/toolkit/automatedtests/client/Email.java

    r4161 r4199  
    3939 
    4040                // send the email 
    41                 email.send(); 
    42  
     41                try { 
     42                        email.send(); 
     43                } catch (org.apache.commons.mail.EmailException e) { 
     44                        System.err.println("Could not send email, reason: " 
     45                                        + e.getMessage()); 
     46                } 
    4347        } 
    4448} 
  • ToolkitAutomatedTesting/src/com/itmill/toolkit/automatedtests/client/LaunchToolkitTests.java

    r4170 r4199  
    153153        private void executeTestcases(HierarchicalConfiguration testRun) 
    154154                        throws Exception { 
     155                // Get testrun name 
    155156                String name = testRun.getString("name"); 
    156157 
     
    164165 
    165166                // Get used memory before testrun 
    166                 Long memoryUsedBefore = ToolkitStatus.getMemoryUsage(120); 
     167                Long memoryUsedBefore = ToolkitStatus.getMemoryUsage(180); 
    167168 
    168169                TestRun run = new TestRun(name); 
     
    233234 
    234235                        // wait task to finish 
    235                         Thread.sleep(8000); 
    236                         int pollCount = (timeout - 8) * 4; 
     236                        Thread.sleep(6000); 
     237                        int pollCount = (timeout - 6) * 2; 
    237238                        TaskStatus taskStatus = TaskStatus.NOT_STARTED; 
    238239                        while (pollCount > 0) { 
    239240                                pollCount--; 
    240                                 // poll every 250ms 
    241                                 Thread.sleep(250); 
     241                                // poll every 500ms 
     242                                Thread.sleep(500); 
    242243                                taskStatus = api.getTaskStatus(taskId); 
    243244                                if (taskStatus != TaskStatus.RUNNING) 
     
    248249                        // Store test result 
    249250                        if (taskStatus == TaskStatus.FINISHED) { 
    250                                 String testCaseHtmlRaport = api.getTaskResults(taskId).get(0); 
    251                                 // Modify test result: 
    252                                 // open "Details" and "Script" divs by default 
    253                                 // also makes backbutton to work correctly 
    254                                 testCaseHtmlRaport = testCaseHtmlRaport.replaceAll( 
    255                                                 "\\<div style=\"display:none\"\\>", "<div style=\"\">"); 
    256                                 if (testCaseHtmlRaport.contains("<title>Passed:")) { 
     251                                String testReport = api.getTaskResults(taskId).get(0); 
     252                                // Open raport divs, which are normally hidden 
     253                                testReport = TestResult.openDivs(testReport); 
     254                                // Update started end ended from testresult 
     255                                try { 
     256                                        String started = TestResult.getId(testReport, "started"); 
     257                                        if (started != null) 
     258                                                result.setStart(Util.dfTestResult.parse(started)); 
     259                                        String ended = TestResult.getId(testReport, "ended"); 
     260                                        if (ended != null) 
     261                                                result.setEnd(Util.dfTestResult.parse(ended)); 
     262                                } catch (Exception ignored) { 
     263                                } 
     264                                // Get status 
     265                                if (testReport.contains("<title>Passed:")) { 
    257266                                        status = Status.PASSED; 
    258267                                } else { 
     
    262271                                                + testcaseName + ".html"; 
    263272                                Util.writeFile("results" + File.separator + filename, 
    264                                                 testCaseHtmlRaport); 
     273                                                testReport); 
    265274                                result.setTestresultLink(filename); 
    266275                        } else { 
     
    303312 
    304313                        LaunchToolkitTests client = new LaunchToolkitTests(); 
    305                         // test locally: for (int i = 0; i < 1000; i++) 
    306                         client.executeTestRuns(); 
     314                        // test locally: 
     315                        for (int i = 0; i < 1000; i++) 
     316                                client.executeTestRuns(); 
    307317 
    308318                } catch (Exception e) { 
  • ToolkitAutomatedTesting/src/com/itmill/toolkit/automatedtests/client/TestResult.java

    r4161 r4199  
    44import java.math.BigDecimal; 
    55import java.util.Date; 
     6import java.util.regex.Matcher; 
     7import java.util.regex.Pattern; 
    68 
    79/** 
     
    7678                float f = (float) (end.getTime() - start.getTime()) / 1000; 
    7779                BigDecimal dec = new BigDecimal(f); 
    78                 dec = dec.setScale(2, BigDecimal.ROUND_HALF_UP); 
     80                dec = dec.setScale(1, BigDecimal.ROUND_HALF_UP); 
    7981                return dec.toString(); 
    8082        } 
     
    8890        } 
    8991 
     92        /** 
     93         * Modify test result: open "Details" and "Script" divs by default also 
     94         * makes backbutton to work correctly. 
     95         *  
     96         * @param testResult 
     97         * @return 
     98         */ 
     99        public static String openDivs(String testResult) { 
     100                return testResult.replaceAll("\\<div style=\"display:none\"\\>", 
     101                                "<div style=\"\">"); 
     102        } 
     103 
     104        public static String getId(String testResult, String id) { 
     105                Pattern pattern = Pattern.compile("<td id=\"" + id + "\">(.*)</td>"); 
     106                Matcher matcher = pattern.matcher(testResult); 
     107                if (matcher.find()) 
     108                        return matcher.group(1); 
     109                else 
     110                        return null; 
     111        } 
     112 
    90113} 
  • ToolkitAutomatedTesting/src/com/itmill/toolkit/automatedtests/client/TestRun.java

    r4170 r4199  
    121121                float f = (float) (end.getTime() - start.getTime()) / 1000; 
    122122                BigDecimal dec = new BigDecimal(f); 
    123                 dec = dec.setScale(2, BigDecimal.ROUND_HALF_UP); 
     123                dec = dec.setScale(1, BigDecimal.ROUND_HALF_UP); 
    124124                return dec.toString(); 
    125125        } 
  • ToolkitAutomatedTesting/src/com/itmill/toolkit/automatedtests/client/Util.java

    r4161 r4199  
    1515 
    1616        public static DateFormat dfHuman = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
     17 
     18        public static DateFormat dfTestResult = new SimpleDateFormat( 
     19                        "yyyy-MM-dd HH:mm:ss.S"); 
    1720 
    1821        // read file to String