Package: pymeter
pymeterSimple JMeter performance tests API for pythonPowered byJMeter-DSLandpyjniusLoad testing with JMeter using python!Read the documentationhereRead about performance benchmarkinghereJMeteris one of the most popular and long standing load testing tools.The original implementation is a gui based tool to script load test scenarios in a hierarchical structure, however this came with limitations and shortcomings.For once, upgrading JMeter versions is painful, as it involved manually downloading and deploying executable files.
This became very clear whenlog4jvulnerability was discovered, and software developers needed to instantly upgrade their log4j versions.
With JMeter, this was even more painful without a proper package management system such as maven or gradle.Other limitations include difficulty to share code between different projects, using source control management tools such as git or svn.
It is quite difficult to extend JMeter and it requires a GUI editor which means to use additional development environment instead of using a single IDE for all needs.The awesome folks atabstractahave put up an amazing amount of work to deliverJMeter-DSL, which allows developers to use plain Java to script their load test scenarios, and pretty much solve all the pain mentioned above.pymeterproject is aimed to capitalize on the success of JMeter-DSL and extend it to the python community!
Usingpyjniusdeveloped by Kivy, it is possible to bridge between JMeter-DSLs classes written in Java and reflect them into python's runtime environment without spawning up java runtime and relying on costly inter-process communication.Pre-requisites:python version 3.9 or higher -downloadJava version 8 or 11 -downloadJAVA_HOME environment variable set -readInstall pymeter>>>pipinstallpymetersimple pymeter script:"""unittest module"""fromunittestimportTestCase,mainfrompymeter.api.configimportTestPlan,ThreadGroupWithRampUpAndHoldfrompymeter.api.postprocessorsimportJsonExtractorfrompymeter.api.reportersimportHtmlReporterfrompymeter.api.samplersimportDummySampler,HttpSamplerfrompymeter.api.timersimportUniformRandomTimerclassTestTestPlanClass(TestCase):deftest_1(self):json_extractor=JsonExtractor("variable","args.var")timer=UniformRandomTimer(1000,2000)http_sampler=HttpSampler("Echo","https://postman-echo.com/get?var=${__Random(0,10)}",timer,json_extractor,)dummy_sampler=DummySampler("dummy ${variable}","hi dummy")tg=ThreadGroupWithRampUpAndHold(10,1,60,http_sampler,dummy_sampler,name="Some Name")html_reporter=HtmlReporter()tp=TestPlan(tg,html_reporter)stats=tp.run()print(f"duration={stats.duration_milliseconds}",f"mean={stats.sample_time_mean_milliseconds}",f"min={stats.sample_time_min_milliseconds}",f"median={stats.sample_time_median_milliseconds}",f"90p={stats.sample_time_90_percentile_milliseconds}",f"95p={stats.sample_time_95_percentile_milliseconds}",f"99p={stats.sample_time_99_percentile_milliseconds}",f"max={stats.sample_time_max_milliseconds}",sep="\t",)self.assertLess(stats.sample_time_99_percentile_milliseconds,2000)if__name__=="__main__":main()In this example, the standard python unittest was used to execute the test code, however pymeter is framework agnostic and can be used by any other testing frameworkFile Structure|   .coverage
|   .gitignore
|   .pylintrc
|   cosmic-ray-config.ini
|   LICENSE
|   make.bat
|   Makefile
|   poetry.lock
|   pyproject.toml
|   README.md
|   tox.ini               
+---source
|   |   conf.py
|   |   index.rst
|   |   
|   +---_static
|   \---_templates
+---src
|   \---pymeter
|       |   __init__.py
|       |   
|       +---api
|       |   |   config.py
|       |   |   postprocessors.py
|       |   |   reporters.py
|       |   |   samplers.py
|       |   |   timers.py
|       |   |   __init__.py
|       |   |   
+---utests
|   |   test_postprocessors.py
|   |   test_reporter.py
|   |   test_sampler.py
|   |   test_test_plan.py
|   |   test_thread_group.py
|   |   test_timers.py
|   |   __init__.py
|   |Code stylingblackused for auto-formatting coderead,pylintused for code linting and pep8 complianceread,mypyused for type hintingread,perflintpylint extension for performance lintingreadcosmic-rayPython tool for mutation testingreadContributorsAntonio Zaitoun📖Eldad Uzman🚇⚠️💻linksJMeter Dslpyjnius