MCPcopy
hub / github.com/kubesphere/kubekey / TestTaskExecutor

Function TestTaskExecutor

pkg/executor/task_executor_test.go:15–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestTaskExecutor(t *testing.T) {
16 testcases := []struct {
17 name string
18 hosts []string
19 task *kkcorev1alpha1.Task
20 }{
21 {
22 name: "debug module in single host",
23 task: &kkcorev1alpha1.Task{
24 TypeMeta: metav1.TypeMeta{},
25 ObjectMeta: metav1.ObjectMeta{
26 Name: "test1",
27 Namespace: corev1.NamespaceDefault,
28 },
29 Spec: kkcorev1alpha1.TaskSpec{
30 Hosts: []string{"node1"},
31 Module: kkcorev1alpha1.Module{
32 Name: "debug",
33 Args: runtime.RawExtension{Raw: []byte(`{"msg":"hello"}`)},
34 },
35 },
36 Status: kkcorev1alpha1.TaskStatus{},
37 },
38 },
39 {
40 name: "debug module in single host with loop",
41 hosts: []string{"node1"},
42 task: &kkcorev1alpha1.Task{
43 TypeMeta: metav1.TypeMeta{},
44 ObjectMeta: metav1.ObjectMeta{
45 Name: "test2",
46 Namespace: corev1.NamespaceDefault,
47 },
48 Spec: kkcorev1alpha1.TaskSpec{
49 Hosts: []string{"node1"},
50 Module: kkcorev1alpha1.Module{
51 Name: "debug",
52 Args: runtime.RawExtension{Raw: []byte(`{"msg":"hello"}`)},
53 },
54 Loop: runtime.RawExtension{
55 Raw: []byte(string(`["a", "b"]`)),
56 },
57 },
58 Status: kkcorev1alpha1.TaskStatus{},
59 },
60 },
61 {
62 name: "debug module in multiple hosts",
63 task: &kkcorev1alpha1.Task{
64 TypeMeta: metav1.TypeMeta{},
65 ObjectMeta: metav1.ObjectMeta{
66 Name: "test3",
67 Namespace: corev1.NamespaceDefault,
68 },
69 Spec: kkcorev1alpha1.TaskSpec{
70 Hosts: []string{"node1", "n2"},
71 Module: kkcorev1alpha1.Module{
72 Name: "debug",

Callers

nothing calls this directly

Calls 3

newTestOptionFunction · 0.85
RunMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected