You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Aurélien Pupier (JIRA)" <ji...@apache.org> on 2018/10/03 09:12:00 UTC

[jira] [Commented] (CAMEL-12852) Fix unstable test PubNubPresenceTest

    [ https://issues.apache.org/jira/browse/CAMEL-12852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16636656#comment-16636656 ] 

Aurélien Pupier commented on CAMEL-12852:
-----------------------------------------

to help reproducing, here is the content of the method used:

protected void doAssertIsSatisfied(long timeoutForEmptyEndpoints) throws InterruptedException {
        if (expectedCount == 0) {
            if (timeoutForEmptyEndpoints > 0) {
                LOG.debug("Sleeping for: {} millis to check there really are no messages received", timeoutForEmptyEndpoints);
                Thread.sleep(timeoutForEmptyEndpoints);
            }
            assertEquals("Received message count", expectedCount, getReceivedCounter());
        } else if (expectedCount > 0) {
        	waitForCompleteLatch();
            if (expectedCount != getReceivedCounter()) {
                waitForCompleteLatch();
            }
            Thread.sleep(1000);
            waitForCompleteLatch();
            assertEquals("Incorrect received message count. Received exchanges are "+ getReceivedExchanges(), expectedCount, getReceivedCounter());
        } else if (expectedMinimumCount > 0 && getReceivedCounter() < expectedMinimumCount) {
            waitForCompleteLatch();
        }

        if (expectedMinimumCount >= 0) {
            int receivedCounter = getReceivedCounter();
            assertTrue("Received message count " + receivedCounter + ", expected at least " + expectedMinimumCount, expectedMinimumCount <= receivedCounter);
        }

        for (Runnable test : tests) {
            test.run();
        }

        for (Throwable failure : failures) {
            if (failure != null) {
                LOG.error("Caught on " + getEndpointUri() + " Exception: " + failure, failure);
                fail("Failed due to caught exception: " + failure);
            }
        }
    }

> Fix unstable test PubNubPresenceTest
> ------------------------------------
>
>                 Key: CAMEL-12852
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12852
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Aurélien Pupier
>            Priority: Major
>
> sometimes it is failing with
> https://fusesource-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/job/camel.redhat.pipeline/job/2.21.x.redhat-7-0-x/18/testReport/junit/org.apache.camel.component.pubnub/PubNubPresenceTest/testPresence/
> {quote}Error Message
> mock://result Received message count. Expected: <1> but was: <2>
> Stacktrace
> java.lang.AssertionError: mock://result Received message count. Expected: <1> but was: <2>
> 	at org.apache.camel.component.pubnub.PubNubPresenceTest.testPresence(PubNubPresenceTest.java:53){quote}
> the problem is that in fact a lot of exchanges are created.
> In org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(long), it is waiting to reach at least the given expected number in the provided timeout.
> As soon as it is reached, it is doing the assertion.
> But between the assertion done in the line just after, a new message may arrive.
> You can notice it by putting a Thread.sleep(1000) fo rinstance before the assertEquals, with PubNubTest it wil lalways fail and there will be a lo tmore messages.
> So 2 possibilities:
> - the test should expect a minimum number of messages
> - the route used in test should be modified to trigger a single message
> - the camel product should not create several messages and in this case it is a product bug



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)