Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Remove some other v1.16 specific logic (#298)
Browse files Browse the repository at this point in the history
* Remove some other v1.14 specific logic

* Remove unused func
  • Loading branch information
avestuk authored and mhmxs committed May 10, 2021
1 parent d54e42a commit c9fa7f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 81 deletions.
27 changes: 1 addition & 26 deletions test/e2e/util/admission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"
"time"

"github.com/blang/semver"
framework "github.com/operator-framework/operator-sdk/pkg/test"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
Expand All @@ -32,33 +31,9 @@ const (
)

// PodSchedulerAdmissionControllerTest checks if the pod scheduler mutating
// admission controller mutates the scheduler name of a pod by creates a pvc
// admission controller mutates the scheduler name of a pod by creating a pvc
// backed by StorageOS and a pod that uses the PVC.
// NOTE: This test has a minimum k8s version requirement.
func PodSchedulerAdmissionControllerTest(t *testing.T, ctx *framework.Context) {
k8sVerMajor := 1
k8sVerMinor := 13
k8sVerPatch := 0
// Minimum version of k8s required to run this test.
minVersion := semver.Version{
Major: uint64(k8sVerMajor),
Minor: uint64(k8sVerMinor),
Patch: uint64(k8sVerPatch),
}

// Check the k8s version before running this test. Admission controller
// does not works on openshift 3.11 (k8s 1.11).
featureSupported, err := featureSupportAvailable(minVersion)
if err != nil {
t.Errorf("failed to check platform support for admission controller test: %v", err)
return
}

// Skip if the feature is not supported.
if !featureSupported {
return
}

scName1 := "sc1"
scName2 := "sc2"

Expand Down
57 changes: 2 additions & 55 deletions test/e2e/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"
"time"

"github.com/blang/semver"
monitoringv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
framework "github.com/operator-framework/operator-sdk/pkg/test"
"github.com/operator-framework/operator-sdk/pkg/test/e2eutil"
Expand All @@ -22,13 +21,11 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/storageos/cluster-operator/pkg/apis"
storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1"
deploy "github.com/storageos/cluster-operator/pkg/storageos"
"github.com/storageos/cluster-operator/pkg/util/k8s"
"github.com/storageos/cluster-operator/pkg/util/k8sutil"
)

// Time constants.
Expand Down Expand Up @@ -388,61 +385,11 @@ func StorageOSClusterCRAttributesTest(t *testing.T, crName string, crNamespace s
}
}

// featureSupportAvailable can be used by tests to check if the platform
// supports the test by passing a minimum version of k8s required to run the
// test.
func featureSupportAvailable(minVersion semver.Version) (bool, error) {
log := logf.Log.WithName("test.featureSupportAvailability")
k := k8sutil.NewK8SOps(framework.Global.KubeClient, log)
version, err := k.GetK8SVersion()
if err != nil {
return false, fmt.Errorf("failed to get k8s version: %v", err)
}

currentVersion, err := semver.Parse(version)
if err != nil {
return false, fmt.Errorf("failed to parse k8s version: %v", err)
}

if currentVersion.Compare(minVersion) >= 0 {
// This test is supported in this version of k8s.
return true, nil
}

// Test is not supported in this version of k8s. Skip the test.
return false, nil
}

// CSIDriverResourceTest checks if the CSIDriver resource is created. In k8s
// 1.14+, CSIDriver is created as part of the cluster deployment.
// CSIDriverResourceTest checks if the CSIDriver resource is created.
func CSIDriverResourceTest(t *testing.T, driverName string) {
k8sVerMajor := 1
k8sVerMinor := 14
k8sVerPatch := 0

// Minimum version of k8s required to run this test.
minVersion := semver.Version{
Major: uint64(k8sVerMajor),
Minor: uint64(k8sVerMinor),
Patch: uint64(k8sVerPatch),
}

// Check the k8s version before running this test. CSIDriver built-in
// resource does not exists in openshift 3.11 (k8s 1.11).
featureSupported, err := featureSupportAvailable(minVersion)
if err != nil {
t.Errorf("failed to check platform support for CSIDriver test: %v", err)
return
}

// Skip if the feature is not supported.
if !featureSupported {
return
}

f := framework.Global
csiDriver := &storagev1beta1.CSIDriver{}
err = f.Client.Get(goctx.TODO(), types.NamespacedName{Name: driverName}, csiDriver)
err := f.Client.Get(goctx.TODO(), types.NamespacedName{Name: driverName}, csiDriver)
if err != nil {
t.Errorf("CSIDriver not found: %v", err)
}
Expand Down

0 comments on commit c9fa7f7

Please sign in to comment.