[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EFDM4H2VWE9X7EAD61DP71":3,"skill-same:01M6EFDM4H2VWE9X7EAD61DP71":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M6EFDM4H2VWE9X7EAD61DP71","locust",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Flocust\u002FSKILL.md",[],[5],"2026-11-10 10:12:30",false,"# Locust\n\n## Overview\n\nYou are an expert in Locust, the Python-based load testing framework. You help users write locustfiles that define user behavior as Python code, configure distributed load generation across multiple machines, use the real-time web UI for monitoring, and integrate Locust into CI pipelines in headless mode. You understand Locust's event hooks, task weighting, and custom load shapes.\n\n## Instructions\n\n### Initial Assessment\n\nBefore writing a locustfile:\n\n1. **Target** — What service or API are you testing?\n2. **User behavior** — What does a typical user session look like?\n3. **Scale** — How many concurrent users? Distributed across machines?\n4. **Mode** — Interactive (web UI) or headless (CI)?\n\n### Basic Locustfile\n\n```python\n# locustfile.py — Basic Locust load test for an e-commerce API.\n# Simulates users browsing products and adding items to cart.\nfrom locust import HttpUser, task, between\n\nclass WebsiteUser(HttpUser):\n    wait_time = between(1, 3)\n    host = \"https:\u002F\u002Fapi.example.com\"\n\n    def on_start(self):\n        \"\"\"Called when a simulated user starts. Login once per user.\"\"\"\n        self.client.post(\"\u002Flogin\", json={\n            \"username\": \"testuser\",\n            \"password\": \"testpass\"\n        })\n\n    @task(3)\n    def browse_products(self):\n        self.client.get(\"\u002Fproducts\")\n\n    @task(2)\n    def view_product(self):\n        self.client.get(\"\u002Fproducts\u002F1\")\n\n    @task(1)\n    def add_to_cart(self):\n        self.client.post(\"\u002Fcart\", json={\"product_id\": 1, \"quantity\": 1})\n```\n\n### Custom Load Shapes\n\n```python\n# load_shape.py — Custom load shape that simulates daily traffic patterns.\n# Ramps up in the morning, peaks at noon, drops in the evening.\nfrom locust import HttpUser, task, between, LoadTestShape\n\nclass ApiUser(HttpUser):\n    wait_time = between(1, 5)\n\n    @task\n    def get_data(self):\n        self.client.get(\"\u002Fapi\u002Fdata\")\n\nclass DailyTrafficShape(LoadTestShape):\n    stages = [\n        {\"duration\": 60, \"users\": 20, \"spawn_rate\": 5},\n        {\"duration\": 120, \"users\": 100, \"spawn_rate\": 10},\n        {\"duration\": 180, \"users\": 200, \"spawn_rate\": 20},\n        {\"duration\": 120, \"users\": 100, \"spawn_rate\": 10},\n        {\"duration\": 60, \"users\": 0, \"spawn_rate\": 20},\n    ]\n\n    def tick(self):\n        run_time = self.get_run_time()\n        elapsed = 0\n        for stage in self.stages:\n            elapsed += stage[\"duration\"]\n            if run_time \u003C elapsed:\n                return (stage[\"users\"], stage[\"spawn_rate\"])\n        return None\n```\n\n### Distributed Testing\n\n```bash\n# distributed-run.sh — Run Locust in distributed mode across multiple machines.\n# One master coordinates, workers generate the actual load.\n\n# Install\npip install locust\n\n# Start master (web UI on port 8089)\nlocust --master --host https:\u002F\u002Fapi.example.com\n\n# Start workers (run on each worker machine)\nlocust --worker --master-host=192.168.1.100\n\n# Headless distributed run\nlocust --master --headless -u 1000 -r 50 --run-time 5m \\\n  --expect-workers 4 --host https:\u002F\u002Fapi.example.com\n```\n\n### Event Hooks\n\n```python\n# events_example.py — Using Locust event hooks for custom reporting.\n# Logs failures to a file and sends alerts on high error rates.\nfrom locust import HttpUser, task, between, events\nimport logging\n\nlogger = logging.getLogger(\"locust_custom\")\n\n@events.request.add_listener\ndef on_request(request_type, name, response_time, response_length, exception, **kwargs):\n    if exception:\n        logger.error(f\"FAILED: {request_type} {name} - {exception}\")\n\n@events.test_stop.add_listener\ndef on_test_stop(environment, **kwargs):\n    stats = environment.runner.stats\n    total = stats.total\n    if total.fail_ratio > 0.05:\n        logger.critical(f\"ALERT: Error rate {total.fail_ratio:.1%} exceeds 5% threshold\")\n\nclass ApiUser(HttpUser):\n    wait_time = between(1, 3)\n\n    @task\n    def get_endpoint(self):\n        self.client.get(\"\u002Fapi\u002Fhealth\")\n```\n\n### Headless CI Mode\n\n```yaml\n# .github\u002Fworkflows\u002Flocust.yml — Run Locust headless in GitHub Actions.\n# Exports CSV results as pipeline artifacts.\nname: Load Test\non:\n  push:\n    branches: [main]\njobs:\n  locust:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: actions\u002Fsetup-python@v5\n        with:\n          python-version: \"3.12\"\n      - run: pip install locust\n      - run: |\n          locust --headless -u 50 -r 10 --run-time 2m \\\n            --host https:\u002F\u002Fapi.example.com \\\n            --csv results \\\n            -f tests\u002Flocustfile.py\n      - uses: actions\u002Fupload-artifact@v4\n        if: always()\n        with:\n          name: locust-results\n          path: results_*.csv\n```\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Flocust",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill locust",{"tool":37,"command":38},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill locust",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill locust","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Flocust\u002FSKILL.md",true,[],[46,60,70,79,85,92],{"skillNo":47,"name":48,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":56,"publishedAt":18},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[51],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[57,58,59],"model","model hierarchy","model hierarchy skill",{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":66,"publishedAt":18},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[65],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[67,68,69],"MCP","zoom","zoom mcp",{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[76,77,78,68],"sdk","zoom apps sdk","apps",{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[81],{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":91,"publishedAt":18},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[90],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[87],{"skillNo":93,"name":94,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[94]]