Skip to main content

Kubernetes test support with KIND for pytest

Project description

pytest-kind

Test your Python Kubernetes app/operator end-to-end with kind and pytest.

Usage

Install pytest-kind via pip or via poetry, e.g.:

poetry add --dev pytest-kind

Write your pytest functions and use the provided kind_cluster fixture, e.g.:

def test_kubernetes_version(kind_cluster):
    assert kind_cluster.api.version == ('1', '15')

To load your custom Docker image and apply deployment manifests:

from pykube import Pod

def test_myapp(kind_cluster):
    kind_cluster.load_docker_image("myapp")
    kind_cluster.kubectl("apply", "-f", "deployment.yaml")
    kind_cluster.kubectl("rollout", "status", "deployment/myapp")

    # using Pykube to query pods
    for pod in Pod.objects(kind_cluster.api).filter(selector="app=myapp"):
        assert "Sucessfully started" in pod.logs()

Pytest Options

The kind cluster name can be set via the --cluster-name CLI option.

The kind cluster is deleted after each pytest session, you can keep the cluster by passing --keep-cluster to pytest.

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

pytest-kind-0.3.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

pytest_kind-0.3.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest-kind-0.3.0.tar.gz.

File metadata

  • Download URL: pytest-kind-0.3.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-58-generic

File hashes

Hashes for pytest-kind-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8b5bef82cb09f57417dd5f8439d9bffa00bf5fcd58fa15600f94b64e255411a2
MD5 a6c54458e8918e40fd403f64319d447a
BLAKE2b-256 e40869b05b83822d62588a954263f3c89d8a21905eae8eedd73cc254dd0b1950

See more details on using hashes here.

File details

Details for the file pytest_kind-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_kind-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-58-generic

File hashes

Hashes for pytest_kind-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 007a8c550413a3456b4fd45ff57eda816dd3eae81775b37c27e8d78c8e0405d7
MD5 a0655d594d23aa1464785bf8e71c7255
BLAKE2b-256 48bd9cc65ae272e23b3e808d060bb47ffb03f61ca96d8fea48508ba75e9d332d

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