{"id":15062561,"url":"https://github.com/grafana/xk6-python","last_synced_at":"2025-06-17T23:35:52.229Z","repository":{"id":257628884,"uuid":"858834394","full_name":"grafana/xk6-python","owner":"grafana","description":"Write k6 tests in Python","archived":false,"fork":false,"pushed_at":"2024-09-18T08:15:16.000Z","size":82,"stargazers_count":52,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T12:05:47.088Z","etag":null,"topics":["xk6"],"latest_commit_sha":null,"homepage":"https://grafana.github.io/xk6-python","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-17T16:01:28.000Z","updated_at":"2025-04-14T14:25:01.000Z","dependencies_parsed_at":"2024-09-24T19:50:48.348Z","dependency_job_id":null,"html_url":"https://github.com/grafana/xk6-python","commit_stats":null,"previous_names":["grafana/xk6-python"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grafana/xk6-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/xk6-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260458288,"owners_count":23012476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["xk6"],"created_at":"2024-09-24T23:42:51.658Z","updated_at":"2025-06-17T23:35:47.198Z","avatar_url":"https://github.com/grafana.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-python\n\n**Write k6 tests in Python**\n\n\u003e [!IMPORTANT]\n\u003e `xk6-python` is not an official k6 extension but was a **Grafana Hackathon #10** project!\n\u003e Active development is not planned in the near future.\n\u003e The purpose of making it public is to assess demand (number of stars on the repo).\n\nThe xk6-python k6 extension allows writing k6 tests in ([a dialect of](https://github.com/google/starlark-go/blob/master/doc/spec.md)) the Python programming language. The tests are executed by a built-in Python interpreter ([starlark-go](https://github.com/google/starlark-go)), so there is no need for Python installation.\n\n```python file=script.star\n\"\"\"\nExample k6 test script.\n\"\"\"\n\nload(\"check\", \"check\")\nload(\"requests\", \"get\")\nload(\"time\", \"sleep\")\n\noptions = {\n    \"vus\": 5,\n    \"duration\": \"5s\",\n    \"thresholds\": {\n        \"checks\": [\"rate\u003e=0.99\"],\n    },\n}\n\ndef default(_):\n    resp = get(\"https://httpbin.test.k6.io/get\")\n\n    check(resp, {\n        \"is status 200\": lambda r: r.status_code == 200,\n    })\n\n    sleep(0.5)\n```\n\n```bash\n./k6 run script.py\n```\n\n_This is not a toy, but a Proof of Concept for full-fledged k6 Python language support._\n\nCheck out the [documentation](https://grafana.github.io/xk6-python/).\n\n## Motivation\n\nPython is quite a popular programming language these days. According to the [TIOBE Programming Community Index](https://www.tiobe.com/tiobe-index/) 2024, Python has secured the top position, beating C++, C, Java, and JavaScript.\n\nEven though [k6 intentionally only supports one programming language](https://k6.io/blog/why-k6-does-not-introduce-multiple-scripting-languages/), it is worth considering making an exception for Python.\n\n## Why Starlark?\n\nThe [starlark-go](https://github.com/google/starlark-go) package is a pure go implementation of the [Starlark python dialect](https://github.com/google/starlark-go/blob/master/doc/spec.md). Its use does not require external dependencies, such as the installation of CPython. It doesn't even require the use of [cgo](https://go.dev/wiki/cgo). This enables the portability of the k6 executable binary and simplifies its use in the cloud.\n\n## Is it Python?\n\nYes and no.\n\nYes, because starlark is a python dialect. The **language and syntax is python**.\n\nNo, because the **usual python ecosystem cannot be used**:\n- no python module system\n- packages that can be installed with pip cannot be used.\n\nThis is an embedded python interpreter that does not make the python ecosystem available in the same way as the k6 JavaScript interpreter does not make the Node.js reason system available. So only the python language and syntax can be used plus the built-in modules and the local and remote python/starlark modules.\n\n## Features\n\nThe xk6-python development is in the PoC phase, but it can be used to write real k6 tests. Currently implemented main features:\n\n- supports the k6 options object as a Python dict\n- fully supports k6 lifecycle functions (setup, default, teardown)\n- supports the use of built-in, remote and local modules\n- partial support of the most important k6 APIs\n\n## Download\n\nYou can download pre-built k6 binaries from [Releases](https://github.com/grafana/xk6-python/releases/) page.\n\n## Status\n\n**xk6-python** is currently in _Proof of Concept_ status, but can already be used to run real k6 tests written in Python.\n\nCheck the [documentation](https://grafana.github.io/xk6-python/) for available modules.\n\n## Contribute\n\nIf you would like to contribute, start by reading [Contributing Guidelines](https://grafana.github.io/xk6-python/CONTRIBUTING.html).\n\n## k6 version\n\nxk6-python is currently compatible with k6 v0.52.0. It is possible that it works with other versions, but it has not been tested.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fxk6-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-python/lists"}