This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): Add csi-sanity tests and fix common errors in csi-driver (#3)
Initial tests for Jiva volumes provisioned via CSI driver. Signed-off-by: Utkarsh Mani Tripathi <[email protected]>
- Loading branch information
Showing
17 changed files
with
686 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ go: | |
env: | ||
global: | ||
- GOARCH=$(go env GOARCH) | ||
- GOPATH=$(go env GOPATH) | ||
- GO_FOR_RELEASE=1.13 | ||
- CHANGE_MINIKUBE_NONE_USER=true | ||
- MINIKUBE_WANTUPDATENOTIFICATION=false | ||
|
@@ -24,27 +25,34 @@ install: | |
- make bootstrap | ||
|
||
before_install: | ||
- git clone https://www.github.com/openebs/jiva-operator $GOPATH/src/github.com/openebs/jiva-operator | ||
- sudo apt-get install -y open-iscsi | ||
- sudo service iscsid start | ||
# Download kubectl, which is a requirement for using minikube. | ||
#- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | ||
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.14.8/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | ||
# Download minikube. | ||
#- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.5.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ | ||
#- mkdir -p $HOME/.kube $HOME/.minikube | ||
#- touch $KUBECONFIG | ||
#- sudo minikube start --vm-driver=none --kubernetes-version=v1.14.0 | ||
#- "sudo chown -R travis: /home/travis/.minikube/" | ||
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.5.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ | ||
- mkdir -p $HOME/.kube $HOME/.minikube | ||
- touch $KUBECONFIG | ||
- sudo minikube start --vm-driver=none --kubernetes-version=v1.14.8 | ||
- "sudo chown -R travis: /home/travis/.minikube/" | ||
script: | ||
#- kubectl cluster-info | ||
- kubectl cluster-info | ||
# Verify kube-addon-manager. | ||
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner.. | ||
#- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done | ||
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done | ||
- make image | ||
#- ./ci/travis-ci.sh | ||
- cd $GOPATH/src/github.com/openebs/jiva-operator | ||
- wget https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-operator.yaml | ||
- kubectl apply -f openebs-operator.yaml | ||
- kubectl apply -f deploy/crds/openebs_v1alpha1_jivavolume_crd.yaml | ||
- kubectl apply -f deploy/ | ||
- cd ${TRAVIS_BUILD_DIR} | ||
- kubectl apply -f deploy/jiva-csi-ubuntu-16.04.yaml | ||
- ./ci/ci.sh | ||
after_success: | ||
- make push-tag | ||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
webhooks: | ||
urls: | ||
- https://webhooks.gitter.im/e/d885a0beef16020c3878 | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/bin/bash | ||
|
||
#set -ex | ||
|
||
function initializeTestEnv() { | ||
echo "===================== Initialize test env ======================" | ||
# Pull image so that provisioning won't take long time | ||
docker pull openebs/jiva:ci | ||
cat <<EOT >> /tmp/parameters.json | ||
{ | ||
"cas-type": "jiva", | ||
"replicaCount": "1" | ||
} | ||
EOT | ||
sudo rm -rf /tmp/csi.sock | ||
} | ||
|
||
|
||
function dumpLogs() { | ||
echo "========================== Dump logs ===========================" | ||
local RESOURCE=$1 | ||
local COMPONENT=$2 | ||
local NS=$3 | ||
local LABEL=$4 | ||
local CONTAINER=$5 | ||
local POD=$(kubectl get pod -n $NS -l $LABEL -o jsonpath='{range .items[*]}{@.metadata.name}') | ||
if [ -z $CONTAINER ]; | ||
then | ||
kubectl logs --tail=50 $POD -n $NS | ||
else | ||
kubectl logs --tail=50 $POD -n $NS -c $CONTAINER | ||
fi | ||
} | ||
|
||
function dumpAllLogs() { | ||
echo "========================= Dump All logs ========================" | ||
kubectl get pods -n openebs | ||
kubectl describe pods -n openebs | ||
kubectl describe pods -n kube-system | ||
dumpLogs "ds" "openebs-jiva-csi-node" "kube-system" "app=openebs-jiva-csi-node" "openebs-jiva-csi-plugin" | ||
dumpLogs "sts" "openebs-jiva-csi-controller" "kube-system" "app=openebs-jiva-csi-controller" "openebs-jiva-csi-plugin" | ||
dumpLogs "deploy" "openebs-localpv-provisioner" "openebs" "name=openebs-localpv-provisioner" | ||
} | ||
|
||
function waitForComponent() { | ||
echo "====================== Wait for component ======================" | ||
local RESOURCE=$1 | ||
local COMPONENT=$2 | ||
local NS=$3 | ||
local CONTAINER=$4 | ||
local replicas="" | ||
|
||
for i in $(seq 1 50) ; do | ||
kubectl get $RESOURCE -n ${NS} ${COMPONENT} | ||
if [ "$RESOURCE" == "ds" ] || [ "$RESOURCE" == "daemonset" ]; | ||
then | ||
replicas=$(kubectl get $RESOURCE -n ${NS} ${COMPONENT} -o json | jq ".status.numberReady") | ||
else | ||
replicas=$(kubectl get $RESOURCE -n ${NS} ${COMPONENT} -o json | jq ".status.readyReplicas") | ||
fi | ||
if [ "$replicas" == "1" ]; | ||
then | ||
echo "${COMPONENT} is ready" | ||
break | ||
else | ||
echo "Waiting for ${COMPONENT} to be ready" | ||
if [ $i -eq "50" ]; | ||
then | ||
dumpAllLogs | ||
fi | ||
fi | ||
sleep 10 | ||
done | ||
} | ||
|
||
function initializeCSISanitySuite() { | ||
echo "=============== Initialize CSI Sanity test suite ===============" | ||
CSI_TEST_REPO=https://github.com/kubernetes-csi/csi-test.git | ||
CSI_REPO_PATH="$GOPATH/src/github.com/kubernetes-csi/csi-test" | ||
if [ ! -d "$CSI_REPO_PATH" ] ; then | ||
git clone $CSI_TEST_REPO $CSI_REPO_PATH | ||
else | ||
cd "$CSI_REPO_PATH" | ||
git pull $CSI_REPO_PATH | ||
fi | ||
|
||
cd "$CSI_REPO_PATH/cmd/csi-sanity" | ||
make clean | ||
make | ||
|
||
SOCK_PATH=/var/lib/kubelet/pods/`kubectl get pod -n kube-system openebs-jiva-csi-controller-0 -o 'jsonpath={.metadata.uid}'`/volumes/kubernetes.io~empty-dir/socket-dir/csi.sock | ||
sudo chmod -R 777 /var/lib/kubelet | ||
sudo ln -s $SOCK_PATH /tmp/csi.sock | ||
sudo chmod -R 777 /tmp/csi.sock | ||
} | ||
|
||
function waitForAllComponentsToBeReady() { | ||
waitForComponent "deploy" "openebs-ndm-operator" "openebs" | ||
waitForComponent "ds" "openebs-ndm" "openebs" | ||
waitForComponent "deploy" "openebs-localpv-provisioner" "openebs" | ||
waitForComponent "sts" "openebs-jiva-csi-controller" "kube-system" "openebs-jiva-csi-plugin" | ||
waitForComponent "ds" "openebs-jiva-csi-node" "kube-system" "openebs-jiva-csi-plugin" | ||
} | ||
|
||
function startTestSuite() { | ||
echo "================== Start csi-sanity test suite =================" | ||
./csi-sanity --ginkgo.v --csi.controllerendpoint=///tmp/csi.sock --csi.endpoint=/var/lib/kubelet/plugins/jiva.csi.openebs.io/csi.sock --csi.testvolumeparameters=/tmp/parameters.json | ||
if [ $? -ne 0 ]; | ||
then | ||
dumpAllLogs | ||
exit 1 | ||
fi | ||
exit 0 | ||
} | ||
|
||
initializeTestEnv | ||
waitForAllComponentsToBeReady | ||
initializeCSISanitySuite | ||
startTestSuite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.