Hello Jmeter-ers. 

I tried setting up a simple JMeter testcase for my
"use-regexs-as-a-diff-flag" idea; but no matter what I did, the assertion do
not work. 

I know the idea itself is sound (see Perl code below), but I may have run
into a bug (feature?) in line terminations in JMeter. Or have I? 

When I run Perl's quotemeta on a string with a "<CR><LF>" line termination
(Say for e.g.: "blah<CR><LF>"), it quotes both the <CR> and the <LF>
characters thus: 

blah\<CR>\<LF>
    ^^^^^^^escaped <CR> and <LF>

Now when I copy this escaped text and paste it into the JMeter Response
Assertion's Swing textbox, something (could be Java) does not like a bare
<LF> without a <CR> immediately before it, and the string gets clobberred
like so:

blah\\<CR><LF>
    ^^^^ Arrgh! 

Manually correcting the text in the Swing checkbox seems to have no effect. 

Anyway, thought I'd pop this up to the list for some ideas and comments... 

Regards,
Sonam Chauhan
-- 
Electronic Commerce, Corporate Express Australia Ltd.
Phone: +61-2-9335-0725, Email: [EMAIL PROTECTED]
 

> -----Original Message-----
> From: Sonam Chauhan
> Sent: Thursday, 5 May 2005 1:57 PM
> To: 'JMeter Users List'
> Subject: RE: Regression Testing w/ JMeter
> 
> > > > > > It would be hard - there could be dozens or even hundreds of
> > characters
> > > > > > that need to be escaped else they'll be treated as funky regular
> > > > > > expression signifiers.
> 
> Mike: It's easy just using quotemeta to automatically escape anything that
> looks dangerous.
> 
> Thanks for the advice guys. I've got a simple prototype working in Perl.
> In
> the code below, both the sample texts with some arbitrary special
> characters
> match against a single 3-part regular expression.
> 
> Regards,
> Sonam Chauhan
> --
> Electronic Commerce, Corporate Express Australia Ltd.
> Phone: +61-2-9335-0725, Email: [EMAIL PROTECTED]
> 
> PERL CODE
> ==========================================
> #!/usr/bin/perl
> 
> #Text that must be matched
> $sample_text1 =       'multi-line test \t with special *?#.
>   VAR 123 characters like . \d and .$';
> $sample_text2 =       'multi-line test \t with special *?#.
>   VAR 457 characters like . \d and .$';
> $text_to_match = $sample_text2; # or $text2
> 
> #Regular Expressions that will match against text
> $regex_1 = 'multi-line test \t with special *?#.
> ';
> $regex_2 = '  VAR \d\d\d ';
> $regex_3 = 'characters like . \d and .$';
> 
> #Actual matching
> $full_regex =         quotemeta ($regex_1).$regex_2.quotemeta ($regex_3);
> $result = $text_to_match =~ /($full_regex)/;
> 
> #Output
> print "----------------------------\n";
> print "Text to match: $text_to_match\n";
> print "----------------------------\n";
> print "Quotemeta'ed Regex: $full_regex\n";
> print "----------------------------\n";
> print "Match result: $result\n";
> print "----------------------------\n";
> print "\$1 from match: $1\n";
> 
> 
> 
> PROGRAM OUTPUT
> ==========================================
> Text to match: multi-line test \t with special *?#.
>   VAR 457 characters like . \d and .$
> ----------------------------
> Quotemeta'ed Regex: multi\-line\ test\ \\t\ with\ special\ \*\?\#\.\ \
>   VAR \d\d\d characters\ like\ \.\ \\d\ and\ \.\$
> ----------------------------
> Match result: 1
> ----------------------------
> $1 from match: multi-line test \t with special *?#.
>   VAR 457 characters like . \d and .$
> 
> 
> 
> 
> 
> > -----Original Message-----
> > From: Michael Stover [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, 27 April 2005 11:16 PM
> > To: [email protected]
> > Subject: Re: Regression Testing w/ JMeter
> >
> > ha, I can never keep them straight without looking them up every time.
> > I need a quick reference for life.
> >
> > On Wed, 2005-04-27 at 14:13 +0100, sebb wrote:
> > > \s* would be better ;-)
> > >
> > > I think it will be much easier to replace the variable bits with
> > > something fixed (e.g. nothing) before trying any comparisons.
> > >
> > > This should all be possible using the BeanShell Assertion - at least
> > > for proof of concept.
> > >
> > > S.
> > > On 4/27/05, Michael Stover <[EMAIL PROTECTED]> wrote:
> > > > Maybe you'll have to take drastic steps like replacing all white
> space
> > > > characters with \S* constructs, since whitespace could be tabs,
> > spaces,
> > > > linefeeds, carriage returns...
> > > >
> > > > The only way I ever have success with big regexes is to build them
> up
> > > > from tiny to large, whereas you are trying to start out with the
> whole
> > > > shebang.
> > > >
> > > > -Mike
> > > >
> > > > On Wed, 2005-04-27 at 11:54 +1000, Sonam Chauhan wrote:
> > > > > Hi Mike, Sebb -
> > > > >
> > > > > > It would be hard - there could be dozens or even hundreds of
> > characters
> > > > > > that need to be escaped else they'll be treated as funky regular
> > > > > > expression signifiers.
> > > > >
> > > > > I played around on this a while back... I recall I used a Perl
> > script to
> > > > > process the text to escape metacharacters. (I used the quotemeta
> > builtin
> > > > > Perl function that escapes just about everything not alphanumeric
> > with a
> > > > > backslash - even spaces!). I could not get it to work though -
> even
> > with
> > > > > modifiers. I _suspect_ it could be a line terminator issue - I
> > suspect Java
> > > > > does something strange with line terminations of text pasted into
> a
> > textbox.
> > > > >
> > > > >
> > > > > Obviously, even if it works, a 4-step process involving external
> > tools isn't
> > > > > practical for everyday use. Ideally, an 'Enhanced Response
> > Assertion'
> > > > > element would allow me to simply paste in a full document, mark
> > certain of
> > > > > text, and edit them as regular expressions (these would then
> display
> > in a
> > > > > different font or color).
> > > > >
> > > > > Seb, you also mentioned:
> > > > > > > The Regex Tester might help here.
> > > > >
> > > > > I haven't used one so far -- is there a specific one you had in
> > mind?
> > > > >
> > > > > Regards,
> > > > > Sonam Chauhan
> > > > > --
> > > > > Electronic Commerce, Corporate Express Australia Ltd.
> > > > > Phone: +61-2-9335-0725, Email: [EMAIL PROTECTED]
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Michael Stover [mailto:[EMAIL PROTECTED]
> > > > > > Sent: Tuesday, 26 April 2005 11:25 PM
> > > > > > To: [email protected]
> > > > > > Subject: Re: Regression Testing w/ JMeter
> > > > > >
> > > > > > It would be hard - there could be dozens or even hundreds of
> > characters
> > > > > > that need to be escaped else they'll be treated as funky regular
> > > > > > expression signifiers.
> > > > > >
> > > > > > -Mike
> > > > > >
> > > > > > On Tue, 2005-04-26 at 11:18 +0100, sebb wrote:
> > > > > > > Clever idea - should work.
> > > > > > > But it is harder to make work than removing/replacing the
> > variable
> > > > > > > bits as you are finding!
> > > > > > >
> > > > > > > The modifiers such as (?m) and (?s) do work in JMeter.
> > > > > > >
> > > > > > > Note that these can change the meaning of ".", ^ $ etc
> > > > > > >
> > > > > > > The Regex Tester might help here.
> > > > > > >
> > > > > > > S.
> > > > > > > On 4/26/05, Sonam Chauhan <[EMAIL PROTECTED]> wrote:
> > > > > > > > > Or one could develop a new Assertion.
> > > > > > > > >
> > > > > > > > > You might still need to add a way to edit the responses to
> > remove
> > > > > > the
> > > > > > > > > variable data.
> > > > > > > >
> > > > > > > > Sebb and Keith - I tried something similar with plain
> response
> > > > > > assertions
> > > > > > > > and regexs... my intention was to get JMeter to act as a
> > rudimentary
> > > > > > diff
> > > > > > > > facility (it just signals if something is different), but I
> > may have
> > > > > > run
> > > > > > > > into a limitation the regex support.
> > > > > > > >
> > > > > > > > The usual way to use Response Assertions is setting snippets
> > of text
> > > > > > (which
> > > > > > > > may have regexs) in an assertion. JMeter then tries to match
> > the
> > > > > > response
> > > > > > > > body (or headers) against it.
> > > > > > > >
> > > > > > > > Is it possible to assert a suitably processed multiline
> > document? I
> > > > > > was
> > > > > > > > thinking of something like this:
> > > > > > > >
> > > > > > > > 1. Take the _entire_ body response from a server
> > > > > > > > 2. Replace the variable bits with suitable regular
> expressions
> > > > > > > > 3. Quote any other regex metacharacters
> > > > > > > > 4. Take the text processed this way, and set it as a JMeter
> > response
> > > > > > > > assertion
> > > > > > > >
> > > > > > > > I tried doing this - JMeter lets me paste in this multi-line
> > text into
> > > > > > the
> > > > > > > > assertion textbox with no problems, but try as I might, I
> > could not it
> > > > > > to
> > > > > > > > work. I also tried using Perl5 extended regular expressions
> of
> > > > > > multiline
> > > > > > > > matching - i.e., instead of /abc/m, I set the assertion to
> > (?m)abc -
> > > > > > but no
> > > > > > > > go.
> > > > > > > >
> > > > > > > > I'd like your thoughts on this issue.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Sonam Chauhan
> > > > > > > > --
> > > > > > > > Electronic Commerce, Corporate Express Australia Ltd.
> > > > > > > > Phone: +61-2-9335-0725, Email: [EMAIL PROTECTED]
> > > > > > > >
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: sebb [mailto:[EMAIL PROTECTED]
> > > > > > > > > Sent: Monday, 25 April 2005 10:51 PM
> > > > > > > > > To: JMeter Users List
> > > > > > > > > Subject: Re: Regression Testing w/ JMeter
> > > > > > > > >
> > > > > > > > > The Post-Processor Save Responses to a File was partly
> > introduced
> > > > > > with
> > > > > > > > > this in mind.
> > > > > > > > >
> > > > > > > > > This takes a name prefix (which I think can be a variable)
> > so you
> > > > > > can
> > > > > > > > > run the test twice, saving the results to two sets of
> files,
> > and
> > > > > > then
> > > > > > > > > use some other tool to do comparisons of the files.
> > > > > > > > >
> > > > > > > > > You may need to pre-process the files to remove some
> dynamic
> > data
> > > > > > > > > (e.g. dates/times) before doing the diffs.
> > > > > > > > >
> > > > > > > > > There's no differencing capability built into JMeter at
> > present.
> > > > > > > > >
> > > > > > > > > However, I guess the Save Responses test element could be
> > extended
> > > > > > to
> > > > > > > > > include a second filename prefix, and could save the new
> > data and
> > > > > > then
> > > > > > > > > compare it. Not sure offhand how this should report
> > differences - I
> > > > > > > > > think it may run too late to change the failure status -
> but
> > it
> > > > > > could
> > > > > > > > > certainly log a message.
> > > > > > > > >
> > > > > > > > > Or one could develop a new Assertion.
> > > > > > > > >
> > > > > > > > > You might still need to add a way to edit the responses to
> > remove
> > > > > > the
> > > > > > > > > variable data.
> > > > > > > > > I think this could be done using another Post-Processor
> > (BeanShell
> > > > > > > > > Assertion should be usable here) that gets run before the
> > Saver gets
> > > > > > > > > the result. Or this could be added to the Saver itself
> > (easier to
> > > > > > > > > understand).
> > > > > > > > >
> > > > > > > > > I suggest you try using external comparisons first, as
> this
> > will
> > > > > > give
> > > > > > > > > a better idea of the sort of text that might need to be
> > removed from
> > > > > > > > > the responses before diffing.
> > > > > > > > >
> > > > > > > > > S.
> > > > > > > > > On 4/25/05, Keith Weicksel <[EMAIL PROTECTED]> wrote:
> > > > > > > > > > I was wondering if anyone used JMeter to regression test
> a
> > site.
> > > > > > > > > > Particularily, what I am looking for is the ability to:
> > > > > > > > > >
> > > > > > > > > > 1 - create a baseline tests for some path in our site
> > (storing the
> > > > > > > > > > HTML/DOM response somewhere)
> > > > > > > > > > 2 - run the same test again after changes were made to
> the
> > site
> > > > > > and be
> > > > > > > > > > able to DIFF the responses (showing the differences
> > somehow)
> > > > > > > > > > 3 - if there are changes (and they are OK), replace the
> > baseline
> > > > > > > > > > responses with the new valid ones
> > > > > > > > > >
> > > > > > > > > > I have used JMeter for about a month now, and do not
> > believe it
> > > > > > has this
> > > > > > > > > > functionality built right into it at this point.  My
> > question is
> > > > > > what is
> > > > > > > > > > the extent of the regression testing ability buiilt into
> > JMeter?
> > > > > > And
> > > > > > > > > > how difficult would it be to add this functionaility to
> it
> > > > > > myselft?
> > > > > > > > > >
> > > > > > > > > > Thanks,
> > > > > > > > > >
> > > > > > > > > > Keith
> > > > > > > > > >
> > > > > > > > > > --------------------------------------------------------
> --
> > --------
> > > > > > ---
> > > > > > > > > > To unsubscribe, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > > > > For additional commands, e-mail: jmeter-user-
> > > > > > [EMAIL PROTECTED]
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > ----------------------------------------------------------
> --
> > --------
> > > > > > -
> > > > > > > > > To unsubscribe, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > > > For additional commands, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > >
> > > > > > > > ------------------------------------------------------------
> --
> > -------
> > > > > > > > To unsubscribe, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > > For additional commands, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > --------------------------------------------------------------
> --
> > -----
> > > > > > > To unsubscribe, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > > > For additional commands, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > > >
> > > > > >
> > > > > >
> > > > > > ----------------------------------------------------------------
> --
> > ---
> > > > > > To unsubscribe, e-mail: jmeter-user-
> [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: jmeter-user-
> > [EMAIL PROTECTED]
> > > > >
> > > > > ------------------------------------------------------------------
> --
> > -
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: jmeter-user-
> [EMAIL PROTECTED]
> > > >
> > > > --------------------------------------------------------------------
> -
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to