Skip to content

Use writable copies for LocalDB tests - #7672

Merged
matouskozak merged 6 commits into
mainfrom
matouskozak-ci-smoke-test
Aug 13, 2026
Merged

Use writable copies for LocalDB tests#7672
matouskozak merged 6 commits into
mainfrom
matouskozak-ci-smoke-test

Conversation

@matouskozak

@matouskozak matouskozak commented Aug 12, 2026

Copy link
Copy Markdown
Member

Fixes #7657.

Summary

  • Copy the packaged Iris LocalDB data and log files to a per-test temporary directory.
  • Clear read-only attributes before LocalDB attaches and upgrades the copied files.
  • Use a unique database name so test runs cannot collide with an existing LocalDB attachment.
  • Drop the temporary database and remove its files after each test.
  • Always clear System.Data.SqlClient connection pools, including when dropping the database fails.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@matouskozak matouskozak added the ** NO MERGE ** Testing PR only, do not merge label Aug 12, 2026
@matouskozak matouskozak self-assigned this Aug 12, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6dd6e79f-ff2e-4596-ae45-1c842d45bd40
Copy packaged database files to a per-test temporary directory before attaching them so newer LocalDB versions can upgrade the files on Windows CI agents.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6dd6e79f-ff2e-4596-ae45-1c842d45bd40
@matouskozak matouskozak changed the title Test CI with a no-op documentation change Use writable copies for LocalDB tests Aug 12, 2026
@matouskozak matouskozak removed the ** NO MERGE ** Testing PR only, do not merge label Aug 12, 2026
matouskozak and others added 2 commits August 12, 2026 14:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Drop each per-test database and remove its temporary files after the test, while logging cleanup failures without masking test results.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6dd6e79f-ff2e-4596-ae45-1c842d45bd40
@matouskozak
matouskozak marked this pull request as ready for review August 12, 2026 15:05
Copilot AI lite review requested due to automatic review settings August 12, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the DatabaseLoaderTests LocalDB setup to avoid CI failures caused by the packaged .mdf/.ldf files being attached read-only on some Windows images. It does this by copying the database files to a per-test temp location, clearing read-only attributes, using a unique database name per test, and attempting best-effort cleanup afterward.

Changes:

  • Copy TestDatabases LocalDB .mdf/.ldf files into a per-test temporary directory and make them writable before attaching.
  • Attach LocalDB using a unique database name per test run to prevent collisions.
  • Add test cleanup logic to drop the temporary LocalDB database and delete the temporary directory (logging failures).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/Microsoft.ML.Tests/DatabaseLoaderTests.cs
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.31034% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.75%. Comparing base (548d4d0) to head (918f387).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
test/Microsoft.ML.Tests/DatabaseLoaderTests.cs 79.31% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7672      +/-   ##
==========================================
+ Coverage   69.59%   69.75%   +0.16%     
==========================================
  Files        1484     1486       +2     
  Lines      273606   275790    +2184     
  Branches    27949    28199     +250     
==========================================
+ Hits       190410   192375    +1965     
- Misses      75832    75953     +121     
- Partials     7364     7462      +98     
Flag Coverage Δ
Debug 69.75% <79.31%> (+0.16%) ⬆️
production 63.92% <ø> (+0.08%) ⬆️
test 89.80% <79.31%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
test/Microsoft.ML.Tests/DatabaseLoaderTests.cs 90.90% <79.31%> (-3.51%) ⬇️

... and 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Clear System.Data.SqlClient pools even when dropping a temporary test database fails, while preserving narrow cleanup exception handling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6dd6e79f-ff2e-4596-ae45-1c842d45bd40
@matouskozak
matouskozak enabled auto-merge (squash) August 13, 2026 12:45
@matouskozak

Copy link
Copy Markdown
Member Author

/ba-g failures are unrelate to this PR and will be addressed as follow up

@matouskozak
matouskozak merged commit cd2fbd6 into main Aug 13, 2026
23 of 26 checks passed
@matouskozak
matouskozak deleted the matouskozak-ci-smoke-test branch August 13, 2026 12:46
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.

DatabaseLoaderTests.Iris* fail: iris.mdf attached read-only on 1es-windows-2022-open image

3 participants