Skip to content

FIX: Fixed bugs in existing test suite and added additional stress tests#523

Open
gargsaumya wants to merge 6 commits intomainfrom
saumya/stress-new
Open

FIX: Fixed bugs in existing test suite and added additional stress tests#523
gargsaumya wants to merge 6 commits intomainfrom
saumya/stress-new

Conversation

@gargsaumya
Copy link
Copy Markdown
Contributor

New tests:

  • test_executemany_large_batch_mixed_types: 10k rows, mixed types via executemany
  • test_null_heavy_large_result_set: 50k rows with 6/8 cols NULL, verify None propagation
  • test_cursor_reuse_high_iteration: single cursor reused 5000 times, memory leak check
  • test_fetchone_loop_vs_fetchall_parity: 100k row bit-identical comparison of both fetch paths
  • test_concurrent_read_write_no_corruption: 5 writers + 5 readers on shared table for 10s

Bug fixes:

Also registers 'slow' mark in pytest.ini to suppress PytestUnknownMarkWarning

Work Item / Issue Reference

AB#<WORK_ITEM_ID>

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request adds several new high-scale stress tests and improves the configurability and coverage of both single-threaded and multi-threaded stress testing. The main updates include three new single-threaded stress tests for executemany with mixed types, NULL-heavy result sets, and high-iteration cursor re-use, plus a fetchone vs fetchall parity test. Multi-threaded stress tests now support explicit pool size configuration and improved pool exhaustion testing. Test documentation and marker registration have also been updated.

Single-threaded stress test enhancements:

  • Added test_executemany_large_batch_mixed_types to stress-test executemany() with 10,000 mixed-type rows, verifying parameter serialization and correctness.
  • Added test_null_heavy_large_result_set to fetch 50,000 rows with 6/8 columns as NULL, ensuring correct NULL handling at scale.
  • Added test_cursor_reuse_high_iteration to re-use a single cursor for 5,000 execute/fetch cycles, checking for memory leaks and state reset.
  • Added test_fetchone_loop_vs_fetchall_parity to verify bit-identical results between fetchone() and fetchall() for 100,000 rows.
  • Updated test docstrings and numbering for clarity and completeness. [1] [2] [3] [4]

Multi-threaded stress test improvements:

  • The MultiThreadedQueryRunner now accepts a pool_max_size parameter, allowing explicit control of the connection pool size in tests. [1] [2]
  • The pool exhaustion test (test_pool_exhaustion_recovery) now uses the explicit pool size parameter and improved query logic for more accurate stress simulation and reporting. [1] [2]
  • Test documentation updated to clarify coverage of pool exhaustion and concurrent mixed read/write.

Test marker and config updates:

  • Registered a new slow pytest marker for extra-slow tests, complementing the existing stress marker.

These changes expand test coverage for edge-case and high-load scenarios, improve test documentation, and make stress tests more configurable and robust.

New tests:
- test_executemany_large_batch_mixed_types: 10k rows, mixed types via executemany
- test_null_heavy_large_result_set: 50k rows with 6/8 cols NULL, verify None propagation
- test_cursor_reuse_high_iteration: single cursor reused 5000 times, memory leak check
- test_fetchone_loop_vs_fetchall_parity: 100k row bit-identical comparison of both fetch paths
- test_concurrent_read_write_no_corruption: 5 writers + 5 readers on shared table for 10s

Bug fixes:
- test_concurrent_fetch_data_integrity_no_corruption: verification block was inside
  thread.join() loop instead of after it (race condition + premature fail)
- test_pool_exhaustion_recovery: pool max_size was silently overridden by run_parallel();
  added pool_max_size param to MultiThreadedQueryRunner; fixed multi-statement query
- test numbering: docstring sequence skipped #4 (renumbered #5-#7 -> #4-#6)

Also registers 'slow' mark in pytest.ini to suppress PytestUnknownMarkWarning
Copilot AI review requested due to automatic review settings April 15, 2026 04:29
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR expands the stress test suite with additional high-scale single-threaded and multi-threaded scenarios, and fixes a few correctness/config issues in existing tests.

Changes:

  • Added multiple new single-threaded stress tests (executemany mixed types, NULL-heavy results, cursor reuse, fetch parity).
  • Improved multi-threaded stress runner configurability via explicit pool_max_size, and updated pool exhaustion test accordingly.
  • Added a new concurrent mixed read/write stress test and registered the slow pytest marker.

Reviewed changes

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

File Description
tests/test_020_multithreaded_stress.py Adds pool_max_size to the runner, adjusts pool exhaustion test, and introduces a new concurrent read/write stress test.
tests/test_011_singlethreaded_stress.py Fixes a race in existing concurrent fetch verification and adds several new large-scale stress tests.
pytest.ini Registers the slow marker to avoid unknown-mark warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_020_multithreaded_stress.py
Comment thread tests/test_020_multithreaded_stress.py
Comment thread tests/test_020_multithreaded_stress.py Outdated
Comment thread tests/test_020_multithreaded_stress.py
Comment thread tests/test_020_multithreaded_stress.py
Comment thread tests/test_020_multithreaded_stress.py Outdated
Comment thread tests/test_020_multithreaded_stress.py Outdated
@github-actions github-actions bot added the pr-size: large Substantial code update label Apr 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 21, 2026

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

79%


📈 Total Lines Covered: 6677 out of 8449
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 67.8%
mssql_python.row.py: 70.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 74.2%
mssql_python.pybind.connection.connection.cpp: 75.8%
mssql_python.__init__.py: 77.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 85.2%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

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

Labels

pr-size: large Substantial code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants