Search in sources :

Example 31 with JMeterTransactions

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

the class RespTimeMaxTestTest method verifyExecuteFail.

@Test
public void verifyExecuteFail() {
    RespTimeMaxTest test = new RespTimeMaxTest("Test #1", "avgRespTimeTest", "Verify response times", "Search", 11220);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.SEARCH_11221_SUCCESS);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.FAIL)));
    assertThat(test.getActualResult(), equalTo(11221));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 32 with JMeterTransactions

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

the class RespTimeAvgTestTest method verifyExecutePassOnNonDefaultLocale.

@Test
public void verifyExecutePassOnNonDefaultLocale() {
    Locale.setDefault(Locale.FRENCH);
    RespTimeAvgTest test = new RespTimeAvgTest("Test #1", "avgRespTimeTest", "Verify response times", "Search", 6010);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.SEARCH_800_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_11221_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 33 with JMeterTransactions

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

the class RespTimeAvgTestTest method verifyExecutePass.

@Test
public void verifyExecutePass() {
    RespTimeAvgTest test = new RespTimeAvgTest("Test #1", "avgRespTimeTest", "Verify response times", "Search", 800);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.SEARCH_800_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 34 with JMeterTransactions

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

the class RespTimeStdDevTest 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));
        }
        actualResult = (int) ds.getStandardDeviation();
        actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, actualResult);
        if (actualResult > maxRespTimeStdDev) {
            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 35 with JMeterTransactions

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

the class PassedTransactionsTest method execute.

@Override
public void execute(ArrayList<String[]> originalJMeterTransactions) {
    try {
        JMeterTransactions transactions = filterTransactions((JMeterTransactions) originalJMeterTransactions);
        transactionCount = transactions.getTransactionCount();
        int failureCount = 0;
        for (String[] transaction : transactions) {
            String success = transaction[2];
            if (!Boolean.parseBoolean(success)) {
                failureCount++;
            }
        }
        if (type.equals(ThresholdType.NUMBER)) {
            if (failureCount > allowedNumberOfFailedTransactions) {
                result = TestResult.FAIL;
            } else {
                result = TestResult.PASS;
            }
            this.actualResult = failureCount;
            actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, this.type.toString(), failureCount);
        } else {
            int percentOfFailedTransactions = (int) (((float) failureCount / transactionCount) * 100);
            if (percentOfFailedTransactions > (float) allowedPercentOfFailedTransactions.getValue()) {
                result = TestResult.FAIL;
            } else {
                result = TestResult.PASS;
            }
            this.actualResult = percentOfFailedTransactions;
            actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, this.type.toString(), percentOfFailedTransactions);
        }
    } catch (Exception e) {
        result = TestResult.ERROR;
        actualResultDescription = e.getMessage();
    }
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions)

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