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.4.tar.gz (14.1 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.4-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spark_k8s_test-0.0.4.tar.gz
  • Upload date:
  • Size: 14.1 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.4.tar.gz
Algorithm Hash digest
SHA256 4c60e983e6527b0e9b6fde05993e8cf8e609f72329636dda152afec1b6f0bb4f
MD5 0452cd002069f3583f7e3a8e36561102
BLAKE2b-256 70b681f06e77c73eb05a6c060ae1c82c1bd5417ac8b9b250d9a1e96e0bbbfa12

See more details on using hashes here.

Provenance

The following attestation bundles were made for spark_k8s_test-0.0.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: spark_k8s_test-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.6 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f102df528a8aa2c32e2bdd707acc981084b09a9bd89a37c237d8184d4bf41247
MD5 810643327329f874b2725e6e91f754ea
BLAKE2b-256 8f61dc6cbb51819cac19ba95f4b39336f4e29a3be88070f483b6451441310aa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for spark_k8s_test-0.0.4-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