mirror of
https://github.com/redis/go-redis.git
synced 2025-06-12 14:21:52 +03:00
feat(tests): validate that ConfigSet and ConfigGet work with Modules (#3258)
* Add tests for unified config in Redis 8 * WIP: fix reading FT.CONFIG with RESP3 * add more tests * use search-timeout * move deprecated warnings on the bottom
This commit is contained in:
138
commands_test.go
138
commands_test.go
@ -344,6 +344,23 @@ var _ = Describe("Commands", func() {
|
||||
Expect(val).NotTo(BeEmpty())
|
||||
})
|
||||
|
||||
It("should ConfigGet Modules", func() {
|
||||
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
|
||||
expected := map[string]string{
|
||||
"search-*": "search-timeout",
|
||||
"ts-*": "ts-retention-policy",
|
||||
"bf-*": "bf-error-rate",
|
||||
"cf-*": "cf-initial-size",
|
||||
}
|
||||
|
||||
for prefix, lookup := range expected {
|
||||
val, err := client.ConfigGet(ctx, prefix).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).NotTo(BeEmpty())
|
||||
Expect(val[lookup]).NotTo(BeEmpty())
|
||||
}
|
||||
})
|
||||
|
||||
It("should ConfigResetStat", Label("NonRedisEnterprise"), func() {
|
||||
r := client.ConfigResetStat(ctx)
|
||||
Expect(r.Err()).NotTo(HaveOccurred())
|
||||
@ -362,6 +379,127 @@ var _ = Describe("Commands", func() {
|
||||
Expect(configSet.Val()).To(Equal("OK"))
|
||||
})
|
||||
|
||||
It("should ConfigGet with Modules", Label("NonRedisEnterprise"), func() {
|
||||
SkipBeforeRedisMajor(8, "config get won't return modules configs before redis 8")
|
||||
configGet := client.ConfigGet(ctx, "*")
|
||||
Expect(configGet.Err()).NotTo(HaveOccurred())
|
||||
Expect(configGet.Val()).To(HaveKey("maxmemory"))
|
||||
Expect(configGet.Val()).To(HaveKey("search-timeout"))
|
||||
Expect(configGet.Val()).To(HaveKey("ts-retention-policy"))
|
||||
Expect(configGet.Val()).To(HaveKey("bf-error-rate"))
|
||||
Expect(configGet.Val()).To(HaveKey("cf-initial-size"))
|
||||
})
|
||||
|
||||
It("should ConfigSet FT DIALECT", func() {
|
||||
SkipBeforeRedisMajor(8, "config doesn't include modules before Redis 8")
|
||||
defaultState, err := client.ConfigGet(ctx, "search-default-dialect").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// set to 3
|
||||
res, err := client.ConfigSet(ctx, "search-default-dialect", "3").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(BeEquivalentTo("OK"))
|
||||
|
||||
defDialect, err := client.FTConfigGet(ctx, "DEFAULT_DIALECT").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(defDialect).To(BeEquivalentTo(map[string]interface{}{"DEFAULT_DIALECT": "3"}))
|
||||
|
||||
resGet, err := client.ConfigGet(ctx, "search-default-dialect").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resGet).To(BeEquivalentTo(map[string]string{"search-default-dialect": "3"}))
|
||||
|
||||
// set to 2
|
||||
res, err = client.ConfigSet(ctx, "search-default-dialect", "2").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(BeEquivalentTo("OK"))
|
||||
|
||||
defDialect, err = client.FTConfigGet(ctx, "DEFAULT_DIALECT").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(defDialect).To(BeEquivalentTo(map[string]interface{}{"DEFAULT_DIALECT": "2"}))
|
||||
|
||||
// set to 1
|
||||
res, err = client.ConfigSet(ctx, "search-default-dialect", "1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(BeEquivalentTo("OK"))
|
||||
|
||||
defDialect, err = client.FTConfigGet(ctx, "DEFAULT_DIALECT").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(defDialect).To(BeEquivalentTo(map[string]interface{}{"DEFAULT_DIALECT": "1"}))
|
||||
|
||||
resGet, err = client.ConfigGet(ctx, "search-default-dialect").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resGet).To(BeEquivalentTo(map[string]string{"search-default-dialect": "1"}))
|
||||
|
||||
// set to default
|
||||
res, err = client.ConfigSet(ctx, "search-default-dialect", defaultState["search-default-dialect"]).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(res).To(BeEquivalentTo("OK"))
|
||||
})
|
||||
|
||||
It("should ConfigSet fail for ReadOnly", func() {
|
||||
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
|
||||
_, err := client.ConfigSet(ctx, "search-max-doctablesize", "100000").Result()
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
|
||||
It("should ConfigSet Modules", func() {
|
||||
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
|
||||
defaults := map[string]string{}
|
||||
expected := map[string]string{
|
||||
"search-timeout": "100",
|
||||
"ts-retention-policy": "2",
|
||||
"bf-error-rate": "0.13",
|
||||
"cf-initial-size": "64",
|
||||
}
|
||||
|
||||
// read the defaults to set them back later
|
||||
for setting, _ := range expected {
|
||||
val, err := client.ConfigGet(ctx, setting).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defaults[setting] = val[setting]
|
||||
}
|
||||
|
||||
// check if new values can be set
|
||||
for setting, value := range expected {
|
||||
val, err := client.ConfigSet(ctx, setting, value).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).NotTo(BeEmpty())
|
||||
Expect(val).To(Equal("OK"))
|
||||
}
|
||||
|
||||
for setting, value := range expected {
|
||||
val, err := client.ConfigGet(ctx, setting).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).NotTo(BeEmpty())
|
||||
Expect(val[setting]).To(Equal(value))
|
||||
}
|
||||
|
||||
// set back to the defaults
|
||||
for setting, value := range defaults {
|
||||
val, err := client.ConfigSet(ctx, setting, value).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).NotTo(BeEmpty())
|
||||
Expect(val).To(Equal("OK"))
|
||||
}
|
||||
})
|
||||
|
||||
It("should Fail ConfigSet Modules", func() {
|
||||
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
|
||||
expected := map[string]string{
|
||||
"search-timeout": "-100",
|
||||
"ts-retention-policy": "-10",
|
||||
"bf-error-rate": "1.5",
|
||||
"cf-initial-size": "-10",
|
||||
}
|
||||
|
||||
for setting, value := range expected {
|
||||
val, err := client.ConfigSet(ctx, setting, value).Result()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(ContainSubstring(setting)))
|
||||
Expect(val).To(BeEmpty())
|
||||
}
|
||||
})
|
||||
|
||||
It("should ConfigRewrite", Label("NonRedisEnterprise"), func() {
|
||||
configRewrite := client.ConfigRewrite(ctx)
|
||||
Expect(configRewrite.Err()).NotTo(HaveOccurred())
|
||||
|
Reference in New Issue
Block a user