Search code examples
dockertsung

Tsung: client connection using port


Is there a way to configure client to communicate over ports.

My Setup:

  • I want to setup multiple tsung clients to distribute load generation.
  • The tsung clients are docker containers, each running in a different box. So one of the ways to connect from the client-master to the client-slaves is ip and port number.

So i want something like the below in the config file. Here client-master is the main client host. client-slave-1 and client-slave-2 are docker containers running on hosts - 10.0.0.101 and 10.0.0.102 respy and are accessible thru 10.0.0.101:8123 and 10.0.0.102:8123 respy.

<clients>
    <client host="client-master" use_controller_vm="true" maxusers="10000"/>
    <client host="client-slave-11" port="8123" weight="3" maxusers="40000" cpu="1">
        <ip value="10.0.0.101"></ip>
    </client>
    <client host="client-slave-2" port="8123" weight="3" maxusers="40000" cpu="1">
        <ip value="10.0.0.102"></ip>
    </client>
</clients>

Like from the client-master if i do a ssh -p 8123 [email protected], i can login to the client-slave-1. But i am not sure how to configure tsung to use this port config or if tsung even allows that.

So what i want is - If tsung allows the client configuration to include port numbers, how do i configure it. - If not, then is there a different option to do this using containers.


Solution

  • If there is not a solution built into tsung, you can use ~/.ssh/config to do it.

    In ~/.ssh/config:

    Host client-slave-11
      Hostname 10.0.0.101
      User root
      Port 8123
    Host client-slave-2
      Hostname 10.0.0.102
      User root
      Port 8123
    

    Due to tsung behavior, the value of Host must be the leftmost component of the domain name provided to tsung in it's config. Tsung will only use the leftmost component when calling the ssh binary.

    Alternatively, you might also be able to use a wrapper script and use -r argument for tsung. Here's the arg doc:

    -r <command>  set remote connector (default is ssh)
    

    Use your wrapper script for the <command>.