Skip to main content

Kubernetes library for Robot Framework

Project description

KubeLibrary

RobotFramework library for testing Kubernetes cluster

Quick start

# install library itself
pip install robotframework-kubelibrary

# export KUBECONFIG
export KUBECONFIG=~/.kube/config

# run example tests
pip install robotframework-requests
git clone https://github.com/devopsspiral/KubeLibrary.git
cd KubeLibrary
robot testcases

Example testcase

Pods in kube-system are ok
    [Documentation]  Test if all pods in kube-system initiated correctly and are running or succeeded
    [Tags]    cluster    smoke
    Given kubernetes API responds
    When getting all pods in  "kube-system"
    Then all pods in "kube-system" are running or succeeded

Grafana has correct version
    [Documentation]  Test if Grafana container image is in correct version
    [Tags]    grafana
    Given kubernetes API responds
    When accessing "grafana-" excluding "svclb" container images version in "default"
    Then "grafana/grafana:6.5.0" version is used

More examples in testcases/ directory.

To see all the tests passing execute below commands.

git clone https://github.com/kyma-incubator/octopus
helm install octopus octopus/chart/octopus/

helm install grafana stable/grafana -f testcases/grafana/values.yaml

# run cluster tests
robot -i cluster testcases/

# run grafana tests
export KLIB_POD_PATTERN='grafana.*'
export KLIB_POD_ANNOTATIONS='{"checksumconfig":"3bb97e1695589c9bcdf6a6cd10c03517286ab7697626e6f02dd6fb2bc4a27796"}'
export KLIB_POD_NAMESPACE=default

robot -i grafana testcases/

# run octopus tests
export KLIB_RESOURCE_LIMITS_MEMORY=30Mi
export KLIB_POD_PATTERN='octopus.*'
export KLIB_RESOURCE_REQUESTS_CPU=100m
export KLIB_POD_LABELS='{"app":"octopus"}'
export KLIB_RESOURCE_LIMITS_CPU=100m
export KLIB_ENV_VARS='{"SECRET_NAME":"webhook-server-secret"}'
export KLIB_POD_NAMESPACE=default
export KLIB_RESOURCE_REQUESTS_MEMORY=20Mi

robot -i octopus testcases/

Keywords documentation

Keywords documentation can be found in docs/.

Further reading

DevOps spiral article on KubeLibrary

RobotFramewrok User Guide

Development

# clone repo
git clone https://github.com/devopsspiral/KubeLibrary.git
cd KubeLibrary

# create virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements

Create keyword and test file, import KubeLibrary using below to point to library under development.

| ***** Settings ***** |

| Library ../src/KubeLibrary/KubeLibrary.py |

For development cluster you can use k3s/k3d as described in DevOps spiral article on K3d and skaffold.

Generate docs

python -m robot.libdoc src/KubeLibrary/KubeLibrary.py docs/KubeLibrary.html

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

robotframework-kubelibrary-0.1.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

robotframework_kubelibrary-0.1.4-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file robotframework-kubelibrary-0.1.4.tar.gz.

File metadata

  • Download URL: robotframework-kubelibrary-0.1.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for robotframework-kubelibrary-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ded48f76298ae701b53a4b9152bf4ec6a6a35c27305b9fb66e3e40f7f8739879
MD5 359c73c922272376b100d126add5af04
BLAKE2b-256 1fc164fb926c143739f6242da8e0127def11ba64c4f90c38dc5fc33e8620b450

See more details on using hashes here.

File details

Details for the file robotframework_kubelibrary-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: robotframework_kubelibrary-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for robotframework_kubelibrary-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 219b79365061385ce13f914b6adf4c5f248f86c6dd3429c9273ea9e7b815e450
MD5 e7ba5aec4af269e72a57f014f19cfbda
BLAKE2b-256 05e1f7b5d0a7cd20f1974051e3e31e04cada13d2f866e1bc6b1fc885eb807cc5

See more details on using hashes here.

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