This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks-controller.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 3bdddb5  Build the kvrocks container to allow running multiple 
intances (#305)
3bdddb5 is described below

commit 3bdddb543c076b197f959a3e6dbcea11d161dca7
Author: hulk <[email protected]>
AuthorDate: Wed May 7 11:33:38 2025 +0800

    Build the kvrocks container to allow running multiple intances (#305)
    
    Currently, we use separate Docker containers for two test Kvrocks
    containers, and they cannot migrate data of slots due to they are not
    sharing the network. This PR builds two instances in one container so
    that we can test the migrate data function.
---
 scripts/docker/docker-compose.yml | 26 +++-----------------------
 scripts/docker/kvrocks/Dockerfile | 12 ++++++++++++
 server/api/cluster_test.go        |  4 ++--
 3 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/scripts/docker/docker-compose.yml 
b/scripts/docker/docker-compose.yml
index 587aa5d..4e67615 100644
--- a/scripts/docker/docker-compose.yml
+++ b/scripts/docker/docker-compose.yml
@@ -20,32 +20,12 @@ version: "3.7"
 
 services:
   kvrocks0:
-    image: "apache/kvrocks:nightly"
-    container_name: kvrocks0
+    build: ./kvrocks
+    container_name: kvrocks-cluster
     ports:
       - "7770:7770"
-    entrypoint:
-     - kvrocks
-     - "--bind"
-     - "0.0.0.0"
-     - "--port"
-     - "7770"
-     - "--cluster-enabled"
-     - "yes"
-
-  kvrocks1:
-    image: "apache/kvrocks:nightly"
-    container_name: kvrocks1
-    ports:
       - "7771:7771"
-    entrypoint:
-      - kvrocks
-      - "--bind"
-      - "0.0.0.0"
-      - "--port"
-      - "7771"
-      - "--cluster-enabled"
-      - "yes"
+
 
   etcd0:
     image: "quay.io/coreos/etcd:v3.5.17"
diff --git a/scripts/docker/kvrocks/Dockerfile 
b/scripts/docker/kvrocks/Dockerfile
new file mode 100644
index 0000000..b3fef97
--- /dev/null
+++ b/scripts/docker/kvrocks/Dockerfile
@@ -0,0 +1,12 @@
+FROM apache/kvrocks:latest
+USER root
+RUN mkdir /tmp/kvrocks7770 /tmp/kvrocks7771
+
+RUN echo "kvrocks -c /var/lib/kvrocks/kvrocks.conf --port 7770 --dir 
/tmp/kvrocks7770 --daemonize yes --cluster-enabled yes --bind 0.0.0.0" >> 
start.sh
+RUN echo "kvrocks -c /var/lib/kvrocks/kvrocks.conf --port 7771 --dir 
/tmp/kvrocks7771 --cluster-enabled yes --bind 0.0.0.0" >> start.sh
+RUN chmod +x start.sh
+
+EXPOSE 7770:7770
+EXPOSE 7771:7771
+
+ENTRYPOINT ["sh","start.sh"]
diff --git a/server/api/cluster_test.go b/server/api/cluster_test.go
index b1f1761..30d781f 100644
--- a/server/api/cluster_test.go
+++ b/server/api/cluster_test.go
@@ -234,7 +234,7 @@ func TestClusterMigrateData(t *testing.T) {
        reqCtx := GetTestContext(recorder)
        reqCtx.Set(consts.ContextKeyStore, handler.s)
        reqCtx.Params = []gin.Param{{Key: "namespace", Value: ns}, {Key: 
"cluster", Value: clusterName}}
-       slotRange, err := store.NewSlotRange(0, 0)
+       slotRange, err := store.NewSlotRange(10, 10)
        require.NoError(t, err)
        testMigrateReq := &MigrateSlotRequest{
                Slot:   *slotRange,
@@ -251,7 +251,7 @@ func TestClusterMigrateData(t *testing.T) {
        require.NoError(t, err)
        require.EqualValues(t, 1, gotCluster.Version.Load())
        require.Len(t, gotCluster.Shards[0].SlotRanges, 1)
-       require.EqualValues(t, &store.SlotRange{Start: 0, Stop: 0}, 
gotCluster.Shards[0].MigratingSlot)
+       require.EqualValues(t, &store.SlotRange{Start: 10, Stop: 10}, 
gotCluster.Shards[0].MigratingSlot)
        require.EqualValues(t, 1, gotCluster.Shards[0].TargetShardIndex)
 
        ctrl, err := controller.New(handler.s.(*store.ClusterStore), 
&config.ControllerConfig{

Reply via email to