Skip to main content

Developer friendly load testing framework Based on asyncio

Project description

What is Aiotest?

Aiotest is an easy to use, scriptable and scalable performance testing tool.

You define the behaviour of your users in Python asyncio code, instead of being stuck in a UI or restrictive domain specific language.

This makes Aiotest infinitely expandable and very developer friendly.

To start using Aiotest, go to Installation

Install the package

pip install aiotest

Run aiotest

aiotest -f aiotestfile.py
from aiotest import AsyncHttpUser, LoadUserShape, logger

class TestUser(AsyncHttpUser):
    host = "https://uat.taobao.com"
    token = None

    async def on_start(self):
        url = "/login"
        data = {"username": "admin", "password": "123456"}
        async with self.session.post(url=url, data=data) as resp:
            data = await resp.json()
            self.token = data["token"]

    async def test_search(self):
        url = "/search"
        hearders = {"Authorization": self.token}
        data = {"keyword": "F22"}
        async with self.session.post(url=url, hearders=hearders, json=data) as resp:
            data = await resp.json()      

    async def test_personal_info(self):
        url = "/personalInfo"
        async with self.session.get(url=url, hearders=hearders) as resp:
            data = await resp.json()

Features

  • Write test scenarios in python asyncio

    If you want your users to loop, perform some conditional behaviour or do some calculations, you just use the asyncio programming constructs provided by Python. Aiotest runs every user inside its task (a asyncio task). This enables you to write your tests like normal (async) Python code instead of having to use callbacks or some other mechanism. Because your scenarios are "just python" you can use your regular IDE, and version control your tests as regular code

  • Distributed and scalable - supports hundreds of thousands of concurrent users

    Aiotest makes it easy to run load tests distributed over multiple machines. It is asyncio-based (using python asyncio, which makes it possible for a single process to handle many thousands concurrent users. While there may be other tools that are capable of doing more requests per second on a given hardware, the low overhead of each Aiotest user makes it very suitable for testing highly concurrent workloads.

  • Command-based UI

    It can also be run without the UI, making it easy to use for CI/CD testing.

  • Can test any system

    Even though Aiotest primarily works with web sites/services, it can be used to test almost any system or protocol. Just write a client for what you want to test

  • Prometheus-Grafana-based Data collection and presentation

    Use Prometheus to collect test data and Grafana to present it grafana grafana

  • Automatic collection of test cases(Reference pytest)

    An automatic collection of use cases similar to pytest, subclasses of User and LoadUserShape must start or end with Test(eg: TestUser,TestShape...), and api coroutines to be tested must also start or end with test(eg: test_search, test_personal_info...)

  • Multiple user classes, flexible setting of test scenarios

    A aiotestfile can have multiple user classes at the same time, set different execution weights through the user class attribute weight, and flexibly set various test scenarios, example, shopping mall ordering scene, a user class simulating direct placing an order, and a user class simulating shopping cart placing an order.

  • Custom load shapes

    Sometimes a completely custom shaped load test is required that cannot be achieved by simply setting or changing the user count and spawn rate. For example, you might want to generate a load spike or ramp up and down at custom times. By using a LoadUserShape class you have full control over the user count and spawn rate at all times.

  • Serial, parallel execution of api coroutines

    Each user (a user class instance) acquiesce executes the test api coroutine serial from top to bottom(eg: when placing an order in the mall, the rear interface must wait for the return data from the front interface before it can be executed);You can override the self.start() method of the user class to execute the api coroutine to be tested in parallel(eg: api do not need to wait for the return data of other apis, and can be executed in parallel)

Authors

License

Open source licensed under the MIT license (see LICENSE file for details).

Express one's thanks

Aiotest is a rewrite of locust (based on python asyncio) that drops the TaskSet class, sets the API to be tested only through the User class, drops the Stats class, collects test data through Prometheus, drops the Web class, and presents test data through Grafana

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotest-0.5.8.tar.gz (469.8 kB view details)

Uploaded Source

Built Distribution

aiotest-0.5.8-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

Details for the file aiotest-0.5.8.tar.gz.

File metadata

  • Download URL: aiotest-0.5.8.tar.gz
  • Upload date:
  • Size: 469.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aiotest-0.5.8.tar.gz
Algorithm Hash digest
SHA256 2ce42e13ab5a7eee869e7ef43351acd2a175fb7bfc23c79cce8dbe3d335132fa
MD5 c857eabf41e6682a91429f157e550788
BLAKE2b-256 aa179a8880481ead89e31deb438bed65ac31db3d0b71dab0c62e1dd52a2b81b7

See more details on using hashes here.

File details

Details for the file aiotest-0.5.8-py3-none-any.whl.

File metadata

  • Download URL: aiotest-0.5.8-py3-none-any.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for aiotest-0.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3067c5d7c8b334f619e7c90266380611654971b80b4df150a9e2cbc9aeae235a
MD5 c5098bf5167cab800308f1ab80cd2e83
BLAKE2b-256 bb2a2b64e2f918926d725699df8f9715e5c90b3ecbc994a2b0b9b6aa1a3b8998

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page