Add COMMAND COUNT test to cover reply-schemas-validator test (#11971)

Since we remove the COMMAND COUNT call in sentinel test in #11950,
reply-schemas-validator started reporting this error:
```
WARNING! The following commands were not hit at all:
  command|count
  ERROR! at least one command was not hit by the tests
```

This PR add a COMMAND COUNT test to cover it and also fix some
typos in req-res-log-validator.py
This commit is contained in:
Binbin 2023-03-26 13:39:04 +08:00 committed by GitHub
parent 9e15b42fda
commit 2cc99c692c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -118,6 +118,10 @@ start_server {tags {"introspection"}} {
assert_match {*calls=1,*} [cmdstat geoadd] assert_match {*calls=1,*} [cmdstat geoadd]
} {} {needs:config-resetstat} } {} {needs:config-resetstat}
test {COMMAND COUNT get total number of Redis commands} {
assert_morethan [r command count] 0
}
test {COMMAND GETKEYS GET} { test {COMMAND GETKEYS GET} {
assert_equal {key} [r command getkeys get key] assert_equal {key} [r command getkeys get key]
} }

View File

@ -12,7 +12,6 @@ import argparse
import multiprocessing import multiprocessing
import collections import collections
import io import io
import signal
import traceback import traceback
from datetime import timedelta from datetime import timedelta
from functools import partial from functools import partial
@ -169,7 +168,7 @@ class Response(object):
value = Response(f, line_counter) value = Response(f, line_counter)
self.json[field] = value.json self.json[field] = value.json
if line[0] == '|': if line[0] == '|':
# We don't care abou the attributes, read the real response # We don't care about the attributes, read the real response
real_res = Response(f, line_counter) real_res = Response(f, line_counter)
self.__dict__.update(real_res.__dict__) self.__dict__.update(real_res.__dict__)
@ -180,7 +179,7 @@ class Response(object):
def process_file(docs, path): def process_file(docs, path):
""" """
This function processes a single filegenerated by logreqres.c This function processes a single file generated by logreqres.c
""" """
line_counter = [0] # A list with one integer: to force python to pass it by reference line_counter = [0] # A list with one integer: to force python to pass it by reference
command_counter = dict() command_counter = dict()
@ -190,7 +189,7 @@ def process_file(docs, path):
# Convert file to StringIO in order to minimize IO operations # Convert file to StringIO in order to minimize IO operations
with open(path, "r", newline="\r\n", encoding="latin-1") as f: with open(path, "r", newline="\r\n", encoding="latin-1") as f:
content = f.read() content = f.read()
with io.StringIO(content) as fakefile: with io.StringIO(content) as fakefile:
while True: while True:
try: try:
@ -244,7 +243,7 @@ def fetch_schemas(cli, port, args, docs):
break break
except Exception as e: except Exception as e:
time.sleep(0.1) time.sleep(0.1)
pass
print('Connected') print('Connected')
cli_proc = subprocess.Popen([cli, '-p', str(port), '--json', 'command', 'docs'], stdout=subprocess.PIPE) cli_proc = subprocess.Popen([cli, '-p', str(port), '--json', 'command', 'docs'], stdout=subprocess.PIPE)
@ -310,7 +309,7 @@ if __name__ == '__main__':
start = time.time() start = time.time()
# Obtain all the files toprocesses # Obtain all the files to processes
paths = [] paths = []
for path in glob.glob('%s/tmp/*/*.reqres' % testdir): for path in glob.glob('%s/tmp/*/*.reqres' % testdir):
paths.append(path) paths.append(path)