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/01/26 11:58:14 UTC
[shardingsphere] branch master updated: Agent it metrics (#9172)
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun 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 12fe834 Agent it metrics (#9172)
12fe834 is described below
commit 12fe8345c7a299faed34fc2566b4668952642390
Author: xiaoyu <54...@qq.com>
AuthorDate: Tue Jan 26 19:57:28 2021 +0800
Agent it metrics (#9172)
* agent metrics IT
* agent metrics IT
* agent metrics IT
* agent metrics IT
* agent metrics IT
* agent metrics IT
---
.github/workflows/it.yml | 6 +-
.../pom.xml | 136 +--------------------
.../Dockerfile | 4 +-
.../pom.xml | 35 ++++--
.../src/test/assembly/bin/start.sh | 4 +-
.../src/test/assembly/bin/stop.sh | 0
...hardingsphere-proxy-agent-metrics-assembly.xml} | 19 +--
.../agent/test/metrics/MetricsPluginIT.java} | 8 +-
.../agent/test/metrics}/entity/OrderEntity.java | 2 +-
.../test/metrics}/env/EnvironmentProperties.java | 2 +-
.../metrics}/env/IntegrationTestEnvironment.java | 4 +-
.../src/test/resources/docker/docker-compose.yml | 24 +++-
.../docker/prometheus/conf/prometheus.yml} | 48 +++-----
.../test/resources/docker/proxy/conf/agent.yaml | 3 +-
.../resources/docker/proxy/conf/config-db.yaml | 6 +-
.../test/resources/docker/proxy/conf/logback.xml | 0
.../test/resources/docker/proxy/conf/server.yaml | 0
.../src/test/resources/env/engine-env.properties | 0
.../src/test/resources/env/mysql/init.sql | 16 +--
19 files changed, 95 insertions(+), 222 deletions(-)
diff --git a/.github/workflows/it.yml b/.github/workflows/it.yml
index 90c792e..53b009f 100644
--- a/.github/workflows/it.yml
+++ b/.github/workflows/it.yml
@@ -192,8 +192,8 @@ jobs:
- name: Run Integration Test
run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=dbtbl_with_replica_query -Dit.databases=MySQL
- mysql-proxy-agent:
- name: MySQL-Proxy with Agent
+ mysql-proxy-agent-metrics:
+ name: MySQL-Proxy with Agent Metrics
runs-on: ubuntu-latest
steps:
- name: Cache Maven Repos
@@ -211,4 +211,4 @@ jobs:
- name: Build Project
run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -Dmaven.test.skip=true
- name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-agent-test/pom.xml -Pit.env.agent
+ run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/pom.xml -Pit.env.metrics
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml
index 95dd367..5fddc9e 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml
@@ -27,137 +27,11 @@
</parent>
<artifactId>shardingsphere-integration-agent-test-plugins</artifactId>
<name>${project.artifactId}</name>
+ <packaging>pom</packaging>
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-bootstrap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <modules>
+ <module>shardingsphere-integration-agent-test-metrics</module>
+ </modules>
- <profiles>
- <profile>
- <id>it.env.agent</id>
- <properties>
- <it.env>agent</it.env>
- </properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>src/test/assembly/shardingsphere-proxy-agent-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>dockerfile-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>shardingsphere-proxy-bin</id>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <repository>apache/shardingsphere-proxy-agent-test</repository>
- <tag>${project.version}</tag>
- <tag>latest</tag>
- <buildArgs>
- <APP_NAME>${project.build.finalName}</APP_NAME>
- </buildArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.dkanejs.maven.plugins</groupId>
- <artifactId>docker-compose-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>agent-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>agent-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>validate</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>target/test-classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
+
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/Dockerfile b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/Dockerfile
similarity index 83%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/Dockerfile
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/Dockerfile
index d7a763a..4257d9e 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/Dockerfile
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/Dockerfile
@@ -23,5 +23,5 @@ ENV WAIT_VERSION 2.7.2
ADD target/${APP_NAME}.tar.gz /opt
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait
RUN chmod +x /wait
-RUN mv /opt/${APP_NAME} /opt/shardingsphere-proxy
-ENTRYPOINT /wait && /opt/shardingsphere-proxy/bin/start.sh && tail -f /opt/shardingsphere-proxy/logs/stdout.log
+RUN mv /opt/${APP_NAME} /opt/shardingsphere-proxy-agent-metrics
+ENTRYPOINT /wait && /opt/shardingsphere-proxy-agent-metrics/bin/start.sh && tail -f /opt/shardingsphere-proxy-agent-metrics/logs/stdout.log
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/pom.xml
similarity index 86%
copy from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml
copy to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/pom.xml
index 95dd367..7024e0f 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/pom.xml
@@ -22,12 +22,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-integration-agent-test</artifactId>
+ <artifactId>shardingsphere-integration-agent-test-plugins</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-integration-agent-test-plugins</artifactId>
+ <artifactId>shardingsphere-integration-agent-test-metrics</artifactId>
<name>${project.artifactId}</name>
+ <properties>
+ <maven.deploy.skip>true</maven.deploy.skip>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -58,9 +62,9 @@
<profiles>
<profile>
- <id>it.env.agent</id>
+ <id>it.env.metrics</id>
<properties>
- <it.env>agent</it.env>
+ <it.env>metrics</it.env>
</properties>
<build>
<plugins>
@@ -69,7 +73,7 @@
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
- <descriptor>src/test/assembly/shardingsphere-proxy-agent-assembly.xml</descriptor>
+ <descriptor>src/test/assembly/shardingsphere-proxy-agent-metrics-assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
@@ -94,7 +98,7 @@
</execution>
</executions>
<configuration>
- <repository>apache/shardingsphere-proxy-agent-test</repository>
+ <repository>apache/shardingsphere-proxy-agent-metrics-test</repository>
<tag>${project.version}</tag>
<tag>latest</tag>
<buildArgs>
@@ -107,7 +111,7 @@
<artifactId>docker-compose-maven-plugin</artifactId>
<executions>
<execution>
- <id>agent-up</id>
+ <id>agent-metrics-up</id>
<phase>pre-integration-test</phase>
<goals>
<goal>up</goal>
@@ -118,7 +122,7 @@
</configuration>
</execution>
<execution>
- <id>agent-down</id>
+ <id>agent-metrics-down</id>
<phase>post-integration-test</phase>
<goals>
<goal>down</goal>
@@ -138,6 +142,19 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-tests</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
@@ -160,4 +177,4 @@
</plugin>
</plugins>
</build>
-</project>
+</project>
\ No newline at end of file
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/start.sh b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/bin/start.sh
similarity index 93%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/start.sh
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/bin/start.sh
index 4c292ae..45fb575 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/start.sh
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/bin/start.sh
@@ -16,7 +16,7 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Proxy
+SERVER_NAME=ShardingSphere-Proxy-Metrics
cd `dirname $0`
cd ..
@@ -66,6 +66,6 @@ fi
echo "The classpath is ${CLASS_PATH}"
-nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -javaagent:/opt/shardingsphere-proxy/shardingsphere-agent.jar -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
+nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -javaagent:/opt/shardingsphere-proxy-agent-metrics/shardingsphere-agent.jar -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
sleep 1
echo "Please check the STDOUT file: $STDOUT_FILE"
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/stop.sh b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/bin/stop.sh
similarity index 100%
copy from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/stop.sh
copy to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/bin/stop.sh
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/shardingsphere-proxy-agent-assembly.xml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/shardingsphere-proxy-agent-metrics-assembly.xml
similarity index 67%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/shardingsphere-proxy-agent-assembly.xml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/shardingsphere-proxy-agent-metrics-assembly.xml
index b3ed9b7..b47aff6 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/shardingsphere-proxy-agent-assembly.xml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/assembly/shardingsphere-proxy-agent-metrics-assembly.xml
@@ -25,29 +25,14 @@
<fileSets>
<fileSet>
- <directory>${project.basedir}/../../../shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/target/plugins</directory>
- <outputDirectory>./plugins</outputDirectory>
- <includes>
- <include>**.jar</include>
- </includes>
- </fileSet>
-
- <fileSet>
- <directory>${project.basedir}/../../../shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/target/plugins</directory>
- <outputDirectory>./plugins</outputDirectory>
- <includes>
- <include>**.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>${project.basedir}/../../../shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/target/plugins</directory>
+ <directory>${project.basedir}/../../../../shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/target/plugins</directory>
<outputDirectory>./plugins</outputDirectory>
<includes>
<include>**.jar</include>
</includes>
</fileSet>
<fileSet>
- <directory>${project.basedir}/../../../shardingsphere-agent/shardingsphere-agent-bootstrap/target</directory>
+ <directory>${project.basedir}/../../../../shardingsphere-agent/shardingsphere-agent-bootstrap/target</directory>
<outputDirectory>./</outputDirectory>
<includes>
<include>shardingsphere-agent.jar</include>
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/BaseAgentIT.java b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/MetricsPluginIT.java
similarity index 93%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/BaseAgentIT.java
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/MetricsPluginIT.java
index d88baa9..77dd162 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/BaseAgentIT.java
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/MetricsPluginIT.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.agent.plugins;
+package org.apache.shardingsphere.integration.agent.test.metrics;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -27,14 +27,14 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.sql.DataSource;
-import org.apache.shardingsphere.test.agent.plugins.entity.OrderEntity;
-import org.apache.shardingsphere.test.agent.plugins.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.agent.test.metrics.entity.OrderEntity;
+import org.apache.shardingsphere.integration.agent.test.metrics.env.IntegrationTestEnvironment;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class BaseAgentIT {
+public final class MetricsPluginIT {
@Test
public void assertProxyWithAgent() {
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/entity/OrderEntity.java b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/entity/OrderEntity.java
similarity index 93%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/entity/OrderEntity.java
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/entity/OrderEntity.java
index 43eb539..e546664 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/entity/OrderEntity.java
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/entity/OrderEntity.java
@@ -16,7 +16,7 @@
*
*/
-package org.apache.shardingsphere.test.agent.plugins.entity;
+package org.apache.shardingsphere.integration.agent.test.metrics.entity;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/EnvironmentProperties.java b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/EnvironmentProperties.java
similarity index 96%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/EnvironmentProperties.java
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/EnvironmentProperties.java
index 8ecac54..30cb8c0 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/EnvironmentProperties.java
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/EnvironmentProperties.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.agent.plugins.env;
+package org.apache.shardingsphere.integration.agent.test.metrics.env;
import java.io.IOException;
import java.io.InputStream;
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/IntegrationTestEnvironment.java b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/IntegrationTestEnvironment.java
similarity index 95%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/IntegrationTestEnvironment.java
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/IntegrationTestEnvironment.java
index 975295a..a9a13f4 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/java/org/apache/shardingsphere/test/agent/plugins/env/IntegrationTestEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/java/org/apache/shardingsphere/integration/agent/test/metrics/env/IntegrationTestEnvironment.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.agent.plugins.env;
+package org.apache.shardingsphere.integration.agent.test.metrics.env;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@@ -48,7 +48,7 @@ public final class IntegrationTestEnvironment {
@SneakyThrows
private IntegrationTestEnvironment() {
Properties engineEnvProps = EnvironmentProperties.loadProperties("env/engine-env.properties");
- isEnvironmentPrepared = "agent".equals(engineEnvProps.getProperty("it.env.type"));
+ isEnvironmentPrepared = "metrics".equals(engineEnvProps.getProperty("it.env.type"));
if (isEnvironmentPrepared) {
waitForEnvironmentReady();
dataSource = createHikariCP();
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/docker-compose.yml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/docker-compose.yml
similarity index 69%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/docker-compose.yml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/docker-compose.yml
index f3f7ba9..ec5d8d4 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/docker-compose.yml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/docker-compose.yml
@@ -20,7 +20,7 @@ version: "2.1"
services:
mysql:
image: "mysql/mysql-server:5.7"
- container_name: agent-mysql
+ container_name: agent-metrics-mysql
command: ['--sql_mode=', '--default-authentication-plugin=mysql_native_password']
volumes:
- ../env/mysql:/docker-entrypoint-initdb.d/
@@ -29,18 +29,30 @@ services:
environment:
- LANG=C.UTF-8
- shardingsphere-proxy:
- image: apache/shardingsphere-proxy-agent-test
- container_name: shardingsphere-proxy-agent
+ prometheus:
+ image: prom/prometheus:latest
+ container_name: agent-prometheus
+ hostname: prometheus
+ restart: always
+ volumes:
+ - ./prometheus/conf:/config
+ ports:
+ - '19090:9090'
+ command: ['--config.file=/config/prometheus.yml']
+
+ shardingsphere-proxy-agent-metrics:
+ image: apache/shardingsphere-proxy-agent-metrics-test
+ container_name: shardingsphere-proxy-agent-metrics
ports:
- "43070:3307"
- "43080:3308"
links:
- - "mysql:mysql.agent.host"
+ - "mysql:mysql.agent.metrics.host"
volumes:
- - ./proxy/conf:/opt/shardingsphere-proxy/conf
+ - ./proxy/conf:/opt/shardingsphere-proxy-agent-metrics/conf
depends_on:
- mysql
+ - prometheus
environment:
- WAIT_HOSTS=mysql:3306
- WAIT_HOSTS_TIMEOUT=300
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/stop.sh b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/prometheus/conf/prometheus.yml
similarity index 52%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/stop.sh
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/prometheus/conf/prometheus.yml
index da8909e..46b2b4d 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/assembly/bin/stop.sh
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/prometheus/conf/prometheus.yml
@@ -1,4 +1,3 @@
-#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -16,36 +15,21 @@
# limitations under the License.
#
-SERVER_NAME=ShardingSphere-Proxy
+global:
+ scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
+ evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
+ # scrape_timeout is set to the global default (10s).
-cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
+# A scrape configuration containing exactly one endpoint to scrape:
+# Here it's Prometheus itself.
+scrape_configs:
+ # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
+ - job_name: 'prometheus'
+ # metrics_path defaults to '/metrics'
+ # scheme defaults to 'http'.
+ static_configs:
+ - targets: ['localhost:9090']
-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"
+ - job_name: 'shardingsphere-agent'
+ static_configs:
+ - targets: ['localhost:8090']
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/agent.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/agent.yaml
similarity index 98%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/agent.yaml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/agent.yaml
index 67f662a..56f780d 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/agent.yaml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/agent.yaml
@@ -19,11 +19,12 @@ applicationName: shardingsphere-agent
ignoredPluginNames:
- Jaeger
- Opentracing
+ - Zipkin
plugins:
prometheus:
host: "localhost"
- port: 9090
+ port: 8090
props:
JVM_INFORMATION_COLLECTOR_ENABLED : "true"
Jaeger:
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/config-db.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/config-db.yaml
similarity index 88%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/config-db.yaml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/config-db.yaml
index 044f9c1..300bfa0 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/config-db.yaml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/config-db.yaml
@@ -15,11 +15,11 @@
# limitations under the License.
#
-schemaName: agent-db
+schemaName: agent-metrics-db
dataSources:
ds_0:
- url: jdbc:mysql://mysql.agent.host:3306/agent_db_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.agent.metrics.host:3306/agent_metrics_db_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -29,7 +29,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
ds_1:
- url: jdbc:mysql://mysql.agent.host:3306/agent_db_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.agent.metrics.host:3306/agent_metrics_db_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/logback.xml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/logback.xml
similarity index 100%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/logback.xml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/logback.xml
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
similarity index 100%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/docker/proxy/conf/server.yaml
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/env/engine-env.properties b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/env/engine-env.properties
similarity index 100%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/env/engine-env.properties
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/env/engine-env.properties
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/env/mysql/init.sql b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/env/mysql/init.sql
similarity index 57%
rename from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/env/mysql/init.sql
rename to shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/env/mysql/init.sql
index d82e10e..3334fac 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/src/test/resources/env/mysql/init.sql
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/env/mysql/init.sql
@@ -21,14 +21,14 @@ GRANT All privileges ON *.* TO 'root'@'%';
SET character_set_database='utf8';
SET character_set_server='utf8';
-DROP DATABASE IF EXISTS agent_db_0;
-DROP DATABASE IF EXISTS agent_db_1;
+DROP DATABASE IF EXISTS agent_metrics_db_0;
+DROP DATABASE IF EXISTS agent_metrics_db_1;
-CREATE DATABASE agent_db_0;
-CREATE DATABASE agent_db_1;
+CREATE DATABASE agent_metrics_db_0;
+CREATE DATABASE agent_metrics_db_1;
-CREATE TABLE agent_db_0.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
-CREATE TABLE agent_db_0.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE agent_metrics_db_0.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE agent_metrics_db_0.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
-CREATE TABLE agent_db_1.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
-CREATE TABLE agent_db_1.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE agent_metrics_db_1.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE agent_metrics_db_1.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));