diff --git a/test/e2e/agent/engine/pom.xml b/test/e2e/agent/engine/pom.xml index 79dc7baf23d41..ea3b0638cdac1 100644 --- a/test/e2e/agent/engine/pom.xml +++ b/test/e2e/agent/engine/pom.xml @@ -107,6 +107,7 @@ ${project.basedir}/src/test/resources/docker/proxy/ Dockerfile + entrypoint/entrypoint.sh diff --git a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java index 0ea49b1fa0628..83cf389f0e3ed 100644 --- a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java +++ b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java @@ -38,7 +38,6 @@ import org.testcontainers.containers.output.OutputFrame; import org.testcontainers.shaded.org.awaitility.Awaitility; -import java.sql.SQLException; import java.time.Duration; import java.util.Collection; import java.util.LinkedList; @@ -115,11 +114,6 @@ private void createProxyEnvironment(final Optional agentPlugi containers.registerContainer(governanceContainer); containers.registerContainer(proxyContainer); containers.start(); - try { - proxyRequestExecutor = new ProxyRequestExecutor(proxyContainer.getConnection()); - proxyRequestExecutor.start(); - } catch (final SQLException ignored) { - } } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") diff --git a/test/e2e/agent/engine/src/test/resources/docker/proxy/Dockerfile b/test/e2e/agent/engine/src/test/resources/docker/proxy/Dockerfile index 70ac09b1d08f0..0c0f821b2396a 100644 --- a/test/e2e/agent/engine/src/test/resources/docker/proxy/Dockerfile +++ b/test/e2e/agent/engine/src/test/resources/docker/proxy/Dockerfile @@ -21,6 +21,11 @@ ARG APP_NAME ENV IS_DOCKER true ENV LOCAL_PATH /opt/shardingsphere-proxy +ADD entrypoint/entrypoint.sh /opt/entrypoint.sh ADD ${APP_NAME}.tar.gz /opt +RUN chmod +x /opt/entrypoint.sh RUN mv /opt/${APP_NAME} ${LOCAL_PATH} && mkdir -p ${LOCAL_PATH}/ext-lib && wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar -P ${LOCAL_PATH}/ext-lib -ENTRYPOINT ${LOCAL_PATH}/bin/start.sh -g +RUN apt update +RUN apt install default-mysql-client -y + +ENTRYPOINT /opt/entrypoint.sh diff --git a/test/e2e/agent/engine/src/test/resources/docker/proxy/entrypoint/entrypoint.sh b/test/e2e/agent/engine/src/test/resources/docker/proxy/entrypoint/entrypoint.sh new file mode 100644 index 0000000000000..c0c9f348a55cb --- /dev/null +++ b/test/e2e/agent/engine/src/test/resources/docker/proxy/entrypoint/entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# 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. +# + +nohup bash -c "/opt/shardingsphere-proxy/bin/start.sh -g" /dev/null & +sleep 20 + +for ((i=1; i<=10; i++)) +do mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;INSERT INTO t_order (order_id, user_id, status) VALUES (${i}, ${i}, \"INSERT_TEST\");" +done +mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;set autocommit=0;INSERT INTO t_order (order_id, user_id, status) VALUES (1000, 1000, \"ROLL_BACK\");rollback" +mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;set autocommit=0;UPDATE t_order SET status = 1000 WHERE order_id =1000;commit;" +mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;SELECT * FROM t_order;" +for ((i=1; i<=10; i++)) +do mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;DELETE FROM t_order WHERE order_id=${i};" +done +set +e +mysql -uroot -h127.0.0.1 -proot -P3307 -e "USE sharding_db;SELECT * FROM non_existent_table;" +set -e