Search in sources :

Example 1 with PerfMonDataEntries

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

the class ServerSideTest method execute.

@Override
public void execute(ArrayList<String[]> originalDataEntries) {
    try {
        PerfMonDataEntries dataEntries = filterDataEntries((PerfMonDataEntries) originalDataEntries);
        dataEntriesCount = dataEntries.getDataEntriesCount();
        DescriptiveStatistics ds = new DescriptiveStatistics();
        for (String[] transaction : dataEntries) {
            String elapsed = transaction[1];
            ds.addValue(Double.parseDouble(elapsed));
        }
        actualResult = (int) ds.getMean();
        actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, actualResult);
        if (subtype.equals(ServerSideTestType.GREATER_THAN)) {
            expectedResultDescription = String.format(expectedResultMessage, metricValueA);
            if (actualResult > metricValueA) {
                result = TestResult.PASS;
            } else {
                result = TestResult.FAIL;
            }
        } else if (subtype.equals(ServerSideTestType.LESS_THAN)) {
            expectedResultDescription = String.format(expectedResultMessage, metricValueA);
            if (actualResult < metricValueA) {
                result = TestResult.PASS;
            } else {
                result = TestResult.FAIL;
            }
        } else if (subtype.equals(ServerSideTestType.BETWEEN)) {
            expectedResultDescription = String.format(expectedResultMessage, metricValueA, metricValueB);
            if ((actualResult > metricValueA) && (actualResult < metricValueB)) {
                result = TestResult.PASS;
            } else {
                result = TestResult.FAIL;
            }
        }
    } catch (Exception e) {
        result = TestResult.ERROR;
        actualResultDescription = e.getMessage();
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries)

Example 2 with PerfMonDataEntries

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

the class LightningTask method runTests.

void runTests() {
    long testSetExecStart = System.currentTimeMillis();
    LightningXMLFileReader xmlFileReader = new LightningXMLFileReader();
    xmlFileReader.readTests(extension.getTestSetXml());
    List<ClientSideTest> clientSideTests = xmlFileReader.getClientSideTests();
    List<ServerSideTest> serverSideTests = xmlFileReader.getServerSideTests();
    testSet = new TestSet(clientSideTests, serverSideTests);
    jmeterTransactions = new JMeterCSVFileReader().getTransactions(extension.getJmeterCsv());
    if (extension.getPerfmonCsv() != null) {
        PerfMonDataEntries perfMonDataEntries = new PerfMonDataReader().getDataEntires(extension.getPerfmonCsv());
        testSet.executeServerSideTests(perfMonDataEntries);
    }
    testSet.executeClientSideTests(jmeterTransactions);
    log(testSet.getTestExecutionReport());
    log(new TestSetReporter(testSet).getTestSetExecutionSummaryReport());
    long testSetExecEnd = System.currentTimeMillis();
    long testExecTime = testSetExecEnd - testSetExecStart;
    log(String.format("Execution time:    %dms", testExecTime));
    if (testSet.getFailCount() + testSet.getErrorCount() != 0) {
        exitCode = 1;
    }
}
Also used : ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest) ServerSideTest(uk.co.automatictester.lightning.tests.ServerSideTest) TestSetReporter(uk.co.automatictester.lightning.reporters.TestSetReporter) JMeterCSVFileReader(uk.co.automatictester.lightning.readers.JMeterCSVFileReader) PerfMonDataReader(uk.co.automatictester.lightning.readers.PerfMonDataReader) PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries) LightningXMLFileReader(uk.co.automatictester.lightning.readers.LightningXMLFileReader) TestSet(uk.co.automatictester.lightning.TestSet)

Example 3 with PerfMonDataEntries

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

the class PerfMonDataReaderTest method verifyReadMethod.

@Test
public void verifyReadMethod() {
    PerfMonDataEntries perfMonDataEntries = new PerfMonDataReader().getDataEntires(TestData.CSV_2_ENTRIES);
    assertThat(perfMonDataEntries, CoreMatchers.hasItem(TestData.CPU_ENTRY_9128));
    assertThat(perfMonDataEntries, CoreMatchers.hasItem(TestData.CPU_ENTRY_21250));
}
Also used : PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries) Test(org.testng.annotations.Test)

Example 4 with PerfMonDataEntries

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

the class ServerSideTestTest method verifyExecute_LessThan_Pass_NonDefaultLocale.

@Test
public void verifyExecute_LessThan_Pass_NonDefaultLocale() {
    Locale.setDefault(Locale.FRENCH);
    ServerSideTest test = new ServerSideTest("Test #1", "serverSideTest", ServerSideTestType.LESS_THAN, "Verify CPU utilisation", "192.168.0.12 CPU", 10001);
    PerfMonDataEntries dataEntries = new PerfMonDataEntries();
    dataEntries.add(TestData.CPU_ENTRY_10000);
    dataEntries.add(TestData.CPU_ENTRY_10001);
    test.execute(dataEntries);
    assertThat(test.getResult(), is(equalTo(TestResult.PASS)));
}
Also used : PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries) Test(org.testng.annotations.Test)

Example 5 with PerfMonDataEntries

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

the class ServerSideTestTest method verifyExecute_Between_Pass.

@Test
public void verifyExecute_Between_Pass() {
    ServerSideTest test = new ServerSideTest("Test #1", "serverSideTest", ServerSideTestType.BETWEEN, "Verify CPU utilisation", "192.168.0.12 CPU", 20000, 27501);
    PerfMonDataEntries dataEntries = new PerfMonDataEntries();
    dataEntries.add(TestData.CPU_ENTRY_25000);
    dataEntries.add(TestData.CPU_ENTRY_30000);
    test.execute(dataEntries);
    assertThat(test.getResult(), is(equalTo(TestResult.PASS)));
}
Also used : PerfMonDataEntries(uk.co.automatictester.lightning.data.PerfMonDataEntries) Test(org.testng.annotations.Test)

Aggregations

PerfMonDataEntries (uk.co.automatictester.lightning.data.PerfMonDataEntries)17 Test (org.testng.annotations.Test)12 ClientSideTest (uk.co.automatictester.lightning.tests.ClientSideTest)4 ServerSideTest (uk.co.automatictester.lightning.tests.ServerSideTest)4 TestSet (uk.co.automatictester.lightning.TestSet)3 TestSetReporter (uk.co.automatictester.lightning.reporters.TestSetReporter)3 JMeterCSVFileReader (uk.co.automatictester.lightning.readers.JMeterCSVFileReader)2 LightningXMLFileReader (uk.co.automatictester.lightning.readers.LightningXMLFileReader)2 PerfMonDataReader (uk.co.automatictester.lightning.readers.PerfMonDataReader)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)1 CSVFileIOException (uk.co.automatictester.lightning.exceptions.CSVFileIOException)1 CSVFileNoTransactionsException (uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException)1 JMeterCSVS3ObjectReader (uk.co.automatictester.lightning.lambda.readers.JMeterCSVS3ObjectReader)1 LightningXMLS3ObjectReader (uk.co.automatictester.lightning.lambda.readers.LightningXMLS3ObjectReader)1 PerfMonS3ObjectDataReader (uk.co.automatictester.lightning.lambda.readers.PerfMonS3ObjectDataReader)1 PassedTransactionsTest (uk.co.automatictester.lightning.tests.PassedTransactionsTest)1