Skip to main content

使用rust开发的高性能python压测工具

Project description

atomic-bomb-engine-py

atomic-bomb-engine的python包装实现

logo

前端仓库

atomic-bomb-engine-front

使用条件:

  • python版本 >= 3.8
  • windows(x86), linux(x86), mac

使用方法:

  • 准备开始

通过pip安装 (0.5.0版本之前)

pip install atomic-bomb-engine-py

在python中引用时注意,需要引用atomic_bomb_engine, 而不是atomic_bomb_engine_py
为了避免混淆,0.5.0版本之后,pip更换了包名,更改为atomic-bomb-engine,

pip install atomic-bomb-engine

在python中导入

import atomic_bomb_engine

异步使用的时候,还需要引用asyncio

import asyncio
  • 开始压测

    • 单接口压测 (功能与多接口压测重叠,已废除)

    • 多接口压测

多接口压测可以使用batch_async方法进行操作,函数签名和解释如下

async def batch_async(
       test_duration_secs: int,
       concurrent_requests: int,
       api_endpoints:List[Dict],
       step_option:Dict[str, int]=None,
       verbose:bool=False,
       should_prevent:bool=False) ->Dict:
 """
     批量压测
     :param test_duration_secs: 测试持续时间
     :param concurrent_requests: 并发数
     :param api_endpoints: 接口信息
     :param step_option: 阶梯加压选项
     :param verbose: 打印详细信息
     :param should_prevent: 是否禁用睡眠
 """

使用assert_option方法可以返回断言选项字典

assert_options=[
atomic_bomb_engine.assert_option("$.code", 429),
atomic_bomb_engine.assert_option("$.code", 200)
])
print(result)

jsonpath如果不会用的话,建议去jsonpath学习

使用step_option方法可以返回阶梯加压选项字典

def step_option(increase_step: int, increase_interval: int) -> Dict[str, int]:
    """
    生成step option
    :param increase_step: 阶梯步长
    :param increase_interval: 阶梯间隔
    """

同样的本包中也包含了一个对api_endpoint的包装:endpoint方法,方便调用,endpoint中的assert_options中也可以套用assert_option方法

   async def run_batch():
       result = await atomic_bomb_engine.batch_async(
           test_duration_secs=10,
           concurrent_requests=10,
           api_endpoints=[
               atomic_bomb_engine.endpoint(
                   name="test1",
                   url="https:xxxxx1.xx",
                   method="get",
                   weight=1,
                   timeout_secs=10,
                   assert_options=[atomic_bomb_engine.assert_option(jsonpath="$.code", reference_object=200)]
               ),
               atomic_bomb_engine.endpoint(
                   name="test2",
                   url="https://xxxxx2.xx",
                   method="get",
                   weight=1,
                   timeout_secs=10)
           ])
       print(result)

监听时可以使用BatchListenIter生成器

async def listen_batch():
    iterator = atomic_bomb_engine.BatchListenIter()
    for message in iterator:
        if message:
            print(message)
        else:
            await asyncio.sleep(0.3)

同时调用时同单接口

async def main():
    await asyncio.gather(
        run_batch(),
        listen_batch(),
    )


if __name__ == "__main__":
    asyncio.run(main())

压测时使用ui界面监控

0.5.0版本后,添加了ui页面,支持批量压测方法
导入

from atomic_bomb_engine import server

使用

import asyncio

import atomic_bomb_engine
from atomic_bomb_engine import server


@server.ui(port=8000)
async def run_batch():
    result = await atomic_bomb_engine.batch_async(
        test_duration_secs=120,
        concurrent_requests=100,
        verbose=False,
        api_endpoints=[
            atomic_bomb_engine.endpoint(name="test-baidu",url="https://baidu.com",method="GET",weight=1,timeout_secs=10),
            atomic_bomb_engine.endpoint(name="test-google", url="https://google.com", method="GET", weight=1, timeout_secs=10),
        ])
    print(result)
    return result


if __name__ == '__main__':
    asyncio.run(run_batch())

使用server.ui装饰器,可以给批量压测方法启动一个简单的web服务器,不需要再手动监听BatchListenIter生成器

内部架构图

architecture.png

bug和需求

  • 如果发现了bug,把复现步骤一起写到Issus中哈
  • 如果有需求也可以在Issues中讨论
  • 本程序是本人业余时间开发,不太准备保证时效性,但是如果有时间,一定第一时间回复和修改bug

TODO

  • 前端展示页面 ✅
  • 接口关联
  • 每个接口可以配置思考时间
  • 增加form支持 ✅
  • 增加附件支持
  • 断言支持不等于等更多表达方式

联系方式

👏🏻👏🏻👏🏻欢迎加群交流

img.png

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

atomic_bomb_engine-0.15.1-cp312-none-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

atomic_bomb_engine-0.15.1-cp312-cp312-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.34+ x86-64

atomic_bomb_engine-0.15.1-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

atomic_bomb_engine-0.15.1-cp312-cp312-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

atomic_bomb_engine-0.15.1-cp311-none-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

atomic_bomb_engine-0.15.1-cp311-cp311-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

atomic_bomb_engine-0.15.1-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

atomic_bomb_engine-0.15.1-cp311-cp311-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

atomic_bomb_engine-0.15.1-cp310-none-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.10 Windows x86-64

atomic_bomb_engine-0.15.1-cp310-cp310-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

atomic_bomb_engine-0.15.1-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

atomic_bomb_engine-0.15.1-cp310-cp310-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10 macOS 10.12+ x86-64

atomic_bomb_engine-0.15.1-cp39-none-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

atomic_bomb_engine-0.15.1-cp39-cp39-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

atomic_bomb_engine-0.15.1-cp39-cp39-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

atomic_bomb_engine-0.15.1-cp39-cp39-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.9 macOS 10.12+ x86-64

atomic_bomb_engine-0.15.1-cp38-none-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

atomic_bomb_engine-0.15.1-cp38-cp38-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.34+ x86-64

atomic_bomb_engine-0.15.1-cp38-cp38-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

atomic_bomb_engine-0.15.1-cp38-cp38-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.8 macOS 10.12+ x86-64

File details

Details for the file atomic_bomb_engine-0.15.1-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 48d943b0133c82977ace1f8ca32a9a258118ec5574a8f2c7db4c4f3198bf8f47
MD5 9963960e1986c002a96304ff83e0a4cd
BLAKE2b-256 3520cfe1e6dec2c268a9bb7d639d517cc1113951c8add80ac866653b9421cb72

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f8cb0f0f453837945b5a5da9619cd8cf18a500accc081bbc3b960c4f0258729b
MD5 1d0a93704b2bdd80875f34b9b7cab727
BLAKE2b-256 87532523e05659ccec5ef6fe3b65d421a55dc57caaed23e34aa590f3baf6932c

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e61c704347c2c0a88c35a756280c5407e8212793b1a6bc3d6a09bfff0036738
MD5 511c1dfcd53a7970c6943a437bd9116a
BLAKE2b-256 44f8cd54303f9e083f2779a494e78f93ed95fa1b4c8a627eea0eea00c4cd65c7

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 57dbc88ae51a224bba02ca15fad15971defd04aa627e62900b5bbf078ea6a9a1
MD5 d115be6b3aabfbb2645478100cfa98b2
BLAKE2b-256 f2bd92636670e8421abc9682b32f721a90d96e4bdd40cd7eab2be43455d3cd63

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 6d17e77ab686fc96a5fff11dccf7b0f67de43238423329c243a7e18cdf0f3323
MD5 7013f221f4619a88d3d4eb114dbd84bb
BLAKE2b-256 ebd95692cb9bc2cc236ee9dac0e2c4bba9a6f9bf142a5f141c75ebb1affbd1cc

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f65d78b053ce83695293e33b465500366563164d045657dccb46948f48f028e9
MD5 45cb0b3d3e31f860867c5b54f480213c
BLAKE2b-256 e00f9a8b70e8333b59d8efec6fc081db185c9e61b56d5ee56b46a2f1d06205fc

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92498319405330c6afc578ed1504c109e1ad274b80933609f731f5c2029ddb4b
MD5 9b2bf94e3cfb389148fce6dd3337c758
BLAKE2b-256 798c9187e4964198bea327c63bc7e53eed5054048541486776848267f33492da

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed735d6dda838a5c227538ac39e0249985ebff80ca2fb85bf0d26d10f56fc3a2
MD5 24f58cd5bbca6fda1000bb5025936547
BLAKE2b-256 57a8cbc524618c7d6440b7cb7d8497822314cd4f9d831870c08384b81a70d4e6

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 55c4a4c4604a2eb7c5c51d06260704044775a6c089976162006ad91973573dde
MD5 cfea25cccde47b0d0e112c115c65f5fe
BLAKE2b-256 b57bc24f934056ad98b68583d61efb1304fbfa192a9427b5e11ad428947a76b5

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5ffc0525ef9d06629b839f98559f4813f84d0604525fd8efdae7ee062e9e5125
MD5 3b8c51f1185b6c3e4780dfa39381ee44
BLAKE2b-256 68a15a7feaa510a32b6f0287f05345a2f64c6bbb14605a1425bec9211d0c2bc1

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99d4a9b3046bc40fe10680c0473885674959c99015aa94c5265d95d1625df530
MD5 ad6900362e8890c4638237aac39a4fcb
BLAKE2b-256 c0b21c00632a73174b216abc3f7e79a60e85db88e02abb14ec03d8e01a8ed7c9

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3a05302b97c2aca1ff06566cb20faa1a79a87bd1c584343a68dbcec9c3319641
MD5 f65826c93fcd96c015b2370a03be6d0c
BLAKE2b-256 0f2c5d3b355859411fb843f9123a573a690f85ea92a3d78c5ebb795582cd22f0

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 52e4566718c10077a2fee29c4763ed721c31a519661f6124840194d6ae12c298
MD5 41fdebc02f9544fa680b5cca26bec5ed
BLAKE2b-256 8496516a587e312571efd4324b71143820502379090f1d78ea11153be5ce80ec

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 72d25b27d5d5a9a91c73f4786f32fe734dae61f98c862a8474079ab9f18b2038
MD5 1c3a98b2565f49eb720c38532458ad4d
BLAKE2b-256 6c3450cb19b330859e58c52f5c1a487b0f099d1f105eda3dcb8ec6a3187a2d04

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 667d4fc584a83bc382ac9a388f0c7fb9e495004c768e15f634954193759697de
MD5 369b9a30cab499dbc7eeb23b48fb7701
BLAKE2b-256 ac096e48c91ddf273b9040460be4b157e0e78a56a89c52d43382779f921c5016

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 67b5c7bfa68adc5f9f02c89636d58585f39fd2dbbe380e098206b4dd23f568e5
MD5 704591a64c55a04544ed98cf85e69639
BLAKE2b-256 6a963e142333e59924d824183ec9ded6d0e7903400d98950cee00d28599f1d01

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 33e3a28af86ceee0296accad778415bb9e19214343af60860c3dc3134796ab1a
MD5 418dd0ae7cc8b967d58af60c9ea1704c
BLAKE2b-256 88eaf0ce4d53abffb7ebda4a979e87a6a00dca37c66759bcceb9a55594245fc5

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3adcf3dc70da5568311a6c7931764d6cb3ea9ecabbd4a300dfe34acaa666cda3
MD5 7493767e0433ca1a25529f4263f2097a
BLAKE2b-256 94e193ea4ce3365a3c4552bd2e4590a0342e6a308d318f769e9dae5436574181

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b20303287e70a830c20a03a3d0f35aeb804a20d25f6d37d26cedbdd826ef4edd
MD5 7bc72a290290a9af4331b4616cae95ca
BLAKE2b-256 670580fefe8e3deed19386760f30d962adc4371529c0a65f50e90629d48d14e0

See more details on using hashes here.

File details

Details for the file atomic_bomb_engine-0.15.1-cp38-cp38-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for atomic_bomb_engine-0.15.1-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7818b46b556b78f130afd6670275f9c9dca1f25efd26525c3b6ab87fccc17d6c
MD5 457573d2226cb603b193a5d7aba1ee71
BLAKE2b-256 c55688a3326fa427c959a62b6746358f45a829ec0a2e824d650351f5c8950181

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