From cf7bb1e2fb985d9656fd15346e041b4bd1f38d3a Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Mon, 26 Aug 2024 23:05:41 +0800
Subject: [PATCH 01/16] [type:feat]add kafka logging e2e test
---
.../k8s/script/e2e-http-sync.sh | 4 +
.../shenyu-e2e-case-http/k8s/shenu-kafka.yml | 98 +++++++++++++++++++
.../shenyu-e2e-case-http/pom.xml | 5 +
.../e2e/testcase/http/DividePluginCases.java | 70 +++++++++++++
.../e2e/testcase/http/DividePluginTest.java | 10 ++
5 files changed, 187 insertions(+)
create mode 100644 shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/script/e2e-http-sync.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/script/e2e-http-sync.sh
index 25f37f01d03f..d3e61c4f7e51 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/script/e2e-http-sync.sh
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/script/e2e-http-sync.sh
@@ -37,6 +37,8 @@ for sync in ${SYNC_ARRAY[@]}; do
kubectl apply -f "${PRGDIR}"/shenyu-rocketmq.yml
+ kubectl apply -f "${PRGDIR}"/shenyu-kafka.yml
+
sleep 30s
echo "[Start ${sync} synchronous] create shenyu-admin-${sync}.yml shenyu-bootstrap-${sync}.yml shenyu-examples-springcloud.yml"
# shellcheck disable=SC2199
@@ -75,6 +77,8 @@ for sync in ${SYNC_ARRAY[@]}; do
kubectl delete -f "${SHENYU_TESTCASE_DIR}"/k8s/sync/shenyu-bootstrap-"${sync}".yml
kubectl delete -f "${PRGDIR}"/shenyu-examples-http.yml
kubectl delete -f "${PRGDIR}"/shenyu-rocketmq.yml
+ kubectl delete -f "${PRGDIR}"/shenyu-kafka.yml
+
# shellcheck disable=SC2199
# shellcheck disable=SC2076
if [[ "${MIDDLEWARE_SYNC_ARRAY[@]}" =~ "${sync}" ]]; then
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml
new file mode 100644
index 000000000000..15e2eb414a4b
--- /dev/null
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml
@@ -0,0 +1,98 @@
+# 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.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: zookeeper
+ namespace: default
+ labels:
+ app: zookeeper
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: zookeeper
+ template:
+ metadata:
+ labels:
+ app: zookeeper
+ spec:
+ containers:
+ - name: zookeeper
+ image: wurstmeister/zookeeper:3.4.6
+ ports:
+ - containerPort: 2181
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: zookeeper
+ namespace: default
+ labels:
+ app: zookeeper
+spec:
+ ports:
+ - port: 2181
+ name: client
+ selector:
+ app: zookeeper
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: kafka
+ namespace: default
+ labels:
+ app: kafka
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: kafka
+ template:
+ metadata:
+ labels:
+ app: kafka
+ spec:
+ containers:
+ - name: kafka
+ image: wurstmeister/kafka:2.12-2.1.1
+ env:
+ - name: KAFKA_ADVERTISED_LISTENERS
+ value: PLAINTEXT://kafka:9092
+ - name: KAFKA_ZOOKEEPER_CONNECT
+ value: zookeeper:2181
+ ports:
+ - containerPort: 9092
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: kafka
+ namespace: default
+ labels:
+ app: kafka
+spec:
+ ports:
+ - port: 9092
+ name: client
+ protocol: TCP
+ targetPort: 9092
+ nodePort: 31877
+
+ selector:
+ app: kafka
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/pom.xml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/pom.xml
index 2a3141908e2b..7fa2a64563db 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/pom.xml
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/pom.xml
@@ -32,5 +32,10 @@
rocketmq-client
4.9.3
+
+ org.apache.kafka
+ kafka-clients
+ 2.4.1
+
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
index 256aca6f1109..c89c22ee9385 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
@@ -20,6 +20,10 @@
import com.google.common.collect.Lists;
import io.restassured.http.Method;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -37,8 +41,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import static org.apache.shenyu.e2e.engine.scenario.function.HttpCheckers.exists;
import static org.apache.shenyu.e2e.template.ResourceDataTemplate.newConditions;
@@ -77,6 +86,67 @@ private ShenYuScenarioSpec testDivideHello() {
.build();
}
+ private ShenYuScenarioSpec testKafkaHello(){
+ return ShenYuScenarioSpec.builder()
+ .name("testKafkaHello")
+ .beforeEachSpec(
+ ShenYuBeforeEachSpec.builder()
+ .addSelectorAndRule(
+ newSelectorBuilder("selector",Plugin.LOGGING_KAFKA)
+ .name("2")
+ .matchMode(MatchMode.OR)
+ .conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/http"))
+ .build(),
+ newRuleBuilder("rule")
+ .name("2")
+ .matchMode(MatchMode.OR)
+ .conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/http"))
+ .build()
+ )
+ .checker(exists(TEST))
+ .build()
+ )
+ .caseSpec(
+ ShenYuCaseSpec.builder()
+ .add(request -> {
+ AtomicBoolean isLog = new AtomicBoolean(false);
+ try {
+ Thread.sleep(1000 * 30);
+ request.request(Method.GET, "/http/order/findById?id=23");
+ Properties props = new Properties();
+ props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
+ StringDeserializer.class.getName());
+ props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
+ StringDeserializer.class.getName());
+ props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,
+ "127.0.0.1:31877");
+ KafkaConsumer consumer = new KafkaConsumer<>(props);
+ consumer.subscribe(Arrays.asList(TOPIC));
+ AtomicReference keepCosuming = new AtomicReference<>(true);
+ Instant start = Instant.now();
+ while(keepCosuming.get()){
+ if (Duration.between(start, Instant.now()).toMillis() > 60000) {
+ keepCosuming.set(false);
+ }
+ ConsumerRecords records = consumer.poll(Duration.ofMillis(1000));
+ records.forEach(record ->{
+ String message = record.value();
+ if (message.contains("/http/order/findById?id=23")) {
+ isLog.set(true);
+ keepCosuming.set(false);
+ }
+ });
+ }
+ Assertions.assertTrue(isLog.get());
+ } catch (InterruptedException e) {
+ LOG.info("isLog.get():{}", isLog.get());
+ LOG.error("error", e);
+ throw new RuntimeException(e);
+ }
+ }).build()
+ ).build();
+ }
+
private ShenYuScenarioSpec testRocketMQHello() {
return ShenYuScenarioSpec.builder()
.name("testRocketMQHello")
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
index 309ff66bc58e..e92df5bf898f 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
@@ -110,6 +110,16 @@ void setup(final AdminClient adminClient, final GatewayClient gatewayClient) thr
formData.add("config", "{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"rocketmq-dialevoneid:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}");
adminClient.changePluginStatus("29", formData);
WaitDataSync.waitGatewayPluginUse(gatewayClient, "org.apache.shenyu.plugin.logging.rocketmq");
+ LOG.info("start loggingKafka plugin");
+ formData.add("id","33");
+ formData.add("name","loggingKafka");
+ formData.add("enabled","true");
+ formData.add("role","Logging");
+ formData.add("sort","180");
+ formData.add("config","{\"topic\":\"shenyu-access-logging\",\"namesrvAddr\":\"kafka:9092\",\"sampleRate\":\"1\",\"maxResponseBody\":524288,\"maxRequestBody\":524288,\"compressAlg\":\"none\"}");
+ adminClient.changePluginStatus("33",formData);
+ WaitDataSync.waitGatewayPluginUse(gatewayClient,"org.apache.shenyu.plugin.logging.kafka");
+
}
@ShenYuScenario(provider = DividePluginCases.class)
From aca9d87fc48854f274e9287c5902b7cb36fd2e99 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sat, 31 Aug 2024 17:04:20 +0800
Subject: [PATCH 02/16] [type:feat]add kafka logging e2e test
---
.../k8s/{shenu-kafka.yml => shenyu-kafka.yml} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/{shenu-kafka.yml => shenyu-kafka.yml} (100%)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
similarity index 100%
rename from shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenu-kafka.yml
rename to shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
From 8513fe1b5ac53e4f7379c9adc30e0668512d116f Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 10:58:39 +0800
Subject: [PATCH 03/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/admin/config/ClusterConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
index bcb7b1b982b7..817f193233a9 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
@@ -72,7 +72,7 @@ public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMast
* Shenyu cluster forward filter.
*
* @param clusterProperties cluster properties
- * @return the Shenyu cluster forward filter
+ * @return the Shenyu cluster forward filter.
*/
@Bean
public ClusterForwardFilter clusterForwardFilter(final ClusterProperties clusterProperties) {
From 1d21de716408702e85cf1ea02d91f03c9c09906e Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 12:44:54 +0800
Subject: [PATCH 04/16] [type:feat]add kafka logging e2e test
---
.../shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
index 15e2eb414a4b..e448ffb5ff88 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
@@ -87,6 +87,7 @@ metadata:
labels:
app: kafka
spec:
+ type: NodePort
ports:
- port: 9092
name: client
From c696c6c1cb6d594d9f0b2897b2a3f28cbe1603c3 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 15:02:28 +0800
Subject: [PATCH 05/16] [type:feat]add kafka logging e2e test
---
.../shenyu-e2e-case-http/k8s/shenyu-kafka.yml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
index e448ffb5ff88..3e973beed141 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
@@ -37,6 +37,7 @@ spec:
ports:
- containerPort: 2181
+---
apiVersion: v1
kind: Service
metadata:
@@ -51,6 +52,7 @@ spec:
selector:
app: zookeeper
+---
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -79,6 +81,7 @@ spec:
ports:
- containerPort: 9092
+---
apiVersion: v1
kind: Service
metadata:
@@ -94,6 +97,5 @@ spec:
protocol: TCP
targetPort: 9092
nodePort: 31877
-
selector:
- app: kafka
+ app: kafka
\ No newline at end of file
From 1f63829664aefbdc85b8728e3bbb8e7a382cf096 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 16:06:30 +0800
Subject: [PATCH 06/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/admin/config/ClusterConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
index 817f193233a9..bcb7b1b982b7 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
@@ -72,7 +72,7 @@ public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMast
* Shenyu cluster forward filter.
*
* @param clusterProperties cluster properties
- * @return the Shenyu cluster forward filter.
+ * @return the Shenyu cluster forward filter
*/
@Bean
public ClusterForwardFilter clusterForwardFilter(final ClusterProperties clusterProperties) {
From e8a2bd4c919d81ce8830e70f7095bdc3d85e0867 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 20:21:52 +0800
Subject: [PATCH 07/16] [type:feat]add kafka logging e2e test
---
.../shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
index 3e973beed141..93dd777c2353 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
@@ -33,7 +33,7 @@ spec:
spec:
containers:
- name: zookeeper
- image: wurstmeister/zookeeper:3.4.6
+ image: zookeeper:3.7
ports:
- containerPort: 2181
From 4a5252c7eca3053120da0f83c341e7a351132b3c Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 1 Sep 2024 20:41:06 +0800
Subject: [PATCH 08/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/admin/config/ClusterConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
index bcb7b1b982b7..817f193233a9 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
@@ -72,7 +72,7 @@ public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMast
* Shenyu cluster forward filter.
*
* @param clusterProperties cluster properties
- * @return the Shenyu cluster forward filter
+ * @return the Shenyu cluster forward filter.
*/
@Bean
public ClusterForwardFilter clusterForwardFilter(final ClusterProperties clusterProperties) {
From 9b077b0e2e2ad10629c5d4bc1d7b3b4c6d15a45f Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Mon, 2 Sep 2024 21:31:24 +0800
Subject: [PATCH 09/16] [type:feat]add kafka logging e2e test
---
.../shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
index 93dd777c2353..0d95d1759997 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/k8s/shenyu-kafka.yml
@@ -72,7 +72,7 @@ spec:
spec:
containers:
- name: kafka
- image: wurstmeister/kafka:2.12-2.1.1
+ image: bitnami/kafka:3.6.2
env:
- name: KAFKA_ADVERTISED_LISTENERS
value: PLAINTEXT://kafka:9092
From 507862046313de19bdaaf50c635f20ac9cd5610b Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Mon, 2 Sep 2024 21:54:01 +0800
Subject: [PATCH 10/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/admin/config/ClusterConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
index 817f193233a9..bcb7b1b982b7 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
@@ -72,7 +72,7 @@ public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMast
* Shenyu cluster forward filter.
*
* @param clusterProperties cluster properties
- * @return the Shenyu cluster forward filter.
+ * @return the Shenyu cluster forward filter
*/
@Bean
public ClusterForwardFilter clusterForwardFilter(final ClusterProperties clusterProperties) {
From 56b53926b6532698bed7fe18615422e1b2efec81 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Mon, 2 Sep 2024 23:11:26 +0800
Subject: [PATCH 11/16] [type:feat]add kafka logging e2e test
---
.../e2e/testcase/http/DividePluginCases.java | 2 +-
.../shenyu/e2e/testcase/http/DividePluginTest.java | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
index e94fd02c8c16..cbfa68c6680c 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
@@ -84,7 +84,7 @@ private ShenYuScenarioSpec testDivideHello() {
.build();
}
- private ShenYuScenarioSpec testKafkaHello(){
+ private ShenYuScenarioSpec testKafkaHello() {
return ShenYuScenarioSpec.builder()
.name("testKafkaHello")
.beforeEachSpec(
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
index e92df5bf898f..4932854e2a33 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
@@ -111,14 +111,14 @@ void setup(final AdminClient adminClient, final GatewayClient gatewayClient) thr
adminClient.changePluginStatus("29", formData);
WaitDataSync.waitGatewayPluginUse(gatewayClient, "org.apache.shenyu.plugin.logging.rocketmq");
LOG.info("start loggingKafka plugin");
- formData.add("id","33");
- formData.add("name","loggingKafka");
- formData.add("enabled","true");
- formData.add("role","Logging");
- formData.add("sort","180");
+ formData.add("id", "33");
+ formData.add("name", "loggingKafka");
+ formData.add("enabled", "true");
+ formData.add("role", "Logging");
+ formData.add("sort", "180");
formData.add("config","{\"topic\":\"shenyu-access-logging\",\"namesrvAddr\":\"kafka:9092\",\"sampleRate\":\"1\",\"maxResponseBody\":524288,\"maxRequestBody\":524288,\"compressAlg\":\"none\"}");
- adminClient.changePluginStatus("33",formData);
- WaitDataSync.waitGatewayPluginUse(gatewayClient,"org.apache.shenyu.plugin.logging.kafka");
+ adminClient.changePluginStatus("33", formData);
+ WaitDataSync.waitGatewayPluginUse(gatewayClient, "org.apache.shenyu.plugin.logging.kafka");
}
From 779cf79d18349d3f9c5e11075f25ba2def173b04 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Mon, 2 Sep 2024 23:26:44 +0800
Subject: [PATCH 12/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/admin/config/ClusterConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
index bcb7b1b982b7..817f193233a9 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/ClusterConfiguration.java
@@ -72,7 +72,7 @@ public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMast
* Shenyu cluster forward filter.
*
* @param clusterProperties cluster properties
- * @return the Shenyu cluster forward filter
+ * @return the Shenyu cluster forward filter.
*/
@Bean
public ClusterForwardFilter clusterForwardFilter(final ClusterProperties clusterProperties) {
From 93a8952111cd167dfa3ceecd089c25c37efbae67 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 8 Sep 2024 00:16:58 +0800
Subject: [PATCH 13/16] [type:feat]add kafka logging e2e test
---
.../shenyu/e2e/testcase/http/DividePluginCases.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
index cbfa68c6680c..8f0efe9193a5 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
@@ -84,13 +84,13 @@ private ShenYuScenarioSpec testDivideHello() {
.build();
}
- private ShenYuScenarioSpec testKafkaHello() {
+ private ShenYuScenarioSpec testKafkaHello() {
return ShenYuScenarioSpec.builder()
.name("testKafkaHello")
.beforeEachSpec(
ShenYuBeforeEachSpec.builder()
.addSelectorAndRule(
- newSelectorBuilder("selector",Plugin.LOGGING_KAFKA)
+ newSelectorBuilder("selector", Plugin.LOGGING_KAFKA)
.name("2")
.matchMode(MatchMode.OR)
.conditionList(newConditions(Condition.ParamType.URI, Condition.Operator.STARTS_WITH, "/http"))
@@ -116,18 +116,18 @@ private ShenYuScenarioSpec testKafkaHello() {
StringDeserializer.class.getName());
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
StringDeserializer.class.getName());
- props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,
- "127.0.0.1:31877");
+ props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG
+ ,"127.0.0.1:31877");
KafkaConsumer consumer = new KafkaConsumer<>(props);
consumer.subscribe(Arrays.asList(TOPIC));
AtomicReference keepCosuming = new AtomicReference<>(true);
Instant start = Instant.now();
- while(keepCosuming.get()){
+ while (keepCosuming.get()) {
if (Duration.between(start, Instant.now()).toMillis() > 60000) {
keepCosuming.set(false);
}
ConsumerRecords records = consumer.poll(Duration.ofMillis(1000));
- records.forEach(record ->{
+ records.forEach(record -> {
String message = record.value();
if (message.contains("/http/order/findById?id=23")) {
isLog.set(true);
From 744ddf9576be7bfee491e243d37954fcf1a8c091 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 8 Sep 2024 20:23:51 +0800
Subject: [PATCH 14/16] [type:feat]add kafka logging e2e test
---
.../main/java/org/apache/shenyu/admin/ShenyuAdminBootstrap.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/ShenyuAdminBootstrap.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/ShenyuAdminBootstrap.java
index 9bd5026202c7..88bc0ddcd0eb 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/ShenyuAdminBootstrap.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/ShenyuAdminBootstrap.java
@@ -30,7 +30,7 @@ public class ShenyuAdminBootstrap {
/**
* Main entrance.
*
- * @param args startup arguments
+ * @param args startup arguments.
*/
public static void main(final String[] args) {
SpringApplication.run(ShenyuAdminBootstrap.class, args);
From 0c265de800c6a1d8d8d1913002710f82d2ef3853 Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Sun, 15 Sep 2024 13:13:37 +0800
Subject: [PATCH 15/16] [type:feat]add kafka logging e2e test
---
.../apache/shenyu/e2e/testcase/http/DividePluginCases.java | 6 +++---
.../apache/shenyu/e2e/testcase/http/DividePluginTest.java | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
index 8f0efe9193a5..518cb72b5236 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginCases.java
@@ -68,7 +68,8 @@ public class DividePluginCases implements ShenYuScenarioProvider {
public List get() {
return Lists.newArrayList(
testDivideHello(),
- testRocketMQHello()
+ testRocketMQHello(),
+ testKafkaHello()
);
}
@@ -116,8 +117,7 @@ private ShenYuScenarioSpec testKafkaHello() {
StringDeserializer.class.getName());
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
StringDeserializer.class.getName());
- props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG
- ,"127.0.0.1:31877");
+ props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:31877");
KafkaConsumer consumer = new KafkaConsumer<>(props);
consumer.subscribe(Arrays.asList(TOPIC));
AtomicReference keepCosuming = new AtomicReference<>(true);
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
index 4932854e2a33..27ffe43a144c 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
@@ -116,7 +116,8 @@ void setup(final AdminClient adminClient, final GatewayClient gatewayClient) thr
formData.add("enabled", "true");
formData.add("role", "Logging");
formData.add("sort", "180");
- formData.add("config","{\"topic\":\"shenyu-access-logging\",\"namesrvAddr\":\"kafka:9092\",\"sampleRate\":\"1\",\"maxResponseBody\":524288,\"maxRequestBody\":524288,\"compressAlg\":\"none\"}");
+ formData.add("config",
+ "{\"topic\":\"shenyu-access-logging\",\"namesrvAddr\":\"kafka:9092\",\"sampleRate\":\"1\",\"maxResponseBody\":524288,\"maxRequestBody\":524288,\"compressAlg\":\"none\"}");
adminClient.changePluginStatus("33", formData);
WaitDataSync.waitGatewayPluginUse(gatewayClient, "org.apache.shenyu.plugin.logging.kafka");
From 3b005734d3ad9be84456ecb2f8800478c3b0264b Mon Sep 17 00:00:00 2001
From: huk <2509913103@qq.com>
Date: Tue, 17 Sep 2024 20:53:14 +0800
Subject: [PATCH 16/16] [type:feat]add kafka logging e2e test
---
.../org/apache/shenyu/e2e/testcase/http/DividePluginTest.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
index 27ffe43a144c..97cf90a25a8f 100644
--- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
+++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-http/src/test/java/org/apache/shenyu/e2e/testcase/http/DividePluginTest.java
@@ -109,6 +109,7 @@ void setup(final AdminClient adminClient, final GatewayClient gatewayClient) thr
formData.add("sort", "170");
formData.add("config", "{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"rocketmq-dialevoneid:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}");
adminClient.changePluginStatus("29", formData);
+ formData = new LinkedMultiValueMap<>();
WaitDataSync.waitGatewayPluginUse(gatewayClient, "org.apache.shenyu.plugin.logging.rocketmq");
LOG.info("start loggingKafka plugin");
formData.add("id", "33");