summaryrefslogtreecommitdiffstats
path: root/cns-libs/cnslibs/common/openshift_ops.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2018-07-26 19:01:56 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-09-24 17:35:40 +0530
commit1545031a488a7c40830fe00aba79e82b7eea3000 (patch)
tree72b6f34605d6f31b3d44c0ec6e018983a3f06b44 /cns-libs/cnslibs/common/openshift_ops.py
parentab4c4a625ae3defba70230282269079177491239 (diff)
[CNS-945] Add arbiter test case
Where we create POD with mounted arbiter volume and write data to it. Change-Id: I3a757f7fd71a0fd3f9f7d3cea463bbba5e399ec4
Diffstat (limited to 'cns-libs/cnslibs/common/openshift_ops.py')
-rw-r--r--cns-libs/cnslibs/common/openshift_ops.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/cns-libs/cnslibs/common/openshift_ops.py b/cns-libs/cnslibs/common/openshift_ops.py
index a4877687..4131ea9c 100644
--- a/cns-libs/cnslibs/common/openshift_ops.py
+++ b/cns-libs/cnslibs/common/openshift_ops.py
@@ -411,6 +411,39 @@ def oc_create_app_dc_with_io(
return dc_name
+def oc_create_tiny_pod_with_volume(hostname, pvc_name, pod_name_prefix='',
+ mount_path='/mnt'):
+ """Create tiny POD from image in 10Mb with attached volume at /mnt"""
+ pod_name = "%s-%s" % (pod_name_prefix, utils.get_random_str())
+ pod_data = json.dumps({
+ "apiVersion": "v1",
+ "kind": "Pod",
+ "metadata": {
+ "name": pod_name,
+ },
+ "spec": {
+ "terminationGracePeriodSeconds": 20,
+ "containers": [{
+ "name": pod_name,
+ "image": "cirros", # noqa: 10 Mb! linux image
+ "volumeMounts": [{"mountPath": mount_path, "name": "vol"}],
+ "command": [
+ "/bin/sh", "-ec",
+ "trap 'exit 0' SIGTERM ; "
+ "while :; do echo '.'; sleep 5 ; done",
+ ]
+ }],
+ "volumes": [{
+ "name": "vol",
+ "persistentVolumeClaim": {"claimName": pvc_name},
+ }],
+ "restartPolicy": "Never",
+ }
+ })
+ oc_create(hostname, pod_data, 'stdin')
+ return pod_name
+
+
def oc_delete(ocp_node, rtype, name):
"""Delete an OCP resource by name.