MCPcopy
hub / github.com/rook/rook / TestCephClientController

Function TestCephClientController

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

Source from the content-addressed store, hash-verified

123}
124
125func TestCephClientController(t *testing.T) {
126 ctx := context.TODO()
127 // Set DEBUG logging
128 capnslog.SetGlobalLogLevel(capnslog.DEBUG)
129 os.Setenv("ROOK_LOG_LEVEL", "DEBUG")
130
131 //
132 // TEST 1 SETUP
133 //
134 // FAILURE because no CephCluster
135 //
136 logger.Info("RUN 1")
137 var (
138 name = "my-client"
139 namespace = "rook-ceph"
140 )
141
142 // A Pool resource with metadata and spec.
143 cephClient := &cephv1.CephClient{
144 ObjectMeta: metav1.ObjectMeta{
145 Name: name,
146 Namespace: namespace,
147 UID: types.UID("c47cac40-9bee-4d52-823b-ccd803ba5bfe"),
148 Finalizers: []string{"cephclient.ceph.rook.io"},
149 },
150 TypeMeta: metav1.TypeMeta{
151 Kind: "CephClient",
152 },
153 Spec: cephv1.ClientSpec{
154 Caps: map[string]string{
155 "osd": "allow *",
156 "mon": "allow *",
157 },
158 },
159 Status: &cephv1.CephClientStatus{
160 Phase: "",
161 },
162 }
163
164 // Objects to track in the fake client.
165 object := []runtime.Object{
166 cephClient,
167 }
168
169 executor := &exectest.MockExecutor{
170 MockExecuteCommandWithOutput: func(command string, args ...string) (string, error) {
171 if args[0] == "status" {
172 return `{"fsid":"c47cac40-9bee-4d52-823b-ccd803ba5bfe","health":{"checks":{},"status":"HEALTH_ERR"},"pgmap":{"num_pgs":100,"pgs_by_state":[{"state_name":"active+clean","count":100}]}}`, nil
173 }
174 if args[0] == "versions" {
175 return dummyVersionsRaw, nil
176 }
177
178 return "", nil
179 },
180 }
181 c := &clusterd.Context{
182 Executor: executor,

Callers

nothing calls this directly

Calls 4

ReconcileMethod · 0.95
EqualMethod · 0.80
CreateMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected