Skip to content

Commit

Permalink
fix object property and add parameter to set key count
Browse files Browse the repository at this point in the history
Signed-off-by: girorme <[email protected]>
  • Loading branch information
girorme committed May 18, 2023
1 parent 1d238c7 commit f132b61
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.7-slim-stretch
RUN apt-get -y update && apt-get -y install build-essential
RUN apt-get -y install gettext-base
RUN apt-get -y install gettext-base redis-tools
RUN mkdir /redis-load-test
COPY ./Scripts /redis-load-test/Scripts
WORKDIR /redis-load-test/Scripts
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ The use of this utility is not a fancy thing, just need to update the **[redis.j
{
"redis_host": "18.215.118.208",
"redis_port": "6379",
"redis_password": ""
"redis_password": "",
"redis_key_count": "500"
}
```

Expand Down
12 changes: 6 additions & 6 deletions Scripts/redis_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def query(self, key, command='GET'):
result = ''
except Exception as e:
total_time = int((time.time() - start_time) * 1000)
events.request_failure.fire(
events.request.fire(
request_type=command, name=key, response_time=total_time, exception=e)
else:
total_time = int((time.time() - start_time) * 1000)
length = len(result)
events.request_success.fire(
events.request.fire(
request_type=command, name=key, response_time=total_time, response_length=length)
return result

Expand All @@ -56,24 +56,24 @@ def write(self, key, value, command='SET'):
result = None
start_time = time.time()
try:
result = self.rc.set(key, value)
result = self.rc.setex(key, 60 * 5, value)
if not result:
result = ''
except Exception as e:
total_time = int((time.time() - start_time) * 1000)
events.request_failure.fire(
events.request.fire(
request_type=command, name=key, response_time=total_time, exception=e)
else:
total_time = int((time.time() - start_time) * 1000)
length = 1
events.request_success.fire(
events.request.fire(
request_type=command, name=key, response_time=total_time, response_length=length)
return result


class RedisLocust(User):
wait_time = constant(0.1)
key_range = 500
key_range = int(configs["redis_key_count"])

def __init__(self, *args, **kwargs):
super(RedisLocust, self).__init__(*args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion Scripts/redis_orig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"redis_host": "$REDIS_HOST",
"redis_port": "$REDIS_PORT",
"redis_password": "$REDIS_PW"
"redis_password": "$REDIS_PW",
"redis_key_count": "$REDIS_KEYS"
}

0 comments on commit f132b61

Please sign in to comment.