Configuration¶
This section explain all the configurations available with a project
Basic configuration¶
The default configuration file look like this
[global]
run_time = 30
rampup = 0
results_ts_interval = 10
progress_bar = on
console_logging = off
base_url = http://localhost
default_sleep_time = 2
statics_enabled = 1
[user_group-1]
threads = 3
script = v_user.py
[user_group-2]
threads = 3
script = v_user.py
Global section¶
Runtime¶
run_time = 30
The time in second for running the project when calling the multimech-run command
Rampup¶
rampup = 0
This variable represent the time in second before reaching the specified number of virtual users requested
Base url¶
base_url = http://localhost
The base url for the tests. This url will be used by the open_url method
Sleep time¶
default_sleep_time = 2
The default sleep time in second, used will calling the user_sleep method
User group sections¶
This sections define the virtual groups for testing
Statics section¶
When testing, you don’t always want to load all statics, some are from CDN, other are from third party, etc... Well, we let you choose each statics domain you want to include within a statics section. If not statics section is provided, then the tests scripts will include all of them, this is the default settings.
If you want to add domain to add a white list of domain to include, just set a configuration section like this :
[statics]
include1=http://my_serveur.net
include2=http://testing.my_serveur.net
With this configuration, all statics with an url starting with one of those address will be load, and only if they start with one of those. All others statics files will be ignored
Custom configuration variables¶
In some projects, you may need some custom configuration, well that’s possible, just add all the section you need in the config.cfg file.
Since the GenericTransaction class load the configuration file by default, you can access all the sections and variables you need inside your script.
Let’s take a basic configuration file for example :
[global]
run_time = 30
rampup = 0
results_ts_interval = 10
progress_bar = on
console_logging = off
base_url = http://localhost
default_sleep_time = 2
statics_enabled = 1
[user_group-1]
threads = 3
script = v_user.py
[custom_section]
custom = spam
Ok so now inside our test script we want to get the custom value, we just need to do this inside our run method :
def run(self):
spam = self.config.get('custom_section', 'custom')
print(spam)
if __name__ == '__main__':
trans = Transaction()
trans.run()
And that’s it, if you run the script, it will print the spam, since the custom variable value is spam