Skip to content

Commit 7deaecf

Browse files
committed
minor logging
1 parent 4fec4fc commit 7deaecf

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

test/dynamic_config_test.go

+41-8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ var _ = Describe(
8686
"Should update config dynamically", func() {
8787

8888
By("Modify dynamic config by adding fields")
89+
8990
aeroCluster, err := getCluster(
9091
k8sClient, ctx, clusterNamespacedName,
9192
)
@@ -122,16 +123,21 @@ var _ = Describe(
122123
err = updateCluster(k8sClient, ctx, aeroCluster)
123124
Expect(err).ToNot(HaveOccurred())
124125

126+
By("Fetch and verify dynamic configs")
127+
125128
pod := aeroCluster.Status.Pods["dynamic-config-test-0-0"]
126129

130+
// Fetch and verify service section config
127131
conf, err := getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
128132
"service", &pod)
129133
Expect(err).ToNot(HaveOccurred())
134+
130135
cv, ok := conf["proto-fd-max"]
131136
Expect(ok).ToNot(BeFalse())
132137

133138
Expect(cv).To(Equal(int64(18000)))
134139

140+
// Fetch and verify security section config
135141
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
136142
"security", &pod)
137143
Expect(err).ToNot(HaveOccurred())
@@ -141,16 +147,19 @@ var _ = Describe(
141147

142148
Expect(reportDataOp).To(Equal("test"))
143149

150+
// Fetch and verify xdr section config
144151
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
145152
"xdr", &pod)
146153
Expect(err).ToNot(HaveOccurred())
147154

148155
Expect(conf["dcs"]).To(HaveLen(2))
149156

150157
By("Verify no warm/cold restarts in Pods")
158+
151159
validateServerRestart(ctx, aeroCluster, podPIDMap, false)
152160

153161
By("Modify dynamic config by removing fields")
162+
154163
aeroCluster, err = getCluster(
155164
k8sClient, ctx, clusterNamespacedName,
156165
)
@@ -168,8 +177,11 @@ var _ = Describe(
168177
err = updateCluster(k8sClient, ctx, aeroCluster)
169178
Expect(err).ToNot(HaveOccurred())
170179

180+
By("Fetch and verify dynamic configs")
181+
171182
pod = aeroCluster.Status.Pods["dynamic-config-test-0-0"]
172183

184+
// Fetch and verify service section config
173185
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
174186
"service", &pod)
175187
Expect(err).ToNot(HaveOccurred())
@@ -178,22 +190,24 @@ var _ = Describe(
178190

179191
Expect(cv).To(Equal(int64(15000)))
180192

193+
// Fetch and verify security section config
181194
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
182195
"security", &pod)
183196
Expect(err).ToNot(HaveOccurred())
184197

185198
_, ok = conf["log.report-data-op[0]"].(string)
186199
Expect(ok).ToNot(BeTrue())
187200

201+
// Fetch and verify xdr section config
188202
conf, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
189203
"xdr", &pod)
190204
Expect(err).ToNot(HaveOccurred())
191205

192206
Expect(conf["dcs"]).To(HaveLen(1))
193207

194208
By("Verify no warm/cold restarts in Pods")
195-
validateServerRestart(ctx, aeroCluster, podPIDMap, false)
196209

210+
validateServerRestart(ctx, aeroCluster, podPIDMap, false)
197211
},
198212
)
199213

@@ -215,6 +229,8 @@ var _ = Describe(
215229
err = updateCluster(k8sClient, ctx, aeroCluster)
216230
Expect(err).ToNot(HaveOccurred())
217231

232+
By("Fetch and verify static configs")
233+
218234
pod := aeroCluster.Status.Pods["dynamic-config-test-0-0"]
219235

220236
conf, err := getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
@@ -227,14 +243,15 @@ var _ = Describe(
227243
Expect(enableQuotas).To(BeTrue())
228244

229245
By("Verify warm restarts in Pods")
246+
230247
validateServerRestart(ctx, aeroCluster, podPIDMap, true)
231248
},
232249
)
233250

234251
It(
235252
"Should update config statically by disabling dynamic update feature", func() {
236253

237-
By("Modify static config")
254+
By("Modify dynamic config statically")
238255

239256
aeroCluster, err := getCluster(
240257
k8sClient, ctx, clusterNamespacedName,
@@ -244,12 +261,15 @@ var _ = Describe(
244261
podPIDMap, err := getPodIDs(ctx, aeroCluster)
245262
Expect(err).ToNot(HaveOccurred())
246263

264+
// Disable dynamic config update and set config
247265
aeroCluster.Spec.EnableDynamicConfigUpdate = ptr.To(false)
248266
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 19000
249267

250268
err = updateCluster(k8sClient, ctx, aeroCluster)
251269
Expect(err).ToNot(HaveOccurred())
252270

271+
By("Fetch and verify static configs")
272+
253273
pod := aeroCluster.Status.Pods["dynamic-config-test-0-0"]
254274

255275
conf, err := getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName,
@@ -320,6 +340,8 @@ var _ = Describe(
320340
podPIDMap, err := getPodIDs(ctx, aeroCluster)
321341
Expect(err).ToNot(HaveOccurred())
322342

343+
// Failure:
344+
// Update invalid config value
323345
// This change will lead to dynamic config update failure.
324346
// In case of full failure, will not fall back to rolling restart
325347
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 9999999
@@ -332,16 +354,18 @@ var _ = Describe(
332354
)
333355
Expect(err).ToNot(HaveOccurred())
334356

335-
// Recovery
357+
// Recovery:
358+
// Update valid config value
359+
// This change will lead to dynamic config update success.
336360
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 15000
337361

338362
err = updateCluster(k8sClient, ctx, aeroCluster)
339363
Expect(err).ToNot(HaveOccurred())
340364

341-
// As pods were failed, expectation is that pods will be cold restarted.
365+
// As there was no full config update failure,
366+
// expectation is that pods will not be restarted.
342367
By("Verify cold restarts in Pods")
343368
validateServerRestart(ctx, aeroCluster, podPIDMap, false)
344-
345369
},
346370
)
347371

@@ -355,6 +379,8 @@ var _ = Describe(
355379
podPIDMap, err := getPodIDs(ctx, aeroCluster)
356380
Expect(err).ToNot(HaveOccurred())
357381

382+
// Failure:
383+
// Update multiple invalid config values
358384
// This change will lead to dynamic config update failure.
359385
// Assuming it will fall back to rolling restart in case of partial failure.
360386
// Which leads to pod failures.
@@ -386,7 +412,9 @@ var _ = Describe(
386412
)
387413
Expect(err).ToNot(HaveOccurred())
388414

389-
// Recovery
415+
// Recovery:
416+
// Update valid config value
417+
// This change will lead to static config update success.
390418
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 15000
391419

392420
err = updateCluster(k8sClient, ctx, aeroCluster)
@@ -545,7 +573,12 @@ var _ = Describe(
545573
By("Verify XDR Context configs dynamically")
546574
err = validateXDRContextDynamically(ctx, flatServer, flatSpec, aeroCluster, dynamic)
547575
Expect(err).ToNot(HaveOccurred())
548-
//
576+
577+
aeroCluster, err = getCluster(
578+
k8sClient, ctx, clusterNamespacedName,
579+
)
580+
Expect(err).ToNot(HaveOccurred())
581+
549582
By("Verify no warm/cold restarts in Pods")
550583
validateServerRestart(ctx, aeroCluster, podPIDMap, false)
551584
},
@@ -630,7 +663,7 @@ func updateValue(val interface{}, confKey string) (interface{}, error) {
630663
return val2 + 1, nil
631664

632665
case lib.Stats:
633-
println("stats", confKey)
666+
pkgLog.Info("got lib.stats type key", confKey)
634667
default:
635668
return nil, fmt.Errorf("format not supported")
636669
}

0 commit comments

Comments
 (0)