-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish rocketmq cpp 4.x test(client cluster filter server pull) (#50)
* finish rocketmq cpp 4.x test(client cluster filter server pull) * Add comments and modify the incorrect method name in the incorrect PullOrderTest * Improved the test content, adding the test content of batchproducer, transactions, offset, retry and other scenarios * Add the use of sockets to connect to rocketmq server during startup and detect whether the server starts normally. Added broadcast and offset tests. Formatted code
- Loading branch information
Showing
87 changed files
with
7,862 additions
and
0 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,88 @@ | ||
#!/bin/sh | ||
|
||
# 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. | ||
|
||
# Detection distribution | ||
if [ -f /etc/os-release ]; then | ||
. /etc/os-release | ||
DISTRO=$ID | ||
elif [ -f /etc/lsb-release ]; then | ||
. /etc/lsb-release | ||
DISTRO=$DISTRIB_ID | ||
elif [ -f /etc/debian_version ]; then | ||
DISTRO="Debian" | ||
else | ||
DISTRO=$(uname -s) | ||
fi | ||
|
||
DISTRO_LOWER=$(echo "$DISTRO" | tr '[:upper:]' '[:lower:]') | ||
|
||
# Select the package manager and install commands based on your distribution | ||
if [ "$DISTRO_LOWER" == "ubuntu" ] || [ "$DISTRO_LOWER" == "debian" ]; then | ||
PACKAGE_MANAGER="apt-get" | ||
INSTALL_COMMAND="sudo $PACKAGE_MANAGER install -y" | ||
$INSTALL_COMMAND libssl-dev libboost-all-dev libspdlog-dev libgtest-dev libfmt-dev libbz2-dev zlib1g-dev libc6-dev libpthread-stubs0-dev cmake automake g++ autoconf libtool | ||
elif [ "$DISTRO_LOWER" == "fedora" ] || [ "$DISTRO_LOWER" == "centos" ] || [ "$DISTRO_LOWER" == "rhel" ]; then | ||
PACKAGE_MANAGER="dnf" | ||
INSTALL_COMMAND="sudo $PACKAGE_MANAGER install -y" | ||
$INSTALL_COMMAND openssl-devel boost-devel spdlog-devel gtest-devel fmt-devel bzip2-devel zlib-devel glibc-devel libpthread-stubs cmake automake g++ autoconf libtool | ||
elif [ "$DISTRO_LOWER" == "arch" ] || [ "$DISTRO_LOWER" == "manjaro" ]; then | ||
PACKAGE_MANAGER="pacman" | ||
INSTALL_COMMAND="sudo $PACKAGE_MANAGER -S --noconfirm" | ||
$INSTALL_COMMAND openssl boost spdlog gtest fmt bzip2 zlib glibc libpthread-stubs cmake automake gcc autoconf libtool | ||
else | ||
echo "Unrecognized distribution: $DISTRO" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "rocketmq-client-cpp-2.1.0" ]; then | ||
echo "rocketmq-client-cpp-2.1.0 folder does not exist, start to download and decompress..." | ||
curl -LO https://github.com/apache/rocketmq-client-cpp/archive/refs/tags/2.1.0.zip | ||
unzip 2.1.0.zip | ||
rm 2.1.0.zip | ||
echo "rocketmq-client-cpp-2.1.0 Download and decompress complete." | ||
cd rocketmq-client-cpp-2.1.0 | ||
bash build.sh | ||
cd .. | ||
fi | ||
|
||
if [ ! -d "rocketmq-client-cpp-2.1.0/tmp_build_dir" ]; then | ||
if [ ! -f "rocketmq-client-cpp-2.1.0/tmp_build_dir/librocketmq.a" ]; then | ||
echo "librocketmq.a file does not exist, start to build..." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [ ! -d "rocketmq-client-cpp-2.1.0/tmp_include_dir" ]; then | ||
mkdir -p rocketmq-client-cpp-2.1.0/tmp_include_dir/rocketmq | ||
cp -r rocketmq-client-cpp-2.1.0/include/* rocketmq-client-cpp-2.1.0/tmp_include_dir/rocketmq | ||
fi | ||
|
||
#设置环境变量ROCKETMQ_CPP_LIB为 pwd+/rocketmq-client-cpp-2.1.0/tmp_build_dir/librocketmq.a | ||
export ROCKETMQ_CPP_LIB=$(pwd)/rocketmq-client-cpp-2.1.0/tmp_build_dir | ||
#设置环境变量ROCKETMQ_CPP_INC为 pwd+/rocketmq-client-cpp-2.1.0/include | ||
export ROCKETMQ_CPP_INC=$(pwd)/rocketmq-client-cpp-2.1.0/tmp_include_dir | ||
|
||
echo "Installation complete!" | ||
# cd project base dir to compile mqadmin utils for other language e2e test using | ||
cd ../common && mvn -Prelease -DskipTests clean package -U | ||
# set env for mqadmin (use source to set linux env variables in current shell) | ||
cd ../rocketmq-admintools && source bin/env.sh | ||
# run cpp e2e test case | ||
cd ../cpp/rocketmq-client-cpp-tests/cpp4.x | ||
cmake . -B build && cd build | ||
make -j && cd .. | ||
./rocketmq_test |
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,6 @@ | ||
cpp4.x/rocketmq_test | ||
cpp4.x/build | ||
cpp4.x/.cache | ||
cpp4.x/logs | ||
nohup.out | ||
cpp5.x |
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,65 @@ | ||
# 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. | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(rocketmq_test) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_CXX_COMPILE "g++") | ||
set(CMAKE_BUILD_TYPE "Release") | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
||
find_package(GTest REQUIRED) | ||
find_package(Threads REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
find_package(spdlog REQUIRED) | ||
find_package(fmt REQUIRED) | ||
find_package(RocketMQ REQUIRED) | ||
find_package(OpenSSL REQUIRED) | ||
|
||
set(SOURCE_FILES "") | ||
add_subdirectory(test) | ||
add_subdirectory(src) | ||
|
||
list(APPEND SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) | ||
|
||
add_executable(${PROJECT_NAME} ${SOURCE_FILES}) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
${GTEST_LIBRARIES} | ||
${RocketMQ_LIBRARIES} | ||
${ZLIB_LIBRARIES} | ||
${CMAKE_THREAD_LIBS_INIT} | ||
spdlog::spdlog | ||
fmt::fmt | ||
dl | ||
rt | ||
frame | ||
utils | ||
enums | ||
factory | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE | ||
${CMAKE_SOURCE_DIR}/include | ||
${ROCKETMQ_INCLUDE_DIR} | ||
/usr/include | ||
/usr/local/include | ||
) |
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,47 @@ | ||
## Apache RocketMQ E2E | ||
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) | ||
|
||
|
||
|
||
### RocketMQ E2E Cpp 4.x Test | ||
The project is a rocketmq 4.x cpp client E2E test project built using CMake, and the following shows how to compile and configure it. | ||
|
||
#### Install dependent library | ||
The project relies on the following libraries, make sure you have them installed: | ||
|
||
* GTest: Used for unit testing. | ||
* Threads: Used for multithreading support. | ||
* ZLIB: Used for compression and decompression support. | ||
* spdlog: Used for logging. | ||
* fmt: Used for format output. | ||
* RocketMQ: Used for interacting with RocketMQ. | ||
|
||
If you already have these libraries installed, CMake will find them automatically. If they are not installed, you can install them by following the steps in the link below: | ||
|
||
* [GTest](https://github.com/google/googletest/blob/main/googletest/README.md) | ||
|
||
* [fmt](https://github.com/fmtlib/fmt) | ||
|
||
* [spdlog](https://github.com/gabime/spdlog) | ||
|
||
* [RocketMQ](https://github.com/apache/rocketmq-client-cpp) | ||
|
||
You can use the following command to help the project find the cmake configuration file to find the installation location of the library if they are installed in a custom directory. | ||
```cmake | ||
list(APPEND CMAKE_MODULE_PATH "custom_directory") | ||
``` | ||
|
||
#### Compile project | ||
To compile the project, follow these steps: | ||
|
||
1. Make sure you have CMake and the required compiler (e.g. g++) installed. | ||
|
||
2. Create a build directory under the project root, such as build. | ||
|
||
3. Go to the build directory and run the following command: | ||
|
||
```shell | ||
cmake .. | ||
make | ||
``` | ||
This will generate the executable file. |
47 changes: 47 additions & 0 deletions
47
cpp/rocketmq-client-cpp-tests/cpp4.x/cmake/FindRocketMQ.cmake
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,47 @@ | ||
# 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. | ||
set(ROCKETMQ_CPP_LIB_PATH $ENV{ROCKETMQ_CPP_LIB}) | ||
set(ROCKETMQ_CPP_INC_PATH $ENV{ROCKETMQ_CPP_INC}) | ||
|
||
find_path(ROCKETMQ_INCLUDE_DIR | ||
NAMES | ||
rocketmq/DefaultMQProducer.h | ||
PATHS | ||
/usr/local/include | ||
/usr/include | ||
${ROCKETMQ_CPP_INC_PATH} | ||
) | ||
|
||
find_library(ROCKETMQ_LIBRARY | ||
NAMES | ||
rocketmq | ||
PATHS | ||
/usr/local/lib | ||
/usr/lib | ||
${ROCKETMQ_CPP_LIB_PATH} | ||
) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(RocketMQ | ||
REQUIRED_VARS | ||
ROCKETMQ_LIBRARY | ||
ROCKETMQ_INCLUDE_DIR | ||
) | ||
|
||
if(RocketMQ_FOUND) | ||
set(RocketMQ_LIBRARIES ${ROCKETMQ_LIBRARY}) | ||
set(RocketMQ_INCLUDE_DIRS ${ROCKETMQ_INCLUDE_DIR}) | ||
mark_as_advanced(RocketMQ_INCLUDE_DIRS RocketMQ_LIBRARIES) | ||
endif() |
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,21 @@ | ||
# 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. | ||
[rocketmq] | ||
namesrv = 127.0.0.1:9876 | ||
brokerAddr = 127.0.0.1:10911 | ||
cluster = | ||
accessKey = | ||
secretKey = | ||
accessChannel = |
Oops, something went wrong.