This is an automated email from the ASF dual-hosted git repository.
chenjiahao 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 3a1b1db314d Improve agent e2e test, add image version config (#30987)
3a1b1db314d is described below
commit 3a1b1db314d2ffb6bdf0aaee0cee837458576d42
Author: jiangML <[email protected]>
AuthorDate: Mon Apr 22 17:11:34 2024 +0800
Improve agent e2e test, add image version config (#30987)
* Improve agent e2e test, add image version config
* Improve ContentAssert
---
.../agent/common/container/JaegerContainer.java | 5 +--
.../e2e/agent/common/container/MySQLContainer.java | 5 +--
.../common/container/PrometheusContainer.java | 5 +--
.../container/ShardingSphereJdbcContainer.java | 9 ++--
.../container/ShardingSphereProxyContainer.java | 9 ++--
.../agent/common/container/ZipkinContainer.java | 5 +--
.../e2e/agent/common/env/E2ETestEnvironment.java | 48 +++++++++++++++++-----
.../common/src/test/resources/env/image.properties | 23 +++++++++++
.../test/e2e/agent/file/asserts/ContentAssert.java | 5 ++-
9 files changed, 80 insertions(+), 34 deletions(-)
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/JaegerContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/JaegerContainer.java
index 270c23b9157..2b0802c1538 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/JaegerContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/JaegerContainer.java
@@ -28,9 +28,8 @@ import java.util.Map;
*/
public final class JaegerContainer extends DockerITContainer {
- public JaegerContainer() {
- // TODO image version adjusted to be configurable
- super("jaeger", "jaegertracing/all-in-one:1.41");
+ public JaegerContainer(final String image) {
+ super("jaeger", image);
}
@Override
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/MySQLContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/MySQLContainer.java
index 7024ecccb30..6c21095d0c9 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/MySQLContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/MySQLContainer.java
@@ -38,9 +38,8 @@ public final class MySQLContainer extends DockerITContainer {
private static final String READY_USER_PASSWORD = "123456";
- public MySQLContainer() {
- // TODO image version adjusted to be configurable
- super("mysql", "mysql:8.0");
+ public MySQLContainer(final String image) {
+ super("mysql", image);
}
@Override
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/PrometheusContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/PrometheusContainer.java
index 63c8d237e08..6f0032f1f49 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/PrometheusContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/PrometheusContainer.java
@@ -28,9 +28,8 @@ public final class PrometheusContainer extends
DockerITContainer {
private static final int EXPOSED_PORT = 9090;
- public PrometheusContainer() {
- // TODO image version adjusted to be configurable
- super("prometheus", "prom/prometheus:v2.41.0");
+ public PrometheusContainer(final String image) {
+ super("prometheus", image);
}
@Override
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereJdbcContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereJdbcContainer.java
index f9acf4f56f2..062ade73c49 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereJdbcContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereJdbcContainer.java
@@ -39,13 +39,12 @@ public final class ShardingSphereJdbcContainer extends
DockerITContainer {
private final Consumer<OutputFrame> consumer;
- public ShardingSphereJdbcContainer(final String plugin) {
- this(plugin, null);
+ public ShardingSphereJdbcContainer(final String image, final String
plugin) {
+ this(image, plugin, null);
}
- public ShardingSphereJdbcContainer(final String plugin, final
Consumer<OutputFrame> consumer) {
- // TODO image version adjusted to be configurable
- super("jdbc", "apache/shardingsphere-jdbc-agent-test:latest");
+ public ShardingSphereJdbcContainer(final String image, final String
plugin, final Consumer<OutputFrame> consumer) {
+ super("jdbc", image);
this.consumer = consumer;
this.plugin = plugin;
}
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereProxyContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereProxyContainer.java
index f8786873f68..5730f6f7757 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereProxyContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ShardingSphereProxyContainer.java
@@ -51,13 +51,12 @@ public final class ShardingSphereProxyContainer extends
DockerITContainer {
private final Consumer<OutputFrame> consumer;
- public ShardingSphereProxyContainer(final String plugin) {
- this(plugin, null);
+ public ShardingSphereProxyContainer(final String image, final String
plugin) {
+ this(image, plugin, null);
}
- public ShardingSphereProxyContainer(final String plugin, final
Consumer<OutputFrame> consumer) {
- // TODO image version adjusted to be configurable
- super("proxy", "apache/shardingsphere-proxy-agent-test:latest");
+ public ShardingSphereProxyContainer(final String image, final String
plugin, final Consumer<OutputFrame> consumer) {
+ super("proxy", image);
this.consumer = consumer;
this.plugin = plugin;
}
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ZipkinContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ZipkinContainer.java
index 06d45e0861f..37d688dd224 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/ZipkinContainer.java
@@ -24,9 +24,8 @@ public final class ZipkinContainer extends DockerITContainer {
private static final int EXPOSED_PORT = 9411;
- public ZipkinContainer() {
- // TODO image version adjusted to be configurable
- super("zipkin", "openzipkin/zipkin:3.2");
+ public ZipkinContainer(final String image) {
+ super("zipkin", image);
}
@Override
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/E2ETestEnvironment.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/E2ETestEnvironment.java
index da2fbde3f47..1192ff4ecfe 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/E2ETestEnvironment.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/E2ETestEnvironment.java
@@ -82,13 +82,38 @@ public final class E2ETestEnvironment {
private ProxyRequestExecutor proxyRequestExecutor;
+ private boolean initialized;
+
+ private String jaegerImage;
+
+ private String zipkinImage;
+
+ private String mysqlImage;
+
+ private String prometheusImage;
+
+ private String proxyImage;
+
+ private String jdbcProjectImage;
+
private E2ETestEnvironment() {
+ initContainerImage();
Properties props =
EnvironmentProperties.loadProperties("env/engine-env.properties");
adapter = props.getProperty("it.env.adapter");
plugin = props.getProperty("it.env.plugin");
collectDataWaitSeconds =
Long.parseLong(props.getProperty("it.env.collect.data.wait.seconds", "0"));
}
+ private void initContainerImage() {
+ Properties props =
EnvironmentProperties.loadProperties("env/image.properties");
+ proxyImage = props.getProperty("proxy.image",
"apache/shardingsphere-proxy-agent-test:latest");
+ jdbcProjectImage = props.getProperty("jdbc.project.image",
"apache/shardingsphere-jdbc-agent-test:latest");
+ mysqlImage = props.getProperty("mysql.image", "mysql:8.0");
+ jaegerImage = props.getProperty("jaeger.image",
"jaegertracing/all-in-one:1.41");
+ zipkinImage = props.getProperty("zipkin.image",
"openzipkin/zipkin:3.2");
+ prometheusImage = props.getProperty("prometheus.image",
"prom/prometheus:v2.41.0");
+ }
+
/**
* Get instance.
*
@@ -114,15 +139,16 @@ public final class E2ETestEnvironment {
if (0 < collectDataWaitSeconds) {
Awaitility.await().ignoreExceptions().atMost(Duration.ofSeconds(collectDataWaitSeconds
+ 1)).pollDelay(collectDataWaitSeconds, TimeUnit.SECONDS).until(() -> true);
}
+ initialized = true;
}
private void createProxyEnvironment() {
containers = new ITContainers();
- MySQLContainer storageContainer = new MySQLContainer();
+ MySQLContainer storageContainer = new MySQLContainer(mysqlImage);
GovernanceContainer governanceContainer =
GovernanceContainerFactory.newInstance("ZooKeeper");
ShardingSphereProxyContainer proxyContainer =
PluginType.FILE.getValue().equalsIgnoreCase(plugin)
- ? new ShardingSphereProxyContainer(plugin, this::collectLogs)
- : new ShardingSphereProxyContainer(plugin);
+ ? new ShardingSphereProxyContainer(proxyImage, plugin,
this::collectLogs)
+ : new ShardingSphereProxyContainer(proxyImage, plugin);
proxyContainer.dependsOn(storageContainer);
proxyContainer.dependsOn(governanceContainer);
Optional<DockerITContainer> pluginContainer = getPluginContainer();
@@ -143,10 +169,10 @@ public final class E2ETestEnvironment {
private void createJDBCEnvironment() {
containers = new ITContainers();
Optional<DockerITContainer> pluginContainer = getPluginContainer();
- MySQLContainer storageContainer = new MySQLContainer();
+ MySQLContainer storageContainer = new MySQLContainer(mysqlImage);
ShardingSphereJdbcContainer jdbcContainer =
PluginType.FILE.getValue().equalsIgnoreCase(plugin)
- ? new ShardingSphereJdbcContainer(plugin, this::collectLogs)
- : new ShardingSphereJdbcContainer(plugin);
+ ? new ShardingSphereJdbcContainer(jdbcProjectImage, plugin,
this::collectLogs)
+ : new ShardingSphereJdbcContainer(jdbcProjectImage, plugin);
jdbcContainer.dependsOn(storageContainer);
pluginContainer.ifPresent(jdbcContainer::dependsOn);
pluginContainer.ifPresent(optional ->
containers.registerContainer(optional));
@@ -158,20 +184,22 @@ public final class E2ETestEnvironment {
private Optional<DockerITContainer> getPluginContainer() {
if (PluginType.PROMETHEUS.getValue().equalsIgnoreCase(plugin)) {
- prometheusContainer = new PrometheusContainer();
+ prometheusContainer = new PrometheusContainer(prometheusImage);
return Optional.of(prometheusContainer);
} else if (PluginType.ZIPKIN.getValue().equalsIgnoreCase(plugin)) {
- zipkinContainer = new ZipkinContainer();
+ zipkinContainer = new ZipkinContainer(zipkinImage);
return Optional.of(zipkinContainer);
} else if (PluginType.JAEGER.getValue().equalsIgnoreCase(plugin)) {
- jaegerContainer = new JaegerContainer();
+ jaegerContainer = new JaegerContainer(jaegerImage);
return Optional.of(jaegerContainer);
}
return Optional.empty();
}
private void collectLogs(final OutputFrame outputFrame) {
- actualLogs.add(outputFrame.getUtf8StringWithoutLineEnding());
+ if (!initialized) {
+ actualLogs.add(outputFrame.getUtf8StringWithoutLineEnding());
+ }
}
private void initHttpUrl() {
diff --git
a/test/e2e/agent/plugins/common/src/test/resources/env/image.properties
b/test/e2e/agent/plugins/common/src/test/resources/env/image.properties
new file mode 100644
index 00000000000..c2772304eb0
--- /dev/null
+++ b/test/e2e/agent/plugins/common/src/test/resources/env/image.properties
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+proxy.image=apache/shardingsphere-proxy-agent-test:latest
+jdbc.project.image=apache/shardingsphere-jdbc-agent-test:latest
+mysql.image=mysql:8.0
+jaeger.image=jaegertracing/all-in-one:1.41
+zipkin.image=openzipkin/zipkin:3.2
+prometheus.image=prom/prometheus:v2.41.0
diff --git
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/asserts/ContentAssert.java
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/asserts/ContentAssert.java
index 4698c98920c..41787214b13 100644
---
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/asserts/ContentAssert.java
+++
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/asserts/ContentAssert.java
@@ -20,7 +20,8 @@ package org.apache.shardingsphere.test.e2e.agent.file.asserts;
import java.util.Collection;
import java.util.regex.Pattern;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* Content assert.
@@ -42,6 +43,6 @@ public final class ContentAssert {
break;
}
}
- assertNotNull(String.format("The log for the specified regular `%s`
does not exist", expectedLogRegex), actualLog);
+ assertThat(String.format("No logs matching `%s`", expectedLogRegex),
actualLog, notNullValue());
}
}