Skip to content

Commit

Permalink
Update to use codeflare-common repo functions + update to RayV1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianZaccaria committed Nov 13, 2023
1 parent 6cab591 commit d27d327
Show file tree
Hide file tree
Showing 11 changed files with 650 additions and 261 deletions.
20 changes: 17 additions & 3 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,50 @@ go 1.19
require (
github.com/onsi/gomega v1.27.10
github.com/openshift/api v0.0.0-20230718161610-2a3e8b481cec
github.com/project-codeflare/codeflare-operator v1.0.0-rc.1
github.com/project-codeflare/multi-cluster-app-dispatcher v1.35.0
github.com/ray-project/kuberay/ray-operator v0.0.0-20230920050528-dfdc51a88b6d
github.com/project-codeflare/codeflare-common v0.0.0-20231110155354-042fb171fcdb
github.com/project-codeflare/multi-cluster-app-dispatcher v1.37.0
github.com/ray-project/kuberay/ray-operator v0.0.0-20231016183545-097828931d15
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
)

replace sigs.k8s.io/custom-metrics-apiserver => sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230306170449-63d8c93851f3

require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/microcosm-cc/bluemonday v1.0.18 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openshift-online/ocm-sdk-go v0.1.368 // indirect
github.com/openshift/client-go v0.0.0-20230718165156-6014fb98e86a // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/net v0.12.0 // indirect
Expand Down
541 changes: 535 additions & 6 deletions tests/go.sum

Large diffs are not rendered by default.

61 changes: 31 additions & 30 deletions tests/integration/mcad_ray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,28 @@ import (
"testing"

. "github.com/onsi/gomega"
cfosupport "github.com/project-codeflare/codeflare-operator/test/support"
. "github.com/project-codeflare/codeflare-common/support"
"github.com/opendatahub-io/distributed-workloads/tests/integration/support"
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
rayv1alpha1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1"

corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/opendatahub-io/distributed-workloads/tests/integration/support"
)

func TestMCADRay(t *testing.T) {
test := cfosupport.With(t)
test := With(t)

// Create a namespace
namespace := test.NewTestNamespace()

// Test configuration
jupyterNotebookConfigMapFileName := "mnist_ray_mini.ipynb"
config := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.String(),
Kind: "ConfigMap",
},
ObjectMeta: metav1.ObjectMeta{
Name: "notebooks-ray",
},
BinaryData: map[string][]byte{
// MNIST MCAD Notebook
jupyterNotebookConfigMapFileName: ReadFile(test, "resources/mnist_ray_mini.ipynb"),
"mnist.py": ReadFile(test, "resources/mnist.py"),
"requirements.txt": ReadFile(test, "resources/requirements.txt"),
},
Immutable: cfosupport.Ptr(true),
}
config, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Create(test.Ctx(), config, metav1.CreateOptions{})
test.Expect(err).NotTo(HaveOccurred())
test.T().Logf("Created ConfigMap %s/%s successfully", config.Namespace, config.Name)
config := CreateConfigMap(test, namespace.Name, map[string][]byte{
// MNIST Ray Notebook
jupyterNotebookConfigMapFileName: ReadFile(test, "resources/mnist_ray_mini.ipynb"),
"mnist.py": ReadFile(test, "resources/mnist.py"),
"requirements.txt": ReadFile(test, "resources/requirements.txt"),
})

// Create RBAC, retrieve token for user with limited rights
policyRules := []rbacv1.PolicyRule{
Expand All @@ -77,22 +61,39 @@ func TestMCADRay(t *testing.T) {
Resources: []string{"routes"},
},
}
token := support.CreateTestRBAC(test, namespace, policyRules)

// Create cluster wide RBAC, required for SDK OpenShift check
// TODO reevaluate once SDK change OpenShift detection logic
clusterPolicyRules := []rbacv1.PolicyRule{
{
Verbs: []string{"get", "list"},
APIGroups: []string{"config.openshift.io"},
Resources: []string{"ingresses"},
ResourceNames: []string{"cluster"},
},
}

sa := CreateServiceAccount(test, namespace.Name)
role := CreateRole(test, namespace.Name, policyRules)
CreateRoleBinding(test, namespace.Name, sa, role)
clusterRole := CreateClusterRole(test, clusterPolicyRules)
CreateClusterRoleBinding(test, sa, clusterRole)
token := CreateToken(test, namespace.Name, sa)

// Create Notebook CR
support.CreateNotebook(test, namespace, token, config.Name, jupyterNotebookConfigMapFileName)

// Make sure the AppWrapper is created and running
test.Eventually(cfosupport.AppWrappers(test, namespace), cfosupport.TestTimeoutLong).
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).
Should(
And(
HaveLen(1),
ContainElement(WithTransform(cfosupport.AppWrapperName, HavePrefix("mnisttest"))),
ContainElement(WithTransform(cfosupport.AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))),
ContainElement(WithTransform(AppWrapperName, HavePrefix("mnisttest"))),
ContainElement(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))),
),
)

// Make sure the AppWrapper finishes and is deleted
test.Eventually(cfosupport.AppWrappers(test, namespace), cfosupport.TestTimeoutLong).
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).
Should(HaveLen(0))
}
19 changes: 11 additions & 8 deletions tests/integration/pytorch_mcad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

. "github.com/onsi/gomega"
cfosupport "github.com/project-codeflare/codeflare-operator/test/support"
. "github.com/project-codeflare/codeflare-common/support"
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"

corev1 "k8s.io/api/core/v1"
Expand All @@ -31,7 +31,7 @@ import (
)

func TestMnistPyTorchMCAD(t *testing.T) {
test := cfosupport.With(t)
test := With(t)

// Create a namespace
namespace := test.NewTestNamespace()
Expand All @@ -50,7 +50,7 @@ func TestMnistPyTorchMCAD(t *testing.T) {
// MNIST MCAD Notebook
jupyterNotebookConfigMapFileName: ReadFile(test, "resources/mnist_mcad_mini.ipynb"),
},
Immutable: cfosupport.Ptr(true),
Immutable: Ptr(true),
}
config, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Create(test.Ctx(), config, metav1.CreateOptions{})
test.Expect(err).NotTo(HaveOccurred())
Expand All @@ -70,22 +70,25 @@ func TestMnistPyTorchMCAD(t *testing.T) {
Resources: []string{"pods/log"},
},
}
token := support.CreateTestRBAC(test, namespace, policyRules)
sa := CreateServiceAccount(test, namespace.Name)
role := CreateRole(test, namespace.Name, policyRules)
CreateRoleBinding(test, namespace.Name, sa, role)
token := CreateToken(test, namespace.Name, sa)

// Create Notebook CR
support.CreateNotebook(test, namespace, token, config.Name, jupyterNotebookConfigMapFileName)

// Make sure the AppWrapper is created and running
test.Eventually(cfosupport.AppWrappers(test, namespace), cfosupport.TestTimeoutLong).
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).
Should(
And(
HaveLen(1),
ContainElement(WithTransform(cfosupport.AppWrapperName, HavePrefix("mnistjob"))),
ContainElement(WithTransform(cfosupport.AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))),
ContainElement(WithTransform(AppWrapperName, HavePrefix("mnistjob"))),
ContainElement(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))),
),
)

// Make sure the AppWrapper finishes and is deleted
test.Eventually(cfosupport.AppWrappers(test, namespace), cfosupport.TestTimeoutLong).
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).
Should(HaveLen(0))
}
Loading

0 comments on commit d27d327

Please sign in to comment.