From 65a13f210e491b623d2a0c8ed9f374f4d81976d0 Mon Sep 17 00:00:00 2001 From: Srinivasan Selvam Date: Thu, 21 May 2020 21:50:55 +0530 Subject: [PATCH] CSIT Tests added Signed-off-by: Srinivasan Selvam Change-Id: I027fa03cec057122b3d20247d756c6ae7fc10f2e --- .../csit/{verifyPods.sh => verifyCluster.sh} | 37 +++++++++++---- ci/daily build/csit/verifyk8Cluster.sh | 54 ---------------------- 2 files changed, 27 insertions(+), 64 deletions(-) rename ci/daily build/csit/{verifyPods.sh => verifyCluster.sh} (55%) mode change 100644 => 100755 delete mode 100644 ci/daily build/csit/verifyk8Cluster.sh diff --git a/ci/daily build/csit/verifyPods.sh b/ci/daily build/csit/verifyCluster.sh old mode 100644 new mode 100755 similarity index 55% rename from ci/daily build/csit/verifyPods.sh rename to ci/daily build/csit/verifyCluster.sh index 788e729..f276e5d --- a/ci/daily build/csit/verifyPods.sh +++ b/ci/daily build/csit/verifyCluster.sh @@ -1,6 +1,6 @@ #!/bin/bash -ex ############################################################################## -# Copyright (c) 2019 Huawei Tech and others. +# Copyright (c) 2020 Huawei Tech and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -36,18 +36,35 @@ spec: hostPort: 80 EOF -#check if kubernetes is already running -if ! kubectl cluster-info ; then - kubectl create -f ~/testk8s-kubernetes.yaml +CLUSTER_INFO=$(kubectl cluster-info) +RUNNING_PODS_COUNT=$(kubectl get pods | grep -c -e STATUS -e Running) + +if [[ $CLUSTER_INFO != "" ]]; then + kubectl create -f ~/testk8s-kubernetes.yaml +else + echo "No kubernetes cluster present" fi -#To check the pods which is not running -if kubectl get pods | grep -c -e STATUS -e Running > 0; then -PODS_NOT_RUNNING=$(kubectl get pods --field-selector=status.phase!=Running) +sleep 60 + +echo "Kubectl deployments........................................." +kubectl get deployments + +echo "Kubectl pods in default namespace............................" +kubectl get pods + +echo "-------------------------------------------------------------------" +echo "-------------------------------------------------------------------" + +sleep 60 + +echo "Checking for Pods not in running status in default namespace" + +if [[ $RUNNING_PODS_COUNT > 0 ]]; then + kubectl get pods --field-selector=status.phase!=Running +else + echo "No Pods are presently running" fi echo "-------------------------------------------------------------------" -echo -echo $PODS_NOT_RUNNING > /dev/null 2>&1 -echo echo "-------------------------------------------------------------------" diff --git a/ci/daily build/csit/verifyk8Cluster.sh b/ci/daily build/csit/verifyk8Cluster.sh deleted file mode 100644 index b8bd3d2..0000000 --- a/ci/daily build/csit/verifyk8Cluster.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -ex -############################################################################## -# Copyright (c) 2019 Huawei Tech and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -KUBERNETES=~/testk8s-kubernetes.yaml - -cat < "${KUBERNETES}" ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: kubernets-deployment - labels: - app: nginx -spec: - replicas: 1 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: nginx - image: nginx:1.15.12 - ports: - - containerPort: 80 - hostPort: 80 -EOF - -#check if kubernetes is already running -if ! kubectl cluster-info ; then - kubectl create -f ~/testk8s-kubernetes.yaml -fi - -#To check whether the kubernetes has started successfully -retry=10 -while [ $retry -gt 0 ] -do - if [ 2 == "$(kubectl get pods | grep -c -e STATUS -e Running)" ]; then - break - fi - ((retry-=1)) - sleep 10 -done -[ $retry -gt 0 ] || exit 1 -- 2.16.6