Skip to content

Commit 42652a8

Browse files
ChughShilpaabhijeet-dhumal
authored andcommitted
Update smoke tests
1 parent 254a792 commit 42652a8

File tree

4 files changed

+29
-63
lines changed

4 files changed

+29
-63
lines changed

tests/common/support/config.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2424
"k8s.io/apimachinery/pkg/runtime/schema"
25+
26+
openshiftclient "github.com/openshift/client-go/config/clientset/versioned"
2527
)
2628

2729
var ingressConfigResource = schema.GroupVersionResource{Group: "config.openshift.io", Version: "v1", Resource: "ingresses"}
@@ -55,19 +57,18 @@ func GetOpenShiftApiUrl(test Test) string {
5557
return openShiftApiUrl
5658
}
5759

58-
func GetExpectedRegistry(test Test, applicationsNamespace string) string {
59-
test.T().Helper()
60+
func GetExpectedRegistry(test Test) string {
61+
configClient, err := openshiftclient.NewForConfig(test.Config())
62+
test.Expect(err).NotTo(gomega.HaveOccurred())
63+
64+
infra, err := configClient.ConfigV1().Infrastructures().Get(test.Ctx(), "cluster", metav1.GetOptions{})
65+
test.Expect(err).NotTo(gomega.HaveOccurred())
6066

61-
var registryName string
62-
switch applicationsNamespace {
63-
case "redhat-ods-applications":
64-
registryName = "registry.redhat.io"
65-
case "opendatahub":
67+
envType := infra.Labels["hypershift.openshift.io/managed"]
68+
registryName := "registry.redhat.io"
69+
if envType == "true" {
6670
registryName = "quay.io"
67-
default:
68-
test.T().Fatalf("Unknown namespace: %s. Expected 'redhat-ods-applications' for RHOAI operator or 'opendatahub' ODH operator.", applicationsNamespace)
6971
}
7072

71-
test.T().Logf("Namespace '%s' is using registry: %s", applicationsNamespace, registryName)
7273
return registryName
7374
}

tests/kfto/kfto_smoke_test.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818

1919
func TestKftoSmoke(t *testing.T) {
2020
Tags(t, Smoke)
21-
runSmoke(t, "kubeflow-training-operator", "odh-training-operator", "training-operator")
21+
runSmoke(t, "kubeflow-training-operator", "odh-training-operator")
2222
}
2323

2424
// runSmoke runs a smoke test for a given deployment and expected image name.
25-
func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage string) {
25+
func runSmoke(t *testing.T, deploymentName string, expectedImage string) {
2626
test := With(t)
2727
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
2828
test.Expect(err).NotTo(HaveOccurred())
@@ -39,8 +39,8 @@ func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage s
3939

4040
test.T().Logf("%s deployment is available", deploymentName)
4141

42-
// Determine registry based on namespace
43-
registryName := GetExpectedRegistry(test, namespace)
42+
// Determine registry based on cluster environment
43+
registryName := GetExpectedRegistry(test)
4444

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

@@ -67,19 +67,8 @@ func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage s
6767
test.T().FailNow()
6868
}
6969

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-
8070
containerImage := matchedPods[0].Spec.Containers[0].Image
81-
test.Expect(containerImage).To(ContainSubstring(expectedImage),
82-
"Image %s should contain %s", containerImage, expectedImage)
71+
test.Expect(containerImage).To(ContainSubstring(registryName + "/rhoai/" + expectedImage))
8372
test.T().Logf("%s container image is referred from %s", deploymentName, registryName)
8473

8574
}

tests/trainer/cluster_training_runtimes_test.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ import (
3030

3131
type ClusterTrainingRuntime struct {
3232
Name string
33-
ODHImage string
3433
RHOAIImage string
3534
}
3635

3736
var expectedRuntimes = []ClusterTrainingRuntime{
38-
{Name: "torch-distributed", ODHImage: "training:py312-cuda128-torch280", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
39-
{Name: "torch-distributed-rocm", ODHImage: "training:py312-rocm64-torch280", RHOAIImage: "odh-training-rocm64-torch28-py312-rhel9"},
40-
{Name: "torch-distributed-th03-cuda128-torch28-py312", ODHImage: "training:py312-cuda128-torch280", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
41-
{Name: "training-hub", ODHImage: "training:py312-cuda128-torch280", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
42-
{Name: "training-hub03-cuda128-torch28-py312", ODHImage: "training:py312-cuda128-torch280", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
37+
{Name: "torch-distributed", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
38+
{Name: "torch-distributed-rocm", RHOAIImage: "odh-training-rocm64-torch28-py312-rhel9"},
39+
{Name: "torch-distributed-th03-cuda128-torch28-py312", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
40+
{Name: "training-hub", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
41+
{Name: "training-hub03-cuda128-torch28-py312", RHOAIImage: "odh-training-cuda128-torch28-py312-rhel9"},
4342
}
4443

4544
// defaultClusterTrainingRuntime is used across integration tests
@@ -49,10 +48,8 @@ func TestDefaultClusterTrainingRuntimes(t *testing.T) {
4948
Tags(t, Smoke)
5049
test := With(t)
5150

52-
// Determine registry based on ODH namespace
53-
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
54-
test.Expect(err).NotTo(HaveOccurred())
55-
registryName := GetExpectedRegistry(test, namespace)
51+
// Determine registry based on cluster environment
52+
registryName := GetExpectedRegistry(test)
5653

5754
// Build a map of expected runtimes for quick lookup
5855
expectedRuntimeMap := make(map[string]ClusterTrainingRuntime)
@@ -101,16 +98,7 @@ func TestDefaultClusterTrainingRuntimes(t *testing.T) {
10198
test.T().Logf("Image referred in ClusterTrainingRuntime is %s", foundImage)
10299

103100
// Verify image based on environment
104-
var expectedImage string
105-
switch registryName {
106-
case "registry.redhat.io":
107-
expectedImage = registryName + "/rhoai/" + expectedRuntime.RHOAIImage
108-
case "quay.io":
109-
expectedImage = registryName + "/modh/" + expectedRuntime.ODHImage
110-
default:
111-
test.T().Fatalf("Unexpected registry: %s", registryName)
112-
}
113-
101+
expectedImage := registryName + "/rhoai/" + expectedRuntime.RHOAIImage
114102
test.Expect(foundImage).To(ContainSubstring(expectedImage),
115103
"Image %s should contain %s", foundImage, expectedImage)
116104
test.T().Logf("ClusterTrainingRuntime '%s' uses expected image: %s", expectedRuntime.Name, expectedImage)

tests/trainer/trainer_smoke_test.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818

1919
func TestKubeflowTrainerSmoke(t *testing.T) {
2020
Tags(t, Smoke)
21-
runSmoke(t, "kubeflow-trainer-controller-manager", "odh-trainer", "trainer")
21+
runSmoke(t, "kubeflow-trainer-controller-manager", "odh-trainer")
2222
}
2323

2424
// runSmoke runs a smoke test for a given deployment and expected image names.
25-
func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage string) {
25+
func runSmoke(t *testing.T, deploymentName string, expectedImage string) {
2626
test := With(t)
2727
namespace, err := GetApplicationsNamespaceFromDSCI(test, DefaultDSCIName)
2828
test.Expect(err).NotTo(HaveOccurred())
@@ -39,8 +39,8 @@ func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage s
3939

4040
test.T().Logf("%s deployment is available", deploymentName)
4141

42-
// Determine registry based on namespace
43-
registryName := GetExpectedRegistry(test, namespace)
42+
// Determine registry based on cluster environment
43+
registryName := GetExpectedRegistry(test)
4444

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

@@ -69,18 +69,6 @@ func runSmoke(t *testing.T, deploymentName string, rhoaiImage string, odhImage s
6969
}
7070

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

0 commit comments

Comments
 (0)