Skip to content

Commit 40f894a

Browse files
[BugFix][Change] Updated the write and read task of locust
1 parent 46dae8f commit 40f894a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Scripts/redis_get_set.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a script to Get and Set key in Redis Server for load testing.
55
This script will use locust as framework.
66
7-
Author:- OpsTree Solutions
7+
Author:- Abhishek Dubey
88
"""
99

1010
import json
@@ -47,7 +47,7 @@ def query(self, key, command='GET'):
4747
events.request_success.fire(request_type=command, name=key, response_time=total_time, response_length=length)
4848
return result
4949

50-
def write(self,key,value,command='write'):
50+
def write(self, key, value, command='SET'):
5151
"""Function to Test SET operation on Redis"""
5252
result = None
5353
start_time = time.time()
@@ -78,11 +78,16 @@ class RedisLua(RedisLocust):
7878
class task_set(TaskSet):
7979
@task(2)
8080
def get_time(self):
81-
self.client.query('key1')
81+
for i in range(100):
82+
self.key='key'+str(i)
83+
self.client.query(self.key)
8284

8385
@task(1)
8486
def write(self):
85-
self.client.write(self.key,self.value)
87+
for i in range(100):
88+
self.key='key'+str(i)
89+
self.value='value'+str(i)
90+
self.client.write(self.key,self.value)
8691

8792
@task(1)
8893
def get_key(self):

0 commit comments

Comments
 (0)