@@ -344,6 +344,23 @@ var _ = Describe("Commands", func() {
344
344
Expect (val ).NotTo (BeEmpty ())
345
345
})
346
346
347
+ It ("should ConfigGet Modules" , func () {
348
+ SkipBeforeRedisMajor (8 , "Config doesn't include modules before Redis 8" )
349
+ expected := map [string ]string {
350
+ "search-*" : "search-timeout" ,
351
+ "ts-*" : "ts-retention-policy" ,
352
+ "bf-*" : "bf-error-rate" ,
353
+ "cf-*" : "cf-initial-size" ,
354
+ }
355
+
356
+ for prefix , lookup := range expected {
357
+ val , err := client .ConfigGet (ctx , prefix ).Result ()
358
+ Expect (err ).NotTo (HaveOccurred ())
359
+ Expect (val ).NotTo (BeEmpty ())
360
+ Expect (val [lookup ]).NotTo (BeEmpty ())
361
+ }
362
+ })
363
+
347
364
It ("should ConfigResetStat" , Label ("NonRedisEnterprise" ), func () {
348
365
r := client .ConfigResetStat (ctx )
349
366
Expect (r .Err ()).NotTo (HaveOccurred ())
@@ -362,6 +379,127 @@ var _ = Describe("Commands", func() {
362
379
Expect (configSet .Val ()).To (Equal ("OK" ))
363
380
})
364
381
382
+ It ("should ConfigGet with Modules" , Label ("NonRedisEnterprise" ), func () {
383
+ SkipBeforeRedisMajor (8 , "config get won't return modules configs before redis 8" )
384
+ configGet := client .ConfigGet (ctx , "*" )
385
+ Expect (configGet .Err ()).NotTo (HaveOccurred ())
386
+ Expect (configGet .Val ()).To (HaveKey ("maxmemory" ))
387
+ Expect (configGet .Val ()).To (HaveKey ("search-timeout" ))
388
+ Expect (configGet .Val ()).To (HaveKey ("ts-retention-policy" ))
389
+ Expect (configGet .Val ()).To (HaveKey ("bf-error-rate" ))
390
+ Expect (configGet .Val ()).To (HaveKey ("cf-initial-size" ))
391
+ })
392
+
393
+ It ("should ConfigSet FT DIALECT" , func () {
394
+ SkipBeforeRedisMajor (8 , "config doesn't include modules before Redis 8" )
395
+ defaultState , err := client .ConfigGet (ctx , "search-default-dialect" ).Result ()
396
+ Expect (err ).NotTo (HaveOccurred ())
397
+
398
+ // set to 3
399
+ res , err := client .ConfigSet (ctx , "search-default-dialect" , "3" ).Result ()
400
+ Expect (err ).NotTo (HaveOccurred ())
401
+ Expect (res ).To (BeEquivalentTo ("OK" ))
402
+
403
+ defDialect , err := client .FTConfigGet (ctx , "DEFAULT_DIALECT" ).Result ()
404
+ Expect (err ).NotTo (HaveOccurred ())
405
+ Expect (defDialect ).To (BeEquivalentTo (map [string ]interface {}{"DEFAULT_DIALECT" : "3" }))
406
+
407
+ resGet , err := client .ConfigGet (ctx , "search-default-dialect" ).Result ()
408
+ Expect (err ).NotTo (HaveOccurred ())
409
+ Expect (resGet ).To (BeEquivalentTo (map [string ]string {"search-default-dialect" : "3" }))
410
+
411
+ // set to 2
412
+ res , err = client .ConfigSet (ctx , "search-default-dialect" , "2" ).Result ()
413
+ Expect (err ).NotTo (HaveOccurred ())
414
+ Expect (res ).To (BeEquivalentTo ("OK" ))
415
+
416
+ defDialect , err = client .FTConfigGet (ctx , "DEFAULT_DIALECT" ).Result ()
417
+ Expect (err ).NotTo (HaveOccurred ())
418
+ Expect (defDialect ).To (BeEquivalentTo (map [string ]interface {}{"DEFAULT_DIALECT" : "2" }))
419
+
420
+ // set to 1
421
+ res , err = client .ConfigSet (ctx , "search-default-dialect" , "1" ).Result ()
422
+ Expect (err ).NotTo (HaveOccurred ())
423
+ Expect (res ).To (BeEquivalentTo ("OK" ))
424
+
425
+ defDialect , err = client .FTConfigGet (ctx , "DEFAULT_DIALECT" ).Result ()
426
+ Expect (err ).NotTo (HaveOccurred ())
427
+ Expect (defDialect ).To (BeEquivalentTo (map [string ]interface {}{"DEFAULT_DIALECT" : "1" }))
428
+
429
+ resGet , err = client .ConfigGet (ctx , "search-default-dialect" ).Result ()
430
+ Expect (err ).NotTo (HaveOccurred ())
431
+ Expect (resGet ).To (BeEquivalentTo (map [string ]string {"search-default-dialect" : "1" }))
432
+
433
+ // set to default
434
+ res , err = client .ConfigSet (ctx , "search-default-dialect" , defaultState ["search-default-dialect" ]).Result ()
435
+ Expect (err ).NotTo (HaveOccurred ())
436
+ Expect (res ).To (BeEquivalentTo ("OK" ))
437
+ })
438
+
439
+ It ("should ConfigSet fail for ReadOnly" , func () {
440
+ SkipBeforeRedisMajor (8 , "Config doesn't include modules before Redis 8" )
441
+ _ , err := client .ConfigSet (ctx , "search-max-doctablesize" , "100000" ).Result ()
442
+ Expect (err ).To (HaveOccurred ())
443
+ })
444
+
445
+ It ("should ConfigSet Modules" , func () {
446
+ SkipBeforeRedisMajor (8 , "Config doesn't include modules before Redis 8" )
447
+ defaults := map [string ]string {}
448
+ expected := map [string ]string {
449
+ "search-timeout" : "100" ,
450
+ "ts-retention-policy" : "2" ,
451
+ "bf-error-rate" : "0.13" ,
452
+ "cf-initial-size" : "64" ,
453
+ }
454
+
455
+ // read the defaults to set them back later
456
+ for setting , _ := range expected {
457
+ val , err := client .ConfigGet (ctx , setting ).Result ()
458
+ Expect (err ).NotTo (HaveOccurred ())
459
+ defaults [setting ] = val [setting ]
460
+ }
461
+
462
+ // check if new values can be set
463
+ for setting , value := range expected {
464
+ val , err := client .ConfigSet (ctx , setting , value ).Result ()
465
+ Expect (err ).NotTo (HaveOccurred ())
466
+ Expect (val ).NotTo (BeEmpty ())
467
+ Expect (val ).To (Equal ("OK" ))
468
+ }
469
+
470
+ for setting , value := range expected {
471
+ val , err := client .ConfigGet (ctx , setting ).Result ()
472
+ Expect (err ).NotTo (HaveOccurred ())
473
+ Expect (val ).NotTo (BeEmpty ())
474
+ Expect (val [setting ]).To (Equal (value ))
475
+ }
476
+
477
+ // set back to the defaults
478
+ for setting , value := range defaults {
479
+ val , err := client .ConfigSet (ctx , setting , value ).Result ()
480
+ Expect (err ).NotTo (HaveOccurred ())
481
+ Expect (val ).NotTo (BeEmpty ())
482
+ Expect (val ).To (Equal ("OK" ))
483
+ }
484
+ })
485
+
486
+ It ("should Fail ConfigSet Modules" , func () {
487
+ SkipBeforeRedisMajor (8 , "Config doesn't include modules before Redis 8" )
488
+ expected := map [string ]string {
489
+ "search-timeout" : "-100" ,
490
+ "ts-retention-policy" : "-10" ,
491
+ "bf-error-rate" : "1.5" ,
492
+ "cf-initial-size" : "-10" ,
493
+ }
494
+
495
+ for setting , value := range expected {
496
+ val , err := client .ConfigSet (ctx , setting , value ).Result ()
497
+ Expect (err ).To (HaveOccurred ())
498
+ Expect (err ).To (MatchError (ContainSubstring (setting )))
499
+ Expect (val ).To (BeEmpty ())
500
+ }
501
+ })
502
+
365
503
It ("should ConfigRewrite" , Label ("NonRedisEnterprise" ), func () {
366
504
configRewrite := client .ConfigRewrite (ctx )
367
505
Expect (configRewrite .Err ()).NotTo (HaveOccurred ())
0 commit comments