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

Function TestPods

pkg/webhook/plugins/plugins_impl_test.go:40–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38)
39
40func TestPods(t *testing.T) {
41 r := rand.New(rand.NewSource(time.Now().UnixNano()))
42
43 tieredLocality := `
44preferred:
45- name: fluid.io/node
46 weight: 100
47required:
48- fluid.io/node
49`
50 jindoRuntime := &datav1alpha1.JindoRuntime{
51 ObjectMeta: metav1.ObjectMeta{
52 Name: "hbase",
53 Namespace: "default",
54 },
55 }
56
57 schema := runtime.NewScheme()
58 _ = corev1.AddToScheme(schema)
59 _ = datav1alpha1.AddToScheme(schema)
60 var (
61 pod corev1.Pod
62 c = fake.NewFakeClientWithScheme(schema, jindoRuntime)
63 plugin api.MutatingHandler
64 pluginName string
65 lenNodePrefer int
66 lenNodeRequire int
67 lenPodPrefer int
68 lenPodAntiPrefer int
69 lenPodRequire int
70 lenPodAntiRequire int
71 )
72
73 // build slice of RuntimeInfos
74 var nilRuntimeInfos map[string]base.RuntimeInfoInterface = map[string]base.RuntimeInfoInterface{}
75 runtimeInfo, err := base.BuildRuntimeInfo("hbase", "default", "jindo")
76 if err != nil {
77 t.Error("fail to build runtimeInfo because of err", err)
78 }
79 runtimeInfo.SetFuseNodeSelector(map[string]string{})
80 runtimeInfo.SetDeprecatedNodeLabel(false)
81 // runtimeInfos := append(nilRuntimeInfos, runtimeInfo)
82 runtimeInfos := map[string]base.RuntimeInfoInterface{"hbase": runtimeInfo}
83
84 // test all plugins for 3 turns
85 for i := 0; i < 3; i++ {
86 lenNodePrefer = r.Intn(3) + 1
87 lenNodeRequire = r.Intn(3) + 1
88 lenPodPrefer = r.Intn(3) + 1
89 lenPodAntiPrefer = r.Intn(3) + 1
90 lenPodRequire = r.Intn(3) + 1
91 lenPodAntiRequire = r.Intn(3) + 1
92
93 // build affinity of pod
94 pod.Spec.Affinity = &corev1.Affinity{
95 NodeAffinity: &corev1.NodeAffinity{
96 RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
97 NodeSelectorTerms: make([]corev1.NodeSelectorTerm, lenNodeRequire),

Callers

nothing calls this directly

Calls 9

NewFakeClientWithSchemeFunction · 0.92
BuildRuntimeInfoFunction · 0.92
NewPluginFunction · 0.92
NewPluginFunction · 0.92
SetFuseNodeSelectorMethod · 0.65
GetNameMethod · 0.65
MutateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected