Fix ovnaction cnitype key value
[multicloud/k8s.git] / kud / tests / optane.sh
1 #!/bin/bash
2 # PDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 echo "[OPTANE-TEST] Check the NVDIMM hardware ..."
12 ndctl_region=`ndctl list -R`
13 if [[ $ndctl_region == "" ]] ; then
14     echo "No NVDIMM hardware, exit ..."
15     exit 0
16 fi
17
18 pod_sc_01=pod-sc-case-01
19 pod_pvc_01=pod-pvc-case-01
20 pod_app_01=pod-app-case-01
21
22 cat << POD > $HOME/$pod_sc_01.yaml
23 apiVersion: storage.k8s.io/v1
24 kind: StorageClass
25 metadata:
26   name: pmem-csi-sc-ext4
27 parameters:
28   csi.storage.k8s.io/fstype: ext4
29   eraseafter: "true"
30 provisioner: pmem-csi.intel.com
31 reclaimPolicy: Delete
32 volumeBindingMode: Immediate
33 POD
34
35 cat << POD > $HOME/$pod_pvc_01.yaml
36 apiVersion: v1
37 kind: PersistentVolumeClaim
38 metadata:
39   name: pmem-csi-pvc-ext4
40 spec:
41   accessModes:
42   - ReadWriteOnce
43   resources:
44     requests:
45       storage: 4Gi
46   storageClassName: pmem-csi-sc-ext4
47 POD
48
49 cat << POD > $HOME/$pod_app_01.yaml
50 kind: Pod
51 apiVersion: v1
52 metadata:
53   name: my-csi-app-1
54 spec:
55   containers:
56     - name: my-frontend
57       image: busybox
58       command: [ "sleep", "100000" ]
59       volumeMounts:
60       - mountPath: "/data"
61         name: my-csi-volume
62   volumes:
63   - name: my-csi-volume
64     persistentVolumeClaim:
65       claimName: pmem-csi-pvc-ext4
66 POD
67
68 kubectl apply -f $HOME/$pod_sc_01.yaml
69 kubectl apply -f $HOME/$pod_pvc_01.yaml
70 kubectl apply -f $HOME/$pod_app_01.yaml
71
72 echo "Sleep for several minutes ..."
73 sleep 300
74
75 pvc_meta="$(kubectl get pvc -o jsonpath='{.items[0].metadata.name}')"
76 pvc_status="$(kubectl get pvc -o jsonpath='{.items[0].status.phase}')"
77 if [[ $pvc_meta == "pmem-csi-pvc-ext4" ]] && [[ $pvc_status == "Bound" ]] ; then
78     echo "[OPTANE] SUCCESS: created PMEM-CSI volume!"
79 else
80     echo "[OPTANE] FAILED: cannot create PMEM-CSI volume!"
81 fi
82
83 echo "Wait and remove the test resource ..."
84 sleep 60
85
86 kubectl delete -f $HOME/$pod_sc_01.yaml
87 kubectl delete -f $HOME/$pod_pvc_01.yaml
88 kubectl delete -f $HOME/$pod_app_01.yaml
89