mirror of
https://github.com/redis/go-redis.git
synced 2025-11-10 00:00:57 +03:00
feat: Add support for certain slowlog commands (#3585)
* Add support for certain slowlog commands * add NonRedisEnterprise label for slow reset test --------- Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
This commit is contained in:
@@ -8294,7 +8294,7 @@ var _ = Describe("Commands", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SlowLogGet", func() {
|
||||
Describe("SlowLog", func() {
|
||||
It("returns slow query result", func() {
|
||||
const key = "slowlog-log-slower-than"
|
||||
|
||||
@@ -8311,6 +8311,34 @@ var _ = Describe("Commands", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(result)).NotTo(BeZero())
|
||||
})
|
||||
|
||||
It("returns the number of slow queries", Label("NonRedisEnterprise"), func() {
|
||||
// Reset slowlog
|
||||
err := client.SlowLogReset(ctx).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
const key = "slowlog-log-slower-than"
|
||||
|
||||
old := client.ConfigGet(ctx, key).Val()
|
||||
// first slowlog entry is the config set command itself
|
||||
client.ConfigSet(ctx, key, "0")
|
||||
defer client.ConfigSet(ctx, key, old[key])
|
||||
|
||||
// Set a key to trigger a slow query, and this is the second slowlog entry
|
||||
client.Set(ctx, "test", "true", 0)
|
||||
result, err := client.SlowLogLen(ctx).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result).Should(Equal(int64(2)))
|
||||
|
||||
// Reset slowlog
|
||||
err = client.SlowLogReset(ctx).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// Check if slowlog is empty, this is the first slowlog entry after reset
|
||||
result, err = client.SlowLogLen(ctx).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result).Should(Equal(int64(1)))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Latency", Label("NonRedisEnterprise"), func() {
|
||||
|
||||
Reference in New Issue
Block a user