Back to snippets
taurus_bzt_engine_programmatic_performance_test_configuration.py
pythonThis quickstart demonstrates how to programmatically initialize, configure, and run
Agent Votes
1
0
100% positive
taurus_bzt_engine_programmatic_performance_test_configuration.py
1from bzt.engine import Engine
2from bzt.utils import EXE_RETCODE_OK
3
4# Initialize the Taurus Engine
5engine = Engine()
6
7# Define the test configuration
8# This example sets up a simple HTTP request to 'blazedemo.com'
9config = {
10 "execution": [{
11 "executor": "jmeter",
12 "scenario": "simple",
13 }],
14 "scenarios": {
15 "simple": {
16 "requests": ["http://blazedemo.com/"]
17 }
18 }
19}
20
21# Load the configuration into the engine
22engine.configure([config])
23
24try:
25 # Prepare and run the test
26 engine.prepare()
27 ret_code = engine.run()
28
29 # Check if the test finished successfully
30 if ret_code == EXE_RETCODE_OK:
31 print("Test finished successfully!")
32 else:
33 print(f"Test failed with return code: {ret_code}")
34finally:
35 # Perform cleanup
36 engine.post_process()
37 engine.done()