Permalink
Browse files

Initial support for jabber MUC. (TSUN-107)

SVN Revision: 979
  • Loading branch information...
1 parent 035d969 commit 68f8e0cd01276533ff6317b696ea7b755e0b3527 @ppolv ppolv committed Jan 16, 2009
View
@@ -0,0 +1,94 @@
+
+<?xml version="1.0"?>
+<!DOCTYPE tsung SYSTEM "@prefix@/share/@PACKAGE_NAME@/@DTD@">
+<tsung loglevel="notice" version="1.0">
+
+ <clients>
+ <client host="localhost" use_controller_vm="true"></client>
+ </clients>
+
+ <!-- Server side setup -->
+ <servers>
+ <server host="127.0.0.1" port="5222" type="tcp"></server>
+ </servers>
+
+ <load>
+ <arrivalphase phase="1" duration="1" unit="minute">
+ <users interarrival="2" unit="second"></users>
+ </arrivalphase>
+ </load>
+
+ <!-- JABBER parameters -->
+ <!-- to synchronise users, use a global acknoledgement -->
+ <options>
+ <option type="ts_jabber" name="global_number" value="100"></option>
+ <option type="ts_jabber" name="userid_max" value="10000"></option>
+ <option type="ts_jabber" name="domain" value="mydomain.org"></option>
+ <option type="ts_jabber" name="username" value="user"></option>
+ <option type="ts_jabber" name="passwd" value="pass"></option>
+
+ <option type="ts_jabber" name="muc_service" value="conference.mydomain.org"/>
+ <!-- full name of the MUC component -->
+ </options>
+
+ <sessions>
+ <session bidi="true" probability="100" name="jabber-muc" type="ts_jabber">
+
+ <request> <jabber type="connect" ack="no_ack"></jabber> </request>
+ <thinktime value="2"></thinktime>
+ <transaction name="authenticate">
+ <request> <jabber type="auth_get" ack="local"></jabber> </request>
+ <request> <jabber type="auth_set_plain" ack="local"></jabber> </request>
+ </transaction>
+
+ <request> <jabber type="presence:initial" ack="no_ack"/> </request>
+ <thinktime value="2"></thinktime>
+
+ <transaction name="roster">
+ <request> <jabber type="iq:roster:get" ack="local"></jabber></request>
+ </transaction>
+
+ <thinktime value="30"></thinktime>
+
+ <!-- choose room name and nick. -->
+ <setdynvars sourcetype="random_number" start="1" end="100">
+ <var name="room"/>
+ </setdynvars>
+ <setdynvars sourcetype="random_string" length="10">
+ <var name="nick1"/>
+ </setdynvars>
+
+ <!-- join an existing room or create a new one -->
+ <request subst="true"> <jabber type='muc:join' ack = "local" room = "room%%_room%%" nick = "%%_nick1%%"/> </request>
+
+ <for from="1" to="4" var="i">
+ <thinktime value="45"/>
+ <transaction name="online_chat">
+ <request subst="true"> <jabber type="muc:chat" ack="no_ack" size="16" room = "room%%_room%%"/> </request>
+ </transaction>
+ </for>
+
+ <!-- choose a new nickname -->
+ <thinktime value="2"/>
+ <setdynvars sourcetype="random_string" length="10">
+ <var name="nick2"/>
+ </setdynvars>
+ <request subst="true"><jabber type="muc:nick" room="room%%_room%%" nick="%%_nick2%%" ack="no_ack"/></request>
+
+ <for from="1" to="2" var="i">
+ <thinktime value="35"/>
+ <transaction name="online_chat">
+ <request subst="true"> <jabber type="muc:chat" ack="no_ack" size="16" room="room%%_room%%"/> </request>
+ </transaction>
+ </for>
+
+ <transaction name="close">
+ <request> <jabber type="close" ack="no_ack"></jabber> </request>
+ </transaction>
+
+ </session>
+
+
+ </sessions>
+</tsung>
+
View
@@ -39,7 +39,10 @@
nonce, %% used to generate sip-digest passwd
sid, %% used to generate digest passwd
show, %% presence <show/> - see RFC 3921, section 2.2
- status %% presence <status/> - see RFC 3921, section 2.2
+ status, %% presence <status/> - see RFC 3921, section 2.2
+ muc_service, %% ej: conference.localhost
+ room, %% MUC room name
+ nick %% nickname in MUC room
}).
-define(setroster_intensity, 1/(ts_utils:get_val(setroster)*1000)).
View
@@ -163,6 +163,10 @@ init_dynparams() ->
%% Function: subst/2
%% Purpose: Replace on the fly dynamic element
%%----------------------------------------------------------------------
+subst(Req=#jabber{type = Type}, DynData) when Type == 'muc:chat' ; Type == 'muc:join'; Type == 'muc:nick' ->
+ Req#jabber{nick = ts_search:subst(Req#jabber.nick, DynData),
+ room = ts_search:subst(Req#jabber.room, DynData)};
+
subst(Req=#jabber{data=Data}, DynData) ->
Req#jabber{data=ts_search:subst(Data,DynData)}.
@@ -197,6 +197,14 @@ get_message(#jabber{type = 'pubsub:publish', size=Size, id=Id,
<< >>
end;
+%% MUC benchmark support
+get_message(#jabber{type = 'muc:join', room = Room, nick = Nick, muc_service = Service }) ->
+ muc_join(Room,Nick, Service);
+get_message(#jabber{type = 'muc:chat', room = Room, muc_service = Service, size = Size}) ->
+ muc_chat(Room, Service, Size);
+get_message(#jabber{type = 'muc:nick', room = Room, muc_service = Service, nick = Nick}) ->
+ muc_nick(Room, Nick, Service);
+
get_message(Jabber=#jabber{username=Name, passwd=Passwd, id=Id}) ->
FullName = username(Name, Id),
FullPasswd = password(Passwd,Id),
@@ -514,6 +522,22 @@ publish_pubsub_node(Domain, Username, Node, Size) ->
"</pubsub></iq>"]),
Result.
+muc_join(Room,Nick, Service) ->
+ Result = list_to_binary(["<presence to='", Room,"@", Service,"/", Nick, "'>",
+ "<x xmlns='http://jabber.org/protocol/muc'/>",
+ " </presence>"]),
+ Result.
+
+
+muc_chat(Room, Service, Size) ->
+ Result = list_to_binary(["<message type='groupchat' to ='", Room,"@", Service,"'>",
+ "<body>", ts_utils:urandomstr_noflat(Size), "</body>",
+ "</message>"]),
+ Result.
+muc_nick(Room, Nick, Service) ->
+ Result = list_to_binary(["<presence to='", Room,"@", Service,"/", Nick, "'/>"]),
+ Result.
+
%%%----------------------------------------------------------------------
%%% Func: username/2
%%% Generate the username given a prefix and id
@@ -58,10 +58,14 @@ parse_config(Element = #xmlElement{name=jabber},
Show= ts_config:getAttr(string,Element#xmlElement.attributes, show, "chat"),
Status= ts_config:getAttr(string,Element#xmlElement.attributes, status, "Available"),
Type= list_to_atom(TypeStr),
+ Room = ts_config:getAttr(string,Element#xmlElement.attributes, room, undefined),
+ Nick = ts_config:getAttr(string,Element#xmlElement.attributes, nick, undefined),
Domain =ts_config:get_default(Tab, jabber_domain_name, jabber_domain),
UserName=ts_config:get_default(Tab, jabber_username, jabber_username),
Passwd =ts_config:get_default(Tab, jabber_passwd, jabber_passwd),
+ MUC_service = ts_config:get_default(Tab, muc_service, muc_service),
+
Msg=#ts_request{ack = Ack,
dynvar_specs= DynVar,
@@ -76,7 +80,10 @@ parse_config(Element = #xmlElement{name=jabber},
dest = Dest,
size = Size,
show = Show,
- status = Status
+ status = Status,
+ room = Room,
+ nick = Nick,
+ muc_service = MUC_service
}
},
ts_config:mark_prev_req(Id-1, Tab, CurS),
@@ -103,7 +110,10 @@ parse_config(Element = #xmlElement{name=option}, Conf = #config{session_tab = Ta
"userid_max" ->
N = ts_config:getAttr(integer,Element#xmlElement.attributes, value, 10000),
ts_user_server:reset(N),
- ets:insert(Tab,{{jabber_userid_max,value}, N})
+ ets:insert(Tab,{{jabber_userid_max,value}, N});
+ "muc_service" ->
+ N = ts_config:getAttr(string,Element#xmlElement.attributes, value, "conference.localhost"),
+ ets:insert(Tab,{{muc_service,value}, N})
end,
lists:foldl( fun(A,B) -> ts_config:parse(A,B) end, Conf, Element#xmlElement.content);
%% Parsing other elements
View
@@ -163,7 +163,9 @@ repeat | if )*>
data CDATA #IMPLIED
type NMTOKEN #REQUIRED
show (away|chat|dnd|xa) "chat"
- status CDATA "Available">
+ status CDATA "Available"
+ nick CDATA #IMPLIED
+ room CDATA #IMPLIED>
<!ELEMENT pgsql (#PCDATA) >
<!ATTLIST pgsql

0 comments on commit 68f8e0c

Please sign in to comment.