You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2020/12/31 06:59:23 UTC

[dubbo-samples] branch master updated: Improve test image build (#201)

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

liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new 9aed44f  Improve test image build (#201)
9aed44f is described below

commit 9aed44f833143cfb0d362a7e95eefcd508f8e682
Author: gongdewei <ky...@qq.com>
AuthorDate: Thu Dec 31 14:59:14 2020 +0800

    Improve test image build (#201)
---
 .github/workflows/java-ci.yml                | 62 ++++++++++------------------
 test/build-samples-and-test-image.sh         | 42 +++++++++++++++++++
 test/dubbo-test-runner/build.sh              |  2 +-
 test/dubbo-test-runner/src/docker/Dockerfile | 57 +++++++++++--------------
 4 files changed, 87 insertions(+), 76 deletions(-)

diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml
index ac9382a..122dc6f 100644
--- a/.github/workflows/java-ci.yml
+++ b/.github/workflows/java-ci.yml
@@ -12,7 +12,7 @@ env:
   FORK_COUNT: 2
   FAIL_FAST: 0
   SHOW_ERROR_DETAIL: 1
-  BUILD_OPTS: -U --batch-mode --no-transfer-progress --settings .mvn/settings.xml clean package dependency:copy-dependencies -DskipTests
+  BUILD_OPTS: -U --no-transfer-progress --settings .mvn/settings.xml clean package dependency:copy-dependencies -DskipTests
 
 jobs:
   build:
@@ -84,16 +84,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -125,16 +123,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -166,16 +162,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -207,16 +201,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -248,16 +240,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -289,16 +279,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -330,16 +318,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -371,16 +357,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -412,16 +396,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
@@ -453,16 +435,14 @@ jobs:
         uses: actions/setup-java@v1
         with:
           java-version: 1.8
-      - name: Build with Maven
+      - name: Build dubbo-samples and test image
         run: |
-          ./mvnw $BUILD_OPTS
+          cd test && bash ./build-samples-and-test-image.sh
       - name: Download test list
         uses: actions/download-artifact@v2
         with:
           name: test-list
           path: test/jobs/
-      - name: Build test image
-        run: cd test && bash ./build-test-image.sh
       - name: Run tests
         run: cd test && BUILD=n bash ./run-tests.sh
       - name: Clean images
diff --git a/test/build-samples-and-test-image.sh b/test/build-samples-and-test-image.sh
new file mode 100755
index 0000000..0fc81ee
--- /dev/null
+++ b/test/build-samples-and-test-image.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+test_image_log=$DIR/test-image.log
+samples_log=$DIR/samples.log
+
+export DIR=$DIR
+export test_image_log=$test_image_log
+export samples_log=$samples_log
+
+cd $DIR
+echo "Build test image .."
+bash ./build-test-image.sh &> $test_image_log &
+build_image_pid=$!
+
+echo "Build samples .."
+BUILD_OPTS="-U --batch-mode --no-transfer-progress --settings .mvn/settings.xml"
+BUILD_OPTS="$BUILD_OPTS clean package dependency:copy-dependencies -DskipTests"
+cd $DIR/..
+./mvnw $BUILD_OPTS &> $samples_log &
+build_samples_pid=$!
+
+echo "-------------------------------------------------------------------"
+echo "Waiting test image building: $build_image_pid .."
+tail -n 1000 -f $test_image_log &
+wait $build_image_pid
+result=$?
+if [ $result -ne 0 ];then
+  echo "Build test image failed"
+  exit $result
+fi
+
+echo ""
+echo "-------------------------------------------------------------------"
+echo "Waiting samples building: $build_samples_pid .."
+tail -n 500 -f $samples_log &
+wait $build_samples_pid
+result=$?
+if [ $result -ne 0 ];then
+  echo "Build dubbo-samples with maven failed"
+  exit $result
+fi
diff --git a/test/dubbo-test-runner/build.sh b/test/dubbo-test-runner/build.sh
index b1b31fb..a1ed26e 100755
--- a/test/dubbo-test-runner/build.sh
+++ b/test/dubbo-test-runner/build.sh
@@ -15,7 +15,7 @@ fi
 
 mkdir -p $DOCKER_DIR
 cp -r $DIR/src/docker/* $DOCKER_DIR/
-cp $DIR/target/dubbo-test-runner-*-jar-with-dependencies.jar $DOCKER_DIR/
+cp $DIR/target/dubbo-test-runner-*-jar-with-dependencies.jar $DOCKER_DIR/dubbo-test-runner.jar
 
 cd $DOCKER_DIR
 docker build -t dubbo/sample-test . --build-arg DEBIAN_MIRROR=$DEBIAN_MIRROR
diff --git a/test/dubbo-test-runner/src/docker/Dockerfile b/test/dubbo-test-runner/src/docker/Dockerfile
index eb1b4f9..3bd2988 100644
--- a/test/dubbo-test-runner/src/docker/Dockerfile
+++ b/test/dubbo-test-runner/src/docker/Dockerfile
@@ -25,40 +25,29 @@ RUN apt-get update && \
   apt-get install -y telnet && \
   rm -rf /var/lib/apt/lists/*
 
-VOLUME /usr/local/dubbo/app
-VOLUME /usr/local/dubbo/logs
-
-# Jvm flags
-ENV JAVA_OPTS=""
-ENV DEBUG_OPTS=""
-
-# service name
-ENV SERVICE_NAME=""
-
-# classpath
-# assert mounting $project_dir/target:/usr/local/dubbo/app/
-ENV TEST_CLASSES_DIR="/usr/local/dubbo/app/test-classes"
-ENV APP_CLASSES_DIR="/usr/local/dubbo/app/classes"
-ENV APP_DEPENDENCY_DIR="/usr/local/dubbo/app/dependency"
-
-# check ports/log timeout
-ENV CHECK_TIMEOUT=60
-
-# service type: app, test
-ENV SERVICE_TYPE="app"
-ENV WAIT_PORTS_BEFORE_RUN=""
-
-# dubbo provider bootstrap class
-ENV APP_MAIN_CLASS=""
-ENV CHECK_PORTS_AFTER_RUN=""
-ENV CHECK_LOG=""
-
-# test envs
-ENV TEST_PATTERNS="**/*IT.class"
-
-
-ADD *.sh /usr/local/dubbo/
-ADD dubbo-test-runner-*-jar-with-dependencies.jar /usr/local/dubbo/dubbo-test-runner.jar
+VOLUME /usr/local/dubbo/app /usr/local/dubbo/logs
+
+# JAVA_OPTS/DEBUG_OPTS: Jvm flags
+# SERVICE_TYPE: app, test
+# CHECK_TIMEOUT: check ports/log timeout
+# TEST_PATTERNS: test class pattern
+# classpath: assert mounting $project_dir/target:/usr/local/dubbo/app/
+ENV JAVA_OPTS="" \
+    DEBUG_OPTS="" \
+    TEST_CLASSES_DIR="/usr/local/dubbo/app/test-classes" \
+    APP_CLASSES_DIR="/usr/local/dubbo/app/classes" \
+    APP_DEPENDENCY_DIR="/usr/local/dubbo/app/dependency" \
+    CHECK_TIMEOUT=60 \
+    SERVICE_NAME="" \
+    SERVICE_TYPE="app" \
+    WAIT_PORTS_BEFORE_RUN="" \
+    APP_MAIN_CLASS="" \
+    CHECK_PORTS_AFTER_RUN="" \
+    CHECK_LOG="" \
+    TEST_PATTERNS="**/*IT.class"
+
+
+ADD dubbo-test-runner.jar *.sh /usr/local/dubbo/
 
 WORKDIR /usr/local/dubbo/
 #ENTRYPOINT exec java $JAVA_OPTS -jar dubbo-test-runner.jar $TEST_CLASSES_DIR $APP_CLASSES_DIR $APP_DEPENDENCY_DIR


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org