CSIT Tests added
[ealt-edge.git] / ci / daily build / csit / verifyCluster.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2020 Huawei Tech and others.
4 #
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 KUBERNETES=~/testk8s-kubernetes.yaml
12
13 cat <<EOF > "${KUBERNETES}"
14 ---
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18   name: kubernets-deployment
19   labels:
20     app: nginx
21 spec:
22   replicas: 1
23   selector:
24     matchLabels:
25       app: nginx
26   template:
27     metadata:
28       labels:
29         app: nginx
30     spec:
31       containers:
32         - name: nginx
33           image: nginx:1.15.12
34           ports:
35             - containerPort: 80
36               hostPort: 80
37 EOF
38
39 CLUSTER_INFO=$(kubectl cluster-info)
40 RUNNING_PODS_COUNT=$(kubectl get pods | grep -c -e STATUS -e Running)
41
42 if [[ $CLUSTER_INFO != "" ]]; then
43    kubectl create -f ~/testk8s-kubernetes.yaml
44 else
45    echo "No kubernetes cluster present"
46 fi
47
48 sleep 60
49
50 echo "Kubectl deployments........................................."
51 kubectl get deployments
52
53 echo "Kubectl pods in default namespace............................"
54 kubectl get pods
55
56 echo "-------------------------------------------------------------------"
57 echo "-------------------------------------------------------------------"
58
59 sleep 60
60
61 echo "Checking for Pods not in running status in default namespace"
62
63 if [[ $RUNNING_PODS_COUNT > 0 ]]; then
64    kubectl get pods --field-selector=status.phase!=Running
65 else
66    echo "No Pods are presently running"
67 fi
68
69 echo "-------------------------------------------------------------------"
70 echo "-------------------------------------------------------------------"