Skip to content

Commit

Permalink
fix(ci): adding check for healthy CVR (#42)
Browse files Browse the repository at this point in the history
Signed-off-by: mayank <[email protected]>
  • Loading branch information
mynktl authored and vishnuitta committed Sep 30, 2019
1 parent e59b9c1 commit dace6ff
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
6 changes: 3 additions & 3 deletions script/install-velero.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export MAPI_ADDR="http://${MAPI_SVC_ADDR}:5656"
export KUBERNETES_SERVICE_HOST="127.0.0.1"
export KUBECONFIG=$HOME/.kube/config

wget -O velero.tar.gz https://github.com/heptio/velero/releases/download/${VELERO_RELEASE}/velero-${VELERO_RELEASE}-linux-amd64.tar.gz
wget -nv -O velero.tar.gz https://github.com/heptio/velero/releases/download/${VELERO_RELEASE}/velero-${VELERO_RELEASE}-linux-amd64.tar.gz
mkdir velero
tar xf velero.tar.gz -C velero
velero=$PWD/velero/velero-${VELERO_RELEASE}-linux-amd64/velero
Expand All @@ -65,11 +65,11 @@ if [ ! -f ${velero} ]; then
fi

if [ ! -f minio ]; then
wget https://dl.min.io/server/minio/release/linux-amd64/minio
wget -nv https://dl.min.io/server/minio/release/linux-amd64/minio
fi

if [ ! -f mc ]; then
wget https://dl.min.io/client/mc/release/linux-amd64/mc
wget -nv https://dl.min.io/client/mc/release/linux-amd64/mc
fi
chmod +x minio
chmod +x mc
Expand Down
21 changes: 18 additions & 3 deletions tests/openebs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,32 @@ limitations under the License.
package openebs

import (
"fmt"

k8s "github.com/openebs/velero-plugin/tests/k8s"
corev1 "k8s.io/api/core/v1"
)

const (
mayaAPIPodLabel = "openebs.io/component-name=maya-apiserver"
cstorPodLabel = "app=cstor-pool"
pvcPodLabel = "openebs.io/target=cstor-target"
)

// DumpLogs will dump openebs logs
func (c *ClientSet) DumpLogs() error {
mayaPod := c.getMayaAPIServerPodName()
spcPod := c.getSPCPodName()
pvcPod := c.getPVCPodName()

for _, v := range mayaPod {
_ = k8s.Client.DumpLogs(OpenEBSNs, v[0], v[1])
}
for _, v := range spcPod {
_ = k8s.Client.DumpLogs(OpenEBSNs, v[0], v[1])
}
for _, v := range pvcPod {
_ = k8s.Client.DumpLogs(OpenEBSNs, v[0], v[1])
}

return nil
}

Expand Down Expand Up @@ -66,14 +70,25 @@ func (c *ClientSet) getSPCPodName() [][]string {
return getPodContainerList(podList)
}

// getPVCPodName return PVC pod name and container
// {{"pod1","container1"},{"pod2","container2"},}
func (c *ClientSet) getPVCPodName() [][]string {
podList, err := k8s.Client.GetPodList(OpenEBSNs,
pvcPodLabel,
)
if err != nil {
return [][]string{}
}
return getPodContainerList(podList)
}

// returns {{"pod1","container1"},{"pod2","container2"},}
func getPodContainerList(podList *corev1.PodList) [][]string {
pod := make([][]string, 0)

for _, p := range podList.Items {
for _, c := range p.Spec.Containers {
pod = append(pod, []string{p.Name, c.Name})
fmt.Println(c.Name)
}
}
return pod
Expand Down
8 changes: 7 additions & 1 deletion tests/openebs/storage_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ var (

// PVCName for PVC
PVCName string

// AppPVC created by openebs
AppPVC *corev1.PersistentVolumeClaim
)

const (
Expand Down Expand Up @@ -105,7 +108,10 @@ func (c *ClientSet) CreateVolume(pvcYAML, pvcNs string, wait bool) error {
time.Sleep(5 * time.Second)
PVCName = pvc.Name
if wait {
err = c.waitForHealthyCVR(&pvc)
err = c.WaitForHealthyCVR(&pvc)
}
if err == nil {
AppPVC = &pvc
}
return err
}
Expand Down
3 changes: 2 additions & 1 deletion tests/openebs/storage_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const (
CVRMaxRetry = 5
)

func (c *ClientSet) waitForHealthyCVR(pvc *v1.PersistentVolumeClaim) error {
// WaitForHealthyCVR wait till CVR for given PVC becomes healthy
func (c *ClientSet) WaitForHealthyCVR(pvc *v1.PersistentVolumeClaim) error {
dumpLog := 0
for {
if healthy := c.CheckCVRStatus(pvc.Name,
Expand Down
7 changes: 7 additions & 0 deletions tests/sanity/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package sanity

import (
"testing"
"time"

v1 "github.com/heptio/velero/pkg/apis/velero/v1"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -72,6 +73,12 @@ var _ = Describe("Backup/Restore Test", func() {
It("Backup Test 1", func() {
var status v1.BackupPhase
By("Creating a backup")

err = openebs.Client.WaitForHealthyCVR(openebs.AppPVC)
Expect(err).NotTo(HaveOccurred())
// There are chances that istgt is not updated, but replica is healthy
time.Sleep(30 * time.Second)

backupName, status, err = velero.Client.CreateBackup(AppNs)
if ((err != nil) || status != v1.BackupPhaseCompleted) &&
len(backupName) != 0 {
Expand Down

0 comments on commit dace6ff

Please sign in to comment.