Search in sources :

Example 1 with ParticipantResult

use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.

the class ConsumerParticipant method startTest.

@Override
public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception {
    final int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName());
    final String providerVersion = _jmsDelegate.getProviderVersion(_command.getSessionName());
    final String protocolVersion = _jmsDelegate.getProtocolVersion(_command.getSessionName());
    if (_command.isSynchronous()) {
        synchronousRun();
    } else {
        LOGGER.debug("Consumer {} registering listener", getName());
        _jmsDelegate.registerListener(_command.getParticipantName(), new MessageListener() {

            @Override
            public void onMessage(Message message) {
                processAsyncMessage(message);
            }
        });
        waitUntilMsgListenerHasFinished();
        rethrowAnyAsyncMessageListenerException();
    }
    Date end = new Date();
    final Date start = new Date(_startTime);
    int numberOfMessagesReceived = _totalNumberOfMessagesReceived.get();
    long totalPayloadSize = _totalPayloadSizeOfAllMessagesReceived.get();
    int payloadSize = getPayloadSizeForResultIfConstantOrZeroOtherwise(_allConsumedPayloadSizes);
    LOGGER.info("Consumer {} finished consuming. Number of messages consumed: {}", getName(), numberOfMessagesReceived);
    ParticipantResult result = _resultFactory.createForConsumer(getName(), registeredClientName, _command, acknowledgeMode, numberOfMessagesReceived, payloadSize, totalPayloadSize, start, end, _messageLatencies, providerVersion, protocolVersion);
    resultReporter.reportResult(result);
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) Message(javax.jms.Message) MessageListener(javax.jms.MessageListener) Date(java.util.Date)

Example 2 with ParticipantResult

use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.

the class ResultsForAllTests method getAllParticipantsResult.

public List<ITestResult> getAllParticipantsResult() {
    List<ITestResult> results = new ArrayList<>(_results.size());
    for (ITestResult testResult : _results) {
        for (ParticipantResult participantResult : testResult.getParticipantResults()) {
            if (TestResultAggregator.ALL_PARTICIPANTS_NAME.equals(participantResult.getParticipantName())) {
                TestResult summaryTestResult = new TestResult(testResult.getName());
                summaryTestResult.addParticipantResult(participantResult);
                results.add(summaryTestResult);
            }
        }
    }
    return results;
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) ArrayList(java.util.ArrayList) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult)

Example 3 with ParticipantResult

use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.

the class ProducerParticipant method startTest.

@Override
public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception {
    long startTime = 0;
    Message lastPublishedMessage = null;
    int numberOfMessagesSent = 0;
    long totalPayloadSizeOfAllMessagesSent = 0;
    NavigableSet<Integer> allProducedPayloadSizes = new TreeSet<>();
    LOGGER.debug("Producer {} about to send messages. Duration limit: {} ms Message Limit : {}", getName(), _maximumDuration, _numberOfMessages);
    while (_stopTestLatch.getCount() != 0) {
        if (_rateLimiter != null) {
            _rateLimiter.acquire();
        }
        if (_collectData) {
            if (startTime == 0) {
                startTime = System.currentTimeMillis();
            }
            if ((_maximumDuration > 0 && System.currentTimeMillis() - startTime >= _maximumDuration) || (_numberOfMessages > 0 && numberOfMessagesSent >= _numberOfMessages)) {
                ParticipantResult result = finaliseResults(registeredClientName, startTime, numberOfMessagesSent, totalPayloadSizeOfAllMessagesSent, allProducedPayloadSizes);
                resultReporter.reportResult(result);
                _collectData = false;
            }
            lastPublishedMessage = _jmsDelegate.sendNextMessage(_command);
            numberOfMessagesSent++;
            int lastPayloadSize = _jmsDelegate.calculatePayloadSizeFrom(lastPublishedMessage);
            totalPayloadSizeOfAllMessagesSent += lastPayloadSize;
            allProducedPayloadSizes.add(lastPayloadSize);
            LOGGER.trace("message {} sent by {}", numberOfMessagesSent, this);
            final boolean batchLimitReached = (_batchSize <= 0 || numberOfMessagesSent % _batchSize == 0);
            if (batchLimitReached) {
                if (LOGGER.isTraceEnabled() && _batchSize > 0) {
                    LOGGER.trace("Committing: batch size " + _batchSize);
                }
                _jmsDelegate.commitIfNecessary(_command.getSessionName());
                doSleepForInterval();
            }
        } else {
            if (_maximumDuration > 0) {
                _jmsDelegate.sendNextMessage(_command);
                _jmsDelegate.commitIfNecessary(_command.getSessionName());
                LOGGER.trace("Pre-message sent by {}", this);
            }
            if (_rateLimiter == null && _maximumDuration == 0) {
                if (!_startDataCollectionLatch.await(1, TimeUnit.SECONDS)) {
                    LOGGER.debug("Producer {} still waiting for collectingData command from coordinator", getName());
                }
            }
        }
    }
    _hasStoppedLatch.countDown();
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) Message(javax.jms.Message) TreeSet(java.util.TreeSet)

Example 4 with ParticipantResult

use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.

the class ParticipantResultFactory method createForError.

public ParticipantResult createForError(String participantName, String clientRegisteredName, String errorMessage) {
    ParticipantResult result = new ParticipantResult();
    result.setParticipantName(participantName);
    result.setRegisteredClientName(clientRegisteredName);
    result.setErrorMessage(errorMessage);
    return result;
}
Also used : ConsumerParticipantResult(org.apache.qpid.disttest.message.ConsumerParticipantResult) ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ProducerParticipantResult(org.apache.qpid.disttest.message.ProducerParticipantResult)

Example 5 with ParticipantResult

use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.

the class ResultsDbWriterTest method testWriteResults.

@Test
public void testWriteResults() throws Exception {
    Context context = getContext();
    ResultsForAllTests results = _resultsTestFixture.createResultsForAllTests();
    String runId = "myRunId";
    ResultsDbWriter resultsDbWriter = new ResultsDbWriter(context, runId, _clock);
    resultsDbWriter.begin();
    resultsDbWriter.writeResults(results, "testfile");
    ParticipantResult expectedResult = _resultsTestFixture.getFirstParticipantResult(results);
    assertResultsAreInDb(context, expectedResult, runId);
}
Also used : Context(javax.naming.Context) ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Aggregations

ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)38 Test (org.junit.Test)25 ConsumerParticipantResult (org.apache.qpid.disttest.message.ConsumerParticipantResult)9 ProducerParticipantResult (org.apache.qpid.disttest.message.ProducerParticipantResult)9 ITestResult (org.apache.qpid.disttest.results.aggregation.ITestResult)6 Date (java.util.Date)5 TestResult (org.apache.qpid.disttest.controller.TestResult)4 ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Message (javax.jms.Message)2 ParticipantAttribute (org.apache.qpid.disttest.message.ParticipantAttribute)2 TreeSet (java.util.TreeSet)1 MessageListener (javax.jms.MessageListener)1 Context (javax.naming.Context)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Transformer (javax.xml.transform.Transformer)1 TransformerException (javax.xml.transform.TransformerException)1 DOMSource (javax.xml.transform.dom.DOMSource)1