Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: redis-version to 7.2-rc1 #2532

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

services:
redis:
image: redis
image: redis:7.2-rc
options: >-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bench: testdeps

testdata/redis:
mkdir -p $@
wget -qO- https://download.redis.io/releases/redis-7.0.10.tar.gz | tar xvz --strip-components=1 -C $@
wget -qO- https://download.redis.io/releases/redis-7.2-rc1.tar.gz | tar xvz --strip-components=1 -C $@

testdata/redis/src/redis-server: testdata/redis
cd $< && make all
Expand Down
38 changes: 26 additions & 12 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -1892,9 +1892,10 @@ type XInfoConsumersCmd struct {
}

type XInfoConsumer struct {
Name string
Pending int64
Idle time.Duration
Name string
Pending int64
Idle time.Duration
Inactive time.Duration
}

var _ Cmder = (*XInfoConsumersCmd)(nil)
Expand Down Expand Up @@ -1932,12 +1933,13 @@ func (cmd *XInfoConsumersCmd) readReply(rd *proto.Reader) error {
cmd.val = make([]XInfoConsumer, n)

for i := 0; i < len(cmd.val); i++ {
if err = rd.ReadFixedMapLen(3); err != nil {
nn, err := rd.ReadMapLen()
if err != nil {
return err
}

var key string
for f := 0; f < 3; f++ {
for f := 0; f < nn; f++ {
key, err = rd.ReadString()
if err != nil {
return err
Expand All @@ -1952,6 +1954,10 @@ func (cmd *XInfoConsumersCmd) readReply(rd *proto.Reader) error {
var idle int64
idle, err = rd.ReadInt()
cmd.val[i].Idle = time.Duration(idle) * time.Millisecond
case "inactive":
var inactive int64
inactive, err = rd.ReadInt()
cmd.val[i].Inactive = time.Duration(inactive) * time.Millisecond
default:
return fmt.Errorf("redis: unexpected content %s in XINFO CONSUMERS reply", key)
}
Expand Down Expand Up @@ -2226,10 +2232,11 @@ type XInfoStreamGroupPending struct {
}

type XInfoStreamConsumer struct {
Name string
SeenTime time.Time
PelCount int64
Pending []XInfoStreamConsumerPending
Name string
SeenTime time.Time
ActiveTime time.Time
PelCount int64
Pending []XInfoStreamConsumerPending
}

type XInfoStreamConsumerPending struct {
Expand Down Expand Up @@ -2452,13 +2459,14 @@ func readXInfoStreamConsumers(rd *proto.Reader) ([]XInfoStreamConsumer, error) {
consumers := make([]XInfoStreamConsumer, 0, n)

for i := 0; i < n; i++ {
if err = rd.ReadFixedMapLen(4); err != nil {
nn, err := rd.ReadMapLen()
if err != nil {
return nil, err
}

c := XInfoStreamConsumer{}

for f := 0; f < 4; f++ {
for f := 0; f < nn; f++ {
cKey, err := rd.ReadString()
if err != nil {
return nil, err
Expand All @@ -2472,7 +2480,13 @@ func readXInfoStreamConsumers(rd *proto.Reader) ([]XInfoStreamConsumer, error) {
if err != nil {
return nil, err
}
c.SeenTime = time.Unix(seen/1000, seen%1000*int64(time.Millisecond))
c.SeenTime = time.UnixMilli(seen)
case "active-time":
active, err := rd.ReadInt()
if err != nil {
return nil, err
}
c.ActiveTime = time.UnixMilli(active)
case "pel-count":
c.PelCount, err = rd.ReadInt()
case "pending":
Expand Down
8 changes: 6 additions & 2 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5749,7 +5749,9 @@ var _ = Describe("Commands", func() {
}
for k3, c := range g.Consumers {
Expect(now.Sub(c.SeenTime)).To(BeNumerically("<=", maxElapsed))
Expect(now.Sub(c.ActiveTime)).To(BeNumerically("<=", maxElapsed))
res.Groups[k].Consumers[k3].SeenTime = time.Time{}
res.Groups[k].Consumers[k3].ActiveTime = time.Time{}

for k4, p := range c.Pending {
Expect(now.Sub(p.DeliveryTime)).To(BeNumerically("<=", maxElapsed))
Expand All @@ -5773,10 +5775,12 @@ var _ = Describe("Commands", func() {
Expect(err).NotTo(HaveOccurred())
for i := range res {
res[i].Idle = 0
res[i].Inactive = 0
}

Expect(res).To(Equal([]redis.XInfoConsumer{
{Name: "consumer1", Pending: 2, Idle: 0},
{Name: "consumer2", Pending: 1, Idle: 0},
{Name: "consumer1", Pending: 2, Idle: 0, Inactive: 0},
{Name: "consumer2", Pending: 1, Idle: 0, Inactive: 0},
}))
})
})
Expand Down