You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/05/31 15:19:08 UTC

[shardingsphere] branch master updated: Fix scaling-it (#10593)

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

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new fb81efb  Fix scaling-it (#10593)
fb81efb is described below

commit fb81efb4fd30cf553b2372826d037b906d6cb7a3
Author: avalon5666 <64...@users.noreply.github.com>
AuthorDate: Mon May 31 23:18:23 2021 +0800

    Fix scaling-it (#10593)
    
    * Fix #10590
---
 .../Dockerfile                                     | 27 ++++++++++++
 .../src/test/assembly/bin/stop.sh                  | 51 ++++++++++++++++++++++
 .../integration/scaling/test/mysql/ScalingIT.java  |  7 +--
 .../src/test/resources/env/engine-env.properties   | 27 ++++++++++++
 4 files changed, 109 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
new file mode 100644
index 0000000..8f60721
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+FROM openjdk:8-jdk-alpine
+
+ARG APP_NAME
+ENV WAIT_VERSION 2.7.2
+
+ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait
+RUN chmod +x /wait
+ADD target/${APP_NAME}.tar.gz /opt
+RUN mv /opt/${APP_NAME} /opt/shardingsphere-scaling
+ENTRYPOINT /wait && /opt/shardingsphere-scaling/bin/start.sh && tail -f /opt/shardingsphere-scaling/logs/stdout.log
diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
new file mode 100644
index 0000000..132e2f1
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 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.
+#
+
+SERVER_NAME=ShardingSphere-Scaling
+
+cd `dirname $0`
+cd ..
+DEPLOY_DIR=`pwd`
+
+PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep |awk '{print $2}'`
+if [ -z "$PIDS" ]; then
+    echo "ERROR: The $SERVER_NAME does not started!"
+    exit 1
+fi
+
+echo -e "Stopping the $SERVER_NAME ...\c"
+for PID in ${PIDS} ; do
+    kill ${PID} > /dev/null 2>&1
+done
+
+COUNT=0
+while [ ${COUNT} -lt 1 ]; do
+    echo -e ".\c"
+    sleep 1
+    COUNT=1
+    for PID in ${PIDS} ; do
+        PID_EXIST=`ps -f -p ${PID} | grep java`
+        if [ -n "$PID_EXIST" ]; then
+            COUNT=0
+            break
+        fi
+    done
+done
+
+echo "OK!"
+echo "PID: $PIDS"
diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
index 68a9e8f..e32234c 100644
--- a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
@@ -19,18 +19,19 @@ package org.apache.shardingsphere.integration.scaling.test.mysql;
 
 import groovy.lang.Tuple2;
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
 import org.apache.shardingsphere.integration.scaling.test.mysql.fixture.FixtureWriteThread;
 import org.apache.shardingsphere.integration.scaling.test.mysql.util.ExecuteUtil;
 import org.apache.shardingsphere.integration.scaling.test.mysql.util.ScalingUtil;
 import org.apache.shardingsphere.integration.scaling.test.mysql.util.TargetDataSourceUtil;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.IOException;
 
 import static org.junit.Assert.assertTrue;
 
+@Slf4j
 public final class ScalingIT {
     
     private static final long TIMEOUT_MS = 2 * 60 * 1000;
@@ -41,9 +42,9 @@ public final class ScalingIT {
     
     private final FixtureWriteThread fixtureWriteThread = new FixtureWriteThread(TIMEOUT_MS, 1000);
     
-    @Ignore
+    @SneakyThrows(InterruptedException.class)
     @Test
-    public void assertScaling() throws InterruptedException {
+    public void assertScaling() {
         if (IntegrationTestEnvironment.getInstance().isEnvironmentPrepared()) {
             IntegrationTestEnvironment.getInstance().waitForEnvironmentReady();
             fixtureWriteThread.start();
diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
new file mode 100644
index 0000000..5817727
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+it.env.type=${it.env}
+it.env.value=scaling
+
+db.host.docker=mysql:3306
+db.host.host=127.0.0.1:13306
+db.username=root
+db.password=123456
+scaling.url=http://127.0.0.1:18888
+scaling.retry=30
+scaling.waitMs=1000