[Tsung] dynamic variables: lowercase and 5.6.1 ---- check_httpd_old_version() bug!? erlang logic.

Stein, Martin martin.stein at sap.com
Tue Apr 22 20:53:37 CEST 2008


Hello

 

Continuing my quest for dynamic variables I found that the "name" field
has to be in lower case. It would be great if this was in the manual. I
would propose rewriting the section:

 

------ OLD

<request>
   <dyn_variable name="random_num" ></dyn_variable>
   <http url="/testtsung.html" method="GET" version="1.0"></http>
 </request>

Now random_num will be set to 42 during the user's session. ****  It's
value will be replace in all mark-up of the form %%_random_num%% if and
only if the request tag has the attribute subst="true", like:

 ------- NEW

This value (42) will be replaced wherever the variable appears in the
http request. The variable name has to begin with %%_ and end with %%.
It also has to be in lower case. Note: the replacement will only by made
if the request tag has the attribute subst="true", like:

----- END

 

(I include context in the old section. Don't know how to hand-write
diff. Just replace after the ****).

 

 

 

 

**** Chapter 2 ****

 

Of course the journey doesn't end here. After I changed the name="" to
lower case, another error: 

 

["Config Error, aborting !
",{undef,[{httpd_util,to_lower,["POST"]},{ts_config_http,parse_config,2}
,

 

Heck - my Erlang version doesn't have that function any more. What's
wrong. 

 

(mynode at vowng1.pal.sap.corp)2> erlang:system_info(version).

"5.6.1"

 

It turns out that there is a subtle bug in ts_utils:
check_httpd_old_version/0. The following

 

F1=fun() -> case erlang:system_info(version) of [$5,$.,Maj, $.,Min] when
( Maj > $5 ) or ((Maj == $5) and Min > $3 ) -> false; _ -> true end end.

 

Returns true! Let's check:

 

4> [$5,$.,Maj, $.,Min] =  erlang:system_info(version).

 

5>  ( Maj > $5 ) or ((Maj == $5) and Min > $3 ).

** exception error: bad argument

     in operator  and/2

        called as false and 49

 

 

 

Aha! Erlang evaluates "(Maj == $5) and Min > $3"  as follows: (Maj ==
$5) first, then it does the and statement (which fails) and finally it
would do the or. We have to tell it to do the Min>$3 first and things
should be fine.

 

6>  ( Maj > $5 ) or ((Maj == $5) and (Min > $3) ).

true

 

 

Yeah! I propose changing in ts_utils: check_httpd_old_version/0 to

 

%% check erlang version to know if we need to use the old httpd_utils
functions

check_httpd_old_version()->

    case erlang:system_info(version) of

        [$5,$.,Maj] when Maj > $5  ->

            false;

        [$5,$.,Maj, $.,Min] when ( Maj > $5 ) or ((Maj == $5) and (Min >
$3)) ->

            false;

        _  ->

            true

    end.

 

 

Let me know what you think!

Martin

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.process-one.net/pipermail/tsung-users/attachments/20080422/6ae74e2c/attachment-0001.html


More information about the Tsung-users mailing list