Package hudson.plugins.performance.IagoParser

Examples of hudson.plugins.performance.IagoParser.Stats


  }
 
  @Test
  public void testParseValidFile() throws Exception {

    Stats stats1 = new IagoParser.Stats();
    stats1.setClientRequestLatencyMsAverage((long) 4);
    stats1.setClientRequestLatencyMsMaximum((long) 5);
    stats1.setClientRequestLatencyMsMinimum((long) 1);
    stats1.setClientSuccess((long) 10);
    stats1.setClientRequests((long) 10);
    stats1.setClientSendBytes((long) 9000);
   
    Stats stats2 = new IagoParser.Stats();
    stats2.setClientRequestLatencyMsAverage((long) 3);
    stats2.setClientRequestLatencyMsMaximum((long) 4);
    stats2.setClientRequestLatencyMsMinimum((long) 2);
    stats2.setClientSuccess((long) 12);
    stats2.setClientRequests((long) 13);
    stats2.setClientSendBytes((long) 12000);

 
    // Create a temp file.
    // We can move this to resources, but allow flexibility in
    // unit test to create on the fly
    File temp = File.createTempFile("parrot-server-stats", ".log");
    // Delete the file when program exits.
    temp.deleteOnExit();
 
    GsonBuilder objGsonBuilder = new GsonBuilder();
    Gson gson = objGsonBuilder.create();
    boolean exceptionOccured = false;
 
    // Write to temp file
    BufferedWriter out = null;
    try {
      out = new BufferedWriter(new FileWriter(temp));
   
    System.out.println(gson.toJson(stats1));
   
      out.write("INF [20140611-21:34:01.224] stats: " + gson.toJson(stats1));
      out.write("INF [20140611-21:35:01.111] stats: " + gson.toJson(stats2));
    } catch (IOException e) {
      exceptionOccured = true;
    } finally {
      if (out != null) {
        out.close();
      }
    }
    Assert.assertFalse(exceptionOccured);

 
    IagoParser parser = new IagoParser("","","");
    Collection<PerformanceReport> reports = parser.parse(new FreeStyleBuild(createFreeStyleProject()), Arrays.asList(temp), createTaskListener());
    Assert.assertEquals(1, reports.size());
 
    PerformanceReport report = (PerformanceReport) reports.toArray()[0];
 
    Assert.assertEquals((stats1.getClientRequestLatencyMsAverage() + stats2.getClientRequestLatencyMsAverage()) / 2, report.getAverage());
  }
View Full Code Here

TOP

Related Classes of hudson.plugins.performance.IagoParser.Stats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.