Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/actions/common/plugin-change-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,27 @@ runs:
shell: bash
run: |
echo "rocketmqTagTransmissionChanged=${{ steps.changed-tag-transmission-rocketmq.outputs.changed }}" >> $GITHUB_ENV
- uses: ktamas77/has-changed-path@v1.0.3
id: changed-tag-transmission-rabbitmq
with:
paths: sermant-plugins/sermant-tag-transmission/tag-transmission-common
sermant-plugins/sermant-tag-transmission/tag-transmission-crossthread-plugin
sermant-plugins/sermant-tag-transmission/tag-transmission-service
sermant-plugins/sermant-tag-transmission/tag-transmission-rabbitmq5.x-plugin
sermant-plugins/sermant-tag-transmission/config
sermant-integration-tests/tag-transmission-test/tag-transmission-integration-test
sermant-integration-tests/tag-transmission-test/tag-transmission-util-demo
sermant-integration-tests/tag-transmission-test/rabbitmq-consumer-demo
sermant-integration-tests/tag-transmission-test/rabbitmq-producer-demo
sermant-integration-tests/tag-transmission-test/midware-common-demo
sermant-integration-tests/tag-transmission-test/httpserver-common-demo
./.github/workflows/tagtransmission_integration_test.yml
./.github/actions/common/tag-transmission
./.github/actions/scenarios/tag-transmission/rabbitmq
- name: env tag-transmission-rabbitmq
shell: bash
run: |
echo "rabbitMqTagTransmissionChanged=${{ steps.changed-tag-transmission-rabbitmq.outputs.changed }}" >> $GITHUB_ENV
- uses: ktamas77/has-changed-path@v1.0.3
id: changed-tag-transmission-servicecomb
with:
Expand Down Expand Up @@ -1027,3 +1048,10 @@ runs:
${{ env.sermantFlowcontrolChanged }} == 'true'];then
echo "enableXdsFlowControl=true" >> $GITHUB_ENV
fi

# ==========rabbit mq Tag Transmission is needed to test?==========
if [ ${{ env.rabbitMqTagTransmissionChanged }} == 'true' -o \
${{ env.sermantAgentCoreChanged }} == 'true' -o \
${{ steps.changed-common-action.outputs.changed }} == 'true' -o ${{ env.triggerPushEvent }} == 'true' ];then
echo "enableRabbitMqTagTransmissionAction=true" >> $GITHUB_ENV
fi
70 changes: 70 additions & 0 deletions .github/actions/scenarios/tag-transmission/rabbitmq/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Tag Transmission Plugin RabbitMQ Test"
description: "Auto test for tag transmission by rabbit mq"
runs:
using: composite
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/tag-transmission/rabbitmq
- name: install rabbit mq
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
docker run -d --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4-management
- name: package demos
shell: bash
run: |
mvn package -Drabbitmq-client.version=${{ matrix.rabbitmqVersion }} -DskipTests -Prabbitmq-test --file \
sermant-integration-tests/tag-transmission-test/pom.xml
- name: start rabbitmq producer demo
shell: bash
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
-Dsermant_log_dir=${{ env.logDir }}/sermant \
sermant-integration-tests/tag-transmission-test/rabbitmq-producer-demo/target/rabbitmq-producer-demo.jar > ${{ env.logDir }}/rabbitmq-producer.log 2>&1 &
- name: start rabbitmq consumer demo
shell: bash
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
-Dsermant_log_dir=${{ env.logDir }}/sermant \
sermant-integration-tests/tag-transmission-test/rabbitmq-consumer-demo/target/rabbitmq-consumer-demo.jar > ${{ env.logDir }}/rabbitmq-consumer.log 2>&1 &
- name: waiting for services start
shell: bash
run: |
docker ps | grep rabbit
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:15672 120
ps -ef | grep java
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:9040/common/httpServer 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:9057/rabbitMqProducer/checkRabbitMqProducerStatus 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:9056/rabbitMqConsumer/queryRabbitMqTag 120
- name: test rabbitmq
shell: bash
run: |
mvn test -Dtag.transmission.integration.test.type=RABBITMQ --file \
sermant-integration-tests/tag-transmission-test/tag-transmission-integration-test/pom.xml
- name: test rabbitmq consecutive messages
shell: bash
run: |
mvn test -Dtag.transmission.integration.test.type=RABBITMQ-CONSECUTIVE-MESSAGE --file \
sermant-integration-tests/tag-transmission-test/tag-transmission-integration-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
with:
processor-keyword: httpserver-common
- name: if failure then upload error log
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: (${{ github.job }})-tag-transmission-rabbitmq-(${{ matrix.rabbitMqVersion }}-logs
path: |
./*.log
./logs/**
if-no-files-found: warn
retention-days: 2
27 changes: 27 additions & 0 deletions .github/workflows/tagtransmission_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
echo "enableJettyTagTransmissionAction=${{env.enableJettyTagTransmissionAction}}" >> $GITHUB_OUTPUT
echo "enableTomcatTagTransmissionAction=${{env.enableTomcatTagTransmissionAction}}" >> $GITHUB_OUTPUT
echo "enableJakartaServlet56TagTransmissionAction=${{env.enableJakartaServlet56TagTransmissionAction}}" >> $GITHUB_OUTPUT
echo "enableRabbitMqTagTransmissionAction=${{env.enableRabbitMqTagTransmissionAction}}" >> $GITHUB_OUTPUT
outputs:
enableHttpclientV3TagTransmissionAction: ${{ steps.set-outputs.outputs.enableHttpclientV3TagTransmissionAction }}
enableHttpclientV4TagTransmissionAction: ${{ steps.set-outputs.outputs.enableHttpclientV4TagTransmissionAction }}
Expand All @@ -65,6 +66,7 @@ jobs:
enableJettyTagTransmissionAction: ${{ steps.set-outputs.outputs.enableJettyTagTransmissionAction }}
enableTomcatTagTransmissionAction: ${{ steps.set-outputs.outputs.enableTomcatTagTransmissionAction }}
enableJakartaServlet56TagTransmissionAction: ${{ steps.set-outputs.outputs.enableJakartaServlet56TagTransmissionAction }}
enableRabbitMqTagTransmissionAction: ${{ steps.set-outputs.outputs.enableRabbitMqTagTransmissionAction }}
download-midwares-and-cache:
name: download midwares and cache
runs-on: ubuntu-latest
Expand Down Expand Up @@ -611,3 +613,28 @@ jobs:
uses: ./.github/actions/common/tag-transmission
- name: tag transmission test for jakarta-servlet-java8
uses: ./.github/actions/scenarios/tag-transmission/jakarta-servlet-java8
test-for-tag-transmission-rabbitmq:
name: Test for tag transmission rabbitmq
runs-on: ubuntu-latest
if: needs.set-execution-conditions.outputs.enableRabbitMqTagTransmissionAction=='true'
needs: [set-execution-conditions, build-agent-and-cache, download-midwares-and-cache]
strategy:
matrix:
include:
- rabbitMqVersion: "5.25.0"
- rabbitMqVersion: "5.21.0"
- rabbitMqVersion: "5.16.0"
- rabbitMqVersion: "5.9.0"
- rabbitMqVersion: "5.0.0"
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/tag-transmission
- name: tag transmission test for rabbitMqVersion=${{ matrix.rabbitMqVersion }}
uses: ./.github/actions/scenarios/tag-transmission/rabbitmq
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ node_modules/
node/
sermant-integration-tests/tag-transmission-test/grpc-api-demo/src/main/java/io/sermant/demo/tagtransmission/grpc/api
sermant-*.tar.gz

# os
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,16 @@ private CollectionUtils() {
public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
}

/**
* Get the first element of the collection
*
* @param collection collection
* @param <T> type
* @param orElse when the collection is null or empty, return this
* @return first element of the collection, or orElse if the collection is null or empty
*/
public static <T> T getFirst(Collection<T> collection, T orElse) {
return isEmpty(collection) ? orElse : collection.iterator().next();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,15 @@ public static String trim(String target) {
public static String getString(Object object) {
return object == null ? "" : object.toString();
}

/**
* Get the object's toString information
*
* @param object object
* @param defaultValue default value
* @return string if object is null, default value otherwise
*/
public static String getString(Object object, String defaultValue) {
return object == null ? defaultValue : object.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2025-2025 Sermant Authors. All rights reserved.
*
* Licensed 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 io.sermant.core.utils;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* Test for CollectionUtils
*
* @since 2025-07-05
*/
public class CollectionUtilsTest {

@Test
public void testGetFirst_whenCollectionIsEmpty() {
List<String> emptyCollection = Collections.emptyList();
String result = CollectionUtils.getFirst(emptyCollection, "default");
Assertions.assertEquals("default", result);
}

@Test
public void testGetFirst_whenCollectionIsNotEmpty() {
List<String> collection = Arrays.asList("apple", "banana", "cherry");
String result = CollectionUtils.getFirst(collection, "default");
Assertions.assertEquals("apple", result);
}

@Test
public void testGetFirst_whenCollectionIsNull() {
List<String> nullCollection = null;
String result = CollectionUtils.getFirst(nullCollection, "default");
Assertions.assertEquals("default", result);
}

@Test
public void testGetFirst_whenCollectionHasMultipleElements() {
List<Integer> collection = Arrays.asList(10, 20, 30);
Integer result = CollectionUtils.getFirst(collection, 0);
Assertions.assertEquals(10, result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2025-2025 Sermant Authors. All rights reserved.
*
* Licensed 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 io.sermant.core.utils;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Test for StringUtils
*
* @since 2025-07-28
*/
class StringUtilsTest {
@Test
public void testGetString() {
assertEquals("default", StringUtils.getString(null, "default"));
assertEquals("test", StringUtils.getString("test", ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public class MessageConstant {
*/
public static final int KAFKA_CONSUMER_TIMEOUT = 100;

/**
* rabbitmq message body
*/
public static final String MESSAGE_BODY_RABBITMQ = "hello inner rabbitmq:";

private MessageConstant() {
}
}
10 changes: 10 additions & 0 deletions sermant-integration-tests/tag-transmission-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<alibaba.dubbo.version>2.6.12</alibaba.dubbo.version>
<grpc.version>1.52.1</grpc.version>
<protobuf.version>3.21.7</protobuf.version>
<rabbitmq-client.version>5.20.0</rabbitmq-client.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -119,6 +120,15 @@
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>rabbitmq-test</id>
<modules>
<module>rabbitmq-consumer-demo</module>
<module>rabbitmq-producer-demo</module>
<module>midware-common-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>kafka-test</id>
<modules>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>tag-transmission-test</artifactId>
<groupId>io.sermant.tagtransmission</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>rabbitmq-consumer-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>io.sermant.tagtransmission</groupId>
<artifactId>midware-common-demo</artifactId>
</dependency>
<dependency>
<groupId>io.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-util-demo</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${rabbitmq-client.version}</version>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Loading
Loading