Skip to main content

Automate the process of distributed testing on a Kubernetes cluster by extending the functionality of pytest-xdist, allowing users to efficiently run tests in parallel across multiple pods.

Project description

Pytest-xdist-kubernetes

The pytest-xdist-plugin extends pytest-xdist with new kubernetes pod communication. It is capable of creating Kubernetes deployment using the given namespace and docker image, run tests from pods, and display the result at the end from the terminal.

How to Install

In order to use the plugin, >= Python 3.9 is required. Can be installed with the following command:

pip install pxk

How to Use

By giving --tx='pod' as part of the xdist command, it triggers Pytest-xdist-kubernetes plugin.

pytest {test files to run} -n {number of pods per deployment} --tx='pod'

On top of the existing pytest-xdist library, various options have been added to support running tests from kubernetes pods remotely.

pytest --namespace='{custom namspace}' --custom_image='{custom image}' {test files to run} -n {number of pods per deployment} --tx='pod'

When there are multiple images, multiple deployments get created and each deployment will contain its own image. The plugin will then try its best to evenly distribute the workers as much as possible. If the number of workers is less than the number of custom images, an exception would occur. Multiple custom images can be provided through the command without spaces in between images:

pytest --namespace='{custom namspace}' --custom_image='{custom image1,custom image2}' {test files to run} -n {number of pods per deployment} --tx='pod'

Logger is included as part of the functions added by the plugin. You can check the progress of the plugin by specifying:

--log-cli-level INFO

Since the plugin relies on xdist library's task scheduler for distributing tasks, you can specify how you would like to distribute tasks across multiple pods. By default, it evenly distributes test files.
But if you would like each pod to run all the specified test files:

pytest {testfiles to run} -n {number of pods per deployment} --tx='pod' --dist=each

All the testfiles must be from the same folder.
The plugin may have issues in Windows OS.

Reference

The plugin uses Kubernetes API to create/delete kubernetes deployments.
https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md

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

pxk-0.0.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

pxk-0.0.4-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pxk-0.0.4.tar.gz.

File metadata

  • Download URL: pxk-0.0.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

File hashes

Hashes for pxk-0.0.4.tar.gz
Algorithm Hash digest
SHA256 889592a70bd7e0c81ef0b8ca6f6254a80b9095f281d0d4bf7948a13b1b348e5f
MD5 fad1ee3ad9dd8d3ae574f4e93109a5b1
BLAKE2b-256 89e8735c3241afbd030b60b49a814cf04bdb1db6a99612ff729f642510a145e2

See more details on using hashes here.

File details

Details for the file pxk-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pxk-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

File hashes

Hashes for pxk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6862ce6d04a03069217d67b86ef3ae2a9761d537282c9ed0bf3aff46e9f186c3
MD5 0f3a926cf28b1e2dce3942aaf7cc1ab0
BLAKE2b-256 41dc49c723f6a06278a2821afc5bf7356d2c2d7e1d3ad500a3643e6dcba19a93

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