Search in sources :

Example 36 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class RespTimeMaxTest method execute.

@Override
public void execute(ArrayList<String[]> originalJMeterTransactions) {
    try {
        JMeterTransactions transactions = filterTransactions((JMeterTransactions) originalJMeterTransactions);
        transactionCount = transactions.getTransactionCount();
        DescriptiveStatistics ds = new DescriptiveStatistics();
        for (String[] transaction : transactions) {
            String elapsed = transaction[1];
            ds.addValue(Double.parseDouble(elapsed));
        }
        longestTransactions = transactions.getLongestTransactions();
        actualResult = (int) ds.getMax();
        actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, actualResult);
        if ((long) actualResult > this.maxRespTime) {
            result = TestResult.FAIL;
        } else {
            result = TestResult.PASS;
        }
    } catch (Exception e) {
        result = TestResult.ERROR;
        actualResultDescription = e.getMessage();
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions)

Example 37 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class JMeterCSVS3ObjectReader method getTransactions.

public JMeterTransactions getTransactions(String csvObject) {
    long start = System.currentTimeMillis();
    log.debug("Reading CSV file - start");
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    String csvObjectContent = s3Client.getS3ObjectContent(csvObject);
    try (InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(csvObjectContent.getBytes()))) {
        jmeterTransactions.addAll(getParser().parseAll(isr));
    } catch (IOException e) {
        throw new CSVFileIOException(e);
    }
    if (jmeterTransactions.isEmpty()) {
        throw new CSVFileNoTransactionsException();
    }
    long finish = System.currentTimeMillis();
    long millisecondsBetween = finish - start;
    log.debug("Reading CSV file - finish, read {} rows, took {}ms", jmeterTransactions.size(), millisecondsBetween);
    return jmeterTransactions;
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException) CSVFileNoTransactionsException(uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) CSVFileIOException(uk.co.automatictester.lightning.exceptions.CSVFileIOException)

Example 38 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class RespTimeNthPercentileTestTest method testExecuteFail.

@Test
public void testExecuteFail() {
    RespTimeNthPercentileTest test = new RespTimeNthPercentileTest("Test #1", "nthPercRespTimeTest", "Verify 90th percentile", "Search", 90, 220);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(SEARCH_121_SUCCESS);
    jmeterTransactions.add(SEARCH_125_SUCCESS);
    jmeterTransactions.add(SEARCH_129_SUCCESS);
    jmeterTransactions.add(SEARCH_135_SUCCESS);
    jmeterTransactions.add(SEARCH_143_SUCCESS);
    jmeterTransactions.add(SEARCH_148_SUCCESS);
    jmeterTransactions.add(SEARCH_178_SUCCESS);
    jmeterTransactions.add(SEARCH_198_SUCCESS);
    jmeterTransactions.add(SEARCH_221_SUCCESS);
    jmeterTransactions.add(SEARCH_249_SUCCESS);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.FAIL)));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 39 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class RespTimeStdDevTestTest method verifyExecuteAllTransactionsPass.

@Test
public void verifyExecuteAllTransactionsPass() {
    RespTimeStdDevTest test = new RespTimeStdDevTest("Test #1", "respTimeStdDevTest", "Verify standard deviance", null, 25);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(LOGIN_198_SUCCESS);
    jmeterTransactions.add(LOGIN_221_SUCCESS);
    jmeterTransactions.add(SEARCH_249_SUCCESS);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.PASS)));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 40 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class RespTimeMedianTestTest method testExecuteFail.

@Test
public void testExecuteFail() {
    RespTimeMedianTest test = new RespTimeMedianTest("Test #1", "medianRespTimeTest", "Verify median", "Search", 144);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(SEARCH_121_SUCCESS);
    jmeterTransactions.add(SEARCH_125_SUCCESS);
    jmeterTransactions.add(SEARCH_129_SUCCESS);
    jmeterTransactions.add(SEARCH_135_SUCCESS);
    jmeterTransactions.add(SEARCH_143_SUCCESS);
    jmeterTransactions.add(SEARCH_148_SUCCESS);
    jmeterTransactions.add(SEARCH_178_SUCCESS);
    jmeterTransactions.add(SEARCH_198_SUCCESS);
    jmeterTransactions.add(SEARCH_221_SUCCESS);
    jmeterTransactions.add(SEARCH_249_SUCCESS);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.FAIL)));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Aggregations

JMeterTransactions (uk.co.automatictester.lightning.data.JMeterTransactions)67 Test (org.testng.annotations.Test)58 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)5 ClientSideTest (uk.co.automatictester.lightning.tests.ClientSideTest)5 PassedTransactionsTest (uk.co.automatictester.lightning.tests.PassedTransactionsTest)5 ServerSideTest (uk.co.automatictester.lightning.tests.ServerSideTest)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CSVFileIOException (uk.co.automatictester.lightning.exceptions.CSVFileIOException)2 CSVFileNoTransactionsException (uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException)2 RespTimeAvgTest (uk.co.automatictester.lightning.tests.RespTimeAvgTest)2 Percent (uk.co.automatictester.lightning.utils.Percent)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 Percentile (org.apache.commons.math3.stat.descriptive.rank.Percentile)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 IntToOrdConverter (uk.co.automatictester.lightning.utils.IntToOrdConverter)1