Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #2872 to release/v1.7 for implement bidirectional_stream #2880

Open
wants to merge 2 commits into
base: release/v1.7
Choose a base branch
from

Conversation

vdaas-ci
Copy link
Collaborator

@vdaas-ci vdaas-ci commented Mar 3, 2025

Description

  • implement bidirectional stream utility function
  • add function level unit test and test over network

Related Issue

Versions

  • Vald Version: v1.7.16
  • Go Version: v1.24.0
  • Rust Version: v1.84.1
  • Docker Version: v27.4.0
  • Kubernetes Version: v1.32.0
  • Helm Version: v3.16.3
  • NGT Version: v2.3.5
  • Faiss Version: v1.9.0

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • New Features

    • Enhanced the agent’s streaming capabilities to efficiently process concurrent, bidirectional data flows for improved responsiveness.
  • Chores

    • Refined internal build and testing processes to bolster overall quality and reliability.

* implement bidirectional_stream

* fix

* add network test

* add network test with duration

* add CI

* fix test command
Copy link

cloudflare-workers-and-pages bot commented Mar 3, 2025

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9eaebcd
Status: ✅  Deploy successful!
Preview URL: https://86c6fc6e.vald.pages.dev
Branch Preview URL: https://backport-release-v1-7-featur-wepr.vald.pages.dev

View logs

Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

📝 Walkthrough

Walkthrough

This pull request updates the continuous integration workflows and testing infrastructure for Rust components. The changes include renaming an existing test step for the qbg component and adding a new test step for the agent component in the workflow file. Additionally, the Makefile now defines a composite test target with specific targets for qbg and agent. In the agent package, new dependencies are introduced in the Cargo.toml, and a new asynchronous function, bidirectional_stream, is added along with an updated macro and a set of tests to handle bidirectional streaming.

Changes

File(s) Change Summary
.github/workflows/unit-test-rust.yaml
Makefile.d/test.mk
Renamed test step from "Run tests for Rust / gotestfmt" to "Run tests for qbg / gotestfmt" and added a new step for "Run tests for agent / gotestfmt" in the workflow; added new Makefile targets (test/rust, test/rust/qbg, and test/rust/agent) for structured Rust tests.
rust/bin/agent/Cargo.toml Added a new dependency: futures = "0.3.31"; introduced a [dev-dependencies] section with bytes = "1.10.0" and http-body = "1.0.1".
rust/bin/agent/src/handler/common.rs Introduced an asynchronous function bidirectional_stream for handling bidirectional streaming requests; updated the stream_type! macro to return a ReceiverStream; added tests (using a mock body and decoder) to verify the functionality and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant bidirectional_stream
    participant TokioChannel
    participant ProcessingFunction

    Client->>bidirectional_stream: Send request stream
    bidirectional_stream->>TokioChannel: Buffer incoming requests
    loop Process up to concurrency limit
        TokioChannel->>ProcessingFunction: Process individual request
        ProcessingFunction-->>TokioChannel: Return result/error
    end
    TokioChannel->>Client: Send aggregated responses
Loading

Possibly related PRs

Suggested labels

type/feature, priority/medium, size/XXL, type/ci, area/makefile

Suggested reviewers

  • vankichi
  • kmrmt
  • datelier
✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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: 0

🧹 Nitpick comments (2)
rust/bin/agent/src/handler/common.rs (2)

31-84: Consider a more robust concurrency approach.
Using an array of spawned tasks and manually popping handles works, but you might benefit from tokio::sync::Semaphore or a FuturesUnordered approach for more fine-grained parallelism and earlier completion.


86-356: Comprehensive test coverage is commendable!
These tests thoroughly validate normal and error scenarios, plus network integration. A further nitpick is to include a concurrency=1 or zero-message scenario for edge case coverage.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce5483a and 211e6cd.

⛔ Files ignored due to path filters (1)
  • rust/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/unit-test-rust.yaml (1 hunks)
  • Makefile.d/test.mk (2 hunks)
  • rust/bin/agent/Cargo.toml (2 hunks)
  • rust/bin/agent/src/handler/common.rs (1 hunks)
🔇 Additional comments (8)
rust/bin/agent/Cargo.toml (2)

30-30: Nice addition of the futures dependency.
This version should integrate well with Tokio for async handling.


39-42:

❓ Verification inconclusive

Check for up-to-date and secure dev dependencies.
It's always a good idea to verify that bytes and http-body are on stable, vulnerability-free releases.

Below is a script to run a preliminary security check on these crates:


🏁 Script executed:

#!/bin/bash
# Description: Use cargo-audit to check for vulnerabilities in newly added dependencies.

# Ensure cargo-audit is installed
cargo install cargo-audit || echo "cargo-audit already installed or failed to install; continuing..."

# Run cargo-audit in the agent manifest directory
cd rust/bin/agent
cargo audit

Length of output: 394


Dependency Security Check Advisory

The preliminary audit didn't run successfully due to the lack of a configured Rust environment (i.e. cargo was not found). Please verify in an environment where Rust and Cargo are available that the versions listed for bytes (1.10.0) and http-body (1.0.1) have no known vulnerabilities.

  • Confirm that Cargo is installed and accessible.
  • Re-run cargo audit in the appropriate environment to ensure these dev-dependencies are secure.
Makefile.d/test.mk (2)

293-298: Grouping Rust tests together is a clean organization.
Invoking test/rust/qbg and test/rust/agent under test/rust keeps the workflow consistent.


309-313:

❓ Verification inconclusive

Verify coverage of all Agent tests.
Limiting tests to handler::common::tests may skip other tests if present in the agent package. Please verify that you’re not missing any other test modules.

Below is a script that searches for other test attributes within the agent package:


🏁 Script executed:

#!/bin/bash
# Description: Search for all test definitions to ensure none are missed in the new Make target.
rg '#\[test\]' rust/bin/agent/src/ -A 5

Length of output: 41


Ensure complete Agent test coverage manually.

The automated search for #[test] attributes in the rust/bin/agent/src/ directory did not return any additional tests beyond those in handler::common::tests. However, since the search command produced no output—which might be due to tests being defined in other directories or modules—it’s recommended that you manually verify the agent package for any extra test definitions.

  • Revisit the agent package’s directory structure in case tests are located outside of rust/bin/agent/src/.
  • Confirm that there are no additional test modules that need to be included in the Make target.
.github/workflows/unit-test-rust.yaml (2)

49-49: Renaming the test step provides clarity.
Switching from "Run tests for Rust / gotestfmt" to "Run tests for qbg / gotestfmt" makes it more explicit.


52-54: Adding a dedicated step for agent testing is well-structured.
This ensures each Rust component is tested individually and reported clearly.

rust/bin/agent/src/handler/common.rs (2)

16-23: Imports look appropriate for async streaming.
These crates align well with the bidirectional streaming logic.


27-27: Simplifying the stream_type! macro.
Switching to ReceiverStream can improve readability and reduce complexity compared to pinned streams.

@vdaas-ci
Copy link
Collaborator Author

vdaas-ci commented Mar 3, 2025

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants