Skip to content

Commit 9adede8

Browse files
committed
instascale hypershift/nodepool e2e test
1 parent 0afa252 commit 9adede8

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Diff for: test/e2e/instascale_nodepool_test.go

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

0 commit comments

Comments
 (0)