-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #862 from 4t145/eda-integration-test
event: eda integration test and fix relative bugs
- Loading branch information
Showing
34 changed files
with
1,125 additions
and
121 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
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 |
---|---|---|
|
@@ -3,7 +3,9 @@ use std::env; | |
|
||
use tardis::basic::result::TardisResult; | ||
use tardis::test::test_container::TardisTestContainer; | ||
use tardis::testcontainers::ContainerAsync; | ||
use tardis::testcontainers::core::Mount; | ||
use tardis::testcontainers::runners::AsyncRunner; | ||
use tardis::testcontainers::{ContainerAsync, ImageExt}; | ||
use tardis::TardisFuns; | ||
use testcontainers_modules::postgres::Postgres; | ||
use testcontainers_modules::rabbitmq::RabbitMq; | ||
|
@@ -12,11 +14,30 @@ use testcontainers_modules::redis::Redis; | |
pub struct LifeHold { | ||
pub reldb: ContainerAsync<Postgres>, | ||
pub redis: ContainerAsync<Redis>, | ||
pub rabbit: ContainerAsync<RabbitMq>, | ||
// pub rabbit: ContainerAsync<RabbitMq>, | ||
} | ||
|
||
pub async fn postgres_custom(init_script_path: Option<&str>) -> TardisResult<ContainerAsync<Postgres>> { | ||
let mut postgres = Postgres::default() | ||
.with_tag("alpine") | ||
.with_env_var("POSTGRES_PASSWORD", "123456").with_env_var("POSTGRES_DB", "test"); | ||
postgres = if let Some(init_script_path) = init_script_path { | ||
let path = env::current_dir() | ||
.expect("[Tardis.Test_Container] Current path get error") | ||
.join(std::path::Path::new(init_script_path)) | ||
.to_str() | ||
.unwrap_or_else(|| panic!("[Tardis.Test_Container] Script Path [{init_script_path}] get error")) | ||
.to_string(); | ||
postgres.with_mount(Mount::volume_mount(path, "/docker-entrypoint-initdb.d/")) | ||
} else { | ||
postgres | ||
}; | ||
let postgres = postgres.start().await?; | ||
Ok(postgres) | ||
} | ||
|
||
pub async fn init(sql_init_path: Option<String>) -> TardisResult<LifeHold> { | ||
let reldb_container = TardisTestContainer::postgres_custom(sql_init_path.as_deref()).await?; | ||
let reldb_container = postgres_custom(sql_init_path.as_deref()).await?; | ||
let port = reldb_container.get_host_port_ipv4(5432).await?; | ||
let url = format!("postgres://postgres:[email protected]:{port}/test"); | ||
env::set_var("TARDIS_FW.DB.URL", url); | ||
|
@@ -27,15 +48,15 @@ pub async fn init(sql_init_path: Option<String>) -> TardisResult<LifeHold> { | |
env::set_var("TARDIS_FW.CACHE.URL", url); | ||
|
||
// TODO remove | ||
let rabbit_container = TardisTestContainer::rabbit_custom().await?; | ||
let port = rabbit_container.get_host_port_ipv4(5672).await?; | ||
let url = format!("amqp://guest:[email protected]:{port}/%2f"); | ||
env::set_var("TARDIS_FW.MQ.URL", url); | ||
// let rabbit_container = TardisTestContainer::rabbit_custom().await?; | ||
// let port = rabbit_container.get_host_port_ipv4(5672).await?; | ||
// let url = format!("amqp://guest:[email protected]:{port}/%2f"); | ||
// env::set_var("TARDIS_FW.MQ.URL", url); | ||
|
||
TardisFuns::init(Some("tests/config")).await?; | ||
Ok(LifeHold { | ||
reldb: reldb_container, | ||
redis: redis_container, | ||
rabbit: rabbit_container, | ||
// rabbit: rabbit_container, | ||
}) | ||
} |
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,175 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store |
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 @@ | ||
registry=https://registry.npmmirror.com/ |
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,94 @@ | ||
/** | ||
|
||
# EDA测试计划 | ||
|
||
## 测试目标 | ||
|
||
1. **消息队列测试** | ||
- 测试消息队列在不同数据体积下的消息发送和接收能力,确保系统能够正确处理小数据包和大数据包。 | ||
- 验证消息队列的顺序性、一致性和持久性,确保消息不会丢失、重复或乱序。 | ||
- 测试多节点环境下消息队列的顺序性、一致性和持久性,确保消息在多节点之间正常传递。 | ||
- 测试消息持久化后,在不同负载条件下队列的吞吐量和响应时间。 | ||
- 验证消息队列在高并发条件下的处理能力,包括多生产者、多消费者场景的表现。 | ||
- 在并发条件下,测试增加服务节点后的扩展性,确保吞吐量随节点增加而提升。 | ||
- 测试消息队列在故障场景(如断网、宕机、队列超时等)下的恢复能力,确保系统能够迅速恢复并保证消息的完整性。 | ||
|
||
2. **WebSocket测试** | ||
- 测试WebSocket在不同大小的数据体下的消息发送和接收性能。 | ||
- 在不同并发条件下,测试WebSocket连接的建立时间、吞吐量和响应时间。 | ||
- 验证WebSocket消息的传递顺序和可靠性,确保消息不会丢失、乱序或重复。 | ||
- 测试WebSocket连接的稳定性和恢复能力,确保在异常断开后能够重新建立连接。 | ||
|
||
3. **点对点和发布/订阅模式测试** | ||
- 验证点对点(P2P)通信模式下消息的可靠性,确保消息从单个发送者到单个接收者的准确传递。 | ||
- 测试发布/订阅(Pub/Sub)模式下消息的广播性能,确保所有订阅者能够收到完整的消息。 | ||
- 在多节点和高并发环境下,测试点对点与发布/订阅模式的消息传递效率和系统表现。 | ||
|
||
## 测试内容与用例说明 | ||
|
||
### 详细测试用例说明 | ||
|
||
以下测试用例提供了详细的步骤、输入数据、执行方法以及预期结果,以确保测试人员能够准确地执行测试并获取可靠的结果。 | ||
|
||
### 1. 消息队列测试 | ||
|
||
- **用例1:不同大小数据包的发送与接收** | ||
- **输入**:发送小至1KB、大至10MB的数据包。 | ||
- **预期结果**:所有数据包均能被成功接收,且无丢失、延迟明显增加等异常。 | ||
|
||
- **用例2:顺序性、一致性和持久性验证** | ||
- **输入**:发送一组有序的消息并对其进行持久化。 | ||
- **预期结果**:接收端收到的消息顺序与发送顺序一致,所有消息均被持久化且无重复。 | ||
|
||
- **用例3:多节点环境下的消息传递** | ||
- **输入**:在多节点集群中发送消息。 | ||
- **预期结果**:所有节点均能正确接收到消息,顺序和一致性保持一致。 | ||
|
||
- **用例4:持久化后的吞吐量和响应时间测试** | ||
- **输入**:在启用持久化的情况下,以不同负载发送消息。 | ||
- **预期结果**:记录每种负载下的吞吐量和响应时间,分析其随负载变化的表现。 | ||
|
||
- **用例5:并发处理能力测试** | ||
- **输入**:模拟多生产者和多消费者同时对消息队列进行操作。 | ||
- **预期结果**:系统能够正常处理所有请求,且吞吐量符合预期。 | ||
|
||
- **用例6:扩展性测试** | ||
- **输入**:增加服务节点数量,并保持相同的并发负载。 | ||
- **预期结果**:随着节点数量增加,系统的吞吐量相应提升。 | ||
|
||
- **用例7:故障恢复能力测试** | ||
- **输入**:模拟网络断开、系统宕机等故障。 | ||
- **预期结果**:系统能够迅速恢复,且消息不丢失、不重复。 | ||
|
||
### 2. WebSocket测试 | ||
|
||
- **用例1:不同数据体积下的消息传递** | ||
- **输入**:通过WebSocket发送小至1KB、大至5MB的数据包。 | ||
- **预期结果**:消息能够成功传递,无显著延迟或丢失。 | ||
|
||
- **用例2:并发条件下的连接建立与响应** | ||
- **输入**:模拟高并发条件下同时建立多个WebSocket连接。 | ||
- **预期结果**:记录连接建立时间、吞吐量和响应时间,确保在高并发条件下性能符合预期。 | ||
|
||
- **用例3:消息传递顺序与可靠性验证** | ||
- **输入**:发送一系列有序消息。 | ||
- **预期结果**:接收端收到的消息顺序与发送顺序一致,无丢失或重复。 | ||
|
||
- **用例4:连接稳定性和恢复能力测试** | ||
- **输入**:模拟WebSocket连接的异常断开情况。 | ||
- **预期结果**:连接能够自动重新建立,且消息继续传递。 | ||
|
||
### 3. 点对点和发布/订阅模式测试 | ||
|
||
- **用例1:点对点通信的可靠性测试** | ||
- **输入**:通过点对点模式发送消息。 | ||
- **预期结果**:消息能够准确地从发送者传递到接收者,无丢失。 | ||
|
||
- **用例2:发布/订阅模式的广播性能测试** | ||
- **输入**:通过发布/订阅模式发送消息,多名订阅者接收。 | ||
- **预期结果**:所有订阅者均能收到消息,无遗漏或延迟过大。 | ||
|
||
- **用例3:高并发环境下的点对点与发布/订阅模式测试** | ||
- **输入**:在高并发环境下,通过点对点和发布/订阅模式发送大量消息。 | ||
- **预期结果**:系统能够保持高效的消息传递,所有订阅者与接收者均能正常收到消息。 | ||
|
Binary file not shown.
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,3 @@ | ||
[build] | ||
entry = "src/index.ts" | ||
output = "dist/index.mjs" |
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,17 @@ | ||
{ | ||
"name": "bios-event-intergration-test", | ||
"module": "src/index.ts", | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.6.3" | ||
}, | ||
"dependencies": { | ||
"asteroid-mq-sdk": "^0.1.0-alpha.9" | ||
}, | ||
"scripts": { | ||
"build": "bun build src/index.ts --outfile dist/index.mjs" | ||
} | ||
} |
Oops, something went wrong.