Skip to content

Commit 0cf71d1

Browse files
committed
addressing feedback
1 parent a34ea19 commit 0cf71d1

File tree

5 files changed

+35
-87
lines changed

5 files changed

+35
-87
lines changed

test/e2e/instascale_app_wrapper.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package e2e
1818

1919
import (
20-
. "github.com/onsi/gomega"
2120
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
2221

2322
batchv1 "k8s.io/api/batch/v1"
@@ -138,11 +137,6 @@ func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, confi
138137
}
139138

140139
_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})
141-
test.Expect(err).NotTo(HaveOccurred())
142-
test.T().Logf("AppWrapper created successfully %s/%s", aw.Namespace, aw.Name)
143-
144-
test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutGpuProvisioning).
145-
Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive)))
146140

147141
return job, aw, err
148142
}

test/e2e/instascale_machinepool_test.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3128
func 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

test/support/config_map.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

test/support/core.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ import (
2727
"k8s.io/apimachinery/pkg/runtime"
2828
)
2929

30+
func CreateConfigMap(t Test, namespace string, content map[string][]byte) *corev1.ConfigMap {
31+
configMap := &corev1.ConfigMap{
32+
TypeMeta: metav1.TypeMeta{
33+
APIVersion: corev1.SchemeGroupVersion.String(),
34+
Kind: "ConfigMap",
35+
},
36+
ObjectMeta: metav1.ObjectMeta{
37+
GenerateName: "config-",
38+
Namespace: namespace,
39+
},
40+
BinaryData: content,
41+
Immutable: Ptr(true),
42+
}
43+
44+
configMap, err := t.Client().Core().CoreV1().ConfigMaps(namespace).Create(t.Ctx(), configMap, metav1.CreateOptions{})
45+
t.Expect(err).NotTo(gomega.HaveOccurred())
46+
t.T().Logf("Created ConfigMap %s/%s successfully", configMap.Namespace, configMap.Name)
47+
48+
return configMap
49+
}
50+
3051
func Raw(t Test, obj runtime.Object) runtime.RawExtension {
3152
t.T().Helper()
3253
data, err := json.Marshal(obj)

test/support/codeflare.go renamed to test/support/environment.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ package support
1818

1919
import (
2020
"os"
21-
"strconv"
22-
23-
"github.com/onsi/gomega"
2421
)
2522

2623
const (
@@ -41,8 +38,6 @@ const (
4138
InstaScaleOcmSecretNamespace = "INSTASCALE_OCM_SECRET_NAMESPACE"
4239
// Cluster ID for OSD cluster used in tests, used for testing InstaScale
4340
OsdClusterID = "CLUSTERID"
44-
// Determine if test is being run on an OSD cluster, used for testing InstaScale.
45-
IsOSD = "IS_OSD"
4641
)
4742

4843
func GetCodeFlareSDKVersion() string {
@@ -73,16 +68,12 @@ func GetOsdClusterId() (string, bool) {
7368
return os.LookupEnv(OsdClusterID)
7469
}
7570

76-
func IsOsd(test Test) bool {
77-
test.T().Helper()
78-
env := lookupEnvOrDefault(IsOSD, "false")
79-
osd, err := strconv.ParseBool(env)
80-
if err != nil {
81-
test.T().Logf("error parsing IS_OSD environment variable, using default 'false' value, error: %v ", err)
82-
return false
71+
func IsOsd() bool {
72+
osdClusterId, found := GetOsdClusterId()
73+
if found && osdClusterId != "" {
74+
return true
8375
}
84-
test.Expect(err).NotTo(gomega.HaveOccurred())
85-
return osd
76+
return false
8677
}
8778

8879
func lookupEnvOrDefault(key, value string) string {

0 commit comments

Comments
 (0)