Unverified Commit f809e10f authored by guybe7's avatar guybe7 Committed by GitHub
Browse files

Minor change around the req-res validator, skip sentinel commands (#12083)

1. Check for missing schema only after the docs contain sentinel commands
2. The ignore-list in the C file contain only commands that cannot have a reply
  schema. The one in the py file is an extension of that list
3. Temp: skipsentinel commands don't have a schema or test coverage yet,
  add them to the py list

Solve CI error introduced by #12018
parent 2f46e96d
...@@ -186,7 +186,8 @@ size_t reqresAppendRequest(client *c) { ...@@ -186,7 +186,8 @@ size_t reqresAppendRequest(client *c) {
/* Ignore commands that have streaming non-standard response */ /* Ignore commands that have streaming non-standard response */
sds cmd = argv[0]->ptr; sds cmd = argv[0]->ptr;
if (!strcasecmp(cmd,"sync") || if (!strcasecmp(cmd,"debug") || /* because of DEBUG SEGFAULT */
!strcasecmp(cmd,"sync") ||
!strcasecmp(cmd,"psync") || !strcasecmp(cmd,"psync") ||
!strcasecmp(cmd,"monitor") || !strcasecmp(cmd,"monitor") ||
!strcasecmp(cmd,"subscribe") || !strcasecmp(cmd,"subscribe") ||
...@@ -194,11 +195,7 @@ size_t reqresAppendRequest(client *c) { ...@@ -194,11 +195,7 @@ size_t reqresAppendRequest(client *c) {
!strcasecmp(cmd,"ssubscribe") || !strcasecmp(cmd,"ssubscribe") ||
!strcasecmp(cmd,"sunsubscribe") || !strcasecmp(cmd,"sunsubscribe") ||
!strcasecmp(cmd,"psubscribe") || !strcasecmp(cmd,"psubscribe") ||
!strcasecmp(cmd,"punsubscribe") || !strcasecmp(cmd,"punsubscribe"))
!strcasecmp(cmd,"debug") ||
!strcasecmp(cmd,"pfdebug") ||
!strcasecmp(cmd,"lolwut") ||
(!strcasecmp(cmd,"sentinel") && argc > 1 && !strcasecmp(argv[1]->ptr,"debug")))
{ {
return 0; return 0;
} }
......
...@@ -43,7 +43,9 @@ Future validations: ...@@ -43,7 +43,9 @@ Future validations:
1. Fail the script if one or more of the branches of the reply schema (e.g. oneOf, anyOf) was not hit. 1. Fail the script if one or more of the branches of the reply schema (e.g. oneOf, anyOf) was not hit.
""" """
IGNORED_COMMANDS = [ IGNORED_COMMANDS = {
# Commands that don't work in a req-res manner (see logreqres.c)
"debug", # because of DEBUG SEGFAULT
"sync", "sync",
"psync", "psync",
"monitor", "monitor",
...@@ -53,11 +55,21 @@ IGNORED_COMMANDS = [ ...@@ -53,11 +55,21 @@ IGNORED_COMMANDS = [
"sunsubscribe", "sunsubscribe",
"psubscribe", "psubscribe",
"punsubscribe", "punsubscribe",
"debug", # Commands to which we decided not write a reply schema
"pfdebug", "pfdebug",
"lolwut", "lolwut",
] # TODO: write a reply schema for the following commands
"sentinel|debug",
"sentinel|info-cache",
"sentinel|pending-scripts",
"sentinel|reset",
"sentinel|simulate-failure",
"sentinel|help",
"sentinel|masters",
"sentinel|myid",
"sentinel|sentinels",
"sentinel|slaves",
}
class Request(object): class Request(object):
""" """
...@@ -216,6 +228,9 @@ def process_file(docs, path): ...@@ -216,6 +228,9 @@ def process_file(docs, path):
if res.error or res.queued: if res.error or res.queued:
continue continue
if req.command in IGNORED_COMMANDS:
continue
try: try:
jsonschema.validate(instance=res.json, schema=req.schema, cls=schema_validator) jsonschema.validate(instance=res.json, schema=req.schema, cls=schema_validator)
except (jsonschema.ValidationError, jsonschema.exceptions.SchemaError) as err: except (jsonschema.ValidationError, jsonschema.exceptions.SchemaError) as err:
...@@ -286,16 +301,6 @@ if __name__ == '__main__': ...@@ -286,16 +301,6 @@ if __name__ == '__main__':
fetch_schemas(args.cli, args.port, redis_args, docs) fetch_schemas(args.cli, args.port, redis_args, docs)
missing_schema = [k for k, v in docs.items()
if "reply_schema" not in v and k not in IGNORED_COMMANDS]
if missing_schema:
print("WARNING! The following commands are missing a reply_schema:")
for k in sorted(missing_schema):
print(f" {k}")
if args.fail_missing_reply_schemas:
print("ERROR! at least one command does not have a reply_schema")
sys.exit(1)
# Fetch schemas from a sentinel # Fetch schemas from a sentinel
print('Starting Redis sentinel') print('Starting Redis sentinel')
...@@ -307,6 +312,16 @@ if __name__ == '__main__': ...@@ -307,6 +312,16 @@ if __name__ == '__main__':
fetch_schemas(args.cli, args.port, sentinel_args, docs) fetch_schemas(args.cli, args.port, sentinel_args, docs)
os.unlink(config_file) os.unlink(config_file)
missing_schema = [k for k, v in docs.items()
if "reply_schema" not in v and k not in IGNORED_COMMANDS]
if missing_schema:
print("WARNING! The following commands are missing a reply_schema:")
for k in sorted(missing_schema):
print(f" {k}")
if args.fail_missing_reply_schemas:
print("ERROR! at least one command does not have a reply_schema")
sys.exit(1)
start = time.time() start = time.time()
# Obtain all the files to processes # Obtain all the files to processes
......
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