@@ -124,7 +124,12 @@ var _ = g.Describe("[sig-network-edge][OCPFeatureGate:GatewayAPIController][Feat
124124 )
125125 g .BeforeEach (func () {
126126 // Check platform support and get capabilities (LoadBalancer, DNS)
127- loadBalancerSupported , managedDNS = checkPlatformSupportAndGetCapabilities (oc )
127+ skip , reason , err := shouldSkipGatewayAPITests (oc )
128+ o .Expect (err ).NotTo (o .HaveOccurred ())
129+ if skip {
130+ g .Skip (reason )
131+ }
132+ loadBalancerSupported , managedDNS = getPlatformCapabilities (oc )
128133
129134 if ! isNoOLMFeatureGateEnabled (oc ) {
130135 // GatewayAPIController without GatewayAPIWithoutOLM featuregate
@@ -548,44 +553,58 @@ var _ = g.Describe("[sig-network-edge][OCPFeatureGate:GatewayAPIController][Feat
548553 })
549554})
550555
551- // checkPlatformSupportAndGetCapabilities verifies the platform is supported and returns
552- // platform capabilities for LoadBalancer services and managed DNS.
553- func checkPlatformSupportAndGetCapabilities (oc * exutil.CLI ) (loadBalancerSupported bool , managedDNS bool ) {
554- // Skip on OKD since OSSM is not available as a community operator
556+ // shouldSkipGatewayAPITests checks if Gateway API tests should be skipped on this cluster.
557+ // It returns (skip bool, reason string, err error). An error indicates a failure to
558+ // determine skip status and should be treated as a test failure, not a skip.
559+ // This function avoids calling g.Skip() or o.Expect() so it is safe to call from
560+ // upgrade test Skip() methods that run outside of Ginkgo leaf nodes.
561+ func shouldSkipGatewayAPITests (oc * exutil.CLI ) (bool , string , error ) {
555562 // TODO: Determine if we can enable and start testing OKD with Sail Library
556563 isokd , err := isOKD (oc )
557- o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to get clusterversion to determine if release is OKD" )
564+ if err != nil {
565+ return false , "" , fmt .Errorf ("failed to determine if release is OKD: %v" , err )
566+ }
558567 if isokd {
559- g . Skip ( "Skipping on OKD cluster as OSSM is not available as a community operator" )
568+ return true , "Skipping on OKD cluster as OSSM is not available as a community operator" , nil
560569 }
561570
562571 infra , err := oc .AdminConfigClient ().ConfigV1 ().Infrastructures ().Get (context .Background (), "cluster" , metav1.GetOptions {})
563- o .Expect (err ).NotTo (o .HaveOccurred ())
564- o .Expect (infra ).NotTo (o .BeNil ())
572+ if err != nil {
573+ return false , "" , fmt .Errorf ("failed to get infrastructure: %v" , err )
574+ }
565575
566576 o .Expect (infra .Status .PlatformStatus ).NotTo (o .BeNil ())
567577 platformType := infra .Status .PlatformStatus .Type
568- o .Expect (platformType ).NotTo (o .BeEmpty ())
569578 switch platformType {
570579 case configv1 .AWSPlatformType , configv1 .AzurePlatformType , configv1 .GCPPlatformType , configv1 .IBMCloudPlatformType :
571- // Cloud platforms with native LoadBalancer support
572- loadBalancerSupported = true
573580 case configv1 .VSpherePlatformType , configv1 .BareMetalPlatformType , configv1 .EquinixMetalPlatformType :
574- // Platforms without native LoadBalancer support (may have MetalLB or similar)
575- loadBalancerSupported = false
576581 default :
577- g . Skip ( fmt .Sprintf ("Skipping on unsupported platform type %q" , platformType ))
582+ return true , fmt .Sprintf ("Skipping on unsupported platform type %q" , platformType ), nil
578583 }
579584
580- // Check if DNS is managed (has public or private zones configured)
581- managedDNS = isDNSManaged (oc )
582-
583- // Skip Gateway API tests on IPv6 or dual-stack clusters (any platform)
584585 if isIPv6OrDualStack (oc ) {
585- g . Skip ( "Skipping Gateway API tests on IPv6/dual-stack cluster" )
586+ return true , "Skipping Gateway API tests on IPv6/dual-stack cluster" , nil
586587 }
587588
588- e2e .Logf ("Platform: %s, LoadBalancer supported: %t, DNS managed: %t" , platformType , loadBalancerSupported , managedDNS )
589+ return false , "" , nil
590+ }
591+
592+ // getPlatformCapabilities returns platform capabilities for LoadBalancer services and managed DNS.
593+ func getPlatformCapabilities (oc * exutil.CLI ) (loadBalancerSupported bool , managedDNS bool ) {
594+ infra , err := oc .AdminConfigClient ().ConfigV1 ().Infrastructures ().Get (context .Background (), "cluster" , metav1.GetOptions {})
595+ o .Expect (err ).NotTo (o .HaveOccurred ())
596+ o .Expect (infra .Status .PlatformStatus ).NotTo (o .BeNil ())
597+
598+ switch infra .Status .PlatformStatus .Type {
599+ case configv1 .AWSPlatformType , configv1 .AzurePlatformType , configv1 .GCPPlatformType , configv1 .IBMCloudPlatformType :
600+ loadBalancerSupported = true
601+ case configv1 .VSpherePlatformType , configv1 .BareMetalPlatformType , configv1 .EquinixMetalPlatformType :
602+ loadBalancerSupported = false
603+ }
604+
605+ managedDNS = isDNSManaged (oc )
606+
607+ e2e .Logf ("Platform: %s, LoadBalancer supported: %t, DNS managed: %t" , infra .Status .PlatformStatus .Type , loadBalancerSupported , managedDNS )
589608 return loadBalancerSupported , managedDNS
590609}
591610
0 commit comments