diff options
author | guybe7 <guy.benoish@redislabs.com> | 2023-04-20 22:28:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 23:28:44 +0300 |
commit | f809e10fd8f9e210291d05e80f6d08e3ddc01ae7 (patch) | |
tree | ed0ffbfa5b6772013e58640b7a71b8742c7899c0 | |
parent | 2f46e96d44341669df0c9872b8082fccfed148d3 (diff) | |
download | redis-f809e10fd8f9e210291d05e80f6d08e3ddc01ae7.tar.gz |
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
-rw-r--r-- | src/logreqres.c | 9 | ||||
-rwxr-xr-x | utils/req-res-log-validator.py | 43 |
2 files changed, 32 insertions, 20 deletions
diff --git a/src/logreqres.c b/src/logreqres.c index aa54b721d..6e7621d35 100644 --- a/src/logreqres.c +++ b/src/logreqres.c @@ -186,7 +186,8 @@ size_t reqresAppendRequest(client *c) { /* Ignore commands that have streaming non-standard response */ 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,"monitor") || !strcasecmp(cmd,"subscribe") || @@ -194,11 +195,7 @@ size_t reqresAppendRequest(client *c) { !strcasecmp(cmd,"ssubscribe") || !strcasecmp(cmd,"sunsubscribe") || !strcasecmp(cmd,"psubscribe") || - !strcasecmp(cmd,"punsubscribe") || - !strcasecmp(cmd,"debug") || - !strcasecmp(cmd,"pfdebug") || - !strcasecmp(cmd,"lolwut") || - (!strcasecmp(cmd,"sentinel") && argc > 1 && !strcasecmp(argv[1]->ptr,"debug"))) + !strcasecmp(cmd,"punsubscribe")) { return 0; } diff --git a/utils/req-res-log-validator.py b/utils/req-res-log-validator.py index b96e7f4dc..1f11b0307 100755 --- a/utils/req-res-log-validator.py +++ b/utils/req-res-log-validator.py @@ -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. """ -IGNORED_COMMANDS = [ +IGNORED_COMMANDS = { + # Commands that don't work in a req-res manner (see logreqres.c) + "debug", # because of DEBUG SEGFAULT "sync", "psync", "monitor", @@ -53,11 +55,21 @@ IGNORED_COMMANDS = [ "sunsubscribe", "psubscribe", "punsubscribe", - "debug", + # Commands to which we decided not write a reply schema "pfdebug", "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): """ @@ -216,6 +228,9 @@ def process_file(docs, path): if res.error or res.queued: continue + if req.command in IGNORED_COMMANDS: + continue + try: jsonschema.validate(instance=res.json, schema=req.schema, cls=schema_validator) except (jsonschema.ValidationError, jsonschema.exceptions.SchemaError) as err: @@ -286,16 +301,6 @@ if __name__ == '__main__': 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 print('Starting Redis sentinel') @@ -307,6 +312,16 @@ if __name__ == '__main__': fetch_schemas(args.cli, args.port, sentinel_args, docs) 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() # Obtain all the files to processes |