Skip to content

Commit d91d363

Browse files
authored
test: add redis-cluster-proxy to benchmarks (#154)
1 parent 235213f commit d91d363

File tree

6 files changed

+107
-26
lines changed

6 files changed

+107
-26
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Redis Cluster Proxy
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
paths:
8+
- test/proxy/redis-cluster-proxy/**
9+
defaults:
10+
run:
11+
shell: bash
12+
jobs:
13+
container-image:
14+
name: Container Image
15+
timeout-minutes: 15
16+
runs-on: ubuntu-latest
17+
env:
18+
IMAGE_NAME: redis-cluster-proxy
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v3
22+
23+
- name: Build image
24+
run: docker build ./test/proxy/redis-cluster-proxy --file Dockerfile --tag $IMAGE_NAME
25+
26+
- name: Log into GitHub Container Registry
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
28+
29+
- name: Push image to GitHub Container Registry
30+
run: |
31+
IMAGE_ID=$(echo "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME" | tr '[A-Z]' '[a-z]')
32+
VERSION=latest
33+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
34+
docker push $IMAGE_ID:$VERSION

compose.latency.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ services:
101101
condition: service_healthy
102102
node9:
103103
condition: service_healthy
104-
proxy:
104+
envoy:
105105
image: envoyproxy/envoy:v1.23.1
106106
restart: "${RESTART_POLICY:-always}"
107107
ports:
@@ -112,3 +112,15 @@ services:
112112
depends_on:
113113
clustering:
114114
condition: service_completed_successfully
115+
# redis-cluster-proxy:
116+
# image: ghcr.io/redis-rb/redis-cluster-proxy:latest
117+
# restart: "${RESTART_POLICY:-always}"
118+
# command:
119+
# - "--bind"
120+
# - "0.0.0.0"
121+
# - "node1:6379"
122+
# ports:
123+
# - "7001:7777"
124+
# depends_on:
125+
# clustering:
126+
# condition: service_completed_successfully

test/bench_command.rb

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,7 @@ def new_test_client
6666

6767
class Envoy < BenchmarkWrapper
6868
include BenchmarkMixin
69-
70-
def setup
71-
@client = new_test_client
72-
@cluster_client = new_cluster_client
73-
@cluster_client.call('FLUSHDB')
74-
wait_for_replication
75-
end
76-
77-
def teardown
78-
@cluster_client.call('FLUSHDB')
79-
wait_for_replication
80-
@cluster_client&.close
81-
@client&.close
82-
end
69+
include BenchmarkMixinForProxy
8370

8471
# https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_protocols/redis#supported-commands
8572
def bench_echo
@@ -93,17 +80,18 @@ def bench_pipeline_echo
9380
private
9481

9582
def new_test_client
96-
::RedisClient.config(**TEST_GENERIC_OPTIONS.merge(BENCH_PROXY_OPTIONS)).new_client
83+
::RedisClient.config(**TEST_GENERIC_OPTIONS.merge(BENCH_ENVOY_OPTIONS)).new_client
9784
end
85+
end
9886

99-
def new_cluster_client
100-
::RedisClient.cluster(nodes: TEST_NODE_URIS, fixed_hostname: TEST_FIXED_HOSTNAME, **TEST_GENERIC_OPTIONS).new_client
101-
end
87+
# class RedisClusterProxy < BenchmarkWrapper
88+
# include BenchmarkMixin
89+
# include BenchmarkMixinForProxy
10290

103-
def wait_for_replication
104-
client_side_timeout = TEST_TIMEOUT_SEC + 1.0
105-
server_side_timeout = (TEST_TIMEOUT_SEC * 1000).to_i
106-
@cluster_client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
107-
end
108-
end
91+
# private
92+
93+
# def new_test_client
94+
# ::RedisClient.config(**TEST_GENERIC_OPTIONS.merge(BENCH_REDIS_CLUSTER_PROXY_OPTIONS)).new_client
95+
# end
96+
# end
10997
end

test/benchmark_mixin.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,31 @@ def wait_for_replication
7777
@client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
7878
end
7979
end
80+
81+
module BenchmarkMixinForProxy
82+
def setup
83+
@client = new_test_client
84+
@cluster_client = new_cluster_client
85+
@cluster_client.call('FLUSHDB')
86+
wait_for_replication
87+
end
88+
89+
def teardown
90+
@cluster_client.call('FLUSHDB')
91+
wait_for_replication
92+
@cluster_client&.close
93+
@client&.close
94+
end
95+
96+
private
97+
98+
def new_cluster_client
99+
::RedisClient.cluster(nodes: TEST_NODE_URIS, fixed_hostname: TEST_FIXED_HOSTNAME, **TEST_GENERIC_OPTIONS).new_client
100+
end
101+
102+
def wait_for_replication
103+
client_side_timeout = TEST_TIMEOUT_SEC + 1.0
104+
server_side_timeout = (TEST_TIMEOUT_SEC * 1000).to_i
105+
@cluster_client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
106+
end
107+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://hub.docker.com/_/debian
2+
FROM debian:11 as builder
3+
4+
RUN apt-get update
5+
RUN apt-get install -y --no-install-recommends build-essential wget unzip ca-certificates
6+
7+
# https://github.com/RedisLabs/redis-cluster-proxy
8+
ARG TAG=1.0-beta2
9+
WORKDIR /tmp
10+
RUN wget -O redis-cluster-proxy.zip "https://github.com/RedisLabs/redis-cluster-proxy/archive/refs/tags/${TAG}.zip"
11+
RUN unzip redis-cluster-proxy.zip
12+
WORKDIR /tmp/redis-cluster-proxy-${TAG}
13+
RUN make install REDIS_CLUSTER_PROXY_LDFLAGS=-zmuldefs
14+
15+
# https://github.com/GoogleContainerTools/distroless
16+
FROM gcr.io/distroless/cc-debian11:debug
17+
COPY --from=builder /usr/local/bin/redis-cluster-proxy /usr/local/bin/redis-cluster-proxy
18+
ENTRYPOINT ["/usr/local/bin/redis-cluster-proxy"]

test/testing_constants.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
TEST_REDIS_MAJOR_VERSION = Integer(TEST_REDIS_VERSION.split('.').first)
6464
_tmp_cli.close
6565

66-
BENCH_PROXY_OPTIONS = { port: 7000, protocol: 2 }.freeze
66+
BENCH_ENVOY_OPTIONS = { port: 7000, protocol: 2 }.freeze
67+
BENCH_REDIS_CLUSTER_PROXY_OPTIONS = { port: 7001, protocol: 2 }.freeze
6768

6869
# rubocop:enable Lint/UnderscorePrefixedVariableName

0 commit comments

Comments
 (0)