Skip to content

test(nuclei): adds multiproto benchmark test#6270

Merged
ehsandeep merged 2 commits intodevfrom
dwisiswant0/test/nuclei/adds-multiproto-benchmark-test
Jun 24, 2025
Merged

test(nuclei): adds multiproto benchmark test#6270
ehsandeep merged 2 commits intodevfrom
dwisiswant0/test/nuclei/adds-multiproto-benchmark-test

Conversation

@dwisiswant0
Copy link
Member

@dwisiswant0 dwisiswant0 commented Jun 16, 2025

Proposed changes

Follow up on #6253 #6258

Hopefully this gets caught by perf-regression test workflow.

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Refactor
    • Improved the structure and reliability of benchmark tests, including better setup and teardown of shared test resources and clearer error messages.
  • Tests
    • Enhanced benchmark tests to run multiple configurations and report memory allocations, providing more comprehensive performance insights.

Signed-off-by: Dwi Siswanto <git@dw1.io>
@dwisiswant0 dwisiswant0 requested a review from ehsandeep June 16, 2025 23:48
@auto-assign auto-assign bot requested a review from dogancanbakir June 16, 2025 23:48
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 16, 2025

Walkthrough

The benchmark test for the nuclei command was refactored to introduce a TestMain function for shared setup and teardown, including a temporary directory and HTTP server. Benchmark logic was modularized with helper functions, and sub-benchmarks were added for different configurations. Output and logging are now globally silenced during tests.

Changes

File(s) Change Summary
cmd/nuclei/main_benchmark_test.go Refactored: Added TestMain for setup/teardown, modularized benchmarks with helpers, added sub-benchmarks, improved error messages, globally silenced output/logging.

Poem

In the warren of code, a test hops anew,
With helpers and silence, the benchmarks flew.
A server now waits, while logs softly sleep,
Sub-benchmarks emerge, their promises deep.
The rabbit approves, with a twitch of its nose—
Refactored and ready, the test garden grows! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d05bfe5 and 96802d7.

📒 Files selected for processing (1)
  • cmd/nuclei/main_benchmark_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/nuclei/main_benchmark_test.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Tests (windows-latest)
  • GitHub Check: Tests (macOS-latest)
  • GitHub Check: Tests (ubuntu-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
cmd/nuclei/main_benchmark_test.go (2)

16-19: Avoid global‐local variable shadowing for clarity & correctness

getDefaultOptions re-creates its own projectPath variable, silently shadowing the package-level projectPath.
Although both point to temp dirs, the shadowing easily confuses readers and makes it unclear which directory is being cleaned up in TestMain. Renaming the globals (e.g. baseProjectPath) or removing the global entirely would prevent future mistakes.


122-139: Add b.Cleanup for temp dir & improve path robustness

After adopting the proposed getDefaultOptions cleanup callback, remember to register it in each sub-benchmark:

opts, cleanup := getDefaultOptions()
b.Cleanup(cleanup)

Additionally, options.Templates = []string{"./cmd/nuclei/testdata/benchmark/multiproto/"} is a relative path; the working directory during go test ./... is not guaranteed. Use filepath.Join with t.TempDir() or testingpackage’s b.TempDir() to copy the testdata tree, or runtime.Caller to build an absolute path.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5af6feb and d05bfe5.

⛔ Files ignored due to path filters (3)
  • cmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto-mixed.yaml is excluded by !**/*.yaml
  • cmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto-raw.yaml is excluded by !**/*.yaml
  • cmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto.yaml is excluded by !**/*.yaml
📒 Files selected for processing (1)
  • cmd/nuclei/main_benchmark_test.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/nuclei/main_benchmark_test.go (1)
internal/runner/options.go (1)
  • ParseOptions (56-138)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Lint

Signed-off-by: Dwi Siswanto <git@dw1.io>
@ehsandeep ehsandeep merged commit 3bcbcc6 into dev Jun 24, 2025
20 checks passed
@ehsandeep ehsandeep deleted the dwisiswant0/test/nuclei/adds-multiproto-benchmark-test branch June 24, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants