Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 49706 invoked from network); 11 Apr 2010 07:28:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Apr 2010 07:28:27 -0000 Received: (qmail 27189 invoked by uid 500); 11 Apr 2010 07:28:27 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 26963 invoked by uid 500); 11 Apr 2010 07:28:26 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 26954 invoked by uid 99); 11 Apr 2010 07:28:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 07:28:26 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.218.215 as permitted sender) Received: from [209.85.218.215] (HELO mail-bw0-f215.google.com) (209.85.218.215) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 07:28:20 +0000 Received: by bwz7 with SMTP id 7so111632bwz.36 for ; Sun, 11 Apr 2010 00:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=0qvOsI6UufHrfvkP2i+cfurAql51R2Be60l7YGkdMps=; b=AXR5sL0x3cCGGFUmBqb3I8t2kUe4OfOm8it63iAr24cRtUr+6l867rcyQQ4aW+32g4 tEzsQ25kq/3Fj3jvy2SsuALimierEc/qMmAhfXP3t/ytKdb7IHtkTS4Bn6bf+NkyUg8O gFdX4c6INDayeLdgATwlteYv1Xr55RUYB2b2w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=wjVW5h6E7Ng79lbSff0pwrX9fMwn9cEejJH6OW+40ohLLO/2T7bPq/wU5nh5UEa9o/ QNKXjK/rSHPEFoF4Uc8Gm/5JMv0OuITC7bcXyaVyBIhAT3LFKN0vpvbMi9WlGEDZrmr5 z+t1HtpG3CK99KEwrEaZzZHjtlZDO4DzfSmqI= MIME-Version: 1.0 Received: by 10.204.72.141 with HTTP; Sun, 11 Apr 2010 00:27:39 -0700 (PDT) In-Reply-To: References: From: Claus Ibsen Date: Sun, 11 Apr 2010 09:27:39 +0200 Received: by 10.204.85.73 with SMTP id n9mr2727063bkl.71.1270970879174; Sun, 11 Apr 2010 00:27:59 -0700 (PDT) Message-ID: Subject: Re: Throttler & mock endpoint question To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi You could just let it route to the mock endpoint. And then afterwards check at what time they arrived at the mock endpoint, to see if there is at most 7 within a second. And btw I think we should add a header to the mock endpoint which records the arrival time. For now you have to do that yourself. For example using targetMock.whenAnyExchange(new Processor() { // set time for arrival } On Sat, Apr 10, 2010 at 8:35 PM, Pavel wrote: > Hi, > > I'm fine with +/- 10%, but perhaps with my massive examples I shifted the > focus away from the original issue: > Route throttler is configured for 7 messages per second, but mock endpoin= t > will match message count of 7, or 14, or anything in between. > > Thus the closest test I can do to verify intended limit of 7/second is > =A0 =A0 =A0 =A0targetMock.expectedMinimumMessageCount(15); > =A0 =A0 =A0 =A0targetMock.setResultWaitTime(1000); > =A0 =A0 =A0 =A0... > =A0 =A0 =A0 =A0targetMock.assertIsNotSatisfied(); > > ... which is +/- 114%, and value of such test is questionable. > And I'm trying to figure out which of the following is the case > > 1. My code or test is incorrect > 2. There is an issue with throttler > 3. There is an issue with mock endpoint > 4. Mock endpoint by design is not the right tool for the job > > If #3 or #4, I'll need different approach to testing. Otherwise > implementation needs to be changed. > > Thanks, > Pavel > > On Sat, Apr 10, 2010 at 7:04 PM, Claus Ibsen wrot= e: > >> Hi >> >> You can newer trust 100% on System time millis as its not accurate. So >> make assertions on a given +/- delta. >> >> >> >> On Sat, Apr 10, 2010 at 5:27 PM, Pavel wrote: >> > Tried that, and noticed a few differences. maximumRequestsPerPeriod is= 7. >> > >> > * Expected message count <7 consistently fails with "Expected , but >> was >> > <7>" >> > * Expected message count 7-11 passes >> > * Expected message count 12,13 seems racy: sometimes test would fail w= ith >> > "Expected , but was " >> > * Expected message count 14,15 passes (or I simply did not catch races= ). >> > * Expected message count 16-18 is racy again, e.g. "Expected <17>, but >> was >> > <19>" >> > * Expected message count 30 is racy, e.g. "Expected: <30> but was: <32= >" >> > >> > That is not 100% precise, as I was giving limited number of tries for >> each >> > case. >> > >> > BTW, camel 2.2.0, activemq-camel 5.3.1. >> > >> > Thanks, >> > Pavel >> > >> > On Sat, Apr 10, 2010 at 2:31 PM, Claus Ibsen >> wrote: >> > >> >> Hi >> >> >> >> Can you try with >> >> targetMock.assertIsSatisfied(1000); >> >> >> >> >> >> On Sat, Apr 10, 2010 at 11:43 AM, Pavel wrote: >> >> > Hello, >> >> > >> >> > I'm facing strange behaviour of throttler + mock endpoint when rout= e >> >> under >> >> > test is this: >> >> > >> >> > =A0 =A0 >> >> > =A0 =A0 =A0 >> >> > =A0 =A0 =A0 >> >> > =A0 =A0 =A0> >> maximumRequestsPerPeriod=3D"7"> >> >> > =A0 =A0 =A0 =A0 >> >> > =A0 =A0 =A0 >> >> > =A0 =A0 >> >> > >> >> > test itself defines producer for "direct -> activemq:A" route, as w= ell >> as >> >> > "activemq:B -> targetMock" route, and then does this: >> >> > >> >> > =A0 =A0 =A0 =A0targetMock.expectedMessageCount(7); >> >> > =A0 =A0 =A0 =A0targetMock.setResultWaitTime(1000); >> >> > =A0 =A0 =A0 =A0for(int i=3D0; i<40; i++) >> >> > =A0 =A0 =A0 =A0{ >> >> > =A0 =A0 =A0 =A0 =A0 =A0producer.sendBody("Message " + i); >> >> > =A0 =A0 =A0 =A0} >> >> > =A0 =A0 =A0 =A0targetMock.assertIsSatisfied(); >> >> > >> >> > This passes. >> >> > *BUT* if I change targetMock.expectedMessageCount(7); to e.g. >> >> > targetMock.expectedMessageCount(11); it passes as well! >> >> > >> >> > Looks like test would pass if expectedMessageCount is anything betw= een >> >> > [maximumRequestsPerPeriod, 2* maximumRequestsPerPeriod]. >> >> > >> >> > I tested various expected message counts against >> >> > maximumRequestsPerPeriod=3D"7" >> >> > >> >> > 3: Expected: <3> but was: <7> >> >> > 4: Expected: <4> but was: <7> >> >> > 5: Expected: <5> but was: <7> >> >> > 6: Expected: <6> but was: <7> >> >> > 7: passed >> >> > 8: passed >> >> > 9: passed >> >> > 10: passed >> >> > 11: passed >> >> > 12: passed >> >> > 13: passed >> >> > 14: passed >> >> > 15: Expected: <15> but was: <14> >> >> > 16: Expected: <16> but was: <14> >> >> > 17: Expected: <17> but was: <14> >> >> > 18: Expected: <18> but was: <14> >> >> > 19: Expected: <19> but was: <14> >> >> > 20: Expected: <20> but was: <14> >> >> > >> >> > ... and against maximumRequestsPerPeriod=3D"3" >> >> > >> >> > 2: Expected: <2> but was: <3> >> >> > 3: passed >> >> > 4: passed >> >> > 5: passed >> >> > 6: passed >> >> > 7: Expected: <7> but was: <6> >> >> > 8: Expected: <8> but was: <6> >> >> > 9: Expected: <9> but was: <6> >> >> > 10: Expected: <10> but was: <6> >> >> > >> >> > Can you please explain that? Is it some sort of mock endpoint >> specifics? >> >> > I'd like my test to be fairly strict, as the goal is to verify that >> route >> >> > meets SLA... >> >> > >> >> > Thanks, >> >> > Pavel >> >> > >> >> >> >> >> >> >> >> -- >> >> Claus Ibsen >> >> Apache Camel Committer >> >> >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> >> Open Source Integration: http://fusesource.com >> >> Blog: http://davsclaus.blogspot.com/ >> >> Twitter: http://twitter.com/davsclaus >> >> >> > >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> > --=20 Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus