Skip to main content

This project provides some utilities function and CLI commands to test Charmed Spark on K8s.

Project description

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.

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

spark_k8s_test-0.0.3.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spark_k8s_test-0.0.3-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file spark_k8s_test-0.0.3.tar.gz.

File metadata

  • Download URL: spark_k8s_test-0.0.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spark_k8s_test-0.0.3.tar.gz
Algorithm Hash digest
SHA256 51b5fdcb99434d77f744b530236549e2381068eeffe44acc88c129f5198cb668
MD5 62ffbe76e3d9a4272d7247a39550689e
BLAKE2b-256 ed607ec1a4d34d7dfea969dab115915dd47a3f068c8325e36873d2d7a0db312d

See more details on using hashes here.

Provenance

The following attestation bundles were made for spark_k8s_test-0.0.3.tar.gz:

Publisher: publish-to-pypi.yaml on canonical/spark-k8s-bundle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spark_k8s_test-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: spark_k8s_test-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spark_k8s_test-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e1e95b6dc252b8a798b6cd4629d247045eb1d5ca1a61f69b3c2fb25adb1a69b4
MD5 2f1c3a704d962044871f18ef1306e286
BLAKE2b-256 4a9041bf99bfc208a69be110add6b16f1aa7d338f6d65681748b1d751c939b48

See more details on using hashes here.

Provenance

The following attestation bundles were made for spark_k8s_test-0.0.3-py3-none-any.whl:

Publisher: publish-to-pypi.yaml on canonical/spark-k8s-bundle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page