| 
 | 1 | +package e2e  | 
 | 2 | + | 
 | 3 | +import (  | 
 | 4 | +	"testing"  | 
 | 5 | + | 
 | 6 | +	. "github.com/onsi/gomega"  | 
 | 7 | +	mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"  | 
 | 8 | + | 
 | 9 | +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"  | 
 | 10 | + | 
 | 11 | +	. "github.com/project-codeflare/codeflare-operator/test/support"  | 
 | 12 | +)  | 
 | 13 | + | 
 | 14 | +func TestInstascaleNodepool(t *testing.T) {  | 
 | 15 | + | 
 | 16 | +	test := With(t)  | 
 | 17 | +	test.T().Parallel()  | 
 | 18 | + | 
 | 19 | +	clusterType := GetClusterType(test)  | 
 | 20 | +	if clusterType != HypershiftCluster {  | 
 | 21 | +		test.T().Skipf("Skipping test as not running on an Hypershift cluster, resolved cluster type: %s", clusterType)  | 
 | 22 | +	}  | 
 | 23 | + | 
 | 24 | +	namespace := test.NewTestNamespace()  | 
 | 25 | + | 
 | 26 | +	// Test configuration  | 
 | 27 | +	cm := CreateConfigMap(test, namespace.Name, map[string][]byte{  | 
 | 28 | +		// pip requirements  | 
 | 29 | +		"requirements.txt": ReadFile(test, "mnist_pip_requirements.txt"),  | 
 | 30 | +		// MNIST training script  | 
 | 31 | +		"mnist.py": ReadFile(test, "mnist.py"),  | 
 | 32 | +	})  | 
 | 33 | + | 
 | 34 | +	//create OCM connection  | 
 | 35 | +	connection := CreateOCMConnection(test)  | 
 | 36 | +	defer connection.Close()  | 
 | 37 | + | 
 | 38 | +	// check existing cluster resources  | 
 | 39 | +	// look for a node pool with a label key equal to aw name - expect NOT to find it  | 
 | 40 | +	test.Expect(GetNodePools(test, connection)).  | 
 | 41 | +		ShouldNot(ContainElement(WithTransform(NodePoolLabels, HaveKey("test-instascale"))))  | 
 | 42 | + | 
 | 43 | +	// Setup batch job and AppWrapper  | 
 | 44 | +	aw := instaScaleJobAppWrapper(test, namespace, cm)  | 
 | 45 | + | 
 | 46 | +	// apply AppWrapper to cluster  | 
 | 47 | +	_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})  | 
 | 48 | +	test.Expect(err).NotTo(HaveOccurred())  | 
 | 49 | +	test.T().Logf("AppWrapper created successfully %s/%s", aw.Namespace, aw.Name)  | 
 | 50 | + | 
 | 51 | +	// assert that AppWrapper goes to "Running" state  | 
 | 52 | +	test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutGpuProvisioning).  | 
 | 53 | +		Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive)))  | 
 | 54 | + | 
 | 55 | +	// look for a node pool with a label key equal to aw name - expect to find it  | 
 | 56 | +	test.Eventually(NodePools(test, connection), TestTimeoutLong).  | 
 | 57 | +		Should(ContainElement(WithTransform(NodePoolLabels, HaveKey("test-instascale"))))  | 
 | 58 | + | 
 | 59 | +	// assert that the AppWrapper goes to "Completed" state  | 
 | 60 | +	test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutShort).  | 
 | 61 | +		Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted)))  | 
 | 62 | + | 
 | 63 | +	// look for a node pool with a label key equal to aw name - expect NOT to find it  | 
 | 64 | +	test.Eventually(NodePools(test, connection), TestTimeoutLong).  | 
 | 65 | +		ShouldNot(ContainElement(WithTransform(NodePoolLabels, HaveKey("test-instascale"))))  | 
 | 66 | + | 
 | 67 | +}  | 
0 commit comments