diff --git a/Dockerfile b/Dockerfile index b4996c7..ee47c58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Scripts/redis_get_set.py b/Scripts/redis_get_set.py index 7f09ad6..1aacb79 100755 --- a/Scripts/redis_get_set.py +++ b/Scripts/redis_get_set.py @@ -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 @@ -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) diff --git a/Scripts/redis_orig.json b/Scripts/redis_orig.json index 887ffec..bbdde25 100644 --- a/Scripts/redis_orig.json +++ b/Scripts/redis_orig.json @@ -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" }