@@ -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
2119func 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}
0 commit comments