Skip to content

Commit 19aa300

Browse files
Merge pull request #29764 from chiragkyal/on-prem
OCPBUGS-55721, OCPBUGS-55832: Fix `RouteExternalCertificate` tests for few other on-prem jobs
2 parents b1ee297 + 32ae2dd commit 19aa300

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

pkg/monitortestlibrary/platformidentification/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ func GetJobType(ctx context.Context, clientConfig *rest.Config) (*JobType, error
207207
platform = "openstack"
208208
case configv1.LibvirtPlatformType:
209209
platform = "libvirt"
210+
case configv1.KubevirtPlatformType:
211+
platform = "kubevirt"
210212
}
211213

212214
networkType := ""

test/extended/router/external_certificate.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
exutil "github.com/openshift/origin/test/extended/util"
2626
rbacv1 "k8s.io/api/rbac/v1"
2727
"k8s.io/apimachinery/pkg/util/rand"
28+
"k8s.io/apimachinery/pkg/util/sets"
2829
"k8s.io/apimachinery/pkg/util/wait"
2930
e2e "k8s.io/kubernetes/test/e2e/framework"
3031
"k8s.io/kubernetes/test/e2e/framework/pod"
@@ -445,11 +446,11 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteExternalCertificate][Featu
445446
hostName, err := getHostnameForRoute(oc, routeToTest.Name)
446447
o.Expect(err).NotTo(o.HaveOccurred())
447448

448-
// Check if the job is running on a metal platform
449-
metal, err := isMetalJob(oc)
449+
// Check if the job is running on an on-prem platform
450+
onPrem, err := isOnPremJob(oc)
450451
o.Expect(err).NotTo(o.HaveOccurred())
451452

452-
if metal {
453+
if onPrem {
453454
execPod := exutil.CreateExecPodOrFail(oc.AdminKubeClient(), oc.Namespace(), "execpod")
454455
defer func() {
455456
oc.AdminKubeClient().CoreV1().Pods(oc.Namespace()).Delete(context.Background(), execPod.Name, *metav1.NewDeleteOptions(1))
@@ -486,7 +487,7 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteExternalCertificate][Featu
486487

487488
// httpsGetCall makes an HTTPS GET request to the specified hostname with retries.
488489
// It uses the provided rootDerBytes as the trusted CA certificate.
489-
// For metal platforms, it uses an exec pod to make the request.
490+
// For on-prem platforms, it uses an exec pod to make the request.
490491
func httpsGetCall(oc *exutil.CLI, hostname string, rootDerBytes []byte) (string, error) {
491492
url := fmt.Sprintf("https://%s", hostname)
492493
e2e.Logf("running https get for host %q", hostname)
@@ -500,14 +501,14 @@ func httpsGetCall(oc *exutil.CLI, hostname string, rootDerBytes []byte) (string,
500501
Bytes: rootDerBytes,
501502
})
502503

503-
// Check if the job is running on a metal platform
504-
metal, err := isMetalJob(oc)
504+
// Check if the job is running on an on-prem platform
505+
onPrem, err := isOnPremJob(oc)
505506
if err != nil {
506507
return "", err
507508
}
508509

509-
if metal {
510-
e2e.Logf("Running on a metal platform")
510+
if onPrem {
511+
e2e.Logf("Running on an on-prem platform")
511512
return httpsGetCallWithExecPod(oc, url, rootCertPEM)
512513
}
513514

@@ -531,7 +532,7 @@ func httpsGetCall(oc *exutil.CLI, hostname string, rootDerBytes []byte) (string,
531532
}
532533

533534
// httpsGetCallWithExecPod makes HTTPS GET request using an exec pod.
534-
// This function is used specifically for metal platforms where external DNS resolution
535+
// This function is used specifically for on-prem platforms where external DNS resolution
535536
// might be problematic. It creates a ConfigMap using the given root CA certificate,
536537
// mounts it to the exec pod, and then uses curl within the pod to make the HTTPS request with retries.
537538
func httpsGetCallWithExecPod(oc *exutil.CLI, url string, rootCertPEM []byte) (string, error) {
@@ -887,11 +888,15 @@ func patchRouteToRemoveExternalCertificate(oc *exutil.CLI, routeName string) err
887888
return err
888889
}
889890

890-
// isMetalJob checks if the current job is running on a metal platform.
891-
func isMetalJob(oc *exutil.CLI) (bool, error) {
891+
// isOnPremJob checks if the current job is running on an on-prem platform.
892+
func isOnPremJob(oc *exutil.CLI) (bool, error) {
893+
onPremPlatforms := sets.NewString("metal", "openstack", "kubevirt")
894+
892895
jobType, err := platformidentification.GetJobType(context.TODO(), oc.AdminConfig())
893896
if err != nil {
894897
return false, err
895898
}
896-
return jobType.Platform == "metal", nil
899+
e2e.Logf("Detected platform: %s", jobType.Platform)
900+
901+
return onPremPlatforms.Has(jobType.Platform), nil
897902
}

0 commit comments

Comments
 (0)