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

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.1.tar.gz (13.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.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for spark_k8s_test-0.0.1.tar.gz
Algorithm Hash digest
SHA256 22a140865cc52235588cbc79a55f18f9a7d39ad82078f297c94e04f7a7c09ccc
MD5 0f92faf492fcd50d42c8ece5a2320342
BLAKE2b-256 ecb2641ef61082893556ef57ba80912f630147539ba2dac19769927d6fec66b2

See more details on using hashes here.

Provenance

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

Publisher: release-spark-test.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for spark_k8s_test-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ce8a920a8c546d5223699f28d0ded18da2e399bd4d96cf32259a1cf85d7e267
MD5 8f7bff5450922a66ddddcc1a07d29657
BLAKE2b-256 150403044afbcdc5f3a04c185f6ba0b46aa2f8e9f635edf3584247cba769d7a8

See more details on using hashes here.

Provenance

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

Publisher: release-spark-test.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