Skip to content

kv: add comprehensive tests for Batch operations #151962

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vishalv1994
Copy link

This commit adds extensive unit tests for the kv.Batch type, covering all major operations including Get, Put, Scan, Delete, conditional operations, bulk operations, and admin methods. Tests also cover error handling, buffer management, and raw vs non-raw batch mixing.

Release notes: None

Epic: None

@vishalv1994 vishalv1994 self-assigned this Aug 15, 2025
Copy link

blathers-crl bot commented Aug 15, 2025

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@vishalv1994 vishalv1994 force-pushed the kv-add-batch-tests branch 2 times, most recently from c87ff87 to cfab05a Compare August 16, 2025 17:23
@vishalv1994 vishalv1994 added the A-testing Testing tools and infrastructure label Aug 17, 2025
@vishalv1994 vishalv1994 requested a review from Copilot August 18, 2025 19:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive unit tests for the kv.Batch type to improve test coverage of batch operations. The tests cover all major batch functionality including basic operations (Get, Put, Scan, Delete), conditional operations, bulk operations, error handling, and batch validation.

Key changes:

  • Adds 492 lines of comprehensive unit tests for the Batch type
  • Tests cover Get, Put, CPut, Inc, Scan, Delete, and bulk operations
  • Includes tests for error handling, buffer management, and raw vs non-raw batch mixing
  • Updates BUILD.bazel to include the new test file

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/kv/batch_test.go New comprehensive test file covering all Batch operations, error handling, and edge cases
pkg/kv/BUILD.bazel Adds batch_test.go to the test sources list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

func (m *mockBulkSourceIterator) Next() (roachpb.Key, []byte) {
m.index++
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The Next() method doesn't check bounds and will panic if called beyond the data length. Add bounds checking: if m.index >= len(m.data) { return nil, nil } or similar error handling.

Suggested change
m.index++
m.index++
if m.index >= len(m.data) {
return nil, nil
}

Copilot uses AI. Check for mistakes.

}

func (m *mockValueBulkSourceIterator) Next() (roachpb.Key, roachpb.Value) {
m.index++
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The Next() method doesn't check bounds and will panic if called beyond the data length. Add bounds checking: if m.index >= len(m.data) { return nil, roachpb.Value{} } or similar error handling.

Suggested change
m.index++
m.index++
if m.index >= len(m.data) {
return nil, roachpb.Value{}
}

Copilot uses AI. Check for mistakes.

This commit adds extensive unit tests for the kv.Batch type, covering
all major operations including Get, Put, Scan, Delete, conditional
operations, bulk operations, and admin methods. Tests also cover
error handling, buffer management, and raw vs non-raw batch mixing.

Release notes: None

Epic: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing Testing tools and infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants