MCPcopy
hub / github.com/fluid-cloudnative/fluid / TestBuildWorkersAffinityForEFCRuntime

Function TestBuildWorkersAffinityForEFCRuntime

pkg/ctrl/affinity_test.go:287–380  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285}
286
287func TestBuildWorkersAffinityForEFCRuntime(t *testing.T) {
288 tests := []struct {
289 name string
290 dataset *datav1alpha1.Dataset
291 worker *appsv1.StatefulSet
292 want *v1.Affinity
293 }{
294 {
295 name: "efc-shared",
296 dataset: &datav1alpha1.Dataset{
297 ObjectMeta: metav1.ObjectMeta{
298 Name: "test-efc",
299 Namespace: "big-data",
300 },
301 Spec: datav1alpha1.DatasetSpec{
302 PlacementMode: datav1alpha1.ShareMode,
303 },
304 },
305 worker: &appsv1.StatefulSet{
306 ObjectMeta: metav1.ObjectMeta{
307 Name: "test-efc-worker",
308 Namespace: "big-data",
309 },
310 Spec: appsv1.StatefulSetSpec{
311 Replicas: ptr.To[int32](1),
312 },
313 },
314 want: &v1.Affinity{
315 PodAntiAffinity: &v1.PodAntiAffinity{
316 PreferredDuringSchedulingIgnoredDuringExecution: []v1.WeightedPodAffinityTerm{},
317 RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
318 {
319 LabelSelector: &metav1.LabelSelector{
320 MatchExpressions: []metav1.LabelSelectorRequirement{
321 {
322 Key: "fluid.io/dataset-placement",
323 Operator: metav1.LabelSelectorOpIn,
324 Values: []string{"Exclusive"},
325 },
326 },
327 },
328 TopologyKey: "kubernetes.io/hostname",
329 },
330 },
331 },
332 NodeAffinity: &v1.NodeAffinity{
333 PreferredDuringSchedulingIgnoredDuringExecution: []v1.PreferredSchedulingTerm{
334 {
335 Weight: 100,
336 Preference: v1.NodeSelectorTerm{
337 MatchExpressions: []v1.NodeSelectorRequirement{
338 {
339 Key: "fluid.io/f-big-data-test-efc",
340 Operator: v1.NodeSelectorOpIn,
341 Values: []string{"true"},
342 },
343 },
344 },

Callers

nothing calls this directly

Calls 5

NewFakeClientWithSchemeFunction · 0.92
BuildRuntimeInfoFunction · 0.92
NullLoggerFunction · 0.92
BuildHelperFunction · 0.85
BuildWorkersAffinityMethod · 0.80

Tested by

no test coverage detected