This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 13da2ebff [type:feat] Add Logging-Pulsar integrated test (#4004)
13da2ebff is described below
commit 13da2ebffedd80bd6eaeeb9f4d85037130ed269a
Author: Bowen Li <[email protected]>
AuthorDate: Fri Sep 30 15:51:47 2022 +0800
[type:feat] Add Logging-Pulsar integrated test (#4004)
* add pulsar integrated test
* add pulsar integtaed test
* fix checkstyle
* typo
* Update docker-compose.yml
* add pulsar command
---
.../shenyu-integrated-test-http/docker-compose.yml | 13 ++++
.../shenyu-integrated-test-http/pom.xml | 8 +++
.../http/combination/LoggingPulsarPluginTest.java | 80 ++++++++++++++++++++++
3 files changed, 101 insertions(+)
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-http/docker-compose.yml
b/shenyu-integrated-test/shenyu-integrated-test-http/docker-compose.yml
index d2636fb6c..6811af8f2 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-http/docker-compose.yml
+++ b/shenyu-integrated-test/shenyu-integrated-test-http/docker-compose.yml
@@ -147,6 +147,19 @@ services:
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
+ shenyu-pulsar:
+ image: apachepulsar/pulsar:2.10.1
+ container_name: shenyu-pulsar
+ restart: always
+ command: bin/pulsar standalone
+ depends_on:
+ shenyu-integrated-test-http:
+ condition: service_healthy
+ networks:
+ - shenyu
+ ports:
+ - "6650:6650"
+
shenyu-rocketmq:
image: apache/rocketmq:4.9.3
container_name: shenyu-rocketmq
diff --git a/shenyu-integrated-test/shenyu-integrated-test-http/pom.xml
b/shenyu-integrated-test/shenyu-integrated-test-http/pom.xml
index eae716a82..f78e430a6 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-http/pom.xml
+++ b/shenyu-integrated-test/shenyu-integrated-test-http/pom.xml
@@ -194,6 +194,14 @@
</dependency>
<!--shenyu logging-kafka plugin end-->
+ <!-- shenyu logging-pulsar plugin start -->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-plugin-logging-pulsar</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu logging-pulsar plugin end -->
+
<!--shenyu logging-elasticsearch plugin start-->
<dependency>
<groupId>org.apache.shenyu</groupId>
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/LoggingPulsarPluginTest.java
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/LoggingPulsarPluginTest.java
new file mode 100644
index 000000000..2aa4c5a7b
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/LoggingPulsarPluginTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.integrated.test.http.combination;
+
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.pulsar.client.PulsarLogCollectClient;
+import org.apache.shenyu.plugin.logging.pulsar.config.PulsarLogCollectConfig;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+public final class LoggingPulsarPluginTest extends AbstractPluginDataInit {
+
+ private final PulsarLogCollectClient pulsarLogCollectClient = new
PulsarLogCollectClient();
+
+ private final PluginData pluginData = new PluginData();
+
+ private final List<ShenyuRequestLog> logs = new ArrayList<>();
+
+ private final ShenyuRequestLog shenyuRequestLog = new ShenyuRequestLog();
+
+ @BeforeEach
+ public void setup() throws IOException {
+ String pluginResult = initPlugin(PluginEnum.LOGGING_PULSAR.getName(),
+ "{\"topic\":\"pulsar-test\",
\"serviceUrl\":\"pulsar://shenyu-pulsar:6650\"}");
+ assertThat(pluginResult, is("success"));
+ }
+
+ @Test
+ public void testPass() {
+ final PulsarLogCollectConfig.PulsarLogConfig pulsarLogConfig =
GsonUtils.getInstance().fromJson(pluginData.getConfig(),
PulsarLogCollectConfig.PulsarLogConfig.class);
+
+ shenyuRequestLog.setClientIp("0.0.0.0");
+ shenyuRequestLog.setPath("org/apache/shenyu/plugin/logging");
+ logs.add(shenyuRequestLog);
+
+ String msg = "";
+ PulsarLogCollectConfig.INSTANCE.setPulsarLogConfig(pulsarLogConfig);
+ pulsarLogCollectClient.initClient(pulsarLogConfig);
+ try {
+ pulsarLogCollectClient.consume(logs);
+ } catch (Exception e) {
+ msg = "false";
+ }
+ Assertions.assertEquals(msg, "");
+ pulsarLogCollectClient.close();
+ }
+
+ @AfterAll
+ public static void clean() throws IOException {
+ cleanPluginData(PluginEnum.LOGGING_PULSAR.getName());
+ }
+}