MCPcopy
hub / github.com/rook/rook / TestOperatorController

Function TestOperatorController

pkg/operator/ceph/controller_test.go:40–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38)
39
40func TestOperatorController(t *testing.T) {
41 ctx := context.TODO()
42 // Set DEBUG logging
43 capnslog.SetGlobalLogLevel(capnslog.DEBUG)
44 os.Setenv("ROOK_LOG_LEVEL", "DEBUG")
45 name := controller.OperatorSettingConfigMapName
46 namespace := "rook-ceph"
47 req := reconcile.Request{
48 NamespacedName: types.NamespacedName{
49 Name: name,
50 Namespace: namespace,
51 },
52 }
53
54 t.Run("success - normal run", func(t *testing.T) {
55 fakeClientSet := test.New(t, 1)
56 test.SetFakeKubernetesVersion(fakeClientSet, "v1.21.0")
57 c := &clusterd.Context{
58 Clientset: fakeClientSet,
59 RookClientset: rookclient.NewSimpleClientset(),
60 }
61
62 // Register operator types with the runtime scheme.
63 s := scheme.Scheme
64
65 // Create a fake client to mock API calls.
66 cl := fake.NewClientBuilder().WithScheme(s).Build()
67
68 // Create a ReconcileCSI object with the scheme and fake client.
69 r := &ReconcileConfig{
70 client: cl,
71 context: c,
72 config: controller.OperatorConfig{
73 OperatorNamespace: namespace,
74 Image: "rook",
75 ServiceAccount: "foo",
76 },
77 }
78
79 res, err := r.Reconcile(ctx, req)
80 assert.NoError(t, err)
81 assert.False(t, res.Requeue)
82 })
83
84 t.Run("success - env set for command timeout", func(t *testing.T) {
85 fakeClientSet := test.New(t, 1)
86 test.SetFakeKubernetesVersion(fakeClientSet, "v1.21.0")
87 c := &clusterd.Context{
88 Clientset: fakeClientSet,
89 RookClientset: rookclient.NewSimpleClientset(),
90 }
91
92 // Register operator types with the runtime scheme.
93 s := scheme.Scheme
94
95 // Create a fake client to mock API calls.
96 cl := fake.NewClientBuilder().WithScheme(s).Build()
97

Callers

nothing calls this directly

Calls 7

ReconcileMethod · 0.95
NewFunction · 0.92
SetFakeKubernetesVersionFunction · 0.92
LoopDevicesAllowedFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65
ListMethod · 0.65

Tested by

no test coverage detected