@可持久流/服务器-合规测试
持久流服务器执行的礼宾合规测试套件.
此软件包提供了一个全面的测试套件,以验证服务器是否正确执行 持久流协议。 。 。 .
安装
npm install @durable-streams/server-conformance-tests
# or
pnpm add @durable-streams/server-conformance-tests
CLI 使用量
对您的服务器进行兼容性测试的最简单方式 :
运行一次( CI)
npx @durable-streams/server-conformance-tests --run http://localhost:4437
监视模式( 开发)
当检测到变化时, 监视源文件并自动重运行测试 :
npx @durable-streams/server-conformance-tests --watch src http://localhost:4437
# Watch multiple directories
npx @durable-streams/server-conformance-tests --watch src lib http://localhost:4437
CLI 选项
Usage:
npx @durable-streams/server-conformance-tests --run <url>
npx @durable-streams/server-conformance-tests --watch <path> [path...] <url>
Options:
--run Run tests once and exit (for CI)
--watch <paths> Watch source paths and rerun tests on changes (for development)
--help, -h Show help message
Arguments:
<url> Base URL of the Durable Streams server to test against
程序用途
您也可以在自己的测试套间内进行符合性测试:
import { runConformanceTests } from "@durable-streams/server-conformance-tests"
// In your test file (e.g., with vitest)
describe("My Server Implementation", () => {
const config = { baseUrl: "" }
beforeAll(async () => {
// Start your server
const server = await startMyServer({ port: 0 })
config.baseUrl = server.url
})
afterAll(async () => {
await server.stop()
})
// Run all conformance tests
runConformanceTests(config)
})
CI 整合
在您的 CI 管道中添加符合性测试 :
# GitHub Actions example
jobs:
conformance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Start server
run: npm run start:server &
- name: Wait for server
run: npx wait-on http://localhost:4437
- name: Run conformance tests
run: npx @durable-streams/server-conformance-tests --run http://localhost:4437
测试范围
符合性测试套房包括:
- 基本流程操作 - 创建、删除、一能操作
- 附加操作 - 弦数据、分块、顺序顺序
- 读取操作 - 空/全流,相抵读
- 长波操作 - 数据等待,立即返回
- HTTP 协议 - 标题、状态代码、内容谈判
- TTL 和过期 - TTL/延期处理
- 案件敏感性 - 内容类型,头壳
- 内容 - 类型验证 - 匹配执法
- 总部元数据 - 只有元数据的答复
- 偏移验证 - 偏差,可复用
- 协议边缘案件 - 空体、二进制数据、单声道进取
- 字节精确度 - 数据完整性保障
- 缓存和ETAG - Etag和304的答复
- 弹簧和大有效载荷 - 平地取出大文件
- 基于财产的模糊 - 随机附加/读取序列
- 输入模糊 - 以安全为重点的测试
- 读取 - 您的写作一致性 - 写后立即可见
- SSE 模式 - 服务器发送事件流出
- JSON 模式 - JSON序列化和分批
许可证
Apache 2.0 (英语)