@@ -26,6 +26,13 @@ import (
26
26
gatewayapiclientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
27
27
)
28
28
29
+ var (
30
+ requiredCapabilities = []configv1.ClusterVersionCapability {
31
+ configv1 .ClusterVersionCapabilityMarketplace ,
32
+ configv1 .ClusterVersionCapabilityOperatorLifecycleManager ,
33
+ }
34
+ )
35
+
29
36
var _ = g .Describe ("[sig-network-edge][OCPFeatureGate:GatewayAPIController][Feature:Router][apigroup:gateway.networking.k8s.io]" , g .Ordered , g .Serial , func () {
30
37
defer g .GinkgoRecover ()
31
38
var (
@@ -73,14 +80,24 @@ var _ = g.Describe("[sig-network-edge][OCPFeatureGate:GatewayAPIController][Feat
73
80
g .Skip (fmt .Sprintf ("Skipping on non cloud platform type %q" , platformType ))
74
81
}
75
82
83
+ capsEnabled , err := requiredCapabilitiesEnabled (oc )
84
+ if err != nil {
85
+ e2e .Failf ("Failed to check required cluster capabilities: %v" , err )
86
+ }
87
+ if ! capsEnabled {
88
+ // GatewayAPIController relies on OSSM OLM operator.
89
+ // Skipping on cluster which doesn't have required capabilities
90
+ // to install an OLM operator.
91
+ g .Skip (fmt .Sprintf ("Skipping on cluster without all required capabilities: %v" , requiredCapabilities ))
92
+ }
93
+
76
94
gwapiClient := gatewayapiclientset .NewForConfigOrDie (oc .AdminConfig ())
77
95
// create the default gatewayClass
78
96
gatewayClass := buildGatewayClass (gatewayClassName , gatewayClassControllerName )
79
97
_ , err = gwapiClient .GatewayV1 ().GatewayClasses ().Create (context .TODO (), gatewayClass , metav1.CreateOptions {})
80
98
if err != nil && ! apierrors .IsAlreadyExists (err ) {
81
99
e2e .Failf ("Failed to create GatewayClass %q" , gatewayClassName )
82
100
}
83
-
84
101
})
85
102
86
103
g .AfterAll (func () {
@@ -559,3 +576,24 @@ func isOKD(oc *exutil.CLI) (bool, error) {
559
576
}
560
577
return false , nil
561
578
}
579
+
580
+ // requiredCapabilitiesEnabled verifies if all the necessary capabilities
581
+ // for running GatewayAPIController are enabled on the cluster.
582
+ func requiredCapabilitiesEnabled (oc * exutil.CLI ) (bool , error ) {
583
+ cv , err := exutil .GetClusterVersion (context .TODO (), oc .AdminConfig ())
584
+ if err != nil {
585
+ return false , err
586
+ }
587
+
588
+ capFound := 0
589
+ for _ , rc := range requiredCapabilities {
590
+ for _ , ec := range cv .Status .Capabilities .EnabledCapabilities {
591
+ if rc == ec {
592
+ capFound ++
593
+ break
594
+ }
595
+ }
596
+ }
597
+
598
+ return len (requiredCapabilities ) == capFound , nil
599
+ }
0 commit comments