-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: lilai <[email protected]>
- Loading branch information
Showing
13 changed files
with
1,027 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: "Common operations" | ||
description: "do something common for mq-consume-prohibition plugin test" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up JDK ${{ env.javaVersion }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ env.javaVersion }} | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: get zookeeper from cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: apache-zookeeper-3.6.3-bin.tar.gz | ||
key: ${{ runner.os }}-apache-zookeeper-3.6.3 | ||
- name: run zookeeper | ||
shell: bash | ||
run: | | ||
tar -zxf apache-zookeeper-3.6.3-bin.tar.gz | ||
bash apache-zookeeper-3.6.3-bin/bin/zkServer.sh start apache-zookeeper-3.6.3-bin/conf/zoo_sample.cfg | ||
- name: cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: cache agent | ||
uses: actions/cache@v3 | ||
with: | ||
path: sermant-agent-*/ | ||
key: ${{ runner.os }}-agent-${{ github.run_id }} | ||
- name: entry | ||
uses: ./.github/actions/common/entry | ||
with: | ||
log-dir: ./logs/mq-consume-prohibition/common |
66 changes: 66 additions & 0 deletions
66
.github/actions/scenarios/mq-consume-prohibition/kafka/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: "Mq-consume-prohibition Plugin kafka Test" | ||
description: "Auto test for mq-consume-prohibition by kafka" | ||
runs: | ||
using: composite | ||
steps: | ||
- name: entry | ||
uses: ./.github/actions/common/entry | ||
with: | ||
log-dir: ./logs/mq-consume-prohibition/kafka | ||
- name: get kafka from cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: kafka_2.13-2.7.0.tgz | ||
key: ${{ runner.os }}-kafka_2.13-2.7.0 | ||
restore-keys: | | ||
${{ runner.os }}-kafka_2.13-2.7.0 | ||
- name: start kafka | ||
shell: bash | ||
run: | | ||
tar -zxf kafka_2.13-2.7.0.tgz | ||
nohup bash kafka_2.13-2.7.0/bin/kafka-server-start.sh kafka_2.13-2.7.0/config/server.properties & | ||
- name: package demo | ||
shell: bash | ||
run: | | ||
mvn package -Dkafka-client.version=${{ matrix.kafkaVersion }} -DskipTests -Pkafka-consumer-test --file \ | ||
sermant-integration-tests/mq-consume-prohibition-test/pom.xml | ||
- name: start first kafka consumer demo | ||
shell: bash | ||
run: | | ||
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \ | ||
-Dsermant_log_dir=${{ env.logDir }}/kafka-consumer -Dservice_meta_zone=hangzhou -Dserver.port=7070 \ | ||
-Dclient_id=test-client-1 \ | ||
sermant-integration-tests/mq-consume-prohibition-test/kafka-consumer-demo/target/kafka-consumer-demo.jar > ${{ env.logDir }}/kafka-consumer-1.log 2>&1 & | ||
- name: start second kafka consumer demo | ||
shell: bash | ||
run: | | ||
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \ | ||
-Dsermant_log_dir=${{ env.logDir }}/kafka-consumer -Dservice_meta_zone=shanghai -Dserver.port=7071 \ | ||
-Dclient_id=test-client-2 \ | ||
sermant-integration-tests/mq-consume-prohibition-test/kafka-consumer-demo/target/kafka-consumer-demo.jar > ${{ env.logDir }}/kafka-consumer-2.log 2>&1 & | ||
- name: waiting for services start | ||
shell: bash | ||
run: | | ||
ps -ef | grep java | ||
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:7070/healthCheck 120 | ||
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:7071/healthCheck 120 | ||
- name: test kafka | ||
shell: bash | ||
run: | | ||
mvn test -Dmq.consume.prohibition.test.type=KAFKA --file \ | ||
sermant-integration-tests/mq-consume-prohibition-test/mq-consume-prohibition-integration-test/pom.xml | ||
- name: exit | ||
if: always() | ||
uses: ./.github/actions/common/exit | ||
with: | ||
processor-keyword: mq-consume-prohibition|kafka | ||
- name: if failure then upload error log | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ failure() || cancelled() }} | ||
with: | ||
name: (${{ github.job }})-mq-consume-prohibition-kafka-(${{ matrix.kafkaVersion }}-logs | ||
path: | | ||
./*.log | ||
./logs/** | ||
if-no-files-found: warn | ||
retention-days: 2 |
114 changes: 114 additions & 0 deletions
114
.github/workflows/mq_consume_prohibition_integration_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: mq-consume-prohibition integration test | ||
env: | ||
sermantVersion: 1.0.0 | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- '*' | ||
paths: | ||
- 'sermant-agentcore/**' | ||
- 'sermant-integration-tests/mq-consume-prohibition-test/**' | ||
- 'sermant-plugins/sermant-mq-consume-prohibition/**' | ||
- '.github/workflows/mq-consume-prohibition_integration_test.yml' | ||
- '.github/actions/scenarios/mq-consume-prohibition/**' | ||
- '.github/actions/common/mq-consume-prohibition/**' | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
download-midwares-and-cache: | ||
name: download midwares and cache | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: cache zookeeper | ||
uses: actions/cache@v3 | ||
with: | ||
path: apache-zookeeper-3.6.3-bin.tar.gz | ||
key: ${{ runner.os }}-apache-zookeeper-3.6.3 | ||
restore-keys: | | ||
${{ runner.os }}-apache-zookeeper-3.6.3 | ||
- name: download zookeeper | ||
run: | | ||
export ROOT_PATH=$(pwd) | ||
bash ./sermant-integration-tests/scripts/tryDownloadMidware.sh zk | ||
- name: cache rocketmq | ||
uses: actions/cache@v3 | ||
with: | ||
path: rocketmq-all-4.8.0-bin-release.zip | ||
key: ${{ runner.os }}-rocketmq-all-4.8.0-bin-release | ||
restore-keys: | | ||
${{ runner.os }}-rocketmq-all-4.8.0-bin-release | ||
- name: download rocketmq | ||
run: | | ||
export ROOT_PATH=$(pwd) | ||
bash ./sermant-integration-tests/scripts/tryDownloadMidware.sh rocketmq | ||
- name: cache kafka | ||
uses: actions/cache@v3 | ||
with: | ||
path: kafka_2.13-2.7.0.tgz | ||
key: ${{ runner.os }}-kafka_2.13-2.7.0 | ||
restore-keys: | | ||
${{ runner.os }}-kafka_2.13-2.7.0 | ||
- name: download kafka | ||
run: | | ||
export ROOT_PATH=$(pwd) | ||
bash ./sermant-integration-tests/scripts/tryDownloadMidware.sh kafka | ||
build-agent-and-cache: | ||
name: build agent and cache | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: cache agent | ||
uses: actions/cache@v3 | ||
with: | ||
path: sermant-agent-*/ | ||
key: ${{ runner.os }}-agent-${{ github.run_id }} | ||
- name: package agent | ||
run: | | ||
sed -i '/sermant-backend/d' pom.xml | ||
sed -i '/sermant-integration-tests/d' pom.xml | ||
sed -i '/sermant-injector/d' pom.xml | ||
mvn package -DskipTests -Ptest --file pom.xml | ||
test-for-mq-consume-prohibition-kafka: | ||
name: Test for mq-consume-prohibition kafka | ||
runs-on: ubuntu-latest | ||
needs: [build-agent-and-cache, download-midwares-and-cache] | ||
strategy: | ||
matrix: | ||
include: | ||
- kafkaVersion: "2.0.1" | ||
- kafkaVersion: "2.1.1" | ||
- kafkaVersion: "2.2.2" | ||
- kafkaVersion: "2.3.1" | ||
- kafkaVersion: "2.4.0" | ||
- kafkaVersion: "2.5.1" | ||
- kafkaVersion: "2.6.3" | ||
- kafkaVersion: "2.7.2" | ||
- kafkaVersion: "2.8.2" | ||
- kafkaVersion: "3.0.2" | ||
- kafkaVersion: "3.1.2" | ||
- kafkaVersion: "3.2.2" | ||
- kafkaVersion: "3.3.2" | ||
- kafkaVersion: "3.4.1" | ||
- kafkaVersion: "3.5.2" | ||
- kafkaVersion: "3.6.1" | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 100 | ||
- name: set java version to environment | ||
run: | | ||
echo "javaVersion=8" >> $GITHUB_ENV | ||
- name: common operations | ||
uses: ./.github/actions/common/mq-consume-prohibition | ||
- name: mq-consume-prohibition test for kafkaVersion=${{ matrix.kafkaVersion }} | ||
uses: ./.github/actions/scenarios/mq-consume-prohibition/kafka |
42 changes: 42 additions & 0 deletions
42
sermant-integration-tests/mq-consume-prohibition-test/kafka-consumer-demo/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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>mq-consume-prohibition-test</artifactId> | ||
<groupId>com.huaweicloud.sermant</groupId> | ||
<version>1.0.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>kafka-consumer-demo</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<kafka-client.version>2.7.0</kafka-client.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.kafka</groupId> | ||
<artifactId>kafka-clients</artifactId> | ||
<version>${kafka-client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
38 changes: 38 additions & 0 deletions
38
...main/java/com/huaweicloud/sermant/test/mq/prohibition/kafka/KafkaConsumerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. 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 com.huaweicloud.sermant.test.mq.prohibition.kafka; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* KafkaConsumer demo启动类 | ||
* | ||
* @author lilai | ||
* @since 2024-01-09 | ||
**/ | ||
@SpringBootApplication | ||
public class KafkaConsumerApplication { | ||
/** | ||
* 启动类 | ||
* | ||
* @param args 进程启动入参 | ||
*/ | ||
public static void main(String[] args) { | ||
SpringApplication.run(KafkaConsumerApplication.class, args); | ||
} | ||
} |
Oops, something went wrong.