Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon committed Jun 4, 2024
1 parent 981df3b commit f6b6f1b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions master/internal/rm/kubernetesrm/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"

"github.com/determined-ai/determined/master/internal/mocks"
"github.com/determined-ai/determined/master/pkg/model"
)

func TestGetNonDetPods(t *testing.T) {
Expand Down Expand Up @@ -168,6 +169,54 @@ func TestAllTaintsTolerated(t *testing.T) {
}
}

func TestNodeSelectorsAffinityMatch(t *testing.T) {
cases := []struct {
name string
tcd *model.TaskContainerDefaultsConfig
node *k8sV1.Node
match bool
}{
{"no task containers default", nil, nil, false},
{"no node labels", &model.TaskContainerDefaultsConfig{CPUPodSpec: &k8sV1.Pod{}}, nil, false},
{
"gpu pod spec defined + match",
&model.TaskContainerDefaultsConfig{
GPUPodSpec: &k8sV1.Pod{},
}, &k8sV1.Node{}, true,
},
{"cpu pod spec defined + match", &model.TaskContainerDefaultsConfig{
CPUPodSpec: &k8sV1.Pod{},
}, &k8sV1.Node{}, true},
{"both gpu & cpu pod spec defined + match", &model.TaskContainerDefaultsConfig{
CPUPodSpec: &k8sV1.Pod{},
GPUPodSpec: &k8sV1.Pod{},
}, &k8sV1.Node{}, true},
{"incorrectly formatted task spec, error NewNodeSelector", &model.TaskContainerDefaultsConfig{
CPUPodSpec: &k8sV1.Pod{},
}, &k8sV1.Node{}, true},
{"no match", nil, nil, false},
}

for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
j := newTestJobsService(t)
match := j.podsCanBeScheduledOnNode(tt.tcd, tt.node)
require.Equal(t, tt.match, match)
})
}
}

func TestGetAgentsWithNodeSelectors(t *testing.T) {
cases := []struct {
name string
match bool
}{}

for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {})
}
}

var taintFooBar = k8sV1.Taint{
Key: "foo",
Value: "bar",
Expand Down

0 comments on commit f6b6f1b

Please sign in to comment.