Skip to content

Commit e5c9a13

Browse files
authored
update redis to 8.4.0 (#425)
* update redis to 8.4.0
1 parent 879c91c commit e5c9a13

File tree

11 files changed

+79
-64
lines changed

11 files changed

+79
-64
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ Commands which will probably not be implemented:
329329

330330
## &c.
331331

332-
Integration tests are run against Redis 7.2.4. The [./integration](./integration/) subdir
332+
Integration tests are run against Redis 8.4.0. The [./integration](./integration/) subdir
333333
compares miniredis against a real redis instance.
334334

335335
The Redis 6 RESP3 protocol is supported. If there are problems, please open

cmd_connection.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (m *Miniredis) cmdHello(c *server.Peer, cmd string, args []string) {
177177
c.WriteBulk("server")
178178
c.WriteBulk("miniredis")
179179
c.WriteBulk("version")
180-
c.WriteBulk("6.0.5")
180+
c.WriteBulk("8.4.0")
181181
c.WriteBulk("proto")
182182
c.WriteInt(opts.version)
183183
c.WriteBulk("id")
@@ -186,8 +186,17 @@ func (m *Miniredis) cmdHello(c *server.Peer, cmd string, args []string) {
186186
c.WriteBulk("standalone")
187187
c.WriteBulk("role")
188188
c.WriteBulk("master")
189-
c.WriteBulk("modules")
190-
c.WriteLen(0)
189+
c.WriteBulk("modules") // "modules": [
190+
c.WriteLen(1) // we have 1: "vectorset"
191+
c.WriteMapLen(4) // {
192+
c.WriteBulk("name") //
193+
c.WriteBulk("vectorset") //
194+
c.WriteBulk("ver") //
195+
c.WriteInt(1) //
196+
c.WriteBulk("path") //
197+
c.WriteBulk("") //
198+
c.WriteBulk("args") //
199+
c.WriteLen(0) // ]} end modules
191200
}
192201

193202
// ECHO

cmd_connection_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,21 @@ func TestSetError(t *testing.T) {
236236
func TestHello(t *testing.T) {
237237
t.Run("default user", func(t *testing.T) {
238238
s, c := runWithClient(t)
239-
240239
payl := proto.Map(
241240
proto.String("server"), proto.String("miniredis"),
242-
proto.String("version"), proto.String("6.0.5"),
241+
proto.String("version"), proto.String("8.4.0"),
243242
proto.String("proto"), proto.Int(3),
244243
proto.String("id"), proto.Int(42),
245244
proto.String("mode"), proto.String("standalone"),
246245
proto.String("role"), proto.String("master"),
247-
proto.String("modules"), proto.Array(),
246+
proto.String("modules"), proto.Array(
247+
proto.Map(
248+
proto.String("name"), proto.String("vectorset"),
249+
proto.String("ver"), proto.Int(1),
250+
proto.String("path"), proto.String(""),
251+
proto.String("args"), proto.Array(),
252+
),
253+
),
248254
)
249255

250256
mustDo(t, c,

cmd_scripting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (m *Miniredis) runLuaScript(c *server.Peer, sha, script string, readOnly bo
9797
l.Push(mod)
9898
return 1
9999
}))
100+
l.RegisterModule("os", mkLuaOS())
100101

101102
_ = doScript(l, protectGlobals)
102103

cmd_scripting_test.go

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -169,40 +169,45 @@ func TestScript(t *testing.T) {
169169
"SCRIPT", "FOO",
170170
proto.Error("ERR unknown subcommand 'FOO'. Try SCRIPT HELP."),
171171
)
172-
}
173172

174-
func TestCJSON(t *testing.T) {
175-
_, c := runWithClient(t)
173+
t.Run("CJSON", func(t *testing.T) {
174+
mustDo(t, c,
175+
"EVAL", `return cjson.decode('{"id":"foo"}')['id']`, "0",
176+
proto.String("foo"),
177+
)
178+
mustDo(t, c,
179+
"EVAL", `return cjson.encode({foo=42})`, "0",
180+
proto.String(`{"foo":42}`),
181+
)
176182

177-
mustDo(t, c,
178-
"EVAL", `return cjson.decode('{"id":"foo"}')['id']`, "0",
179-
proto.String("foo"),
180-
)
181-
mustDo(t, c,
182-
"EVAL", `return cjson.encode({foo=42})`, "0",
183-
proto.String(`{"foo":42}`),
184-
)
183+
mustContain(t, c,
184+
"EVAL", `redis.encode()`, "0",
185+
"Error compiling script",
186+
)
187+
mustContain(t, c,
188+
"EVAL", `redis.encode("1", "2")`, "0",
189+
"Error compiling script",
190+
)
191+
mustContain(t, c,
192+
"EVAL", `redis.decode()`, "0",
193+
"Error compiling script",
194+
)
195+
mustContain(t, c,
196+
"EVAL", `redis.decode("{")`, "0",
197+
"Error compiling script",
198+
)
199+
mustContain(t, c,
200+
"EVAL", `redis.decode("1", "2")`, "0",
201+
"Error compiling script",
202+
)
203+
})
185204

186-
mustContain(t, c,
187-
"EVAL", `redis.encode()`, "0",
188-
"Error compiling script",
189-
)
190-
mustContain(t, c,
191-
"EVAL", `redis.encode("1", "2")`, "0",
192-
"Error compiling script",
193-
)
194-
mustContain(t, c,
195-
"EVAL", `redis.decode()`, "0",
196-
"Error compiling script",
197-
)
198-
mustContain(t, c,
199-
"EVAL", `redis.decode("{")`, "0",
200-
"Error compiling script",
201-
)
202-
mustContain(t, c,
203-
"EVAL", `redis.decode("1", "2")`, "0",
204-
"Error compiling script",
205-
)
205+
t.Run("os.", func(t *testing.T) {
206+
mustDo(t, c,
207+
"EVAL", `return os.clock()`, "0",
208+
proto.Int(42),
209+
)
210+
})
206211
}
207212

208213
func TestLog(t *testing.T) {

cmd_stream.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -753,12 +753,6 @@ parsing:
753753
c,
754754
opts.blockTimeout,
755755
func(c *server.Peer, ctx *connCtx) bool {
756-
if ctx.nested {
757-
setDirty(c)
758-
c.WriteError("ERR XREADGROUP command is not allowed with BLOCK option from scripts")
759-
return false
760-
}
761-
762756
db := m.db(ctx.selectedDB)
763757
res, err := xreadgroup(
764758
db,
@@ -969,12 +963,6 @@ parsing:
969963
c,
970964
opts.blockTimeout,
971965
func(c *server.Peer, ctx *connCtx) bool {
972-
if ctx.nested {
973-
setDirty(c)
974-
c.WriteError("ERR XREAD command is not allowed with BLOCK option from scripts")
975-
return false
976-
}
977-
978966
db := m.db(ctx.selectedDB)
979967
res := xread(db, opts.streams, opts.ids, opts.count)
980968
if len(res) == 0 {

cmd_string.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,10 @@ func (m *Miniredis) cmdBitcount(c *server.Peer, cmd string, args []string) {
805805
}
806806
args = args[2:]
807807
}
808+
if len(args) != 0 {
809+
c.WriteError(msgSyntaxError)
810+
return
811+
}
808812

809813
withTx(m, c, func(c *server.Peer, ctx *connCtx) {
810814
db := m.db(ctx.selectedDB)

integration/get_redis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -eu
44

5-
VERSION=7.2.4
5+
VERSION=8.4.0
66

77
cd "$(dirname "$0")"
88
rm -rf ./redis_src/

integration/script_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ func TestScript(t *testing.T) {
110110
})
111111
})
112112

113-
t.Run("blocking", func(t *testing.T) {
114-
testRaw(t, func(c *client) {
115-
c.Do("XADD", "pl", "0-1", "name", "Mercury")
116-
c.Do("EVAL", `redis.call("XINFO", "STREAM", "pl")`, "0")
117-
c.Do("EVAL", `redis.call("XREAD", "STREAMS", "pl", "$")`, "0")
118-
c.Error("not allowed with BLOCK option", "EVAL", `redis.call("XREAD", "BLOCK", "10", "STREAMS", "pl", "$")`, "0")
119-
c.Error("not allowed with BLOCK option", "EVAL", `redis.call("XREADGROUP", "GROUP", "group", "consumer", "BLOCK", 1000, "STREAMS", "pl", ">")`, "0")
120-
})
121-
})
122-
123113
t.Run("setresp", func(t *testing.T) {
124114
testRaw(t, func(c *client) {
125115
c.Do("EVAL", `redis.setresp(3); redis.call("SET", "foo", 12); return redis.call("GET", "foo")`, "0")
@@ -203,8 +193,9 @@ func TestLua(t *testing.T) {
203193
testRaw(t, func(c *client) {
204194
// c.Do("EVAL", "print(1)", "0")
205195
c.Do("EVAL", `return string.format('%q', "pretty string")`, "0")
206-
c.Error("Script attempted to access nonexistent global variable", "EVAL", "os.clock()", "0")
207-
c.Error("Script attempted to access nonexistent global variable", "EVAL", "os.exit(42)", "0")
196+
c.Error("Script attempted to access nonexistent global variable", "EVAL", "foob.clock()", "0")
197+
c.DoLoosely("EVAL", "os.clock()", "0")
198+
c.Error("attempt to call", "EVAL", "os.exit(42)", "0")
208199
c.Do("EVAL", "return table.concat({1,2,3})", "0")
209200
c.Do("EVAL", "return math.abs(-42)", "0")
210201
c.Error("Script attempted to access nonexistent global variable", "EVAL", `return utf8.len("hello world")`, "0")

integration/string_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func TestBitcount(t *testing.T) {
453453
c.Error("out of range", "BITCOUNT", "A", "0", "9223372036854775808")
454454

455455
c.Error("wrong number", "BITCOUNT")
456-
c.Do("BITCOUNT", "wrong", "arguments")
456+
c.Error("syntax error", "BITCOUNT", "wrong", "arguments")
457457
c.Error("syntax error", "BITCOUNT", "str", "4", "2", "2", "2", "2")
458458
c.Error("not an integer", "BITCOUNT", "str", "foo", "2")
459459
c.Do("HSET", "aap", "noot", "mies")

0 commit comments

Comments
 (0)