@@ -22,35 +22,29 @@ import (
2222 . "github.com/onsi/gomega"
2323 mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
2424
25- batchv1 "k8s.io/api/batch/v1"
26- corev1 "k8s.io/api/core/v1"
27-
2825 . "github.com/project-codeflare/codeflare-operator/test/support"
2926)
3027
3128func TestInstascaleMachinePool (t * testing.T ) {
32-
3329 test := With (t )
3430 test .T ().Parallel ()
3531
36- if ! IsOsd (test ) {
32+ if ! IsOsd () {
3733 test .T ().Skip ("Skipping test as not running on an OSD cluster" )
3834 }
3935
4036 namespace := test .NewTestNamespace ()
4137
4238 // Test configuration
43- testConfigData := map [string ][]byte {
39+ cm := CreateConfigMap ( test , namespace . Name , map [string ][]byte {
4440 // pip requirements
4541 "requirements.txt" : ReadFile (test , "mnist_pip_requirements.txt" ),
4642 // MNIST training script
4743 "mnist.py" : ReadFile (test , "mnist.py" ),
48- }
49- cm := CreateConfigMap (test , namespace .Name , testConfigData )
44+ })
5045
5146 //create OCM connection
5247 connection := CreateOCMConnection (test )
53-
5448 defer connection .Close ()
5549
5650 // check existing cluster machine pool resources
@@ -59,25 +53,18 @@ func TestInstascaleMachinePool(t *testing.T) {
5953 ShouldNot (ContainElement (WithTransform (MachinePoolId , Equal ("test-instascale-g4dn-xlarge" ))))
6054
6155 // Setup batch job and AppWrapper
62- job , aw , err := createInstaScaleJobAppWrapper (test , namespace , cm )
56+ _ , aw , err := createInstaScaleJobAppWrapper (test , namespace , cm )
6357 test .Expect (err ).NotTo (HaveOccurred ())
58+ test .T ().Logf ("AppWrapper created successfully %s/%s" , aw .Namespace , aw .Name )
59+
60+ // assert that AppWrapper goes to "Running" state
61+ test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutGpuProvisioning ).
62+ Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateActive )))
6463
6564 // look for machine pool with aw name - expect to find it
6665 test .Eventually (MachinePools (test , connection ), TestTimeoutLong ).
6766 Should (ContainElement (WithTransform (MachinePoolId , Equal ("test-instascale-g4dn-xlarge" ))))
6867
69- // Assert that the job has completed
70- test .T ().Logf ("Waiting for Job %s/%s to complete" , job .Namespace , job .Name )
71- test .Eventually (Job (test , job .Namespace , job .Name ), TestTimeoutLong ).Should (
72- Or (
73- WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )),
74- WithTransform (ConditionStatus (batchv1 .JobFailed ), Equal (corev1 .ConditionTrue )),
75- ))
76-
77- // Assert the job has completed successfully
78- test .Expect (GetJob (test , job .Namespace , job .Name )).
79- To (WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )))
80-
8168 test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutShort ).
8269 Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )))
8370
0 commit comments