e2e: use k8sVersionGreaterEquals() for rbd tests

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-10-14 09:41:49 +02:00 committed by mergify[bot]
parent c4289f01e8
commit d26030ca5f

View File

@ -357,16 +357,12 @@ var _ = Describe("RBD", func() {
}) })
By("create a PVC clone and bind it to an app", func() { By("create a PVC clone and bind it to an app", func() {
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error with error %v", err)
}
// snapshot beta is only supported from v1.17+ // snapshot beta is only supported from v1.17+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") { if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
var wg sync.WaitGroup var wg sync.WaitGroup
totalCount := 10 totalCount := 10
wg.Add(totalCount) wg.Add(totalCount)
err = createRBDSnapshotClass(f) err := createRBDSnapshotClass(f)
if err != nil { if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err) e2elog.Failf("failed to create storageclass with error %v", err)
} }
@ -511,12 +507,8 @@ var _ = Describe("RBD", func() {
}) })
By("create a PVC-PVC clone and bind it to an app", func() { By("create a PVC-PVC clone and bind it to an app", func() {
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error %v", err)
}
// pvc clone is only supported from v1.16+ // pvc clone is only supported from v1.16+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "16") { if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
validatePVCClone(pvcPath, pvcSmartClonePath, appSmartClonePath, f) validatePVCClone(pvcPath, pvcSmartClonePath, appSmartClonePath, f)
} }
@ -586,13 +578,8 @@ var _ = Describe("RBD", func() {
}) })
By("Resize Filesystem PVC and check application directory size", func() { By("Resize Filesystem PVC and check application directory size", func() {
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error with error %v", err)
}
// Resize 0.3.0 is only supported from v1.15+ // Resize 0.3.0 is only supported from v1.15+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "15") { if k8sVersionGreaterEquals(f.ClientSet, 1, 15) {
err := resizePVCAndValidateSize(pvcPath, appPath, f) err := resizePVCAndValidateSize(pvcPath, appPath, f)
if err != nil { if err != nil {
e2elog.Failf("failed to resize filesystem PVC %v", err) e2elog.Failf("failed to resize filesystem PVC %v", err)
@ -617,13 +604,8 @@ var _ = Describe("RBD", func() {
}) })
By("Resize Block PVC and check Device size", func() { By("Resize Block PVC and check Device size", func() {
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error with error %v", err)
}
// Block PVC resize is supported in kubernetes 1.16+ // Block PVC resize is supported in kubernetes 1.16+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "16") { if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
err := resizePVCAndValidateSize(rawPvcPath, rawAppPath, f) err := resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
if err != nil { if err != nil {
e2elog.Failf("failed to resize block PVC with error %v", err) e2elog.Failf("failed to resize block PVC with error %v", err)
@ -920,12 +902,8 @@ var _ = Describe("RBD", func() {
}) })
By("create ROX PVC clone and mount it to multiple pods", func() { By("create ROX PVC clone and mount it to multiple pods", func() {
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error %v", err)
}
// snapshot beta is only supported from v1.17+ // snapshot beta is only supported from v1.17+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") { if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
// create PVC and bind it to an app // create PVC and bind it to an app
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
@ -1084,14 +1062,9 @@ var _ = Describe("RBD", func() {
if err != nil { if err != nil {
e2elog.Failf("failed to validate pvc and application binding with error %v", err) e2elog.Failf("failed to validate pvc and application binding with error %v", err)
} }
v, err := f.ClientSet.Discovery().ServerVersion()
if err != nil {
e2elog.Failf("failed to get server version with error with error %v", err)
}
// Resize Block PVC and check Device size within the namespace // Resize Block PVC and check Device size within the namespace
// Block PVC resize is supported in kubernetes 1.16+ // Block PVC resize is supported in kubernetes 1.16+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "16") { if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f) err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
if err != nil { if err != nil {
e2elog.Failf("failed to resize block PVC with error %v", err) e2elog.Failf("failed to resize block PVC with error %v", err)
@ -1100,7 +1073,7 @@ var _ = Describe("RBD", func() {
// Create a PVC clone and bind it to an app within the namespace // Create a PVC clone and bind it to an app within the namespace
// snapshot beta is only supported from v1.17+ // snapshot beta is only supported from v1.17+
if v.Major > "1" || (v.Major == "1" && v.Minor >= "17") { if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load PVC with error %v", err) e2elog.Failf("failed to load PVC with error %v", err)