Unverified Commit 03cd525f authored by debing.sun's avatar debing.sun Committed by GitHub
Browse files

Fix reply schema for hfe related commands (#13238)

parent c33c91db
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -60,6 +61,7 @@ ...@@ -60,6 +61,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"type": "array", "type": "array",
"minItems": 1, "minItems": 1,
"maxItems": 4294967295, "maxItems": 4294967295,
"items": [ "items": {
"oneOf": [
{ {
"description": "The field does not exist.", "description": "The field does not exist.",
"const": -2 "const": -2
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
} }
] ]
} }
}
] ]
}, },
"arguments": [ "arguments": [
......
...@@ -88,41 +88,63 @@ start_server {tags {"external:skip needs:debug"}} { ...@@ -88,41 +88,63 @@ start_server {tags {"external:skip needs:debug"}} {
# Currently listpack doesn't support HFE # Currently listpack doesn't support HFE
r config set hash-max-listpack-entries 0 r config set hash-max-listpack-entries 0
test {HPEXPIRE - Test 'NX' flag} { test {HPEXPIRE(AT) - Test 'NX' flag} {
r del myhash r del myhash
r hset myhash field1 value1 field2 value2 field3 value3 r hset myhash field1 value1 field2 value2 field3 value3
assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK] assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK]
assert_equal [r hpexpire myhash 1000 NX 2 field1 field2] [list $E_FAIL $E_OK] assert_equal [r hpexpire myhash 1000 NX 2 field1 field2] [list $E_FAIL $E_OK]
r del myhash
r hset myhash field1 value1 field2 value2 field3 value3
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] NX 1 field1] [list $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] NX 2 field1 field2] [list $E_FAIL $E_OK]
} }
test {HPEXPIRE - Test 'XX' flag} { test {HPEXPIRE(AT) - Test 'XX' flag} {
r del myhash r del myhash
r hset myhash field1 value1 field2 value2 field3 value3 r hset myhash field1 value1 field2 value2 field3 value3
assert_equal [r hpexpire myhash 1000 NX 2 field1 field2] [list $E_OK $E_OK] assert_equal [r hpexpire myhash 1000 NX 2 field1 field2] [list $E_OK $E_OK]
assert_equal [r hpexpire myhash 1000 XX 2 field1 field3] [list $E_OK $E_FAIL] assert_equal [r hpexpire myhash 1000 XX 2 field1 field3] [list $E_OK $E_FAIL]
r del myhash
r hset myhash field1 value1 field2 value2 field3 value3
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] NX 2 field1 field2] [list $E_OK $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] XX 2 field1 field3] [list $E_OK $E_FAIL]
} }
test {HPEXPIRE - Test 'GT' flag} { test {HPEXPIRE(AT) - Test 'GT' flag} {
r del myhash r del myhash
r hset myhash field1 value1 field2 value2 r hset myhash field1 value1 field2 value2
assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK] assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK]
assert_equal [r hpexpire myhash 2000 NX 1 field2] [list $E_OK] assert_equal [r hpexpire myhash 2000 NX 1 field2] [list $E_OK]
assert_equal [r hpexpire myhash 1500 GT 2 field1 field2] [list $E_OK $E_FAIL] assert_equal [r hpexpire myhash 1500 GT 2 field1 field2] [list $E_OK $E_FAIL]
r del myhash
r hset myhash field1 value1 field2 value2
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] NX 1 field1] [list $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+2000)*1000}] NX 1 field2] [list $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1500)*1000}] GT 2 field1 field2] [list $E_OK $E_FAIL]
} }
test {HPEXPIRE - Test 'LT' flag} { test {HPEXPIRE(AT) - Test 'LT' flag} {
r del myhash r del myhash
r hset myhash field1 value1 field2 value2 r hset myhash field1 value1 field2 value2
assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK] assert_equal [r hpexpire myhash 1000 NX 1 field1] [list $E_OK]
assert_equal [r hpexpire myhash 2000 NX 1 field2] [list $E_OK] assert_equal [r hpexpire myhash 2000 NX 1 field2] [list $E_OK]
assert_equal [r hpexpire myhash 1500 LT 2 field1 field2] [list $E_FAIL $E_OK] assert_equal [r hpexpire myhash 1500 LT 2 field1 field2] [list $E_FAIL $E_OK]
r del myhash
r hset myhash field1 value1 field2 value2
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1000)*1000}] NX 1 field1] [list $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+2000)*1000}] NX 1 field2] [list $E_OK]
assert_equal [r hpexpireat myhash [expr {([clock seconds]+1500)*1000}] LT 2 field1 field2] [list $E_FAIL $E_OK]
} }
test {HPEXPIREAT - field not exists or TTL is in the past} { test {HPEXPIREAT - field not exists or TTL is in the past} {
r del myhash r del myhash
r hset myhash f1 v1 f2 v2 f4 v4 r hset myhash f1 v1 f2 v2 f4 v4
r hexpire myhash 1000 NX 1 f4 r hexpire myhash 1000 NX 1 f4
assert_equal [r hexpireat myhash [expr {[clock seconds] - 1}] NX 4 f1 f2 f3 f4] "$E_DELETED $E_DELETED $E_NO_FIELD $E_FAIL" assert_equal [r hpexpireat myhash [expr {([clock seconds]-1)*1000}] NX 4 f1 f2 f3 f4] "$E_DELETED $E_DELETED $E_NO_FIELD $E_FAIL"
assert_equal [r hexists myhash field1] 0 assert_equal [r hexists myhash field1] 0
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment