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

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new f450576  [fix] modify ci to use mongo replica set (#1188)
f450576 is described below

commit f4505760f46c65be3c73608d50497b4ed2d3c85c
Author: robotljw <[email protected]>
AuthorDate: Tue Dec 28 21:25:51 2021 +0800

    [fix] modify ci to use mongo replica set (#1188)
---
 .github/workflows/eventbase-ci.yml | 10 +++-------
 .github/workflows/static_check.yml |  2 ++
 scripts/docker-compose.yaml        | 28 ++++++++++++++++++++++++++++
 scripts/ut_test_in_docker.sh       |  2 --
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/eventbase-ci.yml 
b/.github/workflows/eventbase-ci.yml
index a2a0f57..84e474d 100644
--- a/.github/workflows/eventbase-ci.yml
+++ b/.github/workflows/eventbase-ci.yml
@@ -9,16 +9,12 @@ jobs:
         with:
           go-version: 1.16
         id: go
-      - name: Start MongoDB
-        uses: supercharge/[email protected]
-        with:
-          mongodb-version: 4.2
-          mongodb-replica-set: test-rs
-          mongodb-port: 27017
       - name: Check out source code
         uses: actions/checkout@v1
       - name: UT test
         run: |
+          sudo docker-compose -f ./scripts/docker-compose.yaml up -d
+          sleep 20
           export TEST_DB_MODE=mongo
           export TEST_DB_URI=mongodb://127.0.0.1:27017
           cd eventbase
@@ -31,7 +27,7 @@ jobs:
         with:
           go-version: 1.16
         id: go
-      - name: Check out code into the Go module directory
+      - name: Check out source code
         uses: actions/checkout@v1
       - name: UT for etcd
         run: |
diff --git a/.github/workflows/static_check.yml 
b/.github/workflows/static_check.yml
index 7155654..b012651 100644
--- a/.github/workflows/static_check.yml
+++ b/.github/workflows/static_check.yml
@@ -40,6 +40,8 @@ jobs:
         uses: actions/checkout@v1
       - name: UT-MONGO
         run: |
+          sudo docker-compose -f ./scripts/docker-compose.yaml up -d
+          sleep 20
           bash -x scripts/ut_test_in_docker.sh mongo
   integration-test:
     runs-on: ubuntu-latest
diff --git a/scripts/docker-compose.yaml b/scripts/docker-compose.yaml
new file mode 100644
index 0000000..115d08e
--- /dev/null
+++ b/scripts/docker-compose.yaml
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+version: '3.3'
+services:
+  mongo:
+    image: mongo:4.2
+    command: mongod --replSet my-replica-set --port 27017 --bind_ip_all
+    ports:
+      - 27017:27017
+    environment:
+      MONGO_INITDB_DATABASE: servicecomb
+    healthcheck:
+      test: test $$(echo 
"rs.initiate({_id:'my-replica-set',members:[{_id:0,host:\"127.0.0.1:27017\"}]}).ok
 || rs.status().ok" | mongo --port 27017 --quiet) -eq 1
+      interval: 10s
\ No newline at end of file
diff --git a/scripts/ut_test_in_docker.sh b/scripts/ut_test_in_docker.sh
index 2337cb9..6ecaa0f 100644
--- a/scripts/ut_test_in_docker.sh
+++ b/scripts/ut_test_in_docker.sh
@@ -44,8 +44,6 @@ if [ ${db_name} == "etcd" ];then
   done
   echo "${green}Etcd is running......${reset}"
 elif [ ${db_name} == "mongo" ];then
-  echo "${green}Starting mongo in docker${reset}"
-  docker run -d -p 27017:27017 --name mongo mongo
   while ! nc -z 127.0.0.1 27017; do
     echo "Waiting mongo to launch on 27017..."
     sleep 1

Reply via email to