Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
refact(tests): add resize and remount tests for jiva volumes (#32)
Browse files Browse the repository at this point in the history
- add resize tests
- add remount tests
- bump k8s version 1.18.1

Signed-off-by: Payes Anand <[email protected]>
  • Loading branch information
payes authored Oct 12, 2020
1 parent aa7c091 commit 5f1fd6f
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 25 deletions.
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,27 @@ before_install:
- sudo cat /etc/iscsi/initiatorname.iscsi
- systemctl status iscsid
# Download kubectl, which is a requirement for using minikube.
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.15.7/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.1/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.6.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/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.15.7
- sudo apt-get -qq -y install conntrack
- sudo minikube start --profile=minikube --vm-driver=none --kubernetes-version=v1.18.1
- minikube update-context --profile=minikube
- "sudo chown -R travis: /home/travis/.minikube/"
- eval "$(minikube docker-env --profile=minikube)" && export DOCKER_CLI='docker'
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1; done
script:
- 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 -lk8s-app=kube-dns -o jsonpath="$JSONPATH"
2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-dns to
be available"; kubectl get pods --all-namespaces; done
- make license-check
- make image
- cd $GOPATH/src/github.com/openebs/jiva-operator
Expand Down
45 changes: 45 additions & 0 deletions tests/pvc_without_app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2020 The OpenEBS Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package volume

import (
. "github.com/onsi/ginkgo"
)

var _ = Describe("[csi] [jiva] TEST PVC CREATION DELETION WITHOUT APP", func() {
BeforeEach(preparePVCCreationDeletionWithoutAppTest)
AfterEach(cleanupAfterPVCCreationDeletionWithoutAppTest)

Context("PVC is created and deleted", func() {
It("Should run PVC creation and deletion test", pvcCreationDeletionWithoutAppTest)
})
})

func pvcCreationDeletionWithoutAppTest() {
By("creating and verifying PVC bound status", createAndVerifyPVC)
By("should verify jivaVolumeCR has been created", func() { verifyJivaVolumeCRCreated() })
By("Deleting pvc", deletePVC)
By("should verify jivaVolumeCR has been deleted", func() { verifyJivaVolumeCRDeleted() })
}

func preparePVCCreationDeletionWithoutAppTest() {
By("Creating storage class", createStorageClass)
}

func cleanupAfterPVCCreationDeletionWithoutAppTest() {
By("Deleting storage class", deleteStorageClass)
}
49 changes: 49 additions & 0 deletions tests/remount_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2020 The OpenEBS Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package volume

import (
. "github.com/onsi/ginkgo"
)

var _ = Describe("[csi] [jiva] TEST Remount when volume goes into RO mode", func() {
BeforeEach(prepareForRemountTest)
AfterEach(cleanupAfterRemountTest)

Context("App is deployed and restarted on pvc with replica count 1", func() {
It("Should run Volume Creation Test", remountTest)
})
})

func remountTest() {
By("creating and verifying PVC bound status", createAndVerifyPVC)
By("Creating and deploying app pod", createDeployVerifyApp)
By("scale down jiva controller pod", scaleDownControllerPod)
By("Verify app state as CrashLoopBackOff", func() { verifyCrashLoopBackOffStateOfAppPod(true) })
By("Scale up jiva controller pod", scaleUpControllerPod)
By("Verify app state as not CrashLoopBackOff", func() { verifyCrashLoopBackOffStateOfAppPod(false) })
By("Deleting application deployment", deleteAppDeployment)
By("Deleting pvc", deletePVC)
}

func prepareForRemountTest() {
By("Creating storage class", createStorageClass)
}

func cleanupAfterRemountTest() {
By("Deleting storage class", deleteStorageClass)
}
56 changes: 56 additions & 0 deletions tests/resize_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright 2019 The OpenEBS Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package volume

import (
. "github.com/onsi/ginkgo"
"fmt"
)

var _ = Describe("[csi] [jiva] TEST VOLUME RESIZE", func() {
BeforeEach(prepareForVolumeResizeTest)
AfterEach(cleanupAfterVolumeResizeTest)

Context("App is deployed with volume replica count 1 and pvc is resized", func() {
It("Should run Volume Resize Test", volumeResizeTest)
})
})

func volumeResizeTest() {
currentK8sVersion := getCurrentK8sMinorVersion()
if currentK8sVersion < 16 {
fmt.Printf(
"resizing is not supported on Kubernetes version: 1.%d. Min supported version is 1.16\n",
currentK8sVersion,
)
return
}
By("creating and verifying PVC bound status", createAndVerifyPVC)
By("Creating and deploying app pod", createDeployVerifyApp)
By("Expanding PVC", expandPVC)
By("Verifying updated size in application pod", verifyIncreasedSizeInAppPod)
By("Deleting application deployment", deleteAppDeployment)
By("Deleting pvc", deletePVC)
}

func prepareForVolumeResizeTest() {
By("Creating storage class", createStorageClass)
}

func cleanupAfterVolumeResizeTest() {
By("Deleting storage class", deleteStorageClass)
}
Loading

0 comments on commit 5f1fd6f

Please sign in to comment.