fix(sanity): fixing flaky sanity test case

Also moving to bionic docker image for github action also.

Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan 2020-12-10 15:36:08 +05:30 committed by Kiran Mova
parent 2ae14f556b
commit 0409fca095
3 changed files with 34 additions and 8 deletions

View file

@ -41,7 +41,7 @@ COPY . .
RUN make buildx.csi-driver RUN make buildx.csi-driver
FROM ubuntu:19.10 FROM ubuntu:18.04
RUN apt-get clean && rm -rf /var/lib/apt/lists/* RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update; exit 0 RUN apt-get update; exit 0

View file

@ -76,7 +76,7 @@ EOT
function startTestSuite() { function startTestSuite() {
echo "================== Start csi-sanity test suite =================" echo "================== Start csi-sanity test suite ================="
./csi-sanity --ginkgo.v --csi.controllerendpoint=///tmp/csi.sock --csi.endpoint=/var/lib/kubelet/plugins/zfs-localpv/csi.sock --csi.testvolumeparameters=/tmp/parameters.json ./csi-sanity --ginkgo.v --csi.controllerendpoint=///tmp/csi.sock --csi.endpoint=/var/lib/kubelet/plugins/zfs-localpv/csi.sock --csi.testvolumeparameters=/tmp/parameters.json --csi.testsnapshotparameters=/tmp/parameters.json
if [ $? -ne 0 ]; if [ $? -ne 0 ];
then then
dumpAllLogs dumpAllLogs

View file

@ -133,6 +133,23 @@ func waitForVolDestroy(volname string) error {
return nil return nil
} }
func waitForReadySnapshot(snapname string) error {
for true {
snap, err := zfs.GetZFSSnapshot(snapname)
if err != nil {
return status.Errorf(codes.Internal,
"zfs: wait failed, not able to get the snapshot %s %s", snapname, err.Error())
}
switch snap.Status.State {
case zfs.ZFSStatusReady:
return nil
}
time.Sleep(time.Second)
}
return nil
}
// CreateZFSVolume create new zfs volume from csi volume request // CreateZFSVolume create new zfs volume from csi volume request
func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) { func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
volName := strings.ToLower(req.GetName()) volName := strings.ToLower(req.GetName())
@ -224,12 +241,6 @@ func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
"not able to provision the volume %s", err.Error()) "not able to provision the volume %s", err.Error())
} }
if _, ok := parameters["wait"]; ok {
if err := waitForReadyVolume(volName); err != nil {
return "", err
}
}
return selected, nil return selected, nil
} }
@ -370,6 +381,12 @@ func (cs *controller) CreateVolume(
return nil, err return nil, err
} }
if _, ok := parameters["wait"]; ok {
if err := waitForReadyVolume(volName); err != nil {
return nil, err
}
}
sendEventOrIgnore(pvcName, volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision) sendEventOrIgnore(pvcName, volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision)
topology := map[string]string{zfs.ZFSTopologyKey: selected} topology := map[string]string{zfs.ZFSTopologyKey: selected}
@ -661,6 +678,15 @@ func (cs *controller) CreateSnapshot(
) )
} }
originalParams := req.GetParameters()
parameters := helpers.GetCaseInsensitiveMap(&originalParams)
if _, ok := parameters["wait"]; ok {
if err := waitForReadySnapshot(snapName); err != nil {
return nil, err
}
}
state, _ = zfs.GetZFSSnapshotStatus(snapName) state, _ = zfs.GetZFSSnapshotStatus(snapName)
return csipayload.NewCreateSnapshotResponseBuilder(). return csipayload.NewCreateSnapshotResponseBuilder().