mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
refactor(tests): Refactor pytest (#449)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
parent
fabad45d42
commit
072cb2e8d9
17 changed files with 229 additions and 156 deletions
51
tests/integration/generate_sets.py
Executable file
51
tests/integration/generate_sets.py
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import random
|
||||
import string
|
||||
import redis as rclient
|
||||
import uuid
|
||||
import time
|
||||
|
||||
|
||||
def fill_set(args, redis: rclient.Redis):
|
||||
for j in range(args.num):
|
||||
token = uuid.uuid1().hex
|
||||
# print(token)
|
||||
key = f'USER_OTP:{token}'
|
||||
arr = []
|
||||
for i in range(30):
|
||||
otp = ''.join(random.choices(
|
||||
string.ascii_uppercase + string.digits, k=12))
|
||||
arr.append(otp)
|
||||
redis.execute_command('sadd', key, *arr)
|
||||
|
||||
def fill_hset(args, redis):
|
||||
for j in range(args.num):
|
||||
token = uuid.uuid1().hex
|
||||
key = f'USER_INFO:{token}'
|
||||
phone = f'555-999-{j}'
|
||||
user_id = 'user' * 5 + f'-{j}'
|
||||
redis.hset(key, 'phone', phone)
|
||||
redis.hset(key, 'user_id', user_id)
|
||||
redis.hset(key, 'login_time', time.time())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='fill hset entities')
|
||||
parser.add_argument(
|
||||
'-p', type=int, help='redis port', dest='port', default=6380)
|
||||
parser.add_argument(
|
||||
'-n', type=int, help='number of keys', dest='num', default=10000)
|
||||
parser.add_argument(
|
||||
'--type', type=str, choices=['hset', 'set'], help='set type', default='hset')
|
||||
|
||||
args = parser.parse_args()
|
||||
redis = rclient.Redis(host='localhost', port=args.port, db=0)
|
||||
if args.type == 'hset':
|
||||
fill_hset(args, redis)
|
||||
elif args.type == 'set':
|
||||
fill_set(args, redis)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue