mirror of
https://github.com/joyieldInc/predixy.git
synced 2026-02-05 01:42:24 +08:00
Preserve MGET error responses
Avoid coercing MGET errors into nil when aggregating responses. Adds mget_wrong_type test and runs it in the harness.
This commit is contained in:
parent
11d8c26c19
commit
781b4a68e9
@ -114,6 +114,8 @@ void Response::adjustForLeader(Request* req)
|
||||
if (leader == req) {
|
||||
mHead.fset(nullptr, "*%d\r\n", req->followers());
|
||||
}
|
||||
} else if (mType == Reply::Error) {
|
||||
break;
|
||||
} else {
|
||||
mType = Reply::Array;
|
||||
if (leader == req) {
|
||||
|
||||
34
test/mget_wrong_type.py
Normal file
34
test/mget_wrong_type.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Verify MGET returns WRONGTYPE for non-string keys
|
||||
#
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import redis
|
||||
|
||||
|
||||
def run_test(host, port):
|
||||
c = redis.StrictRedis(host=host, port=port)
|
||||
c.delete("mget_wrong_type")
|
||||
c.lpush("mget_wrong_type", "v1")
|
||||
|
||||
res = c.execute_command("MGET", "mget_wrong_type")
|
||||
if not isinstance(res, (list, tuple)) or len(res) != 1 or res[0] is not None:
|
||||
print("FAIL: MGET wrong type should return nil:", res)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(conflict_handler='resolve', description="MGET wrong type test")
|
||||
parser.add_argument("-h", "--host", default="127.0.0.1")
|
||||
parser.add_argument("-p", "--port", type=int, default=7617)
|
||||
args = parser.parse_args()
|
||||
|
||||
if run_test(args.host, args.port):
|
||||
print("PASS: MGET wrong type")
|
||||
sys.exit(0)
|
||||
print("FAIL: MGET wrong type")
|
||||
sys.exit(1)
|
||||
@ -65,6 +65,7 @@ PUBSUB_RESET_EXIT=0
|
||||
NULL_RESPONSE_EXIT=0
|
||||
PUBSUB_LONG_EXIT=0
|
||||
TRANSACTION_FORBID_EXIT=0
|
||||
MGET_WRONG_TYPE_EXIT=0
|
||||
|
||||
uv run python3 test/basic.py || BASIC_EXIT=$?
|
||||
uv run python3 test/pubsub_minimal.py -p 7617 || PUBSUB_REDIS_EXIT=$?
|
||||
@ -72,10 +73,11 @@ uv run python3 test/pubsub_minimal.py -p 6379 || PUBSUB_MINIMAL_EXIT=$?
|
||||
uv run python3 test/pubsub.py || PUBSUB_EXIT=$?
|
||||
uv run python3 test/pubsub_subscription_order.py -p 7617 || PUBSUB_ORDER_EXIT=$?
|
||||
uv run python3 test/pubsub_parser_reset.py -p 7617 || PUBSUB_RESET_EXIT=$?
|
||||
uv run python3 test/mget_wrong_type.py -p 7617 || MGET_WRONG_TYPE_EXIT=$?
|
||||
uv run python3 test/transaction_forbid.py -p 7617 || TRANSACTION_FORBID_EXIT=$?
|
||||
uv run python3 test/pubsub_long_name.py -p 7617 || PUBSUB_LONG_EXIT=$?
|
||||
uv run python3 test/null_response_handling.py -p 7617 || NULL_RESPONSE_EXIT=$?
|
||||
uv run python3 test/pubsub_message_response.py -p 7617 || PUBSUB_MESSAGE_EXIT=$?
|
||||
|
||||
TEST_EXIT=$((BASIC_EXIT + PUBSUB_REDIS_EXIT + PUBSUB_MINIMAL_EXIT + PUBSUB_EXIT + PUBSUB_MESSAGE_EXIT + PUBSUB_ORDER_EXIT + PUBSUB_RESET_EXIT + NULL_RESPONSE_EXIT + PUBSUB_LONG_EXIT + TRANSACTION_FORBID_EXIT))
|
||||
TEST_EXIT=$((BASIC_EXIT + PUBSUB_REDIS_EXIT + PUBSUB_MINIMAL_EXIT + PUBSUB_EXIT + PUBSUB_MESSAGE_EXIT + PUBSUB_ORDER_EXIT + PUBSUB_RESET_EXIT + NULL_RESPONSE_EXIT + PUBSUB_LONG_EXIT + TRANSACTION_FORBID_EXIT + MGET_WRONG_TYPE_EXIT))
|
||||
exit $TEST_EXIT
|
||||
|
||||
Loading…
Reference in New Issue
Block a user