Просмотр исходного кода

chore(CI): cts support redis sentinel

zhanghongtong 4 лет назад
Родитель
Сommit
355b42c623

+ 1 - 1
.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml

@@ -1,7 +1,7 @@
 version: '3.9'
 version: '3.9'
 
 
 services:
 services:
-  redis_cluster:
+  redis_server:
     image: redis:${REDIS_TAG}
     image: redis:${REDIS_TAG}
     container_name: redis
     container_name: redis
     volumes:
     volumes:

+ 1 - 1
.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml

@@ -1,7 +1,7 @@
 version: '3.9'
 version: '3.9'
 
 
 services:
 services:
-  redis_cluster:
+  redis_server:
     container_name: redis
     container_name: redis
     image: redis:${REDIS_TAG}
     image: redis:${REDIS_TAG}
     volumes:
     volumes:

+ 1 - 1
.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml

@@ -1,7 +1,7 @@
 version: '3.9'
 version: '3.9'
 
 
 services:
 services:
-  redis_cluster:
+  redis_server:
     container_name: redis
     container_name: redis
     image: redis:${REDIS_TAG}
     image: redis:${REDIS_TAG}
     volumes:
     volumes:

+ 1 - 0
.ci/docker-compose-file/redis/redis-tls.conf

@@ -5,3 +5,4 @@ tls-cert-file /tls/redis.crt
 tls-key-file /tls/redis.key
 tls-key-file /tls/redis.key
 tls-ca-cert-file /tls/ca.crt
 tls-ca-cert-file /tls/ca.crt
 requirepass public
 requirepass public
+masterauth public

+ 1 - 0
.ci/docker-compose-file/redis/redis.conf

@@ -2,3 +2,4 @@ daemonize yes
 bind 0.0.0.0 ::
 bind 0.0.0.0 ::
 logfile /var/log/redis-server.log
 logfile /var/log/redis-server.log
 requirepass public
 requirepass public
+masterauth public

+ 11 - 4
.ci/docker-compose-file/redis/redis.sh

@@ -61,19 +61,19 @@ REDIS_LOAD_FLG=true;
 while $REDIS_LOAD_FLG;
 while $REDIS_LOAD_FLG;
 do
 do
     sleep 1;
     sleep 1;
-    redis-cli -p 7000 info 1> /data/conf/r7000i.log 2> /dev/null;
+    redis-cli --pass public --no-auth-warning -p 7000 info 1> /data/conf/r7000i.log 2> /dev/null;
     if [ -s /data/conf/r7000i.log ]; then
     if [ -s /data/conf/r7000i.log ]; then
         :
         :
     else
     else
         continue;
         continue;
     fi
     fi
-    redis-cli -p 7001 info 1> /data/conf/r7001i.log 2> /dev/null;
+    redis-cli --pass public --no-auth-warning -p 7001 info 1> /data/conf/r7001i.log 2> /dev/null;
     if [ -s /data/conf/r7001i.log ]; then
     if [ -s /data/conf/r7001i.log ]; then
         :
         :
     else
     else
         continue;
         continue;
     fi
     fi
-    redis-cli -p 7002 info 1> /data/conf/r7002i.log 2> /dev/null;
+    redis-cli --pass public --no-auth-warning -p 7002 info 1> /data/conf/r7002i.log 2> /dev/null;
     if [ -s /data/conf/r7002i.log ]; then
     if [ -s /data/conf/r7002i.log ]; then
         :
         :
     else
     else
@@ -82,7 +82,14 @@ do
     if [ "${node}" = "cluster" ] ; then
     if [ "${node}" = "cluster" ] ; then
       yes "yes" | redis-cli --cluster create "$LOCAL_IP:7000" "$LOCAL_IP:7001" "$LOCAL_IP:7002" --pass public --no-auth-warning;
       yes "yes" | redis-cli --cluster create "$LOCAL_IP:7000" "$LOCAL_IP:7001" "$LOCAL_IP:7002" --pass public --no-auth-warning;
     elif [ "${node}" = "sentinel" ] ; then
     elif [ "${node}" = "sentinel" ] ; then
-      cp /data/conf/sentinel.conf /_sentinel.conf
+      tee /_sentinel.conf>/dev/null << EOF
+port 26379
+bind 0.0.0.0 ::
+daemonize yes
+logfile /var/log/redis-server.log
+dir /tmp
+sentinel monitor mymaster $LOCAL_IP 7000 1
+EOF
       redis-server /_sentinel.conf --sentinel;
       redis-server /_sentinel.conf --sentinel;
     fi
     fi
     REDIS_LOAD_FLG=false;
     REDIS_LOAD_FLG=false;

+ 0 - 4
.ci/docker-compose-file/redis/sentinel.conf

@@ -1,4 +0,0 @@
-port 26379
-dir /tmp
-sentinel monitor mymaster 172.16.239.10 7000 1
-logfile /var/log/redis-server.log

+ 12 - 0
.github/workflows/run_cts_tests.yaml

@@ -301,10 +301,13 @@ jobs:
         - tcp
         - tcp
         node_type:
         node_type:
         - single
         - single
+        - sentinel
         - cluster
         - cluster
         exclude:
         exclude:
         - redis_tag: 5
         - redis_tag: 5
           connect_type: tls
           connect_type: tls
+        - node_type: sentinel
+          connect_type: tls
 
 
     steps:
     steps:
       - uses: actions/checkout@v1
       - uses: actions/checkout@v1
@@ -355,6 +358,15 @@ jobs:
           EMQX_AUTH__REDIS__TYPE=single
           EMQX_AUTH__REDIS__TYPE=single
           EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6380
           EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6380
           EOF
           EOF
+      - name: setup
+        if: matrix.node_type == 'sentinel'
+        run: |
+          cat <<-EOF >> "$GITHUB_ENV"
+          EMQX_AUTH__REDIS__TYPE=sentinel
+          EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:26379
+          EMQX_AUTH__REDIS__SENTINEL=mymaster
+          EMQX_AUTH__REDIS__POOL=1
+          EOF
       - name: setup
       - name: setup
         if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp'
         if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp'
         run: |
         run: |