跳到正文
cccskills
免费在 GitHub 公开

testing-standards

Testing standards for LoongCollector: unit tests, e2e tests, benchmarks. Reference when writing or reviewing tests.

中文简介正在准备中。当前显示原文说明。

集成工具Kubernetes
查看安装方法

包含的文件(1)

  • SKILL.md3.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

LoongCollector Testing Standards

Test Categories

1. Unit Tests (C++)

  • Use Google Test (GTest) / Google Mock
  • Place in core/unittest/
  • Cover success and failure paths
  • Core logic must have 100% coverage
  • Test boundary conditions explicitly
  • Test naming: accurately describe behavior being tested
  • Each core/unittest/*/ directory produces one executable
  • Build and run tests from inside build/ to ensure relative paths and temp files work correctly
  • See skills/compile/SKILL.md for build & run instructions

2. Unit Tests (Go)

  • Use standard testing package
  • Table-driven tests for function coverage
  • Integration tests via E2E framework

3. E2E Tests

  • BDD Godog framework
  • Configuration-driven via .feature files
  • See skills/e2e/SKILL.md for complete guide (design → write → run → debug)

4. Benchmarks

  • Required for performance-sensitive code paths
  • Compare against baseline versions
  • Measure throughput, latency, CPU/Memory usage

E2E Test Quick Reference

Feature File Structure

@input
Feature: input file
  Test input file

  @e2e @host
  Scenario: TestInputFileWithRegexSingle
    Given {host} environment
    Given subcribe data from {sls} with config
    """
    enable: true
    inputs:
      - Type: input_file
    """
    When generate {100} regex logs to file {/tmp/loongcollector/regex_single.log}, with interval {100}ms
    Then there is {100} logs

Behavior Types

TypePurpose
GivenSetup/prepare test conditions
WhenTrigger test actions (e.g., log generation)
ThenVerify test results

Environment Tags

  • @host - Host environment
  • @k8s - Kubernetes environment
  • @docker-compose - Docker Compose environment
  • @e2e - E2E test marker
  • @regression - Regression test marker

Adding New Test Behaviors

  1. Write the Go function in the appropriate directory:
    • cleanup/ - Post-test cleanup (auto-executed)
    • control/ - Control operations (init, config)
    • setup/ - Environment setup
    • trigger/ - Data generation
    • verify/ - Result verification
  2. Function signature: func Name(ctx context.Context, params...) (context.Context, error)
  3. Register in test/e2e_enterprise/main_test.go via scenarioInitializer
  4. Use in feature files with {param} syntax

Strict Rules

  • Do NOT change behavior of the method being tested
  • Do NOT modify existing test behaviors in engine
  • Always start trigger When begin trigger BEFORE generating logs
  • Only use registered behaviors from test/engine/steps.go
  • Verify behavior type matches (Given/When/Then)

Test Naming

  • Format: Test${FunctionName}${CaseBriefDescription}
  • Examples: TestInputFileWithBlackListDir, TestInputFileWithRegexSingle
  • Must include @e2e and environment tags

Benchmark Testing

For performance-sensitive code:

  1. Provide baseline comparison
  2. Measure: throughput, latency, CPU profile, memory profile
  3. Run under realistic load conditions
  4. Document methodology and results

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

在进行 Code Review 时,使用这个技能对 LoongCollector 变更进行安全导向、架构一致性优先的深度代码评审。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

commit

免费

按 Conventional Commits 规范编写提交信息。在创建 git commit 时使用。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

compile

免费

编译 LoongCollector C++ 与 Go 组件。涉及构建、单元测试或镜像时使用。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

Design document writing conventions. Use when writing or reviewing technical design documents.

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

e2e

免费

LoongCollector E2E 测试全流程指南:设计、编写、运行和调试。当需要编写新 E2E 测试、运行现有测试、或排查 E2E 测试失败时使用此 skill。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

LoongCollector E2E Testing Framework Development Guide. Use this rule when you need to understand E2E testing framework architecture, develop new test behavior functions, or extend testing capabilities. Contains detailed BDD testing framework usage, test behavior function development and registration workflows, and comprehensive reference of existing testing capabilities. Example: When adding custom test behaviors for new plugins, use this rule to understand how to write and register new test functions. Example: When developing E2E tests, use this rule to understand the e2e framework.

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月21日 更新

查看 alibaba 的全部技能

报告此技能的问题