vernemq / vmq_mzbench

An MQTT loadtest and usage scenario tool for VerneMQ and other MQTT systems.
Apache License 2.0
42 stars 44 forks source link

how to test auth for a lot of users #31

Closed sevenjay closed 5 years ago

sevenjay commented 5 years ago

its possible to use many user accounts on test auth to run? I have a tsv file like below:

client001    user001      pw001
client002    user002      pw002
...
client100    user100      pw100

I can print a random one row by:

include_resource(tsv_resource, "resource_data.tsv", tsv)

pool(size = 3,
    worker_type = dummy_worker):
    print(choose(resource(tsv_resource)))

but how to put all accounts into test scenario?

make_install(git = "https://github.com/erlio/vmq_mzbench.git",
             branch = "master")

pool(size = 100,
     worker_type = mqtt_worker,
     worker_start = poisson(10 rps)):

            connect([t(host, "test-mqtt"),
                    t(port,1883),
                    t(client,"client001-100"),
                    t(username, "user001-100"),
                    t(password, "pw001-100"),
                    t(clean_session,true),
                    t(keepalive_interval,60),
                    t(proto_version,4), t(reconnect_timeout,4)
                    ])

            set_signal(connect1, 1)
            wait_signal(connect1, 100)
            wait(4 sec)
            loop(time = 10 sec, rate = 1 rps):
                publish("test/broadcast", "THIS IS A TEST", 0)
            disconnect()

just in "client001-100", I cannot find a way to extract the value from the list. there is no operator [] like resource(tsv_resource)[1][1]

ioolkos commented 5 years ago

That's a good question! I'v never loaded clientid/username/password combos from resource files like that. Did you scan the examples from MZBench a little? https://github.com/mzbench/mzbench/tree/master/examples.bdl Maybe there's a hint there.

Pinging @parsifal-47 hi... :) maybe you have an idea on this? (looking for a way to loop through a resource file)

parsifal-47 commented 5 years ago

that is correct, you may access various resource rows to get credentials for your users, you may use loop iterator for that if you have equal number of iterations to users or you may use randomized access. https://github.com/mzbench/mzbench/blob/master/doc/scenarios/spec.md#iterator https://github.com/mzbench/mzbench/blob/master/doc/scenarios/spec.md#random_number

The only problem if you have big number of these (for example 10^6), you may start to suffer from List access O(N) complexity.

sevenjay commented 5 years ago

Thank parsifal-47 and sorry I am newbie with erlang and MZBench. Would you help me to show a grammar to get a value from list by order like below?

include_resource(tsv_resource, "resource_data.tsv", tsv)

pool(size = 5,
    worker_type = dummy_worker):
    tempRow = round_robin(resource(tsv_resource)) #BDL grammar error
    print(sprintf("Client ~p, ID is ~p, password is  ~p", tempRow[1], tempRow[2], tempRow[3])) #BDL grammar error
parsifal-47 commented 5 years ago

np! the example you gave looks almost valid, first just in case, don't forget shebang at the beginning, second -- there are no assignments and no direct list accessors,

please try running the following:

include_resource(tsv_resource, "resource_data.tsv", tsv)

pool(size = 5,
    worker_type = dummy_worker):
    print(sprintf("Client creds are  ~p",  round_robin(resource(tsv_resource))))

or

include_resource(tsv_resource, "resource_data.tsv", tsv)

pool(size = 5,
    worker_type = dummy_worker):
    print(sprintf("Client creds are  ~p",  choose(resource(tsv_resource))))

please let me know if you have questions

sevenjay commented 5 years ago

There are no assignments and no direct list accessors

So it's impossible to extract all value from each index of the list? Or may be we can put info into a list of client like "clientInfoList", and set it to vmq_mzbench? @ioolkos Could it be like below?

make_install(git = "https://github.com/erlio/vmq_mzbench.git",
             branch = "master")

include_resource(tsv_resource, "resource_data.tsv", tsv)

pool(size = 100,
     worker_type = mqtt_worker,
     worker_start = poisson(10 rps)):

            connect([t(host, "test-mqtt"),
                    t(port,1883),
                    t(clientInfoList, round_robin(resource(tsv_resource))),
                    t(clean_session,true),
                    t(keepalive_interval,60),
                    t(proto_version,4), t(reconnect_timeout,4)
                    ])

            set_signal(connect1, 1)
            wait_signal(connect1, 100)
            wait(4 sec)
            loop(time = 10 sec, rate = 1 rps):
                publish("test/broadcast", "THIS IS A TEST", 0)
            disconnect()
parsifal-47 commented 5 years ago

your listing looks valid, yes restructuring or structure conversions supposed to happen inside worker operations