This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 eac4a8a41f4 Use AgentPluginContainerFactory to decouple
AgentPluginContainer in agent test common module (#32215)
eac4a8a41f4 is described below
commit eac4a8a41f404ea5e828130323b1d3bf1958dfe7
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 21 17:02:25 2024 +0800
Use AgentPluginContainerFactory to decouple AgentPluginContainer in agent
test common module (#32215)
* Use AgentPluginContainerFactory decouple AgentPluginContainer in agent
test common module
* Use AgentPluginContainerFactory decouple AgentPluginContainer in agent
test common module
* Use AgentPluginContainerFactory decouple AgentPluginContainer in agent
test common module
---
...ainer.java => AgentPluginContainerFactory.java} | 30 ++++++++++------------
.../agent/common/env/AgentE2ETestEnvironment.java | 20 +++++----------
.../metrics/container}/PrometheusContainer.java | 2 +-
.../container/PrometheusContainerFactory.java} | 22 ++++++++--------
...n.container.plugin.AgentPluginContainerFactory} | 7 +----
.../agent/jaeger/container}/JaegerContainer.java | 2 +-
.../jaeger/container/JaegerContainerFactory.java} | 22 ++++++++--------
...n.container.plugin.AgentPluginContainerFactory} | 7 +----
.../src/test/resources/env/engine-env.properties | 2 +-
.../agent/zipkin/container}/ZipkinContainer.java | 2 +-
.../zipkin/container/ZipkinContainerFactory.java} | 22 ++++++++--------
...n.container.plugin.AgentPluginContainerFactory} | 7 +----
12 files changed, 56 insertions(+), 89 deletions(-)
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/AgentPluginContainerFactory.java
similarity index 59%
copy from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
copy to
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/AgentPluginContainerFactory.java
index 9c282a27cae..3d4d195f3bf 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/AgentPluginContainerFactory.java
@@ -17,24 +17,20 @@
package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
-import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
+import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
-public final class ZipkinContainer extends DockerITContainer {
-
- public ZipkinContainer(final String image) {
- super("zipkin", image);
- }
-
- @Override
- protected void configure() {
-
withExposedPorts(AgentE2ETestConfiguration.getInstance().getDefaultExposePort());
- setWaitStrategy(new
HttpWaitStrategy().forPort(AgentE2ETestConfiguration.getInstance().getDefaultExposePort()));
- }
+/**
+ * Agent plugin container factory.
+ */
+@SingletonSPI
+public interface AgentPluginContainerFactory extends TypedSPI {
- @Override
- public String getAbbreviation() {
- return "zipkin";
- }
+ /**
+ * Create agent plugin container.
+ *
+ * @return created container
+ */
+ DockerITContainer create();
}
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/AgentE2ETestEnvironment.java
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/AgentE2ETestEnvironment.java
index 8e0f2bf4292..fbb498157e4 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/AgentE2ETestEnvironment.java
+++
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/AgentE2ETestEnvironment.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.test.e2e.agent.common.env;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
-import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginHTTPEndpointProvider;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.e2e.agent.common.container.ITContainers;
-import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.JaegerContainer;
import
org.apache.shardingsphere.test.e2e.agent.common.container.MySQLContainer;
-import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.PrometheusContainer;
import
org.apache.shardingsphere.test.e2e.agent.common.container.ShardingSphereJdbcContainer;
import
org.apache.shardingsphere.test.e2e.agent.common.container.ShardingSphereProxyContainer;
-import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.ZipkinContainer;
+import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory;
+import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginHTTPEndpointProvider;
import org.apache.shardingsphere.test.e2e.agent.common.enums.PluginType;
import
org.apache.shardingsphere.test.e2e.agent.common.fixture.executor.ProxyRequestExecutor;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
@@ -155,16 +154,9 @@ public final class AgentE2ETestEnvironment {
}
private Optional<DockerITContainer> getAgentPluginContainer() {
- if
(PluginType.PROMETHEUS.getValue().equalsIgnoreCase(testConfig.getPluginType()))
{
- agentPluginContainer = new
PrometheusContainer(testConfig.getPluginImageName());
- return Optional.of(agentPluginContainer);
- }
- if
(PluginType.ZIPKIN.getValue().equalsIgnoreCase(testConfig.getPluginType())) {
- agentPluginContainer = new
ZipkinContainer(testConfig.getPluginImageName());
- return Optional.of(agentPluginContainer);
- }
- if
(PluginType.JAEGER.getValue().equalsIgnoreCase(testConfig.getPluginType())) {
- agentPluginContainer = new
JaegerContainer(testConfig.getPluginImageName());
+ Optional<AgentPluginContainerFactory> agentPluginContainerFactory =
TypedSPILoader.findService(AgentPluginContainerFactory.class,
testConfig.getPluginType());
+ if (agentPluginContainerFactory.isPresent()) {
+ agentPluginContainer = agentPluginContainerFactory.get().create();
return Optional.of(agentPluginContainer);
}
return Optional.empty();
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/PrometheusContainer.java
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainer.java
similarity index 96%
rename from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/PrometheusContainer.java
rename to
test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainer.java
index 09aef280b34..4100b645e9e 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/PrometheusContainer.java
+++
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.metrics.container;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainerFactory.java
similarity index 62%
copy from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
copy to
test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainerFactory.java
index 9c282a27cae..93ba9226d9c 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/container/PrometheusContainerFactory.java
@@ -15,26 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.metrics.container;
+import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
-public final class ZipkinContainer extends DockerITContainer {
-
- public ZipkinContainer(final String image) {
- super("zipkin", image);
- }
+/**
+ * Prometheus container factory.
+ */
+public final class PrometheusContainerFactory implements
AgentPluginContainerFactory {
@Override
- protected void configure() {
-
withExposedPorts(AgentE2ETestConfiguration.getInstance().getDefaultExposePort());
- setWaitStrategy(new
HttpWaitStrategy().forPort(AgentE2ETestConfiguration.getInstance().getDefaultExposePort()));
+ public DockerITContainer create() {
+ return new
PrometheusContainer(AgentE2ETestConfiguration.getInstance().getPluginImageName());
}
@Override
- public String getAbbreviation() {
- return "zipkin";
+ public Object getType() {
+ return "Prometheus";
}
}
diff --git
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
b/test/e2e/agent/plugins/metrics/prometheus/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
similarity index 78%
copy from
test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
copy to
test/e2e/agent/plugins/metrics/prometheus/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
index d88f01a3226..8d5b09cf7a9 100644
---
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
+++
b/test/e2e/agent/plugins/metrics/prometheus/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
@@ -15,9 +15,4 @@
# limitations under the License.
#
-# The value of it.env.adapter is proxy or jdbc
-it.env.adapter=proxy
-it.env.plugin.type=jaeger
-it.env.plugin.image=jaegertracing/all-in-one:1.41
-it.env.plugin.default.expose.port=16686
-it.env.collect.data.wait.seconds=15
+org.apache.shardingsphere.test.e2e.agent.metrics.container.PrometheusContainerFactory
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/JaegerContainer.java
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainer.java
similarity index 96%
rename from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/JaegerContainer.java
rename to
test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainer.java
index 3d19155b83b..bb9126002f4 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/JaegerContainer.java
+++
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.jaeger.container;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainerFactory.java
similarity index 62%
copy from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
copy to
test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainerFactory.java
index 9c282a27cae..430cf5cbc4a 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/container/JaegerContainerFactory.java
@@ -15,26 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.jaeger.container;
+import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
-public final class ZipkinContainer extends DockerITContainer {
-
- public ZipkinContainer(final String image) {
- super("zipkin", image);
- }
+/**
+ * Jaeger container factory.
+ */
+public final class JaegerContainerFactory implements
AgentPluginContainerFactory {
@Override
- protected void configure() {
-
withExposedPorts(AgentE2ETestConfiguration.getInstance().getDefaultExposePort());
- setWaitStrategy(new
HttpWaitStrategy().forPort(AgentE2ETestConfiguration.getInstance().getDefaultExposePort()));
+ public DockerITContainer create() {
+ return new
JaegerContainer(AgentE2ETestConfiguration.getInstance().getPluginImageName());
}
@Override
- public String getAbbreviation() {
- return "zipkin";
+ public Object getType() {
+ return "Jaeger";
}
}
diff --git
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
b/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
similarity index 78%
copy from
test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
copy to
test/e2e/agent/plugins/tracing/jaeger/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
index d88f01a3226..6087e73fba1 100644
---
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
+++
b/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
@@ -15,9 +15,4 @@
# limitations under the License.
#
-# The value of it.env.adapter is proxy or jdbc
-it.env.adapter=proxy
-it.env.plugin.type=jaeger
-it.env.plugin.image=jaegertracing/all-in-one:1.41
-it.env.plugin.default.expose.port=16686
-it.env.collect.data.wait.seconds=15
+org.apache.shardingsphere.test.e2e.agent.jaeger.container.JaegerContainerFactory
diff --git
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
b/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
index d88f01a3226..7c612a8aeb0 100644
---
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
+++
b/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
@@ -16,7 +16,7 @@
#
# The value of it.env.adapter is proxy or jdbc
-it.env.adapter=proxy
+it.env.adapter=
it.env.plugin.type=jaeger
it.env.plugin.image=jaegertracing/all-in-one:1.41
it.env.plugin.default.expose.port=16686
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainer.java
similarity index 95%
copy from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
copy to
test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainer.java
index 9c282a27cae..0cca42cb6c6 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.zipkin.container;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
diff --git
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainerFactory.java
similarity index 62%
rename from
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
rename to
test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainerFactory.java
index 9c282a27cae..8c0448b9e70 100644
---
a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/container/plugin/ZipkinContainer.java
+++
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/container/ZipkinContainerFactory.java
@@ -15,26 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.e2e.agent.common.container.plugin;
+package org.apache.shardingsphere.test.e2e.agent.zipkin.container;
+import
org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory;
import
org.apache.shardingsphere.test.e2e.agent.common.env.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
-public final class ZipkinContainer extends DockerITContainer {
-
- public ZipkinContainer(final String image) {
- super("zipkin", image);
- }
+/**
+ * Zipkin container factory.
+ */
+public final class ZipkinContainerFactory implements
AgentPluginContainerFactory {
@Override
- protected void configure() {
-
withExposedPorts(AgentE2ETestConfiguration.getInstance().getDefaultExposePort());
- setWaitStrategy(new
HttpWaitStrategy().forPort(AgentE2ETestConfiguration.getInstance().getDefaultExposePort()));
+ public DockerITContainer create() {
+ return new
ZipkinContainer(AgentE2ETestConfiguration.getInstance().getPluginImageName());
}
@Override
- public String getAbbreviation() {
- return "zipkin";
+ public Object getType() {
+ return "Zipkin";
}
}
diff --git
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
b/test/e2e/agent/plugins/tracing/zipkin/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
similarity index 78%
copy from
test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
copy to
test/e2e/agent/plugins/tracing/zipkin/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
index d88f01a3226..a23b59e1c59 100644
---
a/test/e2e/agent/plugins/tracing/jaeger/src/test/resources/env/engine-env.properties
+++
b/test/e2e/agent/plugins/tracing/zipkin/src/test/resources/META-INF/services/org.apache.shardingsphere.test.e2e.agent.common.container.plugin.AgentPluginContainerFactory
@@ -15,9 +15,4 @@
# limitations under the License.
#
-# The value of it.env.adapter is proxy or jdbc
-it.env.adapter=proxy
-it.env.plugin.type=jaeger
-it.env.plugin.image=jaegertracing/all-in-one:1.41
-it.env.plugin.default.expose.port=16686
-it.env.collect.data.wait.seconds=15
+org.apache.shardingsphere.test.e2e.agent.zipkin.container.ZipkinContainerFactory