Lucust

压测工具Lucust,使用python,提供简单UI报表

Lucust script

import random
import json
from locust import HttpUser, task, between

class QuickstartUser(HttpUser):
    wait_time = between(5, 9)
    host = 'http://localhost:8080'

    @task
    def test_compute(self):
        payload = {
              "calculatedFeatures": {},
              "event": {
                "excludeCurrent": False,
                "fields": {
                    "2": "云南省大理白族自治州祥云县"+ str(random.randint(200,500))+ "号"
                },
                "id": "string",
                "name": "string",
                "sentByUpdater": True,
                "time": 0
              },
              "features": [
                18
              ]
            }
        headers = {'content-type': 'application/json'}
        self.client.post("/trial-demo/fp/api-1.0-SNAPSHOT/tenant/features/batch-compute", data=json.dumps(payload), headers=headers)

执行

locust -f locustfile.py # 默认地址 http://localhost:8089/
Written on July 20, 2020