Skip to content

Test support: Return list of AppWrappers #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/support/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
mcadclient "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned"
rayclient "github.com/ray-project/kuberay/ray-operator/pkg/client/clientset/versioned"

"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"

imagev1 "github.com/openshift/client-go/image/clientset/versioned"
routev1 "github.com/openshift/client-go/route/clientset/versioned"

codeflareclient "github.com/project-codeflare/codeflare-operator/client/clientset/versioned"
Expand All @@ -34,17 +36,21 @@ import (
type Client interface {
Core() kubernetes.Interface
Route() routev1.Interface
Image() imagev1.Interface
CodeFlare() codeflareclient.Interface
MCAD() mcadclient.Interface
Ray() rayclient.Interface
Dynamic() dynamic.Interface
}

type testClient struct {
core kubernetes.Interface
route routev1.Interface
image imagev1.Interface
codeflare codeflareclient.Interface
mcad mcadclient.Interface
ray rayclient.Interface
dynamic dynamic.Interface
}

var _ Client = (*testClient)(nil)
Expand All @@ -57,6 +63,10 @@ func (t *testClient) Route() routev1.Interface {
return t.route
}

func (t *testClient) Image() imagev1.Interface {
return t.image
}

func (t *testClient) CodeFlare() codeflareclient.Interface {
return t.codeflare
}
Expand All @@ -69,6 +79,10 @@ func (t *testClient) Ray() rayclient.Interface {
return t.ray
}

func (t *testClient) Dynamic() dynamic.Interface {
return t.dynamic
}

func newTestClient() (Client, error) {
cfg, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
clientcmd.NewDefaultClientConfigLoadingRules(),
Expand All @@ -88,6 +102,11 @@ func newTestClient() (Client, error) {
return nil, err
}

imageClient, err := imagev1.NewForConfig(cfg)
if err != nil {
return nil, err
}

codeFlareClient, err := codeflareclient.NewForConfig(cfg)
if err != nil {
return nil, err
Expand All @@ -103,11 +122,18 @@ func newTestClient() (Client, error) {
return nil, err
}

dynamicClient, err := dynamic.NewForConfig(cfg)
if err != nil {
return nil, err
}

return &testClient{
core: kubeClient,
route: routeClient,
image: imageClient,
codeflare: codeFlareClient,
mcad: mcadClient,
ray: rayClient,
dynamic: dynamicClient,
}, nil
}
12 changes: 12 additions & 0 deletions test/support/mcad.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ func AppWrapper(t Test, namespace *corev1.Namespace, name string) func(g gomega.
}
}

func AppWrappers(t Test, namespace *corev1.Namespace) func(g gomega.Gomega) []mcadv1beta1.AppWrapper {
return func(g gomega.Gomega) []mcadv1beta1.AppWrapper {
aws, err := t.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).List(t.Ctx(), metav1.ListOptions{})
g.Expect(err).NotTo(gomega.HaveOccurred())
return aws.Items
}
}

func AppWrapperName(aw *mcadv1beta1.AppWrapper) string {
return aw.Name
}

func AppWrapperState(aw *mcadv1beta1.AppWrapper) mcadv1beta1.AppWrapperState {
return aw.Status.State
}