Skip to main content

spark-k8s-test

The main purpose of the spark-k8s-test library is to provide a seemless, user-friendly interface to implement tests for Charmed Apache Spark. spark-k8s-test provides a number of pytest fixtures that allow to create, manage and destroy various kind of resources needed for testing, such as:

  • K8s resources (e.g. namespaces, pods, service accounts)
  • S3 Buckets
  • spark8t managed service accounts / secrets

Moreover, spark-k8s-test provides simple API to run spark-jobs within a Python testing environment

Quick start

Installation

The package can be simply installed from PyPI using

pip install spark-k8s-test 

or from the source by cloning this repo and then running:

pip install .

The package assumes that a MicroK8s installation is present in the system, and that the deployment is configured with MinIO to provide object storage capabilities.

You can use the following scripts to setup a MicroK8s deployment along with MinIO:

./spark_test/resources/bin/microk8s.sh setup

./spark_test/resources/bin/microk8s.sh configure dns rbac minio

Basic Usage

You can simply import the fixtures and use them straight away in your tests:

from spark_test.fixtures.pod import admin_pod
from spark_test.fixtures.service_account import registry, service_account

def test_pod_admin(admin_pod, service_account):

    output: str = admin_pod.exec(
        ["spark-client.service-account-registry", "list"]
    ).decode("utf-8")

    assert output.strip("\n") == service_account.id

Development

For development, we recommend to use Poetry. Once Poetry is installed, you can simply setup the project by

poetry install

Tox also provide easy short-cut to provide CI/CD capabilities such as

  • Auto-Formatting: tox -e fmt
  • Linting and Static Typing: tox -e lint
  • Unittest: tox -e unittest
  • Integration tests: tox -e integration

User acceptance tests and benchmarks

The tox environments can be run against a live deployment to assert its compliance. Here is an example running the benchmarks environment to stress-test a deployment in a spark-model Juju model:

tox run -e benchmarks -- --backend terraform --backend-storage azure --no-deploy --keep-models --model spark-model

Contributing

Canonical welcomes contributions to the spark-k8s-test library. Please check out our guidelines if you're interested in contributing to the solution. Also, if you truly enjoy working on open-source projects like this one and you would like to be part of the OSS revolution, please don't forget to check out the open positions we have at Canonical.

License

The spark-k8s-test toolkit is free software, distributed under the Apache Software License, version 2.0. See LICENSE for more information.

See LICENSE for more information.

Metadata

Release files for spark-k8s-test 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spark-k8s-test 0.0.4
File Size Uploaded
spark_k8s_test-0.0.4.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spark-k8s-test 0.0.4
File Interpreter ABI Platform
spark_k8s_test-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 33.8 kB

Release files / spark_k8s_test-0.0.4.tar.gz

Download URL spark_k8s_test-0.0.4.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4c60e983e6527b0e9b6fde05993e8cf8e609f72329636dda152afec1b6f0bb4f
BLAKE2b-256 checksum
How to use checksums
70b681f06e77c73eb05a6c060ae1c82c1bd5417ac8b9b250d9a1e96e0bbbfa12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 22, 2025.

Transparency log

Release files / spark_k8s_test-0.0.4-py3-none-any.whl

Download URL spark_k8s_test-0.0.4-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f102df528a8aa2c32e2bdd707acc981084b09a9bd89a37c237d8184d4bf41247
BLAKE2b-256 checksum
How to use checksums
8f61dc6cbb51819cac19ba95f4b39336f4e29a3be88070f483b6451441310aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 22, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page