Welcome to TestShift’s documentation!¶
TestShift aims to provide the means to validate OpenShift based infrastructures, for this purpose, TestShift is implemented as a pytest plugin, taking after Testinfra for inspiration.
Cluster authentication¶
TestShift can use any of the following to find the cluster configuration file:
Standard configuration location (~/.kube/config)
KUBECONFIG environment variable
–kubeconfig argument.
Usage examples¶
Install it:
$ pip install -U -e "git+https://github.com/tripledes/testshift.git#egg=testshift"
Run it:
def test_sdn_pods_exist(cluster): pod = cluster.Pod(label_selector="app=sdn") assert pod.exists def test_etcd_pods_count(cluster): pod = cluster.Pod(label_selector="app=etcd") assert pod.count == 3 def test_performance_operator_is_running(cluster): pod = cluster.Pod(label_selector="name=performance-operator") assert pod.is_running def test_marketplace_operator(cluster): pod = cluster.Pod(name="marketplace-operator-798dbd94c6-xqj6b") assert pod.is_running assert pod.count == 1 def test_performance_operator_deployment(cluster): deployment = cluster.Deployment(name="performance-operator") assert deployment.exists assert deployment.namespace == "openshift-performance-addon" def test_node_properties_by_selector(cluster): node = cluster.Node(label_selector="node-role.kubernetes.io/worker-cnf=") assert node.count == 2 def test_node_properties_schedulable(cluster): node = cluster.Node("sjr-worker-0.sjr.deslab.net") assert node.schedulable == True
$ pytest --kubeconfig=/home/sjr/clusters/sjr/auth/kubeconfig tests -v =========================================== test session starts =========================================== platform linux -- Python 3.6.8, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /home/sjr/testshift/bin/python3.6 cachedir: .pytest_cache rootdir: /home/sjr plugins: testshift-0.9.3.dev5+g3f6558c collected 7 items tests/node_test.py::test_sdn_pods_exist[testshift] PASSED [ 14%] tests/node_test.py::test_etcd_pods_count[testshift] PASSED [ 28%] tests/node_test.py::test_performance_operator_is_running[testshift] PASSED [ 42%] tests/node_test.py::test_marketplace_operator[testshift] PASSED [ 57%] tests/node_test.py::test_performance_operator_deployment[testshift] PASSED [ 71%] tests/node_test.py::test_node_properties_by_selector[testshift] PASSED [ 85%] tests/node_test.py::test_node_properties_schedulable[testshift] PASSED [100%] ============================================ 7 passed in 2.28s ============================================