Skip to content

Commit 82c7fa0

Browse files
committed
revert LSO networkpolicy cases
1 parent d7e01b7 commit 82c7fa0

File tree

1 file changed

+0
-135
lines changed

1 file changed

+0
-135
lines changed

test/extended/storage/storage_networkpolicy.go

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ import (
55
"fmt"
66
"strings"
77

8-
"github.com/blang/semver/v4"
98
g "github.com/onsi/ginkgo/v2"
109
o "github.com/onsi/gomega"
1110
exutil "github.com/openshift/origin/test/extended/util"
12-
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1311
"k8s.io/apimachinery/pkg/api/errors"
1412
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1513
e2e "k8s.io/kubernetes/test/e2e/framework"
16-
"sigs.k8s.io/controller-runtime/pkg/client"
1714
)
1815

1916
// storage_networkpolicy.go contains tests for verifying network policy configurations
@@ -159,7 +156,6 @@ var _ = g.Describe("[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Netwo
159156
var (
160157
oc = exutil.NewCLI("storage-network-policy")
161158
currentPlatform = e2e.TestContext.Provider
162-
lsoInstallInfo *lsoInfo // LSO installation information detected once per suite
163159
)
164160

165161
g.BeforeEach(func() {
@@ -168,20 +164,6 @@ var _ = g.Describe("[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Netwo
168164
if isMicroShift {
169165
g.Skip("Storage Network Policy tests are not supported on MicroShift")
170166
}
171-
172-
// Detect LSO installation only once (cache the result)
173-
if lsoInstallInfo == nil {
174-
lsoInstallInfo, err = getLSOInfo(oc)
175-
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to detect LSO installation")
176-
177-
if lsoInstallInfo.Installed {
178-
supported := isLSOVersionSupported(lsoInstallInfo.Version)
179-
g.By(fmt.Sprintf("Detected LSO installed in namespace: %s, version: %s (network policy support: %v)",
180-
lsoInstallInfo.Namespace, lsoInstallInfo.Version, supported))
181-
} else {
182-
g.By("LSO is not installed on this cluster")
183-
}
184-
}
185167
})
186168

187169
g.It("should verify required labels for CSO related Operators", func() {
@@ -364,59 +346,6 @@ var _ = g.Describe("[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Netwo
364346
runResourceChecks(oc, CSIResourcesToCheck, currentPlatform)
365347
})
366348

367-
g.It("should verify required labels for LSO related resources", func() {
368-
// Skip if LSO is not installed or version is lower than 4.21.0
369-
if !lsoInstallInfo.Installed {
370-
g.Skip("LSO is not installed on this cluster")
371-
}
372-
373-
if !isLSOVersionSupported(lsoInstallInfo.Version) {
374-
g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
375-
}
376-
377-
LSOResourcesToCheck := []resourceCheck{
378-
{
379-
ResourceType: ResourceTypeDeployment,
380-
Namespace: lsoInstallInfo.Namespace,
381-
Name: "local-storage-operator",
382-
Platform: "all",
383-
RequiredLabels: lsoOperatorRequiredLabels,
384-
},
385-
{
386-
ResourceType: ResourceTypeDaemonSet,
387-
Namespace: lsoInstallInfo.Namespace,
388-
Name: "diskmaker-manager",
389-
Platform: "all",
390-
RequiredLabels: lsoDiskmakerRequiredLabels,
391-
},
392-
{
393-
ResourceType: ResourceTypeDaemonSet,
394-
Namespace: lsoInstallInfo.Namespace,
395-
Name: "diskmaker-discovery",
396-
Platform: "all",
397-
RequiredLabels: lsoDiskmakerRequiredLabels,
398-
},
399-
}
400-
401-
runResourceChecks(oc, LSOResourcesToCheck, currentPlatform)
402-
})
403-
404-
g.It("should ensure required NetworkPolicies exist with correct labels for LSO", func() {
405-
// Skip if LSO is not installed or version is lower than 4.21.0
406-
if !lsoInstallInfo.Installed {
407-
g.Skip("LSO is not installed on this cluster")
408-
}
409-
410-
if !isLSOVersionSupported(lsoInstallInfo.Version) {
411-
g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
412-
}
413-
414-
// Get LSO network policy check configuration
415-
lsoCheck := getLSONetworkPolicyCheck(lsoInstallInfo)
416-
417-
verifyNetworkPolicyPodSelectors(oc, lsoCheck.Namespace, lsoCheck.RequiredPodSelectors)
418-
})
419-
420349
g.It("should ensure required NetworkPolicies exist with correct labels", func() {
421350
for _, c := range networkPolicyChecks {
422351
_, err := oc.AdminKubeClient().CoreV1().Namespaces().Get(context.TODO(), c.Namespace, metav1.GetOptions{})
@@ -496,70 +425,6 @@ func runResourceChecks(oc *exutil.CLI, resources []resourceCheck, currentPlatfor
496425
}
497426
}
498427

499-
// isLSOVersionSupported checks if the LSO version is 4.21.0 or higher
500-
// Supported version formats: "4.21.0", "4.21.0-202511252120"
501-
func isLSOVersionSupported(versionStr string) bool {
502-
// Minimum required version for LSO network policy support
503-
minVersion := semver.MustParse("4.21.0")
504-
505-
// Parse the LSO version
506-
// The version string may contain build metadata (e.g., "4.21.0-202511252120")
507-
// semver.Parse handles this correctly
508-
version, err := semver.Parse(versionStr)
509-
if err != nil {
510-
e2e.Logf("Failed to parse LSO version %q: %v", versionStr, err)
511-
return false
512-
}
513-
514-
// Compare versions: returns true if version >= minVersion
515-
return version.GTE(minVersion)
516-
}
517-
518-
// getLSOInfo detects if LSO is installed by searching for local-storage-operator CSV
519-
// across all namespaces and returns its namespace and version information
520-
func getLSOInfo(oc *exutil.CLI) (*lsoInfo, error) {
521-
info := &lsoInfo{
522-
Installed: false,
523-
}
524-
525-
// Create controller-runtime client
526-
clusterConfig := oc.AdminConfig()
527-
clusterClient, err := client.New(clusterConfig, client.Options{})
528-
if err != nil {
529-
return info, fmt.Errorf("failed to create controller-runtime client: %v", err)
530-
}
531-
532-
// Add operatorsv1alpha1 to scheme
533-
err = operatorsv1alpha1.AddToScheme(clusterClient.Scheme())
534-
if err != nil {
535-
return info, fmt.Errorf("failed to add operators.coreos.com/v1alpha1 to scheme: %v", err)
536-
}
537-
538-
// List all ClusterServiceVersions across all namespaces
539-
csvList := &operatorsv1alpha1.ClusterServiceVersionList{}
540-
err = clusterClient.List(context.TODO(), csvList)
541-
if err != nil {
542-
return info, fmt.Errorf("failed to list ClusterServiceVersions: %v", err)
543-
}
544-
545-
// Search for local-storage-operator CSV
546-
for _, csv := range csvList.Items {
547-
// Match CSV name pattern: local-storage-operator.*
548-
if strings.HasPrefix(csv.Name, "local-storage-operator") {
549-
// Only consider CSVs in Succeeded phase
550-
if csv.Status.Phase == operatorsv1alpha1.CSVPhaseSucceeded {
551-
info.Installed = true
552-
info.Namespace = csv.Namespace
553-
info.Version = csv.Spec.Version.String()
554-
return info, nil
555-
}
556-
}
557-
}
558-
559-
// LSO not found or not in Succeeded phase
560-
return info, nil
561-
}
562-
563428
// podSelectorContainsLabels checks if actualLabels contains all key-value pairs from requiredLabels
564429
func podSelectorContainsLabels(actualLabels map[string]string, requiredLabels map[string]string) bool {
565430
for key, value := range requiredLabels {

0 commit comments

Comments
 (0)