Skip to content

Commit bfc3c29

Browse files
committed
Merge remote-tracking branch 'upstream/main' into rhoai-3.2
2 parents c8d1f63 + 5bde392 commit bfc3c29

File tree

8 files changed

+85
-37
lines changed

8 files changed

+85
-37
lines changed

images/tests/.env-odh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
ODH_NAMESPACE=opendatahub
21
FMS_HF_TUNING_IMAGE=quay.io/modh/fms-hf-tuning:release
32
NOTEBOOK_IMAGE=quay.io/rhoai/odh-workbench-jupyter-datascience-cpu-py312-rhel9:rhoai-3.2

tests/common/environment.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
)
2626

2727
const (
28-
// The environment variable for namespace where ODH is installed to.
29-
odhNamespaceEnvVar = "ODH_NAMESPACE"
3028
// Name of the authenticated Notebook user
3129
notebookUserName = "NOTEBOOK_USER_NAME"
3230
// Token of the authenticated Notebook user
@@ -59,14 +57,6 @@ var testTiers = []string{tierSmoke, tierSanity, tier1, tier2, tier3, preUpgrade,
5957

6058
var testTierParam string
6159

62-
func GetOpenDataHubNamespace(t Test) string {
63-
ns, ok := os.LookupEnv(odhNamespaceEnvVar)
64-
if !ok {
65-
t.T().Fatalf("Expected environment variable %s not found, please use this environment variable to specify namespace where ODH is installed to.", odhNamespaceEnvVar)
66-
}
67-
return ns
68-
}
69-
7060
func GetNotebookUserName(t Test) string {
7161
name, ok := os.LookupEnv(notebookUserName)
7262
if !ok {

tests/common/notebook.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,17 @@ func CreateNotebook(test Test, namespace *corev1.Namespace, notebookUserToken st
147147
selectedContainerResources = SmallContainerResources // Fallback to Small container size
148148
}
149149

150+
// Get the ODH namespace from DSCI
151+
odhNamespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
152+
test.Expect(err).NotTo(gomega.HaveOccurred())
153+
150154
// Read the Notebook CR from resources and perform replacements for custom values using go template
151155
notebookProps := NotebookProps{
152156
IngressDomain: GetOpenShiftIngressDomain(test),
153157
OpenShiftApiUrl: GetOpenShiftApiUrl(test),
154158
KubernetesUserBearerToken: notebookUserToken,
155159
Namespace: namespace.Name,
156-
OpenDataHubNamespace: GetOpenDataHubNamespace(test),
160+
OpenDataHubNamespace: odhNamespace,
157161
Command: strCommand,
158162
NotebookImage: GetNotebookImage(test),
159163
NotebookConfigMapName: jupyterNotebookConfigMapName,

tests/common/support/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ func GetOpenShiftApiUrl(test Test) string {
5555
return openShiftApiUrl
5656
}
5757

58-
func GetExpectedRegistry(test Test, odhNamespace string) string {
58+
func GetExpectedRegistry(test Test, applicationsNamespace string) string {
5959
test.T().Helper()
6060

6161
var registryName string
62-
switch odhNamespace {
62+
switch applicationsNamespace {
6363
case "redhat-ods-applications":
6464
registryName = "registry.redhat.io"
6565
case "opendatahub":
6666
registryName = "quay.io"
6767
default:
68-
test.T().Fatalf("Unknown ODH namespace: %s. Expected 'redhat-ods-applications' for RHOAI operator or 'opendatahub' ODH operator.", odhNamespace)
68+
test.T().Fatalf("Unknown namespace: %s. Expected 'redhat-ods-applications' for RHOAI operator or 'opendatahub' ODH operator.", applicationsNamespace)
6969
}
7070

71-
test.T().Logf("ODH namespace '%s' is using registry: %s", odhNamespace, registryName)
71+
test.T().Logf("Namespace '%s' is using registry: %s", applicationsNamespace, registryName)
7272
return registryName
7373
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package support
18+
19+
import (
20+
"fmt"
21+
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
24+
"k8s.io/apimachinery/pkg/runtime/schema"
25+
)
26+
27+
const DefaultDSCIName = "default-dsci"
28+
29+
var DsciGVR = schema.GroupVersionResource{
30+
Group: "dscinitialization.opendatahub.io",
31+
Version: "v2",
32+
Resource: "dscinitializations",
33+
}
34+
35+
func GetDSCI(test Test, name string) (*unstructured.Unstructured, error) {
36+
return test.Client().Dynamic().Resource(DsciGVR).Get(test.Ctx(), name, metav1.GetOptions{})
37+
}
38+
39+
func GetApplicationsNamespaceFromDSCI(test Test, dsciName string) (string, error) {
40+
dsci, err := GetDSCI(test, dsciName)
41+
if err != nil {
42+
return "", err
43+
}
44+
namespace, found, err := unstructured.NestedString(dsci.Object, "spec", "applicationsNamespace")
45+
if err != nil {
46+
return "", fmt.Errorf("failed to get applicationsNamespace from DSCI %s: %w", dsciName, err)
47+
}
48+
if !found {
49+
return "", fmt.Errorf("applicationsNamespace field not found in DSCI %s", dsciName)
50+
}
51+
return namespace, nil
52+
}

tests/kfto/kfto_smoke_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ import (
1212
corev1 "k8s.io/api/core/v1"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414

15-
openshiftclient "github.com/openshift/client-go/config/clientset/versioned"
16-
1715
. "github.com/opendatahub-io/distributed-workloads/tests/common"
1816
. "github.com/opendatahub-io/distributed-workloads/tests/common/support"
1917
)
2018

2119
func TestKftoSmoke(t *testing.T) {
2220
Tags(t, Smoke)
23-
runSmoke(t, "kubeflow-training-operator", "odh-training-operator")
21+
runSmoke(t, "kubeflow-training-operator", "odh-training-operator", "training-operator")
2422
}
2523

2624
// runSmoke runs a smoke test for a given deployment and expected image name.
27-
func runSmoke(t *testing.T, deploymentName string, expectedImage string) {
25+
func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage string) {
2826
test := With(t)
29-
namespace := GetOpenDataHubNamespace(test)
27+
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
28+
test.Expect(err).NotTo(HaveOccurred())
3029

3130
test.T().Logf("Waiting for %s deployment to be available ...", deploymentName)
3231
test.Eventually(func(g Gomega, ctx context.Context) {
@@ -40,18 +39,8 @@ func runSmoke(t *testing.T, deploymentName string, expectedImage string) {
4039

4140
test.T().Logf("%s deployment is available", deploymentName)
4241

43-
// Determine registry based on cluster environment
44-
configClient, err := openshiftclient.NewForConfig(test.Config())
45-
test.Expect(err).NotTo(HaveOccurred())
46-
47-
infra, err := configClient.ConfigV1().Infrastructures().Get(test.Ctx(), "cluster", metav1.GetOptions{})
48-
test.Expect(err).NotTo(HaveOccurred())
49-
50-
envType := infra.Labels["hypershift.openshift.io/managed"]
51-
registryName := "registry.redhat.io"
52-
if envType == "true" {
53-
registryName = "quay.io"
54-
}
42+
// Determine registry based on namespace
43+
registryName := GetExpectedRegistry(test, namespace)
5544

5645
test.T().Logf("Verifying %s container image is referred from expected registry ...", deploymentName)
5746

@@ -78,7 +67,19 @@ func runSmoke(t *testing.T, deploymentName string, expectedImage string) {
7867
test.T().FailNow()
7968
}
8069

70+
var expectedImage string
71+
switch registryName {
72+
case "registry.redhat.io":
73+
expectedImage = registryName + "/rhoai/" + rhoaiImage
74+
case "quay.io":
75+
expectedImage = registryName + "/opendatahub/" + odhImage
76+
default:
77+
test.T().Fatalf("Unexpected registry: %s", registryName)
78+
}
79+
8180
containerImage := matchedPods[0].Spec.Containers[0].Image
82-
test.Expect(containerImage).To(ContainSubstring(registryName + "/rhoai/" + expectedImage))
81+
test.Expect(containerImage).To(ContainSubstring(expectedImage),
82+
"Image %s should contain %s", containerImage, expectedImage)
8383
test.T().Logf("%s container image is referred from %s", deploymentName, registryName)
84+
8485
}

tests/trainer/cluster_training_runtimes_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func TestDefaultClusterTrainingRuntimes(t *testing.T) {
5050
test := With(t)
5151

5252
// Determine registry based on ODH namespace
53-
namespace := GetOpenDataHubNamespace(test)
53+
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
54+
test.Expect(err).NotTo(HaveOccurred())
5455
registryName := GetExpectedRegistry(test, namespace)
5556

5657
// Build a map of expected runtimes for quick lookup

tests/trainer/trainer_smoke_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func TestKubeflowTrainerSmoke(t *testing.T) {
2424
// runSmoke runs a smoke test for a given deployment and expected image names.
2525
func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage string) {
2626
test := With(t)
27-
namespace := GetOpenDataHubNamespace(test)
27+
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
28+
test.Expect(err).NotTo(HaveOccurred())
2829

2930
test.T().Logf("Waiting for %s deployment to be available ...", deploymentName)
3031
test.Eventually(func(g Gomega, ctx context.Context) {
@@ -38,7 +39,7 @@ func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage s
3839

3940
test.T().Logf("%s deployment is available", deploymentName)
4041

41-
// Determine registry based on ODH namespace
42+
// Determine registry based on namespace
4243
registryName := GetExpectedRegistry(test, namespace)
4344

4445
test.T().Logf("Verifying %s container image is referred from expected registry ...", deploymentName)

0 commit comments

Comments
 (0)