机器人框架的Kubernetes库
robotframework-kubelibrar的Python项目详细描述
库贝里布拉里
用于测试Kubernetes集群的RobotFramework库
快速入门
# 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
示例测试用例
^{pr2}$更多的例子在testcases/目录中。在
要查看所有通过的测试,请执行以下命令。在
集群测试
# run cluster tests
robot -i cluster testcases/
格拉法纳试验
helm install grafana stable/grafana -f testcases/grafana/values.yaml
# run grafana tests
export KLIB_POD_PATTERN='grafana.*'
export KLIB_POD_ANNOTATIONS='{"checksum/config":"3bb97e1695589c9bcdf6a6cd10c03517286ab7697626e6f02dd6fb2bc4a27796"}'
export KLIB_POD_NAMESPACE=default
robot -i grafana testcases/
章鱼测试
git clone https://github.com/kyma-incubator/octopus
helm install octopus octopus/chart/octopus/
# 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/
其他测试
这些测试需要在测试集群中安装kubelib测试头盔图表。在
# run other library tests
export KLIB_POD_PATTERN='busybox.*'
export KLIB_POD_NAMESPACE=kubelib-tests
export KLIB_POD_LABELS='job-name=busybox-job'
kubectl create namespace $KLIB_POD_NAMESPACE
kubectl label namespaces kubelib-tests test=test
helm install kubelib-test ./test-objects-chart -n $KLIB_POD_NAMESPACE
robot -i other testcases/
多群测试
{并利用一个以上的测试。 Download KinD and install it.
# Create Test Cluster 1
kind create cluster --kubeconfig ./cluster1-conf --name kind-cluster-1
# Create namespace in Test Cluster 1
kubectl create namespace test-ns-1 --context kind-kind-cluster-1 --kubeconfig ./cluster1-conf
# Create Test Cluster 2
kind create cluster --kubeconfig ./cluster2-conf --name kind-cluster-2
# Create namespace in Test Cluster 2
kubectl create namespace test-ns-2 --context kind-kind-cluster-2 --kubeconfig ./cluster2-conf
robot -i reload-config testcases/
# Clean up
kind delete cluster --name kind-cluster-1
kind delete cluster --name kind-cluster-2
关键词文档
关键字文档可以在docs/中找到。在
进一步阅读
DevOps spiral article on KubeLibrary
发展
# clone repo
git clone https://github.com/devopsspiral/KubeLibrary.git
cd KubeLibrary
# create virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements
创建关键字和测试文件,导入KubeLibrary使用下面指向正在开发的库。在
|******设置*****
|图书馆../src/KubeLibrary/库贝里布拉里.py|在
对于开发集群,您可以使用k3s/k3d,如DevOps spiral article on K3d and skaffold所述。在
生成单据
python -m robot.libdoc src/KubeLibrary/KubeLibrary.py docs/KubeLibrary.html
- 项目
标签: