@@ -9,55 +9,10 @@ import (
99 "k8s.io/apimachinery/pkg/api/resource"
1010 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
12- ocmsdk "github.com/openshift-online/ocm-sdk-go"
13-
1412 . "github.com/project-codeflare/codeflare-operator/test/support"
1513)
1614
17- func TestConfig (test Test , namespace string ) (* corev1.ConfigMap , error ) {
18- // Test configuration
19- configMap := & corev1.ConfigMap {
20- TypeMeta : metav1.TypeMeta {
21- APIVersion : corev1 .SchemeGroupVersion .String (),
22- Kind : "ConfigMap" ,
23- },
24- ObjectMeta : metav1.ObjectMeta {
25- Name : "mnist-mcad" ,
26- Namespace : namespace ,
27- },
28- BinaryData : map [string ][]byte {
29- // pip requirements
30- "requirements.txt" : ReadFile (test , "mnist_pip_requirements.txt" ),
31- // MNIST training script
32- "mnist.py" : ReadFile (test , "mnist.py" ),
33- },
34- Immutable : Ptr (true ),
35- }
36-
37- config , err := test .Client ().Core ().CoreV1 ().ConfigMaps (namespace ).Create (test .Ctx (), configMap , metav1.CreateOptions {})
38- test .Expect (err ).NotTo (HaveOccurred ())
39- test .T ().Logf ("Created ConfigMap %s/%s successfully" , config .Namespace , config .Name )
40-
41- return configMap , err
42- }
43-
44- func CreateConnection (test Test ) (* ocmsdk.Connection , error ) {
45- instascaleOCMSecret , err := test .Client ().Core ().CoreV1 ().Secrets ("default" ).Get (test .Ctx (), "instascale-ocm-secret" , metav1.GetOptions {})
46- if err != nil {
47- test .T ().Errorf ("unable to retrieve instascale-ocm-secret - Error : %v" , err )
48- }
49- test .Expect (err ).NotTo (HaveOccurred ())
50- ocmToken := string (instascaleOCMSecret .Data ["token" ])
51- test .T ().Logf ("Retrieved Secret %s successfully" , instascaleOCMSecret .Name )
52-
53- connection , err := CreateOCMConnection (ocmToken )
54- if err != nil {
55- test .T ().Errorf ("Unable to create ocm connection - Error : %v" , err )
56- }
57- return connection , err
58- }
59-
60- func JobAppwrapperSetup (test Test , namespace * corev1.Namespace , config * corev1.ConfigMap ) (* batchv1.Job , * mcadv1beta1.AppWrapper , error ) {
15+ func createInstaScaleJobAppWrapper (test Test , namespace * corev1.Namespace , config * corev1.ConfigMap ) (* batchv1.Job , * mcadv1beta1.AppWrapper , error ) {
6116 // Batch Job
6217 job := & batchv1.Job {
6318 TypeMeta : metav1.TypeMeta {
@@ -78,7 +33,7 @@ func JobAppwrapperSetup(test Test, namespace *corev1.Namespace, config *corev1.C
7833 Name : "job" ,
7934 Image : GetPyTorchImage (),
8035 Env : []corev1.EnvVar {
81- corev1. EnvVar {Name : "PYTHONUSERBASE" , Value : "/test2 " },
36+ {Name : "PYTHONUSERBASE" , Value : "/workdir " },
8237 },
8338 Command : []string {"/bin/sh" , "-c" , "pip install -r /test/requirements.txt && torchrun /test/mnist.py" },
8439 Args : []string {"$PYTHONUSERBASE" },
@@ -92,7 +47,7 @@ func JobAppwrapperSetup(test Test, namespace *corev1.Namespace, config *corev1.C
9247 MountPath : "/workdir" ,
9348 },
9449 },
95- WorkingDir : "workdir" ,
50+ WorkingDir : "/ workdir" ,
9651 },
9752 },
9853 Volumes : []corev1.Volume {
@@ -125,7 +80,7 @@ func JobAppwrapperSetup(test Test, namespace *corev1.Namespace, config *corev1.C
12580 Name : "test-instascale" ,
12681 Namespace : namespace .Name ,
12782 Labels : map [string ]string {
128- "orderedinstance" : "m5.xlarge_g4dn .xlarge" ,
83+ "orderedinstance" : "g4dn .xlarge" ,
12984 },
13085 },
13186 Spec : mcadv1beta1.AppWrapperSpec {
@@ -170,7 +125,7 @@ func JobAppwrapperSetup(test Test, namespace *corev1.Namespace, config *corev1.C
170125 test .Expect (err ).NotTo (HaveOccurred ())
171126 test .T ().Logf ("AppWrapper created successfully %s/%s" , aw .Namespace , aw .Name )
172127
173- test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutShort ).
128+ test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutGpuProvisioning ).
174129 Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateActive )))
175130
176131 return job , aw , err
0 commit comments