Molotov

2.6 · active · verified Thu Apr 16

Molotov is a simple, Python 3.7+ tool for writing load tests. It is built upon `asyncio` and `aiohttp.client`, enabling highly concurrent testing scenarios. The current version is 2.6, released in October 2022. While there isn't a fixed release cadence, updates address Python compatibility, dependency changes, and new features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart defines two asynchronous scenarios that make GET requests to a target API. Each scenario receives an `aiohttp.ClientSession` object. The `weight` parameter controls the probability of a scenario being picked. To run, save this as `loadtest.py` and execute from the terminal.

import os
from molotov import scenario

_API = os.environ.get('MOLOTOV_TARGET_API', 'http://localhost:8080')

@scenario(weight=40)
async def scenario_one(session):
    async with session.get(_API) as resp:
        res = await resp.json()
        assert res["result"] == "OK"
        assert resp.status == 200

@scenario(weight=60)
async def scenario_two(session):
    async with session.get(_API) as resp:
        assert resp.status == 200

view raw JSON →