Skip to content

Commit

Permalink
Fix an issue tsh throws assertion error on REDIS_REPLY_STATUS for Red…
Browse files Browse the repository at this point in the history
…is 7 (#19364) (#19400)
  • Loading branch information
greedy52 committed Dec 16, 2022
1 parent 0eba291 commit 5565353
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -373,7 +373,7 @@ replace (
github.com/datastax/go-cassandra-native-protocol => github.com/gravitational/go-cassandra-native-protocol v0.0.0-20221005103706-b9e66c056e90
github.com/denisenkom/go-mssqldb => github.com/gravitational/go-mssqldb v0.11.1-0.20221006130402-25bef12c7ee1
github.com/go-mysql-org/go-mysql => github.com/gravitational/go-mysql v1.5.0-teleport.1
github.com/go-redis/redis/v9 => github.com/gravitational/redis/v9 v9.0.0-teleport.2
github.com/go-redis/redis/v9 => github.com/gravitational/redis/v9 v9.0.0-teleport.3
github.com/gogo/protobuf => github.com/gravitational/protobuf v1.3.2-0.20201123192827-2b9fcfaffcbf
github.com/gravitational/teleport/api => ./api
github.com/julienschmidt/httprouter => github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -729,8 +729,8 @@ github.com/gravitational/predicate v1.3.0 h1:n1lmH6YU1oX/Y546qHQNJb50FJy6Ou/+MvW
github.com/gravitational/predicate v1.3.0/go.mod h1:wPNu01gNYh2LRVtIGmFBvRpfBzl4nI2EaxbYDG8Mm4w=
github.com/gravitational/protobuf v1.3.2-0.20201123192827-2b9fcfaffcbf h1:MQ4e8XcxvZTeuOmRl7yE519vcWc2h/lyvYzsvt41cdY=
github.com/gravitational/protobuf v1.3.2-0.20201123192827-2b9fcfaffcbf/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gravitational/redis/v9 v9.0.0-teleport.2 h1:cX6NjKFy8zcqS0RF+EsOuHBqv+XWAgNUTVxS1y6hg88=
github.com/gravitational/redis/v9 v9.0.0-teleport.2/go.mod h1:8et+z03j0l8N+DvsVnclzjf3Dl/pFHgRk+2Ct1qw66A=
github.com/gravitational/redis/v9 v9.0.0-teleport.3 h1:Eg/j3jiNUZ558KDXOqzF682EFmf97vxAFFnMgZ0YHns=
github.com/gravitational/redis/v9 v9.0.0-teleport.3/go.mod h1:8et+z03j0l8N+DvsVnclzjf3Dl/pFHgRk+2Ct1qw66A=
github.com/gravitational/reporting v0.0.0-20210923183620-237377721140 h1:UACNXsuOXxe2dpjn3SA2g4YUgOoZTxQ6yf+QYAYcQMc=
github.com/gravitational/reporting v0.0.0-20210923183620-237377721140/go.mod h1:rBJeI3JYVzbL7Yw2hYrp4QdKIkncb1pUHo95DyoEGns=
github.com/gravitational/roundtrip v1.0.2 h1:eOCY0NEKKaB0ksJmvhO6lPMFz1pIIef+vyPBTBROQ5c=
Expand Down
21 changes: 21 additions & 0 deletions lib/srv/db/redis/protocol/resp2_test.go
Expand Up @@ -23,6 +23,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"testing"

"github.com/go-redis/redis/v9"
Expand Down Expand Up @@ -111,6 +112,26 @@ func TestWriteCmd(t *testing.T) {
}
}

func TestReadWriteStatus(t *testing.T) {
inputStatusBytes := []byte("+status\r\n")

// Read the status into a redis.Cmd.
cmd := &redis.Cmd{}
err := cmd.ReadReply(redis.NewReader(bytes.NewReader(inputStatusBytes)))
require.NoError(t, err)

// Verify result.
value, err := cmd.Result()
require.NoError(t, err)
require.Equal(t, "status", fmt.Sprintf("%v", value))

// Verify WriteCmd.
outputStatusBytes := &bytes.Buffer{}
err = WriteCmd(redis.NewWriter(outputStatusBytes), value)
require.NoError(t, err)
require.Equal(t, string(inputStatusBytes), outputStatusBytes.String())
}

func TestMakeUnknownCommandErrorForCmd(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 5565353

Please sign in to comment.